|
|
// pages/affirm-order/affirm-order.js
|
|
|
let method = require("../../utils/reuqest.js")
|
|
|
let method = require("../../utils/reuqest.js");
|
|
|
const util = require("../../utils/util.js");
|
|
|
Page({
|
|
|
data: {
|
|
|
userData: {
|
...
|
...
|
@@ -34,7 +35,6 @@ Page({ |
|
|
//商品
|
|
|
getList() {
|
|
|
let pitchList = wx.getStorageSync('pitchList')
|
|
|
//let payment = this.data.goodsList.payment;
|
|
|
method.getRequest("/order/buyNow/" + pitchList, data => {
|
|
|
this.setData({
|
|
|
goodsList: data.data,
|
...
|
...
|
@@ -45,12 +45,12 @@ Page({ |
|
|
discountText: wx.getStorageSync('cardAmount'), //选择使用优惠券金额
|
|
|
})
|
|
|
}
|
|
|
let payment = Number(this.data.goodsList.payment) - Number(this.data.discountText)
|
|
|
let goodsList =this.data.goodsList;
|
|
|
goodsList.payment = payment;
|
|
|
this.setData({
|
|
|
goodsList: goodsList
|
|
|
})
|
|
|
let payment = Number(this.data.goodsList.payment) - Number(this.data.discountText)
|
|
|
let goodsList = this.data.goodsList;
|
|
|
goodsList.payment = payment;
|
|
|
this.setData({
|
|
|
goodsList: goodsList
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
//地址信息
|
...
|
...
|
@@ -232,19 +232,21 @@ Page({ |
|
|
deliveryTime: this.data.date,
|
|
|
note: this.data.leavaWord,
|
|
|
}
|
|
|
console.log(this.data.cartsId, 'cartid')
|
|
|
console.log(this.data.addressId, 'addid')
|
|
|
method.postRequest("/order/buyNow", postData, data => {
|
|
|
if (data.statusCode == 0) {
|
|
|
this.setData({
|
|
|
cartIds: data.data.id
|
|
|
})
|
|
|
this.buys();
|
|
|
// this.buys()
|
|
|
this.payment();
|
|
|
} else {
|
|
|
wx.showToast({
|
|
|
title: data.msg,
|
|
|
icon: 'none'
|
|
|
})
|
|
|
// setTimeout(() => {
|
|
|
// util.getUser()
|
|
|
// }, 2000)
|
|
|
}
|
|
|
})
|
|
|
}, 500)
|
...
|
...
|
@@ -252,11 +254,11 @@ Page({ |
|
|
},
|
|
|
//购物车-立即购买
|
|
|
buys() {
|
|
|
console.log(this.data.cartIds, 'card')
|
|
|
method.getRequest("/order/buyNow/" + this.data.cartIds, data => {
|
|
|
if (data.statusCode == 0) {
|
|
|
this.payment();
|
|
|
wx.setStorageSync('cardAmount', "")
|
|
|
wx.setStorageSync('cardAmount', "")
|
|
|
}else{
|
|
|
}
|
|
|
})
|
|
|
},
|
...
|
...
|
@@ -277,8 +279,15 @@ Page({ |
|
|
wx.showToast({
|
|
|
title: '支付成功',
|
|
|
})
|
|
|
wx.switchTab({
|
|
|
url: '/pages/shopping-cart/shopping-cart',
|
|
|
})
|
|
|
},
|
|
|
'fail': function (res) {
|
|
|
wx.switchTab({
|
|
|
url: '/pages/shopping-cart/shopping-cart',
|
|
|
})
|
|
|
},
|
|
|
'fail': function (res) {},
|
|
|
'complete': function (res) {}
|
|
|
})
|
|
|
}
|
...
|
...
|
@@ -286,8 +295,7 @@ Page({ |
|
|
},
|
|
|
onLoad: function (options) {
|
|
|
this.getList();
|
|
|
|
|
|
if (cardId) {
|
|
|
if (this.data.cardId) {
|
|
|
this.setData({
|
|
|
couponId: cardId,
|
|
|
id: options.id,
|
...
|
...
|
@@ -326,16 +334,15 @@ Page({ |
|
|
that.setData({
|
|
|
cartsId: cartsId,
|
|
|
cartList: goodsCarts,
|
|
|
couponId:cardId,
|
|
|
couponId: cardId,
|
|
|
// date: date,
|
|
|
type: type
|
|
|
})
|
|
|
that.getTotalPrice();
|
|
|
that.getAddress();
|
|
|
that.getDayTime(); //获取当天时间
|
|
|
that.buy();
|
|
|
// that.buy();
|
|
|
that.getList(); //
|
|
|
console.log(this.data.userData, '66')
|
|
|
// wx.removeStorageSync('pitchCart')
|
|
|
// wx.removeStorageSync('pitchList')
|
|
|
wx.removeStorageSync('cardId')
|
...
|
...
|
|