outputCrowdfund.js
3.63 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
// packageOutput/pages/summary/components/outputCrowdfund/outputCrowdfund.js
import wxqrcode from '~/utils/lib/wxqrcode'
import { IMG_URL } from '~/utils/constantData'
Component({
/**
* 组件的属性列表
*/
properties: {
orderObj: {
type: Object,
value: () => { },
observer(n) {
n && this.dealStaffList()
}
},
},
/**
* 组件的初始数据
*/
data: {
IMGURL: IMG_URL,
orderFormList: [{
label: '总场次',
name: 'totalNum'
}, {
label: '总订单',
name: 'totalOrderCount'
}, {
label: '成交金额',
name: 'totalAmount',
prefix: '¥'
}],
merchantFormList: [{
label: '活动时间',
name: 'time'
}, {
label: '订单数',
name: 'orderCount'
}, {
label: '产值',
name: 'realAmount',
className: 'red',
prefix: '¥'
}, {
label: '预估产值',
name: 'predictAmount',
prefix: '¥'
}],
tableHeadList: [{
label: '',
width: '',
width: '28rpx'
}, {
label: '业务员',
name: 'shareName',
}, {
label: '转发',
name: 'shareCount',
}, {
label: '浏览',
name: 'browseCount'
}, {
label: '成交',
name: 'dealCount',
width: '92rpx'
}, {
label: '产值',
name: 'totalAmount',
prefix: '¥'
}]
},
/**
* 组件的方法列表
*/
methods: {
dealStaffList() {
var list = this.data.orderObj
list && list.activityList?.forEach(item => {
// 0-未开始;1-活动中;2-已结束
let sliceNum = item.actStatus == 2 ? 3 : 10
item.showStaffList = item.staffList.length > sliceNum ? item.staffList.slice(0, sliceNum) : item.staffList
item.staffList = item.staffList.length > sliceNum ? item.staffList.slice(sliceNum) : []
})
this.setData({
orderObj: list
})
},
handleMore(e) {
var { idx } = e.currentTarget.dataset
var list = this.data.orderObj
var item = list.activityList[idx]
list.activityList[idx].showStaffList = list.activityList[idx].showStaffList.concat(item.staffList.length > 10 ? item.staffList.slice(0, 10) : item.staffList)
list.activityList[idx].staffList = item.staffList.length > 10 ? item.staffList.slice(10) : []
this.setData({
orderObj: list
})
},
handleCopy(e) {
var { idx } = e.currentTarget.dataset
var currentItem = this.data.orderObj.activityList[idx]
var qr = wxqrcode.createQrCodeImg(currentItem.activityUrl)
const base64src = function (base64data) {
return new Promise((resolve, reject) => {
const [a, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64data) || []
if (!format) reject(new Error('ERROR_BASE64SRC_PARSE'))
const filePath = `${wx.env.USER_DATA_PATH}/tmp_base64src.${format}`
const buffer = wx.base64ToArrayBuffer(bodyData)
wx.getFileSystemManager().writeFile({
filePath,
data: buffer,
encoding: 'binary',
success() {
resolve(filePath)
},
fail() {
reject(new Error('ERROR_BASE64SRC_WRITE'))
}
})
})
}
base64src(qr).then(res => {
wx.getImageInfo({
src: res,
success(obj) {
wx.showShareImageMenu({
path: obj.path
})
},
fail() {
}
})
})
},
download(e){
const {item} = e.currentTarget.dataset
this.setData({
posterItem: item
})
}
}
})