deguodaigou/pages/orderconfirm/orderconfirm.js

126 lines
2.5 KiB
JavaScript
Raw Normal View History

2019-12-23 10:04:09 +08:00
// pages/order/order.js
import bin from "../../utils/bin"
Page({
/**
* 页面的初始数据
*/
data: {
list: {}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
2019-12-23 16:53:54 +08:00
bin.getuserid().then((res) => {
2019-12-23 10:04:09 +08:00
bin.request({
url: "Cart/cart2",
urldata: {
user_id: res
}
}).then((res) => {
console.log(res)
this.setData({
list: res.data.result
})
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
2019-12-24 16:32:27 +08:00
this.onLoad()
2019-12-23 10:04:09 +08:00
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
sub() {
2019-12-28 14:27:57 +08:00
if (this.data.list.addressList == null) {
2019-12-24 16:32:27 +08:00
wx.showToast({
2019-12-28 14:27:57 +08:00
title: "请先添加地址",
icon: "none"
2019-12-24 16:32:27 +08:00
})
console.log(123)
2019-12-28 14:27:57 +08:00
return;
2019-12-24 16:32:27 +08:00
}
2019-12-23 16:53:54 +08:00
bin.getuserid().then((res) => {
2019-12-23 10:04:09 +08:00
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
2019-12-28 14:27:57 +08:00
timeStamp = timeStamp.toString()
2019-12-23 10:04:09 +08:00
console.log(timeStamp)
wx.requestPayment({
2019-12-28 14:27:57 +08:00
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"
})}
2019-12-23 10:04:09 +08:00
})
})
})
}
})