Scene.vue
3.64 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
<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'>
export default {
name: '',
data () {
return {
sceneList: [
{
sceneName: '轻改',
sceneDesc: '太阳膜升级转化',
sceneType: 1,
actived: false
},
{
sceneName: '延保',
sceneDesc: '延保升级',
sceneType: 0,
actived: false
},
],
userInfo: {},
openSceneArr: []
}
},
mounted () {
},
methods: {
init (userInfo) {
this.userInfo = userInfo
this.getSceneArr()
},
getSceneArr () {
uni.showLoading()
// 超管默认开通全部场景
let { userInfo } = this
if (userInfo?.isSuper) return
// 获取4s店关联场景数据
uni.$api.userApi.getYqMerchantSceneConfigAPI({
yqMerchantId: userInfo?.subLoginUser?.merchantId,
merchantId: userInfo?.shopMerchantId
}).then(result => {
uni.hideLoading()
this.openSceneArr = result.map(val => { if (val.sceneOpenFlag == 0) return val.scene }) || []
})
},
// 选择场景
async selectScene ({ sceneType }, index) {
let { sceneList, openSceneArr, userInfo } = this
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
if (userInfo?.isSuper) this.jump(userInfo)
else {
try {
const { message, data, code } = await uni.$api.userApi.selectMerchantScene({
merchantId: userInfo.shopMerchantId,
merchantName: userInfo.shopMerchantName,
sceneType
})
if (code == 0) this.jump(userInfo, data)
else throw message
} catch (error) {
uni.showToast({
title: error,
icon: 'none'
})
}
}
},
jump (userInfo, data) {
if (data) userInfo.loginRoleOnSelectMerchant = data?.loginRoleOnSelectMerchant
uni.$storage.set('userInfo', userInfo)
let url = {
1: '/pages/boutique/index',
0: '/pages/home/home'
}[userInfo.sceneType]
uni.reLaunch({
url
})
}
}
}
</script>
<style scoped lang='scss'>
.box {
display: flex;
align-items: center;
flex-wrap: wrap;
padding: 0 48rpx;
gap: 48rpx;
.items {
width: calc(50% - 24rpx);
height: 160rpx;
background: #ffffff;
border-radius: 16rpx;
padding: 32rpx;
display: flex;
align-items: center;
box-sizing: border-box;
border: 4rpx solid transparent;
.left {
margin-right: 28rpx;
flex-shrink: 0;
}
.right {
flex: 1;
.name {
font-weight: 500;
font-size: 32rpx;
color: #181a1f;
margin-bottom: 12rpx;
}
.shop_no {
font-size: 28rpx;
color: #999ea8;
}
}
}
.active {
border: 4rpx solid #347bff;
}
}
</style>