171 lines
4.0 KiB
JavaScript
171 lines
4.0 KiB
JavaScript
// pages/cartPay/cartPay.js
|
|
const app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
goods: [],
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
//判断登录
|
|
wx.getStorage({
|
|
key: 'user',
|
|
success: user => {
|
|
wx.showLoading({
|
|
title: '加载中..',
|
|
})
|
|
wx.request({
|
|
url: app.globalData.ip + '/wisdommining/api/order/getStoresOrderDetail',
|
|
method: 'GET',
|
|
header: {
|
|
"content-type": "application/x-www-form-urlencoded",
|
|
},
|
|
data: {
|
|
userId: options.id,
|
|
orderNumber: options.orderNumber,
|
|
storesUserId:user.data.id
|
|
},
|
|
success: res => {
|
|
console.log(res)
|
|
wx.hideLoading()
|
|
if (res.data.code == 1) {
|
|
let goods = res.data.value;
|
|
let total = 0;
|
|
let numAll = 0;
|
|
if (goods.orderPayWay != 3) {
|
|
for (let i = 0; i < goods.goodsList.length; i++) {
|
|
total = total + parseFloat(goods.goodsList[i].wisdGoodsSpec.specBulyPrice == null ? goods.goodsList[i].wisdGoodsSpec.specPrice : goods.goodsList[i].wisdGoodsSpec.specBulyPrice) * goods.goodsList[i].goodsNum;
|
|
numAll = numAll + goods.goodsList[i].goodsNum;
|
|
goods.goodsList[i].price = goods.goodsList[i].wisdGoodsSpec.specBulyPrice == null ? goods.goodsList[i].wisdGoodsSpec.specPrice : goods.goodsList[i].wisdGoodsSpec.specBulyPrice;
|
|
}
|
|
} else {
|
|
total = 0;
|
|
numAll = 1
|
|
}
|
|
this.setData({
|
|
goods: goods,
|
|
total: total,
|
|
numAll: numAll
|
|
})
|
|
} else {
|
|
wx.showModal({
|
|
title: '提示!',
|
|
content: res.data.message,
|
|
showCancel: false,
|
|
success:s=>{
|
|
wx.navigateBack()
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
fail: e => {
|
|
wx.navigateTo({
|
|
url: '/pages/login/login',
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
pay(e) {
|
|
this.payM({
|
|
orderNumber: this.data.goods.orderNumber
|
|
})
|
|
},
|
|
|
|
//确认收货
|
|
confirm: function (e) {
|
|
wx.showModal({
|
|
title: '提示!',
|
|
content: '确认客户已提货吗?',
|
|
success: s => {
|
|
if (s.confirm) {
|
|
wx.showLoading({
|
|
title: '加载中..',
|
|
})
|
|
wx.request({
|
|
url: app.globalData.ip + '/wisdommining/api/order/confirmOrder',
|
|
method: 'POST',
|
|
header: {
|
|
"content-type": "application/x-www-form-urlencoded",
|
|
},
|
|
data: {
|
|
orderId: this.data.goods.id
|
|
},
|
|
success: res => {
|
|
console.log(res)
|
|
wx.hideLoading()
|
|
if (res.data.code == 1) {
|
|
wx.showToast({
|
|
title: '操作成功~',
|
|
icon: 'none',
|
|
success: ss => {
|
|
setTimeout(() => {
|
|
wx.navigateBack()
|
|
}, 1000);
|
|
}
|
|
})
|
|
} else {
|
|
wx.showModal({
|
|
title: '确认失败!',
|
|
content: res.data.message,
|
|
showCancel: false,
|
|
})
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
}) |