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) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; } });