openBusiness.js
4.73 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// packageOutput/pages/openBusiness/openBusiness.js
import outputApi from '~/api/outputApi/index'
import { IMG_URL } from '~/utils/constantData'
Page({
/**
* 页面的初始数据
*/
data: {
IMGURL: IMG_URL,
merchantInfo: {},
sceneCodeList: [],
// 场景业务
sceneInfo: {
sceneList: [{
sceneCode: 'SC001',
flag: true
}, {
sceneCode: 'SC002',
flag: true
}, {
sceneCode: 'SC003',
flag: true
}, {
sceneCode: 'SC004',
flag: true
}]
},
sceneActive: 1,
sceneCodeActive: 'SC002',
isLoading: false,
// 活动内容
activityList: [],
sceneActivityObj: {
scene0: [],
scene1: [],
scene2: [],
scene3: []
}
},
// 查找当前高亮场景的idx
findSceneIdx(sceneCode = this.data.sceneCodeActive) {
return this.data.sceneCodeList.findIndex(item => item == sceneCode)
},
getSceneProStatus(sceneCode) {
var params = {
serviceMerchantId: this.data.merchantInfo.pMerchantId,
merchant4sId: this.data.merchantInfo.merchantId,
sceneCode: sceneCode
}
outputApi.getSceneProStatus(params).then(res => {
var proList = res.find(item => item.sceneCode == sceneCode)
this.setData({
['sceneActivityObj.scene' + this.findSceneIdx()]: proList.productList
})
this.setCurActivity()
})
},
// 场景切换
handleSceneChange(e) {
// var idx = e.detail.sceneIdx
var sceneCode = e.detail.sceneCode
this.setData({
sceneCodeActive: sceneCode,
})
if (!this.data.sceneActivityObj['scene' + this.findSceneIdx()].length) {
this.getSceneProStatus(this.data.sceneCodeList[this.findSceneIdx()])
return true
}
this.setCurActivity()
// console.log('换内容---')
},
setCurActivity() {
this.setData({
activityList: JSON.parse(JSON.stringify(this.data.sceneActivityObj['scene' + this.findSceneIdx()]))
})
},
// 活动切换
handleActClick(e) {
var idx = e.currentTarget.dataset.idx
this.setData({
['activityList[' + idx + '].checked']: !this.data.activityList[idx].checked
})
},
handleJump() {
// clearTimeout(this.data.time)
this.data.time = new setTimeout(() => {
wx.$router.go('pages.output', { page: 'client', refresh: true })
}, 2000)
// wx.$api.showToast('申请成功')
// setTimeout(() => {
// wx.$router.back(page => {
// let node = page.selectComponent('#client')
// // console.log(node)
// node.getMerchantRange && node.getMerchantRange()
// // page.getClueInit && page.getClueInit()
// })
// }, 1000)
},
handleConfirm() {
if(this.data.isLoading) {
return
}
var params = {
serviceMerchantId: this.data.merchantInfo.pMerchantId,
serviceMerchantName: this.data.merchantInfo.pMerchantName,
merchantId: this.data.merchantInfo.merchantId,
merchantName: this.data.merchantInfo.merchantName,
sceneCode: this.data.sceneCodeList[this.findSceneIdx()],
productCodes: this.data.activityList.filter(item => item.checked == true).map(item => item.productCode),
clueId: this.data.clueId
}
if (!params.productCodes.length) {
wx.$api.showToast('请选产品/活动')
return true
}
this.setData({
isLoading: true
})
outputApi.applyActivity(params).then(res => {
wx.showToast({
title: '提交成功',
icon: 'success',
duration: 2000,
mask: true,
success: () => {
this.handleJump()
}
})
}).catch(() => {
this.setData({
isLoading: false
})
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
wx.$router.getData(obj => {
this.setData({
merchantInfo: obj.merchantInfo,
// sceneActive: obj.sceneActive,
sceneCodeList: obj.sceneCodeList || ['SC002', 'SC003', 'SC004', 'SC001'],
sceneCodeActive: obj.sceneCodeActive || 'SC002',
clueId: obj.clueId
})
this.getSceneProStatus(this.data.sceneCodeList[this.findSceneIdx()])
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
wx.setNavigationBarTitle({
title: '开通店面业务',
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {}
})