我的订单点击跳转订单详情页;订单详情页展示订单总金额;立即下单可以选择商品数量
This commit is contained in:
@@ -10,7 +10,9 @@ Page({
|
||||
*/
|
||||
data: {
|
||||
goodId: -1,
|
||||
goodinfo: {}
|
||||
goodinfo: {},
|
||||
|
||||
buyGoodCount: 1,
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -74,22 +76,66 @@ Page({
|
||||
|
||||
},
|
||||
|
||||
|
||||
bindCountInput(e) {
|
||||
console.log("e", e)
|
||||
console.log("e.detail.value", e.detail.value)
|
||||
|
||||
let regexp = /^[0-9]+$/.exec(e.detail.value)
|
||||
let buyGoodCountNum = Number(e.detail.value)
|
||||
if (!regexp || isNaN(buyGoodCountNum) || buyGoodCountNum < 1) {
|
||||
wx.showToast({
|
||||
title: '输入无效',
|
||||
icon: "error",
|
||||
})
|
||||
this.setData({
|
||||
buyGoodCount: this.data.buyGoodCount,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.setData({
|
||||
buyGoodCount: buyGoodCountNum,
|
||||
})
|
||||
},
|
||||
btnAddCount() {
|
||||
this.setData({
|
||||
buyGoodCount: this.data.buyGoodCount + 1,
|
||||
})
|
||||
},
|
||||
btnSubtractCount() {
|
||||
this.setData({
|
||||
buyGoodCount: this.data.buyGoodCount - 1,
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
// 立即下单
|
||||
btnBuyTap() {
|
||||
(async () => {
|
||||
// 创建订单
|
||||
let orderList = [{
|
||||
goodId: this.data.goodId,
|
||||
count: 1,
|
||||
count: this.data.buyGoodCount,
|
||||
}]
|
||||
let orderId = await orderService.createOrder(orderList)
|
||||
console.log("orderId", orderId)
|
||||
|
||||
// 跳转订单查看页面(携带订单号)
|
||||
wx.navigateTo({
|
||||
// url: "/pages/scan/entrance?a=1"
|
||||
url: "/pages/shop/orderDetail?orderId=" + orderId
|
||||
})
|
||||
if (!orderId) {
|
||||
wx.showModal({
|
||||
title: '出错了',
|
||||
content: '创建订单失败,请重试',
|
||||
showCancel: false,
|
||||
complete: (res) => {
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// 跳转订单查看页面(携带订单号)
|
||||
wx.navigateTo({
|
||||
// url: "/pages/scan/entrance?a=1"
|
||||
url: "/pages/shop/orderDetail?orderId=" + orderId
|
||||
})
|
||||
}
|
||||
})();
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user