147 lines
3.1 KiB
JavaScript
147 lines
3.1 KiB
JavaScript
// packageD/o2o/recommendind/recommendind.js
|
|
var app = getApp();
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
language: "",
|
|
// 商品展示的数量
|
|
show_num: "",
|
|
store_id: "",
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
if (options.store_id) {
|
|
this.setData({
|
|
store_id: options.store_id,
|
|
});
|
|
}
|
|
this.getStoreInfo();
|
|
},
|
|
add() {
|
|
wx.navigateTo({
|
|
url:
|
|
"/packageD/o2o/recommendlist/recommendlist?store_id=" +
|
|
this.data.store_id,
|
|
});
|
|
},
|
|
deltap(e) {
|
|
console.log(e.currentTarget.id);
|
|
let delId = e.currentTarget.id;
|
|
this.deltapInfo(delId);
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
let language = wx.getStorageSync("langIndex");
|
|
this.setData({ language: language.en });
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
this.getStoreInfo();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {},
|
|
getStoreInfo() {
|
|
let that = this;
|
|
let urlStr = app.getNetAddresss(
|
|
"plugin.store-cashier.frontend.store.near-by-goods.get-store-goods"
|
|
);
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
data: {
|
|
store_id: that.data.store_id,
|
|
},
|
|
success: function (resdata) {
|
|
var res = resdata.data;
|
|
console.log(res);
|
|
if (res.result == 1) {
|
|
// that.setData({
|
|
// goods_data:res.data.goods_data,
|
|
// category: res.data.category
|
|
// })
|
|
that.setData({
|
|
list: res.data.list,
|
|
show_num: res.data.show_num,
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
icon: "none",
|
|
title: res.msg,
|
|
duration: 1500,
|
|
});
|
|
}
|
|
},
|
|
fail: function (res) {
|
|
console.log(res);
|
|
},
|
|
});
|
|
},
|
|
deltapInfo(delId) {
|
|
let that = this;
|
|
let urlStr = app.getNetAddresss(
|
|
"plugin.nearby-store-goods.frontend.controllers.goods.delete-good"
|
|
);
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
data: {
|
|
store_id: that.data.store_id,
|
|
goods_id: delId,
|
|
},
|
|
success: function (resdata) {
|
|
var res = resdata.data;
|
|
if (res.result == 1) {
|
|
wx.showToast({
|
|
icon: "none",
|
|
title: res.msg,
|
|
duration: 1500,
|
|
success: function () {
|
|
that.getStoreInfo();
|
|
},
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
icon: "none",
|
|
title: res.msg,
|
|
duration: 1500,
|
|
});
|
|
}
|
|
},
|
|
fail: function (res) {
|
|
console.log(res);
|
|
},
|
|
});
|
|
},
|
|
});
|