Commit 67347fe4 by 高淑倩

add: 下单参数

parent b7c68781
...@@ -56,7 +56,7 @@ wxService.page({ ...@@ -56,7 +56,7 @@ wxService.page({
const trolleySku = { const trolleySku = {
count: 1, count: 1,
skuId: '1556108807316001' skuId: '1556108807316000'
} }
// 加入购物车 // 加入购物车
wxService.post('/sale/trolley/put', trolleySku).then(res => { wxService.post('/sale/trolley/put', trolleySku).then(res => {
...@@ -205,6 +205,7 @@ wxService.page({ ...@@ -205,6 +205,7 @@ wxService.page({
}, },
goBuy() { goBuy() {
let skuIds = [] let skuIds = []
let trolleySku2Buy = []
let specIds = [] let specIds = []
let quantitys = [] let quantitys = []
let redemptionSpecIds = [] let redemptionSpecIds = []
...@@ -214,24 +215,34 @@ wxService.page({ ...@@ -214,24 +215,34 @@ wxService.page({
cartListData.filter(item => { // 选中的商品信息 cartListData.filter(item => { // 选中的商品信息
return item.checked return item.checked
}).map(item => { }).map(item => {
skuIds.push(item.skuId -0) if(!item.skuId) return false
let trolleySku2BuyObj = {
count: 0,
skuId: 0
}
trolleySku2BuyObj.count = item.count - 0
trolleySku2BuyObj.skuId = item.skuId - 0
// skuIds.push(item.skuId)
trolleySku2Buy.push(trolleySku2BuyObj)
}) })
if (skuIds.length == 0) {
if (trolleySku2Buy.length == 0) {
wx.showToast({ wx.showToast({
title: '请选择商品', title: '请选择商品',
icon: 'none' icon: 'none'
}) })
return false return false
} }
console.log('trolleySku2Buy', trolleySku2Buy)
// 去下单页 && 参数 // 去下单页 && 参数
// let parmas = { let parmas = {
// specId: skuIds.join(',') trolleySku2Buy: JSON.stringify(trolleySku2Buy)
// } }
// wxService wxService
// .router('/pages/confirmOrder/confirmOrder') .router('/pages/confirmOrder/confirmOrder')
// .search(parmas) .search(parmas)
// 直接调支付 // 直接调支付
this.handleGoBuy(skuIds) // this.handleGoBuy(skuIds)
}, },
handleGoBuy(parmas) { handleGoBuy(parmas) {
// 下单 // 下单
......
...@@ -21,16 +21,35 @@ wxService.page({ ...@@ -21,16 +21,35 @@ wxService.page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
let skuIds = [] let trolleySku2Buy = this.options.trolleySku2Buy
skuIds.push(this.options.specId) console.log('thtrolleySku2Bu', JSON.parse(trolleySku2Buy))
// 计算优惠价 // 下单 && 计算优惠价
if(skuIds){this.calPreferentialPrice(skuIds)} if(trolleySku2Buy.length){
this.getBill(trolleySku2Buy) // 下单
// this.calPreferentialPrice(trolleySku2Buy) // 计算优惠价
}
}, },
calPreferentialPrice(skuIds) { // 下单
getBill(trolleySku2Buy) {
wx.showLoading({ wx.showLoading({
title: '加载中' title: '加载中'
}) })
wxService.post(`/sale/trade/buyer/preview`,skuIds).then(res => { wxService.post(`/sale/trade/buyer/bill`,trolleySku2Buy).then(res => {
if (res) {
const { result, data } = res.data
if (result == 0) {
wx.hideLoading()
console.log('data', data)
}
}
})
},
// 计算优惠价
calPreferentialPrice(trolleySku2Buy) {
wx.showLoading({
title: '加载中'
})
wxService.post(`/sale/trade/buyer/preview`,trolleySku2Buy).then(res => {
if (res) { if (res) {
const { result, data } = res.data const { result, data } = res.data
if (result == 0) { if (result == 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment