comment.js
4.04 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
var t = function(t) {
return t && t.__esModule ? t : {
default: t
};
}(require("../../../utils/LoadMore.js")), e = getApp(), rq = e.request, a = new t.default(),
s = require("../../../utils/util.js"), oo = e.globalData, os = e.globalData.setting;
Page({
data: {
url: e.globalData.setting.url,
resourceUrl: e.globalData.setting.imghost,
iurl: e.globalData.setting.imghost,
categories: [ {
name: "全部评价",
status: 2
}, {
name: "待评价",
status: 0
}, {
name: "已评价",
status: 1
} ],
activeStatus: 0,
comments: null,
currentPage: 1
},
onLoad: function(t) {
var e = void 0 === t.status ? this.data.activeStatus : t.status;
a.init(this, "", "comments"), this.requestComments(e);
},
onShow: function() {
wx.getStorageSync("user:comment:update") && (wx.setStorageSync("user:comment:update", !1),
this.resetData(), this.requestComments(this.data.activeStatus));
},
changeTab: function(t) {
this.resetData(), this.requestComments(t.currentTarget.dataset.status);
},
requestComments: function(t) {
var e = this, th=e,n = os.url + "/api/weshop/comment/list?page=" + e.data.currentPage;
console.log('requestComments');
console.log(n);
console.log(t);
this.setData({
activeStatus: t
});
if(t==2){
a.request(n, function (t) {
e.data.currentPage++;
var da = th.data.comments;
da.forEach(function(em,ind){
rq.get("/api/weshop/goods/get/" + os.stoid + "/" + em.goods_id, {
success: function (tt) {
var gd = tt.data.data.original_img;
da[ind]['original_img'] = gd;
th.setData({ comments: da, })
},
});
})
}, null, { store_id: os.stoid, user_id: oo.user_id }),
wx.stopPullDownRefresh();
}else{
a.request(n, function(t) {
e.data.currentPage++;
var da = th.data.comments;
da.forEach(function (em, ind) {
rq.get("/api/weshop/goods/get/" + os.stoid + "/" + em.goods_id, {
success: function (tt) {
var gd = tt.data.data.original_img;
da[ind]['original_img'] = gd;
th.setData({ comments: da, })
},
});
});
}, null, {is_comment:t, store_id: os.stoid,user_id: oo.user_id }),
wx.stopPullDownRefresh();
}
},
onReachBottom: function() {
a.canloadMore() && this.requestComments(this.data.activeStatus);
},
onPullDownRefresh: function(t) {
this.resetData(), this.requestComments(this.data.activeStatus);
},
resetData: function() {
this.data.comments = null, this.data.currentPage = 1, a.resetConfig();
},
/*-----评论-----*/
comment: function(t) {
for (var e = t.currentTarget.dataset.recid, a = this.data.comments, s = 0; s < a.length && a[s].rec_id != e; s++) ;
if (!(s >= a.length)) {
console.log("comment");
console.log(a[s]);
var n = "?order_id=" + a[s].order_id;
n += "&goods_id=" + a[s].goods_id, n += "&goods_name=" + a[s].goods_name, n += "&price=" + a[s].goods_price,
n += "&img=" + a[s].original_img,
wx.navigateTo({
url: "/pages/user/add_comment/add_comment" + n
});
}
},
//图片失败,默认图片
bind_bnerr2: function (e) {
var _errImg = e.target.dataset.errorimg;
var _errObj = {};
_errObj[_errImg] = "/public/images/default_goods_image_240.gif";
this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
}
});