|
@@ -423,6 +423,7 @@
|
|
const that = this;
|
|
const that = this;
|
|
let system = that.system;
|
|
let system = that.system;
|
|
let agree = that.agree;
|
|
let agree = that.agree;
|
|
|
|
+ let openid = that.openid;
|
|
if (agree) {
|
|
if (agree) {
|
|
if (system.uniPlatform == 'app') {
|
|
if (system.uniPlatform == 'app') {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
@@ -432,38 +433,46 @@
|
|
// todo:app端,微信一键登录
|
|
// todo:app端,微信一键登录
|
|
} else if (system.uniPlatform == 'mp-weixin') {
|
|
} else if (system.uniPlatform == 'mp-weixin') {
|
|
if (e == 'wx') {
|
|
if (e == 'wx') {
|
|
- const res = await that.$api(`/user/wxLogin`, 'POST', {
|
|
|
|
- openid: that.openid
|
|
|
|
- })
|
|
|
|
- if (res.errcode == '0') {
|
|
|
|
- uni.setStorage({
|
|
|
|
- key: 'token',
|
|
|
|
- data: res.data,
|
|
|
|
- success: function() {
|
|
|
|
- uni.navigateBack({
|
|
|
|
- delta: 1
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- if (res.errcode == '-5') {
|
|
|
|
- uni.showModal({
|
|
|
|
- title: '提示',
|
|
|
|
- content: '用户不存在,是否注册新账号?',
|
|
|
|
- success: function(res) {
|
|
|
|
- if (res.confirm) {
|
|
|
|
- // 无账号,注册账号
|
|
|
|
- that.wxCreate();
|
|
|
|
- }
|
|
|
|
|
|
+ if (openid) {
|
|
|
|
+ const res = await that.$api(`/user/wxLogin`, 'POST', {
|
|
|
|
+ openid: openid
|
|
|
|
+ })
|
|
|
|
+ if (res.errcode == '0') {
|
|
|
|
+ uni.setStorage({
|
|
|
|
+ key: 'token',
|
|
|
|
+ data: res.data,
|
|
|
|
+ success: function() {
|
|
|
|
+ uni.navigateBack({
|
|
|
|
+ delta: 1
|
|
|
|
+ })
|
|
}
|
|
}
|
|
});
|
|
});
|
|
} else {
|
|
} else {
|
|
- uni.showToast({
|
|
|
|
- title: res.errmsg || '信息错误',
|
|
|
|
- icon: 'none'
|
|
|
|
- })
|
|
|
|
|
|
+ if (res.errcode == '-5') {
|
|
|
|
+ uni.showModal({
|
|
|
|
+ title: '提示',
|
|
|
|
+ content: '用户不存在,是否注册新账号?',
|
|
|
|
+ success: function(res) {
|
|
|
|
+ if (res.confirm) {
|
|
|
|
+ // 无账号,注册账号
|
|
|
|
+ that.wxCreate();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: res.errmsg || '信息错误',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '缺少必要信息,暂无法登录!',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -486,7 +495,6 @@
|
|
}],
|
|
}],
|
|
name: res.userInfo.nickName,
|
|
name: res.userInfo.nickName,
|
|
}
|
|
}
|
|
- console.log(parmas);
|
|
|
|
const arr = await that.$api(`/user`, 'POST', parmas);
|
|
const arr = await that.$api(`/user`, 'POST', parmas);
|
|
if (arr.errcode == '0') {
|
|
if (arr.errcode == '0') {
|
|
that.$set(that, `user`, arr.data);
|
|
that.$set(that, `user`, arr.data);
|