outputCrowdfund.js
4.72 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
// packageOutput/pages/summary/components/outputCrowdfund/outputCrowdfund.js
import wxqrcode from '~/utils/lib/wxqrcode'
import { IMG_URL } from '~/utils/constantData'
import outputApi from '~/api/outputApi/index'
const IMAGES = Object.freeze({
download: `${IMG_URL}/output/download.webp`
})
Component({
/**
* 组件的属性列表
*/
properties: {
orderObj: {
type: Object,
value: () => {},
observer(n) {
n && this.dealStaffList()
}
}
},
options: {
styleIsolation: 'shared'
},
/**
* 组件的初始数据
*/
data: {
IMGURL: IMG_URL,
IMAGES,
isShowTip: true,
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() {}
})
})
},
handleJumpH5(e) {
// const { item } = e.currentTarget.dataset
// wx.$router.jumpH5(item.activityUrl)
},
async download(e) {
const { item } = e.currentTarget.dataset,
posterObj = this.selectComponent('#poster')
try {
let flag = await posterObj.check(item)
posterObj.setData({
poster: flag,
show: true
})
} catch (error) {
wx.$api.showLoading('加载中...')
outputApi
.getPosterUrl({
id: item.activityId
})
.then(res => {
item.posterUrl = res
this.setData({
posterItem: item,
isShowTip: false
})
})
.catch(() => {
wx.$api.showToast('下载海报失败')
})
}
}
}
})