Commit b2ec9124 by 高淑倩

add:下单计算优惠接口

parent addc8f38
...@@ -224,21 +224,27 @@ wxService.page({ ...@@ -224,21 +224,27 @@ wxService.page({
return false return false
} }
// 去下单页 // 去下单页
// wxService let parmas = {
// .router('/pages/confirmOrder/confirmOrder') specId: skuIds.join(',')
// .search(parmas) }
this.handleGoBuy(skuIds)
wxService
.router('/pages/confirmOrder/confirmOrder')
.search(parmas)
// this.handleGoBuy(skuIds)
}, },
handleGoBuy(parmas) { handleGoBuy(parmas) {
// 下单 // 下单
wx.showLoading({ wx.showLoading({
title: '加载中' title: '加载中'
}) })
// 获取支付参数
wxService.post(`/sale/trade/buyer/create`,parmas).then(res => { wxService.post(`/sale/trade/buyer/create`,parmas).then(res => {
if (!res) return false; if (!res) return false;
const { result, data } = res && res.data || res && res.result const { result, data } = res && res.data || res && res.result
if (result == 0) { if (result == 0) {
delete data.appId delete data.appId
console.log('data', data)
wx.requestPayment(Object.assign({ wx.requestPayment(Object.assign({
success(res) { success(res) {
wx.hideLoading() wx.hideLoading()
......
// pages/confirmOrder/confirmOrder.js // pages/confirmOrder/confirmOrder.js
Page({ const wxService = require('../../utils/wxService')
wxService.page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
addressInfo: '', addressInfo: '',
showSelectCoupon: false showSelectCoupon: false,
skuIds: []
}, },
/** /**
...@@ -15,16 +17,29 @@ Page({ ...@@ -15,16 +17,29 @@ Page({
onLoad: function (options) { onLoad: function (options) {
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
let skuIds = []
skuIds.push(this.options.specId)
// 计算优惠价
if(skuIds){this.calPreferentialPrice(skuIds)}
},
calPreferentialPrice(skuIds) {
wx.showLoading({
title: '加载中'
})
wxService.post(`/sale/trade/buyer/preview`,skuIds).then(res => {
if (res) {
const { result, data } = res.data
if (result == 0) {
wx.hideLoading()
console.log('data', data)
}
}
})
}, },
//获取微信地址 //获取微信地址
chooseWxAddress() { chooseWxAddress() {
wx.chooseAddress({ wx.chooseAddress({
......
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