blank.js
2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { commonApi, ssoApi } from '~/api/api'
Page({
// 体验卡中转站---解决H5端跳转小程序swichTab无法传参问题
onLoad(options) {
console.log(options)
if(options.scene){
this.getOptions(options.scene)
}else{
wx.$storage.set('bindInfo', options.freecard)
const index = 1-wx.$util.judgeMerchantForXubao()
wx.$router.reLaunch(`/pages/tab/shopMall/index?tabIndex=${index}`)
}
},
getOptions(scene){
console.log(scene,'scene')
if(!scene) return wx.$api.showToast('二维码错误');
const qrcodeQuery = decodeURIComponent(scene);
const id = qrcodeQuery.split("=").pop();
commonApi
.getQrcodeParams({
id,
})
.then((res) => {
if(res.code=='0'){
let optionByApi = {}
console.log(res.data, 'resdata')
let arr = res.data.scene.split('&')
arr.forEach(item=> {
let newArr = item.split('=')
optionByApi[newArr[0]] = newArr[1]
})
if(!optionByApi.openId) return wx.$api.showToast('暂未登录');
ssoApi.loginByOpenId({openId: optionByApi.openId}).then(({
code,
data,
message
}) => {
if(code=='0'){
wx.clearStorageSync()
wx.$util.setUserInfo(data)
wx.$util.setSessionId(data.sessionId)
wx.$storage.set('srcm_shopmall_merchant_id', optionByApi.merchantId)
wx.setStorageSync('showServicesMerchantId', optionByApi.merchantId);
let { pageType, tabIndex, merchantId } = optionByApi
let path = `/pages/tab/shopMall/index?tabIndex=${tabIndex}&merchantId=${merchantId}&pageType=${pageType}`
wx.reLaunch({
url: path,
});
}else{
wx.$api.showToast(message || '系统异常')
}
})
}else{
wx.$api.showToast(res.message || '系统异常')
}
});
},
})