Authored by 李奇

获取绑定店铺逻辑迁移

... ... @@ -5,6 +5,7 @@ import {verify} from './common/api';
import Promise from './vendors/es6-promise';
import { MD5 } from './vendors/crypto';
import { wechatAuthLogin, verifySessionKey } from './common/login';
import commonModel from './models/common';
import { stringify } from './vendors/query-stringify';
import './router/index';
import Yas from './common/yas';
... ... @@ -86,6 +87,8 @@ App({
yas.report('YB_LAUNCH_APP');
},
onShow(options) {
this.getUnionShop();
// 设置微信场景
this.globalData.ch = options.scene;
... ... @@ -129,6 +132,20 @@ App({
console.log(`wx.setStorageSync set ${key} failed.`);
}
},
getUnionShop: function() {
if (this.globalData.unionShop && this.globalData.unionShop.shopId) {
event.emit('get-union-shop-success');
} else {
commonModel.getBindShop({app_id: this.getAppId()}).then(res => {
if (res.code === 200 && res.data.shopId) {
this.globalData.unionShop = res.data;
event.emit('get-union-shop-success');
} else {
return Promise.reject();
}
}).catch(() => {});
}
},
getWechatThirdSession() {
this.globalData.thirdSession = this._getSync('thirdSession');
return this.globalData.thirdSession;
... ...
... ... @@ -138,7 +138,11 @@ Page({
deleteOrder() {
orderHandle.deleteOrder(this.orderCode, res => {
if (res && res.code === 200) {
wx.navigateBack({delta: 1});
if (getCurrentPages().length > 1) {
wx.navigateBack({delta: 1});
} else {
router.go('orderList', {type: 1});
}
}
});
},
... ...
import wx from '../../utils/wx';
import Yas from '../../common/yas';
import Promise from '../../vendors/es6-promise';
import commonModel from '../../models/common';
import event from '../../common/event';
import indexModel from '../../models/index/index';
let yas;
... ... @@ -47,18 +46,10 @@ Page({
this.getShopData(shopId);
this.getShopProducts(shopId);
} else {
commonModel.getBindShop({app_id: app.getAppId()}).then(res => {
if (res.code === 200 && res.data.shopId) {
const id = res.data.shopId;
app.globalData.unionShop = res.data;
this.getShopData(id);
this.getShopProducts(id);
} else {
return Promise.reject();
}
}).catch(() => {});
event.on('get-union-shop-success', () => {
this.getShopData(app.getShopId());
this.getShopProducts(app.getShopId());
});
}
// 记录
... ...