220 lines
4.8 KiB
JavaScript
220 lines
4.8 KiB
JavaScript
// pages/order/order.js
|
|
import bin from "../../utils/bin"
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
list: {},
|
|
fs:0,
|
|
date:"",
|
|
phone:"",
|
|
name:""
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
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 && this.data.fs == 0) {
|
|
wx.showToast({
|
|
title: "请先添加地址",
|
|
icon: "none"
|
|
})
|
|
}
|
|
if ((!this.data.name || !this.data.phone || !this.data.date) && this.data.fs == 1) {
|
|
wx.showToast({
|
|
title: "请完善提货信息",
|
|
icon: "none"
|
|
})
|
|
console.log(123)
|
|
return;
|
|
}
|
|
if(this.data.fs == 0){
|
|
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"
|
|
})}
|
|
})
|
|
})
|
|
})
|
|
}else{
|
|
bin.getuserid().then((res) => {
|
|
bin.request({
|
|
url: "Cart/cart3",
|
|
urldata: {
|
|
act: "",
|
|
submit_order: "",
|
|
user_id: res,
|
|
user_money: 0,
|
|
pay_points: 0,
|
|
couponTypeSelect: 1,
|
|
coupon_id: 0,
|
|
pay_code: "weixin",
|
|
couponCode: "",
|
|
|
|
},
|
|
data:{
|
|
ziti_name:this.data.name,
|
|
ziti_phone:this.data.phone,
|
|
ziti_date:this.data.date,
|
|
delivery:"ziti"
|
|
}
|
|
}).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"
|
|
})}
|
|
})
|
|
})
|
|
})
|
|
}
|
|
|
|
|
|
},
|
|
tab(a){
|
|
console.log(a.detail.id)
|
|
bin.getuserid().then((res) => {
|
|
bin.request({
|
|
url: "Cart/cart2",
|
|
urldata: {
|
|
user_id: res
|
|
},
|
|
data:{
|
|
delivery:a.detail.id == 1 ? "ziti" : "express"
|
|
}
|
|
}).then((res) => {
|
|
console.log(res)
|
|
this.setData({
|
|
list: res.data.result
|
|
})
|
|
this.setData({
|
|
fs:a.detail.id
|
|
})
|
|
})
|
|
})
|
|
|
|
},
|
|
date(a){
|
|
this.setData({
|
|
date:a.detail.date
|
|
})
|
|
},
|
|
name(a){
|
|
this.setData({
|
|
name:a.detail.value
|
|
})
|
|
},
|
|
phone(a){
|
|
this.setData({
|
|
phone:a.detail.value
|
|
})
|
|
}
|
|
}) |