view_comment.js
3.25 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
var i = require("../../../../utils/util.js"),
ut = i;
var e = getApp(),
a = e.globalData.setting,
os = a,
t = e.request,
d = e.globalData;
Page({
/**
* 页面的初始数据
*/
data: {
url: a.url,
iurl: a.imghost,
comment: [], //用户单个评价的内容
goods_id: "", //商品id
order_id: "", //订单id
is_act: 0, //是否开启活动
actId: "", //活动id
giftBagId: "", //礼包id
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
var th = this;
th.setData({
goods_id: options.goods_id,
order_id: options.order_id,
options: options,
})
th.query_comment();
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
query_comment: function() {
var th = this;
let url = '';
wx.showLoading({
title: '加载中'
})
if(this.data.options.card == 1) { // 卡项订单
url = `/api/weshop/serviceComment/list?card_id=${this.data.goods_id}`;
} else {
url = '/api/weshop/comment/list';
}
getApp().request.promiseGet(url, {
data: {
store_id: a.stoid,
userId: d.user_id,
goods_id: th.data.goods_id,
order_id: th.data.order_id
}
}).then(res => {
wx.hideLoading();
if (res.data.code == 0) {
var data = res.data.data.pageData;
if (data[0].img) data[0].img = ut.unserialize(data[0].img);
if (data[0].weapp_img) data[0].weapp_img = JSON.parse(data[0].weapp_img);
th.setData({
comment: data
})
th.judge_act(); //判断是否开启评价有礼
} else {
getApp().my_warnning("系统繁忙,请稍后再试", 0, th);
}
})
},
//评价有礼判断
judge_act: function() {
var th = this;
var url = "/api/weshop/marketing/comment/act/judge";
getApp().request.promiseGet(url, {
data: {
orderGoodsId: th.data.goods_id,
orderNumber: th.data.order_id,
orderType: 1,
storeId: a.stoid,
userId: d.user_id
}
}).then(res => {
if (res.data.code == 0) {
var id = res.data.data.id;
var giftbagid = res.data.data.giftbagid;
th.setData({
is_act: 1,
actId: id,
giftBagId: giftbagid
})
} else {
}
})
},
//预览图片
previewImg: function(e) {
var th = this;
var index = e.currentTarget.dataset.index;
var sindex = e.currentTarget.dataset.sindex;
var imgArr = th.data.comment;
var image = imgArr[0].weapp_img;
var imagename = "";
var iurl = th.data.iurl;
if (image != "") {
image = imgArr[0].weapp_img[index];
getApp().globalData.no_clear=1;
wx.previewImage({
current: image,
//当前图片地址
urls: imgArr[0].weapp_img, //所有要预览的图片的地址集合 数组形式
})
} else {
image = imgArr[0].img[index];
getApp().globalData.no_clear=1;
wx.previewImage({
current: iurl + image,
//当前图片地址
urls: imgArr[0].img, //所有要预览的图片的地址集合 数组形式
})
}
},
goto: function(e) {
var th = this;
var url = e.currentTarget.dataset.url;
getApp().goto(url);
}
})