Commit b2ec9124 by 高淑倩

add:下单计算优惠接口

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