|
@@ -23,11 +23,14 @@ Page({
|
|
|
list: [],
|
|
|
openAttr: false,
|
|
|
isMapShow: '', //第三方商户是否启用地图显示
|
|
|
- isStartLocation: null,
|
|
|
- isSystemLocation: null
|
|
|
+ isStartLocation: null, // 是否授权地理位置获取权限
|
|
|
+ isSystemLocation: null // 手机系统设置中定位是否开启
|
|
|
},
|
|
|
onLoad: function(options) {
|
|
|
let that = this;
|
|
|
+
|
|
|
+ wx.clearStorageSync();
|
|
|
+
|
|
|
// console.log('http://120.76.26.84:80/group1/M00/00/03/rBJEdVv1LDWAAjsfABCztmpupr8780.mp4')
|
|
|
// console.log(wx.getFileSystemManager().readFile())
|
|
|
wx.setStorageSync("navUrl", "/pages/index/index");
|
|
@@ -37,37 +40,113 @@ Page({
|
|
|
// options.scene = 67;
|
|
|
// options.scene = 28;
|
|
|
// options.scene = 8;
|
|
|
+
|
|
|
+ // 目前共分四种情况进入小程序
|
|
|
+
|
|
|
if (options.scene) {
|
|
|
+ // 是否通过扫门店码进入小程序首页
|
|
|
+
|
|
|
// console.log("have scene");
|
|
|
var scene = decodeURIComponent(options.scene);
|
|
|
console.log("scene is ", scene);
|
|
|
that.setData({
|
|
|
storeId: scene
|
|
|
});
|
|
|
+ wx.removeStorageSync('storeId');
|
|
|
wx.setStorageSync('storeId', scene);
|
|
|
- //扫码进入的小程序则清除是否分享缓存
|
|
|
- wx.removeStorageSync('isShare');
|
|
|
+ console.log('扫门店码进入小程序首页,storeId(scene):', scene)
|
|
|
+
|
|
|
+ //扫门店码进入的小程序首页则清除是否分享缓存
|
|
|
+ // 20210908 add by scott chen
|
|
|
+ wx.setStorageSync('isScanShopEntry', 'true'); // 通过扫门店码进入
|
|
|
+ wx.removeStorageSync('isShareIndexEntry'); // 通过分享首页进入
|
|
|
+ wx.removeStorageSync('isShareGoodEntry'); // 通过分享商品进入
|
|
|
+ wx.removeStorageSync('isDirectEntry'); // 直接进入
|
|
|
+
|
|
|
+ //清除是否分享商品标识缓存
|
|
|
+ wx.removeStorageSync('isShareGood');
|
|
|
+
|
|
|
+ } else if (options.shareIndex) {
|
|
|
+ // 是否通过分享首页进入小程序首页
|
|
|
+
|
|
|
+ // console.log("have shareIndex");
|
|
|
+ var shareIndex = decodeURIComponent(options.shareIndex);
|
|
|
+ console.log("shareIndex is ", shareIndex);
|
|
|
+ that.setData({
|
|
|
+ storeId: shareIndex
|
|
|
+ });
|
|
|
+ wx.removeStorageSync('storeId');
|
|
|
+ wx.setStorageSync('storeId', shareIndex);
|
|
|
+ console.log('分享门店首页进入小程序首页,storeId(shareIndex):', shareIndex)
|
|
|
+
|
|
|
+ wx.setStorageSync('isShareIndexEntry', 'true'); // 通过分享首页进入
|
|
|
+ wx.removeStorageSync('isScanShopEntry'); // 通过扫门店码进入
|
|
|
+ wx.removeStorageSync('isShareGoodEntry'); // 通过分享商品进入
|
|
|
+ wx.removeStorageSync('isDirectEntry'); // 直接进入
|
|
|
+
|
|
|
+ //清除是否分享商品标识缓存
|
|
|
+ wx.removeStorageSync('isShareGood');
|
|
|
+
|
|
|
} else {
|
|
|
- //是否分享过商品,有数据则分享过;从首页进入页面则没有分享过,从详情页进入则分享过
|
|
|
- if (wx.getStorageSync('isShare') == 'true') {
|
|
|
- console.log('是分享进入首页门店id:' + wx.getStorageSync('storeId') + ',从商品页获取的缓存')
|
|
|
- console.log('是分享进入首页:' + wx.getStorageSync('isShare'))
|
|
|
+ // 是否通过分享商品进入,或直接进入小程序
|
|
|
+
|
|
|
+ // 是否分享过商品进入,isShareGoods标识是通过商品分享进入goods页面后,生成的标记;
|
|
|
+ if (wx.getStorageSync('isShareGoods') == 'true') {
|
|
|
+
|
|
|
+ // 商品分享一定会有storeId编号
|
|
|
+ if(!wx.getStorageSync('storeId')) {
|
|
|
+ console.log('商品分享进入首页,从商品页获取缓存的storeId不存在。');
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('商品分享进入首页,从商品页获取缓存的storeId:', wx.getStorageSync('storeId'));
|
|
|
+ that.setData({
|
|
|
+ storeId: wx.getStorageSync('storeId')
|
|
|
+ });
|
|
|
+
|
|
|
+ wx.setStorageSync('isShareGoodEntry', 'true'); // 通过分享商品进入
|
|
|
+ wx.removeStorageSync('isScanShopEntry'); // 通过扫门店码进入
|
|
|
+ wx.removeStorageSync('isShareIndexEntry'); // 通过分享首页进入
|
|
|
+ wx.removeStorageSync('isDirectEntry'); // 直接进入
|
|
|
} else {
|
|
|
- //小程序入口进入的主页,则清除storeId,获取当前地址最近的门店
|
|
|
+
|
|
|
+ //直接进入小程序主页,则清除storeId,通过当前位置获取附近门店
|
|
|
+
|
|
|
wx.removeStorageSync('storeId');
|
|
|
- // console.log('不是分享进入首页门店id:【' + wx.getStorageSync('storeId') + '】,获取最近门店')
|
|
|
- // console.log('不是分享进入首页:' + wx.getStorageSync('isShare'))
|
|
|
+ that.setData({
|
|
|
+ storeId: '',
|
|
|
+ storeName: ''
|
|
|
+ });
|
|
|
+ console.log('直接进入小程序,storeId:', that.data.storeId)
|
|
|
+
|
|
|
+ wx.setStorageSync('isDirectEntry', 'true'); // 直接进入
|
|
|
+ wx.removeStorageSync('isScanShopEntry'); // 通过扫门店码进入
|
|
|
+ wx.removeStorageSync('isShareIndexEntry'); // 通过分享首页进入
|
|
|
+ wx.removeStorageSync('isShareGoodEntry'); // 通过分享商品进入
|
|
|
+
|
|
|
+ //清除是否分享商品标识缓存
|
|
|
+ wx.removeStorageSync('isShareGood');
|
|
|
}
|
|
|
}
|
|
|
+ console.log('isScanShopEntry-0:', wx.getStorageSync('isScanShopEntry'))
|
|
|
+ console.log('isShareIndexEntry-0:', wx.getStorageSync('isShareIndexEntry'))
|
|
|
+ console.log('isShareGoodEntry-0:', wx.getStorageSync('isShareGoodEntry'))
|
|
|
+ console.log('isDirectEntry-0:', wx.getStorageSync('isDirectEntry'))
|
|
|
+
|
|
|
wx.getLocation({
|
|
|
success: function(location) {
|
|
|
- // that.successLoadStore(location);
|
|
|
+ // do nothing
|
|
|
+ // console.log('获取用户位置成功,获取附近门店');
|
|
|
},
|
|
|
fail: function() {
|
|
|
+ // console.log('获取用户位置失败');
|
|
|
wx.hideLoading();
|
|
|
+
|
|
|
+ // 判断获取地理位置失败的原因
|
|
|
+ // 获取配置信息
|
|
|
wx.getSetting({
|
|
|
success: function(res) {
|
|
|
if (!res.authSetting['scope.userLocation']) {
|
|
|
+ // 是否授权地理位置获取权限
|
|
|
wx.showModal({
|
|
|
title: '',
|
|
|
content: '检测到您没有开启获取地理位置权限,是否开启',
|
|
@@ -83,7 +162,9 @@ Page({
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
- //用户已授权,但是获取地理位置失败,提示用户去系统设置中打开定位
|
|
|
+ // 已授权地理位置获取权限,但依然未获取到定位
|
|
|
+ // 用户未在手机系统设置中打开定位
|
|
|
+
|
|
|
wx.showModal({
|
|
|
title: '',
|
|
|
content: '请在系统设置中打开定位服务',
|
|
@@ -110,18 +191,62 @@ Page({
|
|
|
wx.setStorageSync("navUrl", "/pages/index/index");
|
|
|
wx.setStorageSync("isLocationIndex", "false"); //购物车是否已跳转登录页,到首页重置字段为false未跳转
|
|
|
if (!wx.getStorageSync('isRefusedLogin')) {
|
|
|
+ // 是否拒绝授权
|
|
|
if (wx.getStorageSync('userInfo') && wx.getStorageSync('token')) {
|
|
|
console.log('缓存是否授权为空,用户已授权:' + wx.getStorageSync('isRefusedLogin'))
|
|
|
- wx.setStorageSync('isRefusedLogin', 'false');
|
|
|
+ wx.setStorageSync('isRefusedLogin', 'false'); //授权
|
|
|
} else {
|
|
|
console.log('缓存是否授权为空,用户未授权:' + wx.getStorageSync('isRefusedLogin'))
|
|
|
wx.setStorageSync('isRefusedLogin', 'true'); //拒绝授权
|
|
|
}
|
|
|
} else {
|
|
|
- console.log('授权不为空:' + wx.getStorageSync('isRefusedLogin'))
|
|
|
+ console.log('授权不为空,isRefusedLogin:' + wx.getStorageSync('isRefusedLogin'))
|
|
|
wx.setStorageSync('isRefusedLogin', wx.getStorageSync('isRefusedLogin'));
|
|
|
}
|
|
|
- that.syncStore();
|
|
|
+ console.log('是否拒绝授权,isRefusedLogin', wx.getStorageSync('isRefusedLogin'));
|
|
|
+
|
|
|
+ // 判断isMapShow,是否同步门店,没有storeId的,要同步
|
|
|
+ that.syncNearbyStore();
|
|
|
+
|
|
|
+ /*if(wx.getStorageSync('isDirectEntry') == 'true') {
|
|
|
+ // 直接进入小程序,或分享首页进入,同步
|
|
|
+ that.syncNearbyStore();
|
|
|
+ } else if(wx.getStorageSync('isScanShopEntry') == 'true'
|
|
|
+ || wx.getStorageSync('isShareGoodEntry') == 'true'
|
|
|
+ || wx.getStorageSync('isShareIndexEntry' == 'true')) {
|
|
|
+ // 扫门店码,商品分享,首页分享,判断当前门店码判断isMapShow是否开启
|
|
|
+
|
|
|
+ if (!wx.getStorageSync('storeId')) {
|
|
|
+ // 判断条件成立,如发生丢失storeId的问题,为保持容错,加载附近门店
|
|
|
+
|
|
|
+ wx.showModal({
|
|
|
+ title: '',
|
|
|
+ content: '<>通过扫门店码进入,仍然加载附近门店<>',
|
|
|
+ confirmText: '确定',
|
|
|
+ showCancel: true,
|
|
|
+ cancelText: '取消',
|
|
|
+ success: function(resConfirm2) {
|
|
|
+ // 加载附近门店
|
|
|
+ this.syncNearbyStore();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.syncNearbyStore();
|
|
|
+ // isMapShow是否开启
|
|
|
+ // 门店及所属第三方商户信息
|
|
|
+ // function callback() {
|
|
|
+ // // 商户地图是否显示 0:否 1:是
|
|
|
+ // if(that.data.isMapShow == '1') {
|
|
|
+ // this.syncNearbyStore();
|
|
|
+ // }
|
|
|
+ // };
|
|
|
+ // this.getStoreByIdWithMerch(callback);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // do nothing
|
|
|
+ console.log('进入小程序标识异常,onShow() 判断isMapShow,是否同步门店,无进入条件');
|
|
|
+ }*/
|
|
|
+
|
|
|
// if (wx.getStorageSync('userInfo') && wx.getStorageSync('token')) {
|
|
|
|
|
|
// } else {
|
|
@@ -160,19 +285,55 @@ Page({
|
|
|
return {
|
|
|
title: '中网跨境电商主页',
|
|
|
desc: '中网跨境电商主页',
|
|
|
- path: '/pages/index/index?scene=' + that.data.storeId
|
|
|
+ path: '/pages/index/index?shareIndex=' + that.data.storeId
|
|
|
}
|
|
|
},
|
|
|
- // 同步门店
|
|
|
- syncStore: function() {
|
|
|
+
|
|
|
+ // 获取门店及商户信息
|
|
|
+ // 此时 storeId已经保存到本地缓存中
|
|
|
+ getStoreByIdWithMerch: function(callback) {
|
|
|
+ let that = this;
|
|
|
+ util.request(api.StoreByIdWithMerch, {
|
|
|
+ storeId: wx.getStorageSync('storeId'),
|
|
|
+ }).then((res) => {
|
|
|
+ if (res.errno == '0') {
|
|
|
+ if(res.data) {
|
|
|
+ let storeVo = res.data.storeVo;
|
|
|
+ let storeWithThirdMerchBizVo = res.data.storeWithThirdMerchBizVo;
|
|
|
+
|
|
|
+ that.setData({
|
|
|
+ storeId: storeWithThirdMerchBizVo.id,
|
|
|
+ storeName: storeWithThirdMerchBizVo.storeName,
|
|
|
+ isMapShow: storeWithThirdMerchBizVo.isMapShow
|
|
|
+ })
|
|
|
+ console.log('获取第三方商户及门店信息,storeId:', storeWithThirdMerchBizVo.id)
|
|
|
+ console.log('获取第三方商户及门店信息,storeName:', storeWithThirdMerchBizVo.storeName)
|
|
|
+ console.log('获取第三方商户及门店信息,isMapShow:', storeWithThirdMerchBizVo.isMapShow)
|
|
|
+
|
|
|
+ wx.setStorageSync('storeId', storeWithThirdMerchBizVo.id);
|
|
|
+ wx.setStorageSync('storeName', storeWithThirdMerchBizVo.storeName);
|
|
|
+ wx.setStorageSync('isMapShow', storeWithThirdMerchBizVo.isMapShow);
|
|
|
+ wx.setStorageSync('storeVo', JSON.stringify(storeVo));
|
|
|
+ }
|
|
|
+ if(callback){
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }).catch((error) => {
|
|
|
+
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ // 同步附近门店
|
|
|
+ syncNearbyStore: function() {
|
|
|
let that = this;
|
|
|
// console.log(wx.getStorageSync('merchSn'));
|
|
|
//获取附件门店信息
|
|
|
- // util.getLocation((lng, lat) => {
|
|
|
wx.getLocation({
|
|
|
success: function(location) {
|
|
|
// console.log(location)
|
|
|
- that.successLoadStore(location);
|
|
|
+ that.loadNearbyStore(location);
|
|
|
},
|
|
|
fail: function() {
|
|
|
wx.hideLoading();
|
|
@@ -187,33 +348,19 @@ Page({
|
|
|
that.setData({
|
|
|
isSystemLocation: false
|
|
|
});
|
|
|
- // wx.showModal({
|
|
|
- // title: '',
|
|
|
- // content: '请在系统设置中打开定位服务',
|
|
|
- // confirmText: '确定',
|
|
|
- // showCancel: false,
|
|
|
- // success: function (resConfirm2) {
|
|
|
- // that.setData({
|
|
|
- // isSystemLocation: false
|
|
|
- // });
|
|
|
- // }
|
|
|
- // })
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- /**
|
|
|
- * 打开微信定位
|
|
|
- */
|
|
|
- openSetLocation: function() {
|
|
|
- wx.openSetting();
|
|
|
- },
|
|
|
+
|
|
|
/**
|
|
|
* 定位确定授权加载附近门店信息
|
|
|
+ * 分不同情况,加载附近门店信息
|
|
|
*/
|
|
|
- successLoadStore: function(location) {
|
|
|
+ loadNearbyStore: function(location) {
|
|
|
+
|
|
|
let that = this;
|
|
|
that.setData({
|
|
|
isStartLocation: true,
|
|
@@ -221,15 +368,18 @@ Page({
|
|
|
});
|
|
|
var lng = location.longitude;
|
|
|
var lat = location.latitude;
|
|
|
+
|
|
|
wx.setStorageSync('location', JSON.stringify({
|
|
|
lng,
|
|
|
lat
|
|
|
}));
|
|
|
- let storeId = wx.getStorageSync('storeId');
|
|
|
+
|
|
|
+ console.log('定位加载附近门店时,storeId:', wx.getStorageSync('storeId'))
|
|
|
+
|
|
|
util.request(api.NearbyList, {
|
|
|
longitude: lng,
|
|
|
latitude: lat,
|
|
|
- storeId: storeId,
|
|
|
+ storeId: wx.getStorageSync('storeId'),
|
|
|
thirdPartyMerchCode: ''
|
|
|
}).then((res) => {
|
|
|
let nlist = res.data;
|
|
@@ -240,45 +390,73 @@ Page({
|
|
|
if (!wx.getStorageSync('currentCategory')) {
|
|
|
wx.removeStorageSync('currentCategory');
|
|
|
}
|
|
|
+
|
|
|
if (!nlist.length) {
|
|
|
wx.removeStorageSync('nearStoreList');
|
|
|
- wx.removeStorageSync('mapIndexStoreId');
|
|
|
} else {
|
|
|
wx.setStorageSync('nearStoreList', JSON.stringify(nlist));
|
|
|
- wx.setStorageSync('mapIndexStoreId', nlist[0].id);
|
|
|
}
|
|
|
|
|
|
- if (!nlist.length) {
|
|
|
- // wx.removeStorageSync('storeId');
|
|
|
- wx.removeStorageSync('storeVo');
|
|
|
- that.setData({
|
|
|
- storeName: '附近暂无门店'
|
|
|
- })
|
|
|
- } else {
|
|
|
- that.setData({
|
|
|
- storeName: nlist[0].storeName,
|
|
|
- storeId: nlist[0].id
|
|
|
- })
|
|
|
-
|
|
|
- that.checkLoginTokenByUpd(nlist);
|
|
|
- wx.setStorageSync('storeVo', JSON.stringify(nlist[0]));
|
|
|
+ let param = {}
|
|
|
+
|
|
|
+ // 区分情况,对原有门店编号及名称进行覆盖
|
|
|
+ if (wx.getStorageSync('isDirectEntry') == 'true') {
|
|
|
+
|
|
|
+ // 直接进入小程序
|
|
|
+ if (!nlist.length) {
|
|
|
+ wx.removeStorageSync('storeVo');
|
|
|
+ wx.removeStorageSync('mapIndexStoreId');
|
|
|
+
|
|
|
+ that.setData({
|
|
|
+ storeName: '附近暂无门店',
|
|
|
+ storeId: ''
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 更新
|
|
|
+ that.setData({
|
|
|
+ storeId: nlist[0].id,
|
|
|
+ storeName: nlist[0].storeName
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+ wx.setStorageSync('storeId', that.data.storeId);
|
|
|
+
|
|
|
+ param.id = nlist[0].id;
|
|
|
+ param.merchSn = nlist[0].merchSn;
|
|
|
+ } else if(wx.getStorageSync('isScanShopEntry') == 'true'
|
|
|
+ || wx.getStorageSync('isShareIndexEntry') == 'true'
|
|
|
+ || wx.getStorageSync('isShareGoodEntry') == 'true') {
|
|
|
+
|
|
|
+ // 不能使用附近门店编码storeId替代原有的storeId
|
|
|
+ param.id = wx.getStorageSync('storeId');
|
|
|
+ param.merchSn = nlist[0].merchSn;
|
|
|
}
|
|
|
+ wx.setStorageSync('mapIndexStoreId', nlist[0].id);
|
|
|
+
|
|
|
+ // 获取门店及第三方商户对应的信息
|
|
|
+ that.getStoreByIdWithMerch(that.checkLoginTokenByUpd(param));
|
|
|
+
|
|
|
+ // that.checkLoginTokenByUpd(param);
|
|
|
+ // wx.setStorageSync('storeVo', JSON.stringify(nlist[0]));
|
|
|
})
|
|
|
},
|
|
|
/**
|
|
|
* 校验token是否失效,失效则更新新token
|
|
|
*/
|
|
|
- checkLoginTokenByUpd: function (nlist){
|
|
|
+ checkLoginTokenByUpd: function (param){
|
|
|
var that = this;
|
|
|
+ // token验证
|
|
|
util.request(api.checkToken, {
|
|
|
token: wx.getStorageSync('token'),
|
|
|
isRefusedLogin: wx.getStorageSync('isRefusedLogin'),
|
|
|
userId: wx.getStorageSync('userId')+'',
|
|
|
- storeId: parseInt(that.data.storeId)
|
|
|
+ storeId: parseInt(param.storeId)
|
|
|
}, 'POST').then(function (res) {
|
|
|
if (res.data.errno == 401) {
|
|
|
- console.log(res.data.errmsg)
|
|
|
- console.log(wx.getStorageSync('token'))
|
|
|
+ // token在服务端失败
|
|
|
+ console.log('checkLoginTokenByUpd() res.data.errmsg:', res.data.errmsg)
|
|
|
+ console.log('checkLoginTokenByUpd() token:', wx.getStorageSync('token'))
|
|
|
+
|
|
|
wx.getSetting({
|
|
|
success: (setRes) => {
|
|
|
if (setRes.authSetting['scope.userInfo'] == undefined) {
|
|
@@ -286,8 +464,8 @@ Page({
|
|
|
wx.request({
|
|
|
url: api.AuthLoginSaveToken,
|
|
|
data: {
|
|
|
- storeId: that.data.storeId,
|
|
|
- merchSn: nlist[0].merchSn
|
|
|
+ storeId: param.storeId,
|
|
|
+ merchSn: param.merchSn
|
|
|
},
|
|
|
method: 'POST',
|
|
|
header: {
|
|
@@ -297,16 +475,14 @@ Page({
|
|
|
success: function (wxRes) {
|
|
|
// console.log(wxRes)
|
|
|
if (wxRes.data.errno === 0) {
|
|
|
- //存储用户信息
|
|
|
- // wx.setStorageSync('userInfo', wxRes.data.data.userInfo);
|
|
|
+ //存储信息
|
|
|
wx.setStorageSync('token', wxRes.data.data.token);
|
|
|
- console.log('微信用户未授权,获取一个新的token' + wx.getStorageSync('token'))
|
|
|
- // wx.setStorageSync('userId', wxRes.data.data.userId);
|
|
|
- that.chooseStore(nlist[0].id, nlist[0].merchSn);
|
|
|
+ console.log('checkLoginTokenByUpd() loginSaveToken 微信用户未授权,获取到一个新的token:' + wx.getStorageSync('token'))
|
|
|
+ that.chooseStore(param.id, param.merchSn);
|
|
|
}
|
|
|
},
|
|
|
fail: function (err) {
|
|
|
- console.log("failed");
|
|
|
+ console.log("checkLoginTokenByUpd() loginSaveToken failed");
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
@@ -320,8 +496,8 @@ Page({
|
|
|
data: {
|
|
|
code: loginRes.code,
|
|
|
userInfo: wx.getStorageSync('userInfo'),
|
|
|
- storeId: that.data.storeId,
|
|
|
- merchSn: nlist[0].merchSn
|
|
|
+ storeId: wx.getStorageSync('storeId'),
|
|
|
+ merchSn: param.merchSn
|
|
|
},
|
|
|
method: 'POST',
|
|
|
header: {
|
|
@@ -335,54 +511,67 @@ Page({
|
|
|
wx.setStorageSync('token', wxRes.data.data.token);
|
|
|
wx.setStorageSync('userId', wxRes.data.data.userId);
|
|
|
wx.setStorageSync('isRefusedLogin', 'false');//允许授权
|
|
|
- console.log("登录成功");
|
|
|
- that.chooseStore(nlist[0].id, nlist[0].merchSn);
|
|
|
+ console.log("checkLoginTokenByUpd() loginSaveToken token失效,更新token,登录成功");
|
|
|
+ that.chooseStore(param.id, param.merchSn);
|
|
|
}
|
|
|
},
|
|
|
fail: function (err) {
|
|
|
- console.log("failed");
|
|
|
+ console.log("checkLoginTokenByUpd() loginSaveToken failed");
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
- console.log("failed");
|
|
|
+ console.log("checkLoginTokenByUpd() loginSaveToken !loginRes.code failed");
|
|
|
}
|
|
|
},
|
|
|
fail: function (err) {
|
|
|
- console.log("failed");
|
|
|
+ console.log("checkLoginTokenByUpd() wx.login() failed");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
- console.log('token未失效');
|
|
|
+ console.log('checkLoginTokenByUpd() checkToken token未失效');
|
|
|
// console.log(res)
|
|
|
- that.chooseStore(nlist[0].id, nlist[0].merchSn);
|
|
|
+ that.chooseStore(param.id, param.merchSn);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
// 更新门店Id
|
|
|
chooseStore: function(storeId, merchSn) {
|
|
|
let that = this;
|
|
|
+ console.log('chooseStore(),storeId:', storeId,)
|
|
|
+
|
|
|
util.request(api.ChooseStoreId, {
|
|
|
storeId: storeId,
|
|
|
merchSn: merchSn,
|
|
|
isRefusedLogin: wx.getStorageSync('isRefusedLogin')
|
|
|
}, 'POST').then(function (res) {
|
|
|
if (res.errno === 0) {
|
|
|
- wx.setStorageSync('storeId', storeId);
|
|
|
+
|
|
|
+ if(wx.getStorageSync('isScanShopEntry') == 'true'
|
|
|
+ || wx.getStorageSync('isShareIndexEntry') == 'true'
|
|
|
+ || wx.getStorageSync('isShareGoodEntry') == 'true'){
|
|
|
+ // 通过扫门店码,分享首页,分享商品等进入,不更新
|
|
|
+ } else if(wx.getStorageSync('isDirectEntry') == 'true') {
|
|
|
+ // 直接进入,更新
|
|
|
+ that.setData({
|
|
|
+ storeId: storeId,
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log('更新了门店编号,storeId:', storeId)
|
|
|
+ wx.setStorageSync('storeId', storeId);
|
|
|
+ }
|
|
|
+
|
|
|
wx.setStorageSync('merchSn', merchSn);
|
|
|
- console.log(res.data.token)
|
|
|
+
|
|
|
+ console.log('chooseStore() token:',res.data.token)
|
|
|
wx.setStorageSync('token', res.data.token);
|
|
|
- // wx.getSetting({
|
|
|
- // success: (setRes) => {
|
|
|
- // if (setRes.authSetting['scope.userInfo'] == undefined) {
|
|
|
-
|
|
|
- // }else{
|
|
|
- // wx.setStorageSync('token', res.data.token);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // });
|
|
|
+
|
|
|
+ console.log('isScanShopEntry-1:', wx.getStorageSync('isScanShopEntry'))
|
|
|
+ console.log('isShareIndexEntry-1:', wx.getStorageSync('isShareIndexEntry'))
|
|
|
+ console.log('isShareGoodEntry-1:', wx.getStorageSync('isShareGoodEntry'))
|
|
|
+ console.log('isDirectEntry-1:', wx.getStorageSync('isDirectEntry'))
|
|
|
|
|
|
if (wx.getStorageSync('userInfo') && wx.getStorageSync('token')) {
|
|
|
that.reLoad();
|
|
@@ -400,6 +589,7 @@ Page({
|
|
|
// console.log(wx.getStorageSync('userId'));
|
|
|
// console.log(wx.getStorageSync('storeId'));
|
|
|
// console.log(wx.getStorageSync('merchSn'));
|
|
|
+
|
|
|
if (wx.getStorageSync('storeId')) {
|
|
|
if (wx.getStorageSync('userId')) {
|
|
|
wx.request({
|
|
@@ -426,7 +616,7 @@ Page({
|
|
|
}
|
|
|
},
|
|
|
fail: function(err) {
|
|
|
- console.log("failed");
|
|
|
+ console.log("reLoad()::api.updateLoginUser: failed");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -451,18 +641,13 @@ Page({
|
|
|
// groupBanner: res.data.groupBanner,
|
|
|
channel: res.data.channel
|
|
|
});
|
|
|
- // console.log(that.data.hotGoods.length)
|
|
|
- // console.log(wx.getStorageSync('storeId'))
|
|
|
- // console.log(wx.getStorageSync('mapIndexStoreId'))
|
|
|
- // if (that.data.hotGoods.length == 0) {
|
|
|
- // that.getGoodsList();
|
|
|
- // }
|
|
|
- // console.log("mapIndexStoreId:" + wx.getStorageSync('mapIndexStoreId'))
|
|
|
- // console.log("storeId:" + wx.getStorageSync('storeId'))
|
|
|
- // console.log("isShare:" + wx.getStorageSync('isShare'))
|
|
|
- // console.log("isLoadGoods:" + wx.getStorageSync('isLoadGoods'))
|
|
|
- //当切换了门店地图(mapIndexStoreId),或是由用户分享进入的商品详情切换进入的首页(isShare:true)
|
|
|
- if (wx.getStorageSync('storeId') != wx.getStorageSync('mapIndexStoreId') || wx.getStorageSync('isShare') == 'true' || that.data.hotGoods.length == 0 || wx.getStorageSync('isLoadGoods') == '1') {
|
|
|
+
|
|
|
+ //当切换了门店地图(mapIndexStoreId);或由用户分享进入的商品详情页,再切换进入的首页(isShareGoodEntry:true)
|
|
|
+ if (wx.getStorageSync('storeId') != wx.getStorageSync('mapIndexStoreId')
|
|
|
+ || wx.getStorageSync('isShareGoodEntry') == 'true'
|
|
|
+ || that.data.hotGoods.length == 0
|
|
|
+ || wx.getStorageSync('isLoadGoods') == '1') {
|
|
|
+
|
|
|
that.setData({
|
|
|
hotGoods: [],
|
|
|
page: 1
|
|
@@ -473,7 +658,7 @@ Page({
|
|
|
storeId: wx.getStorageSync('storeId')
|
|
|
}).then(function(res) {});
|
|
|
}
|
|
|
- wx.setStorageSync('isShare', 'false');
|
|
|
+ wx.setStorageSync('isShareGoodEntry', 'false');
|
|
|
}
|
|
|
}
|
|
|
wx.hideLoading();
|
|
@@ -513,6 +698,7 @@ Page({
|
|
|
});
|
|
|
},
|
|
|
handleStore() {
|
|
|
+ console.log('进入 handleStore()');
|
|
|
wx.navigateTo({
|
|
|
url: '../map/map',
|
|
|
})
|