// packageD/o2o/recommendtext/recommendtext.js var app = getApp(); Page({ /** * 页面的初始数据 */ data: { language: "", store_id: "", inpvalue: "", page: 1, goods_data: "", }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ store_id: options.store_id, show_num: options.show_num, }); this.getStoreInfo(); }, inpbtn(e) { console.log(e.detail.value); this.setData({ inpvalue: e.detail.value, }); }, rentAllSelectHandle(event) { console.log(event); this.setData({ result: event.detail, }); }, btntap() { console.log(this.data.result); let json = { store_id: this.data.store_id, choose_goods: this.data.result, }; this.tapPush(json); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { let language = wx.getStorageSync("langIndex"); this.setData({ language: language.en }); }, /** * 生命周期函数--监听页面显示 */ onShow: function () {}, /** * 生命周期函数--监听页面隐藏 */ onHide: function () {}, /** * 生命周期函数--监听页面卸载 */ onUnload: function () {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { if (this.data.current_page <= this.data.last_page) { wx.showToast({ title: "没有更多", icon: "none", duration: 1500, }); } else if (this.data.current_page > this.data.last_page) { let pageAge = this.data.page + 1; this.setData({ page: pageAge, }); this.data.getStoreInfo(); } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () {}, getStoreInfo() { let that = this; let urlStr = app.getNetAddresss( "plugin.store-cashier.frontend.store.goods.get-goods-by-kwd" ); app._postNetWork({ url: urlStr, data: { store_id: that.data.store_id, kwd: this.data.inpvalue, page: this.data.page, }, success: function (resdata) { var res = resdata.data; console.log(res); if (res.result == 1) { that.setData({ goods_data: res.data.data, current_page: res.data.current_page, last_page: res.data.last_page, }); } else { wx.showToast({ icon: "none", title: res.msg, duration: 1500, }); } }, fail: function (res) { console.log(res); }, }); }, tapPush(json) { let urlStr = app.getNetAddresss( "plugin.nearby-store-goods.frontend.controllers.goods.index" ); app._postNetWork({ url: urlStr, data: json, success: function (resdata) { var res = resdata.data; console.log(res); if (res.result == 1) { wx.showToast({ icon: "none", title: res.msg, duration: 1500, success: function () { wx.navigateBack({ delta: 1, }); }, }); } else { wx.showToast({ icon: "none", title: res.msg, duration: 1500, }); } }, fail: function (res) { console.log(res); }, }); }, });