|
@@ -443,58 +443,57 @@
|
|
} else if (system.uniPlatform == 'mp-weixin') {
|
|
} else if (system.uniPlatform == 'mp-weixin') {
|
|
if (e == 'wx') {
|
|
if (e == 'wx') {
|
|
if (openid) {
|
|
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
|
|
|
|
- })
|
|
|
|
- let user = that.$jwt(res.data);
|
|
|
|
- //当websocket收到后端发送的消息时,触发
|
|
|
|
- let config = that.$config.wsUrl;
|
|
|
|
- // 开启websocket
|
|
|
|
- that.$store.dispatch('websocketInit', config + `/${user._id}`);
|
|
|
|
- // 如果是团长,请求刷新
|
|
|
|
- if (user.is_leader == '0') {
|
|
|
|
- let pages = getCurrentPages();
|
|
|
|
- let prePage = pages[pages.length - 2];
|
|
|
|
- let prePage2 = pages[pages.length - 3];
|
|
|
|
- if (prePage && prePage.route == 'pagesHome/order/detail')
|
|
|
|
- prePage.$vm
|
|
|
|
- .search()
|
|
|
|
- if (prePage2 && prePage2.route == 'pages/home/index') {
|
|
|
|
- prePage2.$vm.clearPage();
|
|
|
|
- prePage2.$vm.search();
|
|
|
|
|
|
+ uni.getStorage({
|
|
|
|
+ key: 'shop',
|
|
|
|
+ success: async function(aee) {
|
|
|
|
+ const res = await that.$api(`/user/wxLogin`, 'POST', {
|
|
|
|
+ openid: openid,
|
|
|
|
+ shop: aee.data
|
|
|
|
+ })
|
|
|
|
+ if (res.errcode == '0') {
|
|
|
|
+ uni.setStorage({
|
|
|
|
+ key: 'token',
|
|
|
|
+ data: res.data,
|
|
|
|
+ success: function() {
|
|
|
|
+ uni.navigateBack({
|
|
|
|
+ delta: 1
|
|
|
|
+ })
|
|
|
|
+ let user = that.$jwt(res.data);
|
|
|
|
+ //当websocket收到后端发送的消息时,触发
|
|
|
|
+ let config = that.$config.wsUrl;
|
|
|
|
+ // 开启websocket
|
|
|
|
+ that.$store.dispatch('websocketInit',
|
|
|
|
+ config + `/${user._id}`);
|
|
|
|
+ // 如果是团长,请求刷新
|
|
|
|
+ if (user.is_leader == '0') {
|
|
|
|
+ let pages = getCurrentPages();
|
|
|
|
+ let prePage = pages[pages.length - 2];
|
|
|
|
+ let prePage2 = pages[pages.length - 3];
|
|
|
|
+ if (prePage && prePage.route ==
|
|
|
|
+ 'pagesHome/order/detail')
|
|
|
|
+ prePage.$vm
|
|
|
|
+ .search()
|
|
|
|
+ if (prePage2 && prePage2.route ==
|
|
|
|
+ 'pages/home/index') {
|
|
|
|
+ prePage2.$vm.clearPage();
|
|
|
|
+ prePage2.$vm.search();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ if (res.errcode == '-5') {
|
|
|
|
+ // 无账号,注册账号
|
|
|
|
+ that.wxCreate(aee.data);
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: res.errmsg || '信息错误',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- if (res.errcode == '-5') {
|
|
|
|
- // 无账号,注册账号
|
|
|
|
- that.wxCreate();
|
|
|
|
- // uni.showModal({
|
|
|
|
- // title: '提示',
|
|
|
|
- // content: '用户不存在,是否注册新账号?',
|
|
|
|
- // success: function(res) {
|
|
|
|
- // if (res.confirm) {
|
|
|
|
- // // 无账号,注册账号
|
|
|
|
- // that.wxCreate();
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // });
|
|
|
|
- } else {
|
|
|
|
- uni.showToast({
|
|
|
|
- title: res.errmsg || '信息错误',
|
|
|
|
- icon: 'none'
|
|
|
|
- })
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ })
|
|
} else {
|
|
} else {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
title: '系统更新中,请稍后再试!',
|
|
title: '系统更新中,请稍后再试!',
|
|
@@ -512,35 +511,31 @@
|
|
}
|
|
}
|
|
},
|
|
},
|
|
// wx,注册账号
|
|
// wx,注册账号
|
|
- wxCreate() {
|
|
|
|
|
|
+ wxCreate(shop) {
|
|
const that = this;
|
|
const that = this;
|
|
uni.getUserProfile({
|
|
uni.getUserProfile({
|
|
desc: '用于展示',
|
|
desc: '用于展示',
|
|
success: async function(res) {
|
|
success: async function(res) {
|
|
- uni.getStorage({
|
|
|
|
- key: 'shop',
|
|
|
|
- success: async function(aee) {
|
|
|
|
- let parmas = {
|
|
|
|
- openid: that.openid,
|
|
|
|
- icon: [{
|
|
|
|
- url: res.userInfo.avatarUrl
|
|
|
|
- }],
|
|
|
|
- shop: aee.data,
|
|
|
|
- name: res.userInfo.nickName + moment().valueOf()
|
|
|
|
- }
|
|
|
|
- const arr = await that.$api(`/user`, 'POST', parmas);
|
|
|
|
- if (arr.errcode == '0') {
|
|
|
|
- that.$set(that, `user`, arr.data);
|
|
|
|
- // 打开弹框
|
|
|
|
- that.diaShow();
|
|
|
|
- } else {
|
|
|
|
- uni.showToast({
|
|
|
|
- title: arr.errmsg,
|
|
|
|
- icon: 'none'
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ let parmas = {
|
|
|
|
+ openid: that.openid,
|
|
|
|
+ icon: [{
|
|
|
|
+ url: res.userInfo.avatarUrl
|
|
|
|
+ }],
|
|
|
|
+ shop,
|
|
|
|
+ name: res.userInfo.nickName + moment().valueOf()
|
|
|
|
+ }
|
|
|
|
+ const arr = await that.$api(`/user`, 'POST', parmas);
|
|
|
|
+ if (arr.errcode == '0') {
|
|
|
|
+ that.$set(that, `user`, arr.data);
|
|
|
|
+ // // 打开弹框
|
|
|
|
+ // that.diaShow();
|
|
|
|
+ that.otherLogin('wx');
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: arr.errmsg,
|
|
|
|
+ icon: 'none'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
},
|
|
},
|
|
fail: function(err) {
|
|
fail: function(err) {
|
|
console.log(err);
|
|
console.log(err);
|