orderRatingPopup.js
7.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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
import api from '../../api.js'
// import Util from '../../utils/util'
import { uploadImg } from '~/api/api'
const IMG_URL =
'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/miniProgram/'
Component({
options: {
multipleSlots: true // 在组件定义时的选项中启用多slot支持
},
/*组件的属性列表*/
properties: {
title: {
type: String,
value: '标题'
},
// 弹窗内容
content: {
type: String,
value: '内容'
},
// 弹窗取消按钮文字
btn_no: {
type: String,
value: '取消'
},
// 弹窗确认按钮文字
btn_ok: {
type: String,
value: '补录这笔订单'
},
//是否显示取消按钮
isShowCancel: {
type: Boolean,
value: true
},
//是否显示右上角关闭按钮
isShowClose: {
type: Boolean,
value: true
},
//应用于某些场景的button的open-type属性
sureButtonType: {
type: String,
value: ''
},
//控制弹窗的显示
flag: {
type: Boolean,
value: true
},
orderInfoSetting: {
type: Object,
value: {},
observer: function (n) {
console.log(n, 'orderInfoSetting')
n && this.setOrderInfo(n)
}
}
},
/* 组件的初始数据 */
data: {
IMG_URL,
wrapAnimate: 'wrapAnimate',
popupAnimate: 'popupAnimate',
searchSelectData: ['通过', '不通过'],
searchSelectIndex: 0,
showSelect: false,
tags: [
{
name: '服务态度好',
value: '1',
checked: false
},
{
name: '性价比高',
value: '2',
checked: false
},
{
name: '价格便宜',
value: '3',
checked: false
},
{
name: '一般',
value: '4',
checked: false
}
],
orderInfo: {}
},
lifetimes: {
attached: function () {
this.setData({
userInfo: wx.$util.getUserInfo()
})
// 在组件实例进入页面节点树时执行
},
detached: function () {
// 在组件实例被从页面节点树移除时执行
}
},
/* 组件的方法列表 */
methods: {
optionTap(e) {
let { orderInfo } = this.data
let { index, sub, subindex } = e.currentTarget.dataset
orderInfo.subOrderList[subindex].approveStatus = index == 0 ? 'Y' : 'N'
this.setData({
searchSelectIndex: index,
showSelect: !this.data.showSelect,
orderInfo
})
let params = {
orderCode: orderInfo.orderCode,
subOrderCode: sub,
approveStatus: index == 0 ? 'Y' : 'N'
}
api.technicianApprove(params).then((result) => {
wx.$util.showToast('审批成功')
}).catch((err) => {
});
// this.searchEvent(true)
},
closeSelect() {
this.setData({
showSelect: false
})
},
// 查询条件类型切换
selectTap(e) {
let { imgindex } = e.currentTarget.dataset
this.setData({
selectIndex: imgindex,
showSelect: !this.data.showSelect
})
},
updateCustomerphotos(params) {
console.log(params, 'updateCustomerphotos')
api
.updateCustomerphotos(params)
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err)
})
},
handleUpload(e) {
let that = this
// console.log(e);
let { index } = e.currentTarget.dataset
// console.log(index);
let { constructionImgList, orderInfo } = this.data
wx.chooseImage({
count: 1,
success(res) {
let [tempFiles] = res.tempFilePaths
let tempFilesList = tempFiles.split('.')
let imgType = tempFilesList[tempFilesList.length - 1]
let type = imgType == 'unknown' ? 'jpg' : imgType
wx.getFileSystemManager().readFile({
filePath: tempFiles, //选择图片返回的相对路径
encoding: 'base64', //编码格式
success(_res) {
wx.$util.showLoading('上传中...')
uploadImg({
file: `${type}@${_res.data}`
}).then(img => {
wx.$util.hideLoading()
let { code, data, message } = img
if (code == 0) {
orderInfo.subOrderList[index].constructionImgList =
orderInfo.subOrderList[index].constructionImgList || []
orderInfo.subOrderList[index].constructionImgList.push(data)
that.setData({
orderInfo
})
const customerPhotos = orderInfo.subOrderList.reduce((pre, item) => {
if (item.constructionImgList) {
item.constructionImgList.map(el => {
pre.push({
customerPhoto: el,
subOrderCode: item.subOrderCode
})
})
}
return pre;
}, [])
that.updateCustomerphotos({
orderCode: orderInfo.orderCode,
customerPhotos
})
} else {
wx.$util.showToast(message)
}
})
}
})
}
})
},
// 删除图片
handleDelete(e) {
let { index, imgindex } = e.currentTarget.dataset
let { orderInfo, constructionImgList } = this.data
if (orderInfo.subOrderList[imgindex].constructionImgList.length == 1) {
return wx.$util.showToast('最少需要一张图片')
}
orderInfo.subOrderList[imgindex].constructionImgList.splice(index, 1)
const customerPhotos = orderInfo.subOrderList.reduce((pre, item) => {
if (item.constructionImgList) {
item.constructionImgList.map(el => {
pre.push({
customerPhoto: el,
subOrderCode: item.subOrderCode
})
})
}
return pre;
}, [])
this.updateCustomerphotos({
orderCode: orderInfo.orderCode,
customerPhotos
})
this.setData({
orderInfo
})
},
// 放大图片
handlePreviewImg(e) {
let { item, imgIndex } = e.currentTarget.dataset
console.log(item)
wx.$util.previewImage({
urls: [item]
})
},
setOrderInfo(orderInfo) {
console.log(orderInfo, 'orderInfo')
orderInfo?.packageGoodsList.forEach(e => {
e.packageGoodsOrderList.forEach(child => {
orderInfo.subOrderList.push(child)
})
})
// constructionImgList
orderInfo.customerPhotos.forEach(item => {
orderInfo.subOrderList.forEach(el => {
if (item.subOrderCode == el.subOrderCode) {
if (el.constructionImgList) {
el.constructionImgList.push(item.customerPhoto)
} else {
el.constructionImgList = [item.customerPhoto]
}
}
})
})
orderInfo.evaluation = orderInfo.evaluation.split(',')
console.log(orderInfo.subOrderList, 'orderInfo.evaluation')
console.log(orderInfo.evaluation, 'orderInfo.evaluation')
let { tags } = this.data
tags.forEach((item, index) => {
if (orderInfo.evaluation.includes(item.value)) {
item.checked = true
}
})
this.setData({
orderInfo,
tags
})
},
/* 内部私有方法建议以下划线开头 triggerEvent 用于触发事件 */
_close() {
//触发取消回调
this.triggerEvent('close')
},
_success() { }
}
})