|
@@ -443,57 +443,52 @@
|
|
|
} else if (system.uniPlatform == 'mp-weixin') {
|
|
|
if (e == 'wx') {
|
|
|
if (openid) {
|
|
|
- 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();
|
|
|
- }
|
|
|
- }
|
|
|
+ const res = await that.$api(`/user/wxLogin`, 'POST', {
|
|
|
+ openid: openid,
|
|
|
+ shop: that.$config.shop
|
|
|
+ })
|
|
|
+ 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();
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: res.errmsg || '信息错误',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
}
|
|
|
- })
|
|
|
+ }
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
title: '系统更新中,请稍后再试!',
|
|
@@ -511,7 +506,7 @@
|
|
|
}
|
|
|
},
|
|
|
// wx,注册账号
|
|
|
- wxCreate(shop) {
|
|
|
+ wxCreate() {
|
|
|
const that = this;
|
|
|
uni.getUserProfile({
|
|
|
desc: '用于展示',
|
|
@@ -521,7 +516,7 @@
|
|
|
icon: [{
|
|
|
url: res.userInfo.avatarUrl
|
|
|
}],
|
|
|
- shop,
|
|
|
+ shop: that.$config.shop,
|
|
|
name: res.userInfo.nickName + moment().valueOf()
|
|
|
}
|
|
|
const arr = await that.$api(`/user`, 'POST', parmas);
|