MerchantScene.js
2.61 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
// pages/tab/outputValue/components/merchantCom/MerchantScene/MerchantScene.js
import constant from '../constant'
Component({
/**
* 组件的属性列表
*/
properties: {
curInfo: {
type: Object,
value: () => { },
observer(n) {
if (n) {
this.dealYearMonth()
this.dealCrowdData()
}
}
},
searchForm: {
type: Object,
value: () => {
return {
// 服务商商户号
partnerMerchantId: '',
// 4S店商户号
merchantId: '',
// 年月(yyyy-MM)
yearMonth: '',
// 场景(1精品升级,3众筹,0会员权益)
sceneType: '1'
}
},
observer: function (n) {
n & this.dealData()
}
}
},
/**
* 组件的初始数据
*/
data: {
sceneToInfo: constant.sceneToInfo,
sceneTopList: constant.membranesTopList,
sceneFormList: constant.membranesFormList,
sceneObj: {},
date: {
year: '',
month: ''
},
currentMonth: new Date().format('yyyy-MM')
},
/**
* 组件的方法列表
*/
methods: {
dealYearMonth() {
let { yearMonth } = this.data.curInfo
this.setData({
['date.year']: new Date(yearMonth || '').getFullYear(),
['date.month']: new Date(yearMonth || '').getMonth() + 1,
})
},
dealCrowdData() {
let { searchForm, curInfo } = this.data
// 众筹数据处理
if (searchForm.sceneType == 3) {
curInfo?.merchantDataList.length && curInfo?.merchantDataList.forEach(item => {
let productCodes = item.productCodes || []
item.activityTotal = 0
item.orderTotal = 0
item?.curMonthTotalData?.length && item?.curMonthTotalData?.forEach(subItem => {
subItem.isShow = productCodes.includes(subItem.productCode)
if(subItem.isShow) {
item.activityTotal = item.activityTotal + subItem.activityTotal
item.orderTotal = item.orderTotal + subItem.orderTotal
}
})
})
this.setData({
curInfo: curInfo
})
}
},
dealData() {
let { searchForm, sceneToInfo } = this.data
let sceneObj = sceneToInfo.find(item => item.type == (searchForm.sceneType || 1))
this.setData({
sceneObj: sceneObj,
sceneTopList: constant[(sceneObj.name || 'membranes') + 'TopList'],
sceneFormList: constant[(sceneObj.name || 'membranes') + 'FormList']
})
},
jump(e) {
let { info } = e.currentTarget.dataset
wx.$router.go('packagesList.newSummary', info)
},
}
})