Scene.vue
4.88 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<template>
<view class="box">
<template v-for="(item, index) in sceneList">
<view
:key="index"
:class="['items', `${item.actived ? 'active' : ''}`]"
@click="selectScene(item, index)"
>
<view class="left">
<view :class="['sprite-icon', `icon-scene-${item.sceneType}`]"></view>
</view>
<view class="right">
<view class="name">
{{ item.sceneName }}
</view>
<view class="shop_no">
{{ item.sceneDesc }}
</view>
</view>
</view>
</template>
</view>
</template>
<script type="text/ecmascript-6">
import utils from '@/utils/utils.js'
export default {
name: '',
data () {
return {
sceneList: [
{
sceneName: '轻改',
sceneDesc: '太阳膜升级转化',
sceneType: 1,
actived: false
},
{
sceneName: '会员权益/升级',
sceneDesc: '权益、延保',
sceneType: 0,
actived: false
},
{
sceneName: '二手车',
sceneDesc: '二手车业务',
sceneType: 7,
actived: false
},
],
userInfo: {},
}
},
mounted () {
},
methods: {
init (userInfo) {
this.userInfo = userInfo
uni.$logger.local.info(`进入选择场景页!`)
},
// 选择场景
async selectScene ({ sceneType }, index) {
uni.$logger.local.info(`选择场景${sceneType}!`)
let { sceneList, userInfo, userInfo: { openSceneArr } } = this
try {
if (!openSceneArr.includes(sceneType) && !userInfo?.isSuper) return uni.showToast({
title: '暂未开通此场景',
icon: 'none'
})
sceneList.map(i => (i.actived = false))
sceneList[index].actived = true
this.sceneList = sceneList
userInfo.sceneType = sceneType
uni.showLoading({
mask: true
})
if (userInfo?.isSuper) this.jump(userInfo)
else {
const data = await uni.$api.userApi.selectMerchantScene({
merchantId: userInfo.shopMerchantId,
merchantName: userInfo.shopMerchantName,
sceneType
})
if (data) this.jump(userInfo, data)
else {
uni.$logger.local.error(`选择场景异常:merchantId:${userInfo.shopMerchantId},merchantName:${userInfo.shopMerchantName},sceneType:${sceneType},接口返回:${JSON.stringify(data || '')}`)
}
}
} catch (error) {
uni.hideLoading()
uni.showToast({
title: typeof error == "string" ? error : error.toString(),
icon: 'none'
})
uni.$logger.local.error(`选择场景异常:merchantId:${userInfo?.shopMerchantId},merchantName:${userInfo?.shopMerchantName},sceneType:${sceneType},失败原因:${typeof error == "string" ? error : error.toString()}`)
}
},
jump: utils.throttle(async function (userInfo, data) {
uni.$logger.local.info(`跳转进入首页!`)
try {
uni.hideLoading()
if (data) userInfo.loginRoleOnSelectMerchant = data?.loginRoleOnSelectMerchant
let { shopMerchantId } = userInfo
//调接口获取门店主营品牌
uni.showLoading({
mask: true
})
const res = await uni.$api.userApi.getMerchantBrand({
merchantId: shopMerchantId
})
uni.hideLoading()
userInfo.channelType = res.channelType || 1 // 默认1 1问界 2 比亚迪 3 其他
// userInfo.channelType = 2
uni.$storage.set('userInfo', userInfo)
let url = {
1: '/pages/boutique/index',
0: '/pages/equity/index',
7: '/pages/usedCar/index'
}[userInfo.sceneType]
uni.reLaunch({
url
})
uni.$storage.rm("boutique_YQorderSetting") //切换场景后清空配置
} catch (error) {
uni.$logger.local.error(`选择场景后跳转异常:${error}!`)
uni.hideLoading()
uni.showToast({
title: error,
icon: 'none'
})
}
}, 3000)
}
}
</script>
<style scoped lang="scss">
.box {
display: flex;
align-items: center;
flex-wrap: wrap;
padding: 0 toRpx(48);
gap: toRpx(48);
.items {
width: calc(50% - #{toRpx(24)});
height: toRpx(160);
background: #ffffff;
border-radius: toRpx(16);
padding: toRpx(32);
display: flex;
align-items: center;
box-sizing: border-box;
border: toRpx(4) solid transparent;
.left {
margin-right: toRpx(28);
flex-shrink: 0;
}
.right {
flex: 1;
.name {
font-weight: 500;
font-size: toRpx(32);
color: #181a1f;
margin-bottom: toRpx(12);
}
.shop_no {
font-size: toRpx(28);
color: #999ea8;
}
}
}
.active {
border: toRpx(4) solid #347bff;
}
}
</style>