164 lines
3.2 KiB
JavaScript
164 lines
3.2 KiB
JavaScript
// packageI/warehouseFarm/warehouseFarmGood/warehouseFarmGood.js
|
|
const app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
activeRule: null,
|
|
info: {},
|
|
rule: [],
|
|
showCservice: false,
|
|
cserviceData: {}
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.getGood();
|
|
},
|
|
getGood() {
|
|
let urlStr = app.getNetAddresss("plugin.warehouse.frontend.controllers.purchasing.detail.index");
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
data: {
|
|
id: this.options.id
|
|
},
|
|
success: (resdata) => {
|
|
let res = resdata.data;
|
|
if (res.result == 1) {
|
|
this.setData({
|
|
goodsInfo: res.data.get_goods,
|
|
rule: res.data.plugin_rules,
|
|
cserviceData: res.data.customer_service
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
icon: "none",
|
|
title: res.msg,
|
|
duration: 1000,
|
|
});
|
|
}
|
|
},
|
|
fail: (res) => {
|
|
console.log(res);
|
|
},
|
|
});
|
|
},
|
|
clickRule(e){
|
|
let _params = e.currentTarget.dataset;
|
|
this.setData({
|
|
activeRule: _params.num
|
|
});
|
|
},
|
|
toOrder(){
|
|
if (!this.data.activeRule) {
|
|
wx.showToast({
|
|
icon: "none",
|
|
title: "请选择规格!",
|
|
duration: 1200,
|
|
});
|
|
return;
|
|
}
|
|
let urlStr = app.getNetAddresss('plugin.warehouse.frontend.controllers.purchasing.order-create');
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
data: {
|
|
goods_id: this.options.id,
|
|
goods_nums: this.data.activeRule
|
|
},
|
|
success: (resdata) => {
|
|
let res = resdata.data;
|
|
if (res.result == 1) {
|
|
// 跳转支付页
|
|
wx.navigateTo({
|
|
url: '/packageD/buy/orderPay/orderPay?status=1&order_id=' + res.data.order_ids
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
icon: "none",
|
|
title: res.msg,
|
|
duration: 1000,
|
|
});
|
|
}
|
|
},
|
|
fail: (res) => {
|
|
console.log(res);
|
|
},
|
|
});
|
|
},
|
|
showCserviceFun(){
|
|
this.setData({
|
|
showCservice: true
|
|
});
|
|
},
|
|
closePop(){
|
|
this.setData({
|
|
showCservice: false
|
|
});
|
|
},
|
|
gotoChat(evt) {
|
|
let url = evt.currentTarget.dataset.cservice + "&goods_id=" + this.options.id;
|
|
wx.navigateTo({
|
|
url: url,
|
|
fail: (err) => {
|
|
app.tips("客服路由出错");
|
|
}
|
|
});
|
|
},
|
|
callPhone() {
|
|
wx.makePhoneCall({
|
|
phoneNumber: this.data.cserviceData.service_mobile,
|
|
});
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}); |