|
@@ -3,7 +3,27 @@ const app = getApp()
|
|
|
|
|
|
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
|
|
|
const {upLoad} = require('../../utils/util');
|
|
|
+const {chooseImage} = require('../../utils/util');
|
|
|
+const {register, login} = require('../../API/appraise');
|
|
|
var clientWidth = wx.getSystemInfoSync().windowWidth;
|
|
|
+var registerOption = {
|
|
|
+ data: {
|
|
|
+ avatar: avatar,
|
|
|
+ name: name,
|
|
|
+ vid: wx.getStorageSync('vid'),
|
|
|
+ phone: '',
|
|
|
+ sign: '',
|
|
|
+ },
|
|
|
+}
|
|
|
+var loginOption = {
|
|
|
+
|
|
|
+ header :{
|
|
|
+ "content-type": 'application/x-www-form-urlencoded',
|
|
|
+ },
|
|
|
+ data:{
|
|
|
+ vid: wx.getStorageSync('vid')
|
|
|
+ },
|
|
|
+}
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
@@ -82,6 +102,7 @@ Page({
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
+ //微信提供的获取头像和昵称
|
|
|
// onChooseAvatar(e) {
|
|
|
// const { avatarUrl } = e.detail
|
|
|
// this.setData({
|
|
@@ -89,14 +110,17 @@ Page({
|
|
|
// })
|
|
|
// },
|
|
|
onChooseAvatar1(){
|
|
|
- wx.chooseImage({
|
|
|
- count: 1,//可选择图片数量
|
|
|
- sizeType: ['compressed'],//压缩图片
|
|
|
- sourceType: ['album','camera'],//来源
|
|
|
- success: (res) => {
|
|
|
- this.uploadImage(res.tempFilePaths[0]);
|
|
|
- }
|
|
|
- })
|
|
|
+ // wx.chooseImage({
|
|
|
+ // count: 1,//可选择图片数量
|
|
|
+ // sizeType: ['compressed'],//压缩图片
|
|
|
+ // sourceType: ['album','camera'],//来源
|
|
|
+ // success: (res) => {
|
|
|
+ // this.uploadImage(res.tempFilePaths[0]);
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ chooseImage().then((res)=>{
|
|
|
+ this.uploadImage(res.tempFilePaths[0]);
|
|
|
+ })
|
|
|
},
|
|
|
uploadImage(imagePath){
|
|
|
upLoad( imagePath ).then((res) => {
|
|
@@ -104,69 +128,67 @@ Page({
|
|
|
this.setData({
|
|
|
avatarUrl: res.Url
|
|
|
});
|
|
|
- wx.setStorage({
|
|
|
- key: 'avatarUrl',
|
|
|
- data: res.Url,
|
|
|
- success: function() {
|
|
|
- console.log('写入avatarUrl缓存成功')
|
|
|
- },
|
|
|
- fail:function() {
|
|
|
- console.log('写入avatarUrl发生错误')
|
|
|
- }
|
|
|
- });
|
|
|
+ wx.setStorageSync('avatarUrl', res.Url);
|
|
|
})
|
|
|
},
|
|
|
onInputUsername:function(e){
|
|
|
console.log(e);
|
|
|
- wx.setStorage({
|
|
|
- key: 'nickName',
|
|
|
- data: e.detail.value,
|
|
|
- success: function() {
|
|
|
- console.log('写入nickName缓存成功')
|
|
|
- },
|
|
|
- fail:function() {
|
|
|
- console.log('写入nickName发生错误')
|
|
|
- }
|
|
|
- })
|
|
|
+ wx.setStorageSync('nickName', e.detail.value);
|
|
|
},
|
|
|
register(){
|
|
|
var avatar = wx.getStorageSync('avatarUrl');
|
|
|
var name = wx.getStorageSync('nickName');
|
|
|
console.log(avatar);
|
|
|
console.log(name);
|
|
|
- wx.request({
|
|
|
- url: 'http://192.168.31.29:8084/user/register',
|
|
|
- method: 'POST',
|
|
|
- data: {
|
|
|
- avatar: avatar,
|
|
|
- name: name,
|
|
|
- vid: wx.getStorageSync('vid'),
|
|
|
- phone: '',
|
|
|
- sign: '',
|
|
|
- },
|
|
|
- success(res){
|
|
|
- console.log(res);
|
|
|
-
|
|
|
- wx.request({
|
|
|
- url: 'http://192.168.31.29:8084/user/login',
|
|
|
- method: 'POST',
|
|
|
- header: {
|
|
|
- 'content-type': 'application/x-www-form-urlencoded'
|
|
|
- },
|
|
|
- data:{
|
|
|
- vid: wx.getStorageSync('vid')
|
|
|
- },
|
|
|
+ // wx.request({
|
|
|
+ // url: 'http://192.168.31.28:8084/user/register',
|
|
|
+ // method: 'POST',
|
|
|
+ // data: {
|
|
|
+ // avatar: avatar,
|
|
|
+ // name: name,
|
|
|
+ // vid: wx.getStorageSync('vid'),
|
|
|
+ // phone: '',
|
|
|
+ // sign: '',
|
|
|
+ // },
|
|
|
+ // success(res){
|
|
|
+ // console.log(res);
|
|
|
+
|
|
|
+ // wx.request({
|
|
|
+ // url: 'http://192.168.31.28:8084/user/login',
|
|
|
+ // method: 'POST',
|
|
|
+ // header: {
|
|
|
+ // 'content-type': 'application/x-www-form-urlencoded'
|
|
|
+ // },
|
|
|
+ // data:{
|
|
|
+ // vid: wx.getStorageSync('vid')
|
|
|
+ // },
|
|
|
|
|
|
- success(res){
|
|
|
- console.log(res);
|
|
|
- wx.setStorageSync('token', res.data.data.token);
|
|
|
- wx.setStorageSync('uid', res.data.data.Uid);
|
|
|
- wx.switchTab({
|
|
|
- url: '/pages/home/home',
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ // success(res){
|
|
|
+ // console.log(res);
|
|
|
+ // console.log(res.data.data.user_info.uid);
|
|
|
+ // wx.setStorageSync('token', res.data.data.token);
|
|
|
+ // wx.setStorageSync('uid', res.data.data.user_info.uid);
|
|
|
+ // wx.setStorageSync('avatarUrl', res.data.data.user_info.avatar);
|
|
|
+ // wx.setStorageSync('nickName', res.data.data.user_info.name);
|
|
|
+ // wx.switchTab({
|
|
|
+ // url: '/pages/home/home',
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ register(registerOption).then((res)=>{
|
|
|
+ console.log(res);
|
|
|
+ login(loginOption).then((res)=>{
|
|
|
+ console.log(res);
|
|
|
+ wx.setStorageSync('token', res.data.data.token);
|
|
|
+ wx.setStorageSync('uid', res.data.data.user_info.uid);
|
|
|
+ wx.setStorageSync('avatarUrl', res.data.data.user_info.avatar);
|
|
|
+ wx.setStorageSync('nickName', res.data.data.user_info.name);
|
|
|
+ wx.switchTab({
|
|
|
+ url: '/pages/home/home',
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
})
|