126 lines
2.5 KiB
JavaScript
126 lines
2.5 KiB
JavaScript
// pages/order/order.js
|
|
import bin from "../../utils/bin"
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
list: {}
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
bin.getuserid().then((res) => {
|
|
bin.request({
|
|
url: "Cart/cart2",
|
|
urldata: {
|
|
user_id: res
|
|
}
|
|
}).then((res) => {
|
|
console.log(res)
|
|
this.setData({
|
|
list: res.data.result
|
|
})
|
|
})
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
this.onLoad()
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
},
|
|
sub() {
|
|
if (this.data.list.addressList == null) {
|
|
wx.showToast({
|
|
title: "请先添加地址",
|
|
icon: "none"
|
|
})
|
|
console.log(123)
|
|
return;
|
|
}
|
|
bin.getuserid().then((res) => {
|
|
bin.request({
|
|
url: "Cart/cart3",
|
|
urldata: {
|
|
act: "",
|
|
submit_order: "",
|
|
user_id: res,
|
|
address_id: this.data.list.addressList.address_id,
|
|
user_money: 0,
|
|
pay_points: 0,
|
|
couponTypeSelect: 1,
|
|
coupon_id: 0,
|
|
pay_code: "weixin",
|
|
couponCode: ""
|
|
}
|
|
}).then((r) => {
|
|
console.log(r)
|
|
let { timeStamp, nonceStr, signType, sign } = r.data.data.wdata
|
|
// timeStamp = timeStamp
|
|
timeStamp = timeStamp.toString()
|
|
console.log(timeStamp)
|
|
wx.requestPayment({
|
|
timeStamp, nonceStr, package: r.data.data.wdata.package, signType, paySign: sign,
|
|
success(res) {
|
|
console.log("成功")
|
|
wx.redirectTo({
|
|
url: "/pages/order/order?index=1"
|
|
})
|
|
},
|
|
fail(res) { console.log(res)
|
|
wx.redirectTo({
|
|
url: "/pages/order/order?index=0"
|
|
})}
|
|
})
|
|
})
|
|
})
|
|
|
|
}
|
|
}) |