757 lines
23 KiB
JavaScript
757 lines
23 KiB
JavaScript
![]() |
// pages/cartPay/cartPay.js
|
|||
|
import {monthDealWith} from '../../utils/date'
|
|||
|
const app = getApp();
|
|||
|
Page({
|
|||
|
|
|||
|
/**
|
|||
|
* 页面的初始数据
|
|||
|
*/
|
|||
|
data: {
|
|||
|
integral: 0, //积分
|
|||
|
goods: [],
|
|||
|
reduceType: false, //优惠方式
|
|||
|
addressType: false, //收货方式
|
|||
|
reduceTypeXz: 0, //0不选 1现金券 2折扣券
|
|||
|
freight: 0, //运费
|
|||
|
discount: 0, //优惠
|
|||
|
payActual: 0, //实际支付
|
|||
|
note: '',
|
|||
|
addressId: '', //地址ID
|
|||
|
address: '选择收货方式', //地址
|
|||
|
province: '',
|
|||
|
orderPick: 2, //1自提 2物流
|
|||
|
isCar: 0, //购物车进入
|
|||
|
wxVipType: 1,
|
|||
|
date: '',
|
|||
|
time: '',
|
|||
|
startTime: '',
|
|||
|
pay_can: 0, //是否能点击支付
|
|||
|
telNum: '' //联系方式
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面显示
|
|||
|
*/
|
|||
|
onShow: function () {
|
|||
|
if (this.data.orderPick == 2) {
|
|||
|
//收货地址
|
|||
|
if (this.data.total && this.data.province != '') {
|
|||
|
//订单个人信息获取
|
|||
|
wx.showLoading({
|
|||
|
title: '加载中',
|
|||
|
})
|
|||
|
wx.request({
|
|||
|
url: app.globalData.ip + '/wisdommining/api/order/getUserInfo',
|
|||
|
method: 'GET',
|
|||
|
header: {
|
|||
|
"content-type": "application/x-www-form-urlencoded",
|
|||
|
},
|
|||
|
data: {
|
|||
|
userId: app.globalData.userId
|
|||
|
},
|
|||
|
success: res => {
|
|||
|
wx.hideLoading();
|
|||
|
console.log(res)
|
|||
|
if (res.data.code == 1) {
|
|||
|
let dataList = res.data.value;
|
|||
|
this.setData({
|
|||
|
dataList: dataList,
|
|||
|
pay: (parseFloat(this.data.payActual) * parseFloat(dataList.userVipDiscount) / 100).toFixed(2),
|
|||
|
})
|
|||
|
//运费获取
|
|||
|
wx.request({
|
|||
|
url: app.globalData.ip + '/wisdommining/api/order/getFreight',
|
|||
|
method: 'GET',
|
|||
|
header: {
|
|||
|
"content-type": "application/x-www-form-urlencoded",
|
|||
|
},
|
|||
|
data: {
|
|||
|
freightAddress: this.data.province,
|
|||
|
price: this.data.total,
|
|||
|
},
|
|||
|
success: res => {
|
|||
|
wx.hideLoading();
|
|||
|
console.log(res)
|
|||
|
if (res.data.code == 1) {
|
|||
|
this.setData({
|
|||
|
freight: res.data.value,
|
|||
|
payActual: (parseFloat(this.data.total) + parseFloat(res.data.value) - parseFloat(this.data.discount)).toFixed(2),
|
|||
|
payActualIntegral: parseFloat(this.data.total),
|
|||
|
})
|
|||
|
this.setData({
|
|||
|
pay: (parseFloat(this.data.payActual) * parseFloat(this.data.dataList.userVipDiscount) / 100).toFixed(2),
|
|||
|
})
|
|||
|
} else {
|
|||
|
wx.showModal({
|
|||
|
title: '提示!',
|
|||
|
content: res.data.message,
|
|||
|
showCancel: false,
|
|||
|
})
|
|||
|
}
|
|||
|
}
|
|||
|
})
|
|||
|
} else {
|
|||
|
wx.showModal({
|
|||
|
title: '提示!',
|
|||
|
content: res.data.message,
|
|||
|
showCancel: false,
|
|||
|
})
|
|||
|
}
|
|||
|
}
|
|||
|
})
|
|||
|
}
|
|||
|
} else {
|
|||
|
// 自提点
|
|||
|
this.setData({
|
|||
|
freight: 0,
|
|||
|
payActual: (parseFloat(this.data.total) - parseFloat(this.data.discount)).toFixed(2),
|
|||
|
payActualIntegral: parseFloat(this.data.total),
|
|||
|
})
|
|||
|
this.setData({
|
|||
|
pay: (parseFloat(this.data.payActual) * parseFloat(this.data.dataList.userVipDiscount) / 100).toFixed(2),
|
|||
|
})
|
|||
|
console.log(this.data.address)
|
|||
|
}
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面加载
|
|||
|
*/
|
|||
|
onLoad: function (options) {
|
|||
|
// let myDate = new Date();
|
|||
|
// let startTime = myDate.getFullYear() + '-' + (parseFloat(myDate.getMonth()) + 1) + '-' + (parseFloat(myDate.getDate()) + 3)
|
|||
|
console.log(monthDealWith())
|
|||
|
this.setData({
|
|||
|
startTime: monthDealWith()
|
|||
|
})
|
|||
|
// console.log(this.data.startTime)
|
|||
|
//积分商城进入
|
|||
|
if (options.integral) {
|
|||
|
console.log(options.integral)
|
|||
|
this.setData({
|
|||
|
integral: 1
|
|||
|
})
|
|||
|
}
|
|||
|
//购物车进入
|
|||
|
if (options.isCar) {
|
|||
|
console.log(options.isCar)
|
|||
|
this.setData({
|
|||
|
isCar: options.isCar
|
|||
|
})
|
|||
|
}
|
|||
|
//
|
|||
|
// var sumpay=this.pay+,
|
|||
|
|
|||
|
|
|||
|
if (options.goods) {
|
|||
|
let goods = JSON.parse(options.goods)
|
|||
|
for (let i = 0; i < goods.length; i++) {
|
|||
|
if(goods[i].isDiscount ==0){
|
|||
|
this.setData({
|
|||
|
wxVipType: goods[i].isDiscount,
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
console.log(goods)
|
|||
|
let total = 0;
|
|||
|
let numAll = 0;
|
|||
|
let specPriceArr = [];
|
|||
|
for (let i = 0; i < goods.length; i++) {
|
|||
|
total = total + parseFloat(goods[i].specs.price) * parseFloat(goods[i].num)
|
|||
|
numAll = numAll + parseFloat(goods[i].num);
|
|||
|
specPriceArr.push(parseFloat(goods[i].specs.price));
|
|||
|
}
|
|||
|
this.setData({
|
|||
|
goods: goods,
|
|||
|
total: total.toFixed(2),
|
|||
|
total_int: parseInt(total),
|
|||
|
totalIntegral: total,
|
|||
|
specPriceArr: specPriceArr,
|
|||
|
numAll: numAll,
|
|||
|
payActual: (parseFloat(total) + parseFloat(this.data.freight) - parseFloat(this.data.discount)).toFixed(2),
|
|||
|
payActualIntegral: parseFloat(total)
|
|||
|
})
|
|||
|
//订单个人信息获取
|
|||
|
wx.showLoading({
|
|||
|
title: '加载中',
|
|||
|
})
|
|||
|
wx.request({
|
|||
|
url: app.globalData.ip + '/wisdommining/api/order/getUserInfo',
|
|||
|
method: 'GET',
|
|||
|
header: {
|
|||
|
"content-type": "application/x-www-form-urlencoded",
|
|||
|
},
|
|||
|
data: {
|
|||
|
userId: app.globalData.userId
|
|||
|
},
|
|||
|
success: res => {
|
|||
|
wx.hideLoading();
|
|||
|
console.log(res)
|
|||
|
if (res.data.code == 1) {
|
|||
|
let dataList = res.data.value;
|
|||
|
//---------------------------------------------------------------
|
|||
|
if(this.data.wxVipType == 1){
|
|||
|
this.setData({
|
|||
|
dataList: dataList,
|
|||
|
pay: (parseFloat(this.data.payActual) * parseFloat(dataList.userVipDiscount) / 100).toFixed(2),
|
|||
|
})
|
|||
|
}else{
|
|||
|
this.setData({
|
|||
|
dataList: dataList,
|
|||
|
pay: (parseFloat(this.data.payActual)).toFixed(2),
|
|||
|
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
//-------------------------------------------------------------------
|
|||
|
// this.setData({
|
|||
|
// dataList: dataList,
|
|||
|
// pay: (parseFloat(this.data.payActual) * parseFloat(dataList.userVipDiscount) / 100).toFixed(2),
|
|||
|
// })
|
|||
|
if (dataList.wisdUserAddress) {
|
|||
|
//默认地址ID
|
|||
|
this.setData({
|
|||
|
province: dataList.wisdUserAddress.addressProvince,
|
|||
|
addressId: dataList.wisdUserAddress.id,
|
|||
|
address: dataList.wisdUserAddress.addressProvince + dataList.wisdUserAddress.addressCity + dataList.wisdUserAddress.addressArea + dataList.wisdUserAddress.addressDetailed,
|
|||
|
})
|
|||
|
//运费获取
|
|||
|
wx.request({
|
|||
|
url: app.globalData.ip + '/wisdommining/api/order/getFreight',
|
|||
|
method: 'GET',
|
|||
|
header: {
|
|||
|
"content-type": "application/x-www-form-urlencoded",
|
|||
|
},
|
|||
|
data: {
|
|||
|
freightAddress: dataList.wisdUserAddress.addressProvince,
|
|||
|
price: total,
|
|||
|
},
|
|||
|
success: res => {
|
|||
|
wx.hideLoading();
|
|||
|
console.log(res)
|
|||
|
if (res.data.code == 1) {
|
|||
|
this.setData({
|
|||
|
freight: res.data.value,
|
|||
|
payActual: (parseFloat(this.data.total) + parseFloat(res.data.value) - parseFloat(this.data.discount)).toFixed(2),
|
|||
|
payActualIntegral: parseFloat(this.data.total),
|
|||
|
})
|
|||
|
if(this.data.wxVipType == 1){
|
|||
|
this.setData({
|
|||
|
pay: (parseFloat(this.data.payActual) * parseFloat(dataList.userVipDiscount) / 100).toFixed(2),
|
|||
|
})
|
|||
|
}else{
|
|||
|
this.setData({
|
|||
|
pay: (parseFloat(this.data.payActual)).toFixed(2),
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
// this.setData({
|
|||
|
// pay: (parseFloat(this.data.payActual) * parseFloat(dataList.userVipDiscount) / 100).toFixed(2),
|
|||
|
// })
|
|||
|
} else {
|
|||
|
wx.showModal({
|
|||
|
title: '提示!',
|
|||
|
content: res.data.message,
|
|||
|
showCancel: false,
|
|||
|
})
|
|||
|
}
|
|||
|
}
|
|||
|
})
|
|||
|
}
|
|||
|
} else {
|
|||
|
wx.showModal({
|
|||
|
title: '提示!',
|
|||
|
content: res.data.message,
|
|||
|
showCancel: false,
|
|||
|
})
|
|||
|
}
|
|||
|
}
|
|||
|
})
|
|||
|
}
|
|||
|
},
|
|||
|
//备注
|
|||
|
note(e) {
|
|||
|
this.setData({
|
|||
|
note: e.detail.value
|
|||
|
})
|
|||
|
},
|
|||
|
//选择地址类型
|
|||
|
addressType() {
|
|||
|
this.setData({
|
|||
|
addressType: true, //收货
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
//选择收货地址
|
|||
|
address() {
|
|||
|
wx.navigateTo({
|
|||
|
url: '/pages/my/my_address/my_address?orderAddress=true&addressId=' + this.data.addressId,
|
|||
|
})
|
|||
|
this.setData({
|
|||
|
addressType: false, //收货
|
|||
|
})
|
|||
|
},
|
|||
|
//选择自提点
|
|||
|
ztd() {
|
|||
|
wx.navigateTo({
|
|||
|
url: '/pages/index/index_address/index_address?pay=true',
|
|||
|
})
|
|||
|
this.setData({
|
|||
|
addressType: false, //收货
|
|||
|
})
|
|||
|
},
|
|||
|
//收获 遮罩层
|
|||
|
addressZzc() {
|
|||
|
this.setData({
|
|||
|
addressType: false, //收货
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
//选择优惠方式
|
|||
|
reduceType() {
|
|||
|
this.setData({
|
|||
|
reduceType: true, //优惠
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
//选择优惠
|
|||
|
reduceTypeXz(e) {
|
|||
|
let index = e.currentTarget.dataset.index;
|
|||
|
let reduceTypeXz = this.data.reduceTypeXz;
|
|||
|
let goods = this.data.goods;
|
|||
|
console.log("**********")
|
|||
|
if (reduceTypeXz == index) {
|
|||
|
console.log("**********")
|
|||
|
this.setData({
|
|||
|
reduceTypeXz: 0, //优惠
|
|||
|
})
|
|||
|
//改变显示价格为员工价格
|
|||
|
console.log(goods)
|
|||
|
let total = 0;
|
|||
|
let specPriceArr = [];
|
|||
|
let userVipDiscountYN = 0; //判断是否有商品为团购价
|
|||
|
for (let i = 0; i < goods.length; i++) {
|
|||
|
total = total + parseFloat(goods[i].specs.price) * parseFloat(goods[i].num);
|
|||
|
specPriceArr.push(parseFloat(goods[i].specs.price));
|
|||
|
if (goods[i].isDiscount == 1) {
|
|||
|
if (goods[i].specs.specBulyPrice != null) {
|
|||
|
userVipDiscountYN++
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
this.setData({
|
|||
|
goods: goods,
|
|||
|
total: total.toFixed(2),
|
|||
|
total_int: parseInt(total),
|
|||
|
specPriceArr: specPriceArr,
|
|||
|
payActual: (parseFloat(total) + parseFloat(this.data.freight)).toFixed(2)
|
|||
|
})
|
|||
|
if (userVipDiscountYN > 0 && this.data.wxVipType ==0) {
|
|||
|
this.setData({
|
|||
|
pay: parseFloat(this.data.payActual).toFixed(2),
|
|||
|
})
|
|||
|
} else {
|
|||
|
this.setData({
|
|||
|
pay: (parseFloat(this.data.payActual) * parseFloat(this.data.dataList.userVipDiscount) / 100).toFixed(2),
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
} else {
|
|||
|
wx.showModal({
|
|||
|
title: '提示!',
|
|||
|
content: '选择优惠后,公司员工不再享有员工价~',
|
|||
|
success: ss => {
|
|||
|
if (ss.confirm) {
|
|||
|
if (index == 1 && this.data.dataList.userVolumeBalance == 0) {
|
|||
|
return
|
|||
|
}
|
|||
|
if (index == 2 && this.data.dataList.userDiscountBalance == 0) {
|
|||
|
return
|
|||
|
}
|
|||
|
//改变显示价格为普通价格
|
|||
|
console.log(goods)
|
|||
|
let total = 0;
|
|||
|
let specPriceArr = [];
|
|||
|
for (let i = 0; i < goods.length; i++) {
|
|||
|
total = total + parseFloat(goods[i].specs.specPrice) * parseFloat(goods[i].num);
|
|||
|
specPriceArr.push(parseFloat(goods[i].specs.specPrice));
|
|||
|
}
|
|||
|
this.setData({
|
|||
|
goods: goods,
|
|||
|
total: total.toFixed(2),
|
|||
|
total_int: parseInt(total),
|
|||
|
specPriceArr: specPriceArr,
|
|||
|
payActual: (parseFloat(total) + parseFloat(this.data.freight) - parseFloat(this.data.discount)).toFixed(2)
|
|||
|
})
|
|||
|
|
|||
|
let goodsList = [];
|
|||
|
for (let i = 0; i < goods.length; i++) {
|
|||
|
goodsList.push({
|
|||
|
goodsId: goods[i].goodsId,
|
|||
|
specId: goods[i].specs.id,
|
|||
|
num: goods[i].num,
|
|||
|
})
|
|||
|
}
|
|||
|
wx.showLoading({
|
|||
|
title: '加载中',
|
|||
|
})
|
|||
|
wx.request({
|
|||
|
url: app.globalData.ip + '/wisdommining/api/order/amountCalculation',
|
|||
|
method: 'POST',
|
|||
|
data: {
|
|||
|
goods: goodsList,
|
|||
|
userId: app.globalData.userId,
|
|||
|
volumeType: parseInt(index) //1现金券 2折扣券
|
|||
|
},
|
|||
|
success: res => {
|
|||
|
wx.hideLoading();
|
|||
|
console.log(res)
|
|||
|
if (res.data.code == 1) {
|
|||
|
this.setData({
|
|||
|
reduceTypeXz: index, //优惠
|
|||
|
reduceType: false,
|
|||
|
discount: res.data.value.volumeBalance, //当前商品优惠数
|
|||
|
priceSum: res.data.value.priceSum, //折扣券現金券減少数
|
|||
|
payActual: (parseFloat(this.data.total) + parseFloat(this.data.freight) - parseFloat(res.data.value.volumeBalance)).toFixed(2),
|
|||
|
})
|
|||
|
// if(this.data.wxVipType == 1){
|
|||
|
// this.setData({
|
|||
|
// pay: (parseFloat(this.data.payActual) * parseFloat(dataList.userVipDiscount) / 100).toFixed(2),
|
|||
|
// })
|
|||
|
// }else{
|
|||
|
// this.setData({
|
|||
|
// pay: (parseFloat(this.data.payActual)).toFixed(2),
|
|||
|
// })
|
|||
|
// }
|
|||
|
this.setData({
|
|||
|
pay: (parseFloat(this.data.payActual) * parseFloat(this.data.dataList.userVipDiscount) / 100).toFixed(2),
|
|||
|
})
|
|||
|
} else {
|
|||
|
wx.showModal({
|
|||
|
title: '提示!',
|
|||
|
content: res.data.message,
|
|||
|
showCancel: false,
|
|||
|
})
|
|||
|
}
|
|||
|
}
|
|||
|
})
|
|||
|
}
|
|||
|
}
|
|||
|
})
|
|||
|
}
|
|||
|
},
|
|||
|
// 联系方式
|
|||
|
telNum(e) {
|
|||
|
this.setData({
|
|||
|
telNum: e.detail.value
|
|||
|
})
|
|||
|
},
|
|||
|
//立即支付
|
|||
|
pay(e) {
|
|||
|
|
|||
|
if (this.data.pay_can == 1) {
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
if (this.data.addressId == '') {
|
|||
|
wx.showToast({
|
|||
|
title: '请选择收货方式',
|
|||
|
icon: 'none'
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
if (this.data.orderPick == 1) {
|
|||
|
if (this.data.date == '') {
|
|||
|
wx.showToast({
|
|||
|
title: '请选择提货日期',
|
|||
|
icon: 'none'
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
if (this.data.time == '') {
|
|||
|
wx.showToast({
|
|||
|
title: '请选择提货时间',
|
|||
|
icon: 'none'
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
if (this.data.telNum === '') {
|
|||
|
wx.showToast({
|
|||
|
title: '请输入联系方式~',
|
|||
|
icon: 'none'
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
// 手机号验证
|
|||
|
let phoneReg = /^1(3|4|5|6|7|8|9)\d{9}$/;
|
|||
|
if (!phoneReg.test(this.data.telNum)) {
|
|||
|
wx.showToast({
|
|||
|
title: '请输入正确的手机号~',
|
|||
|
icon: 'none'
|
|||
|
})
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
wx.showModal({
|
|||
|
title: '提示!',
|
|||
|
content: '确认要购买吗',
|
|||
|
success: sss => {
|
|||
|
if (sss.confirm) {
|
|||
|
let orderActualPay = '';
|
|||
|
let orderOtherPay = '';
|
|||
|
let orderPayWay = '';
|
|||
|
let orderPick = this.data.orderPick;
|
|||
|
let wisdOrderDetailList = [];
|
|||
|
let orderAllPay = +this.data.freight + (+this.data.total) //订单原价
|
|||
|
let orderVolumePay = this.data.discount //优惠金额
|
|||
|
console.log(this.data.goods)
|
|||
|
//商品信息
|
|||
|
for (let i = 0; i < this.data.goods.length; i++) {
|
|||
|
wisdOrderDetailList.push({
|
|||
|
goodsId: this.data.goods[i].goodsId,
|
|||
|
goodsNum: this.data.goods[i].num,
|
|||
|
specId: this.data.goods[i].specs.id,
|
|||
|
specPrice: this.data.specPriceArr[i], //规格价格集合
|
|||
|
})
|
|||
|
}
|
|||
|
console.log(wisdOrderDetailList)
|
|||
|
//支付方式
|
|||
|
if (!this.data.integral == 1) {
|
|||
|
orderActualPay = parseFloat(this.data.pay)
|
|||
|
if (this.data.reduceTypeXz == 0) {
|
|||
|
//1纯微信支付
|
|||
|
orderPayWay = 1;
|
|||
|
orderOtherPay = 0;
|
|||
|
}
|
|||
|
if (this.data.reduceTypeXz == 1) {
|
|||
|
//4现金券(+微信支付)
|
|||
|
orderPayWay = 4;
|
|||
|
orderOtherPay = parseFloat(this.data.priceSum)
|
|||
|
}
|
|||
|
if (this.data.reduceTypeXz == 2) {
|
|||
|
//5折扣券(+微信支付)
|
|||
|
orderPayWay = 5;
|
|||
|
orderOtherPay = parseFloat(this.data.priceSum)
|
|||
|
}
|
|||
|
} else {
|
|||
|
//2积分支付
|
|||
|
orderPayWay = 2;
|
|||
|
orderActualPay = 0;
|
|||
|
orderVolumePay = 0;
|
|||
|
orderOtherPay = parseFloat(this.data.payActualIntegral);
|
|||
|
orderAllPay = +this.data.freight + (+this.data.totalIntegral); //订单原价
|
|||
|
}
|
|||
|
wx.showLoading({
|
|||
|
title: '加载中',
|
|||
|
mask: true
|
|||
|
})
|
|||
|
wx.request({
|
|||
|
url: app.globalData.ip + '/wisdommining/api/order/addOrder',
|
|||
|
method: 'POST',
|
|||
|
data: {
|
|||
|
userId: app.globalData.userId,
|
|||
|
addressId: this.data.addressId,
|
|||
|
orderActualPay: orderActualPay, //微信支付的钱 其余传0
|
|||
|
orderOtherPay: orderOtherPay, //积分 现金券 折扣券 套餐0
|
|||
|
orderPayWay: orderPayWay, //1纯微信支付 2积分支付 3套餐券 4现金券(+微信支付) 5折扣券(+微信支付)
|
|||
|
orderPick: orderPick, //1自提 2物流
|
|||
|
orderPickTime: orderPick == 1 ? this.data.date + ' ' + this.data.time : '',
|
|||
|
orderRemark: this.data.note,
|
|||
|
orderFreight: this.data.freight,
|
|||
|
wisdOrderDetailList: wisdOrderDetailList,
|
|||
|
isCar: parseInt(this.data.isCar), //购物车1 别的0
|
|||
|
orderAllPay: orderAllPay,
|
|||
|
orderVolumePay: orderVolumePay,
|
|||
|
userPhone: this.data.telNum
|
|||
|
},
|
|||
|
success: res => {
|
|||
|
wx.hideLoading();
|
|||
|
console.log(res)
|
|||
|
if (res.data.code == 1) {
|
|||
|
//支付
|
|||
|
this.payM({
|
|||
|
orderNumber: res.data.value
|
|||
|
})
|
|||
|
//是否能点击支付
|
|||
|
this.setData({
|
|||
|
pay_can: 1
|
|||
|
})
|
|||
|
} else {
|
|||
|
wx.showModal({
|
|||
|
title: '提示!',
|
|||
|
content: res.data.message,
|
|||
|
showCancel: false,
|
|||
|
})
|
|||
|
}
|
|||
|
}
|
|||
|
})
|
|||
|
}
|
|||
|
}
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
//支付
|
|||
|
payM(options) {
|
|||
|
wx.showLoading({
|
|||
|
title: '支付中',
|
|||
|
mask: true
|
|||
|
})
|
|||
|
wx.request({
|
|||
|
url: app.globalData.ip + '/wisdommining/api/pay/payOrder',
|
|||
|
method: 'PUT',
|
|||
|
header: {
|
|||
|
"content-type": "application/x-www-form-urlencoded",
|
|||
|
},
|
|||
|
data: {
|
|||
|
userId: app.globalData.userId,
|
|||
|
orderNumber: options.orderNumber
|
|||
|
},
|
|||
|
success: res => {
|
|||
|
wx.hideLoading();
|
|||
|
console.log(res)
|
|||
|
if (res.data.code == 1) {
|
|||
|
//调用微信支付API
|
|||
|
wx.requestPayment({
|
|||
|
timeStamp: res.data.value.timeStamp,
|
|||
|
nonceStr: res.data.value.nonceStr,
|
|||
|
package: res.data.value.package,
|
|||
|
signType: 'MD5',
|
|||
|
paySign: res.data.value.paySign,
|
|||
|
success(res) {
|
|||
|
console.log(res)
|
|||
|
//支付成功
|
|||
|
wx.showToast({
|
|||
|
title: '支付成功',
|
|||
|
icon: 'success',
|
|||
|
duration: 1000,
|
|||
|
mask: true,
|
|||
|
success() {
|
|||
|
setTimeout(() => {
|
|||
|
wx.showLoading({
|
|||
|
title: '跳转中..',
|
|||
|
mask: true
|
|||
|
})
|
|||
|
wx.redirectTo({
|
|||
|
url: '/pages/order_details/order_details?orderNumber=' + options.orderNumber,
|
|||
|
})
|
|||
|
}, 1000);
|
|||
|
}
|
|||
|
})
|
|||
|
},
|
|||
|
fail(res) {
|
|||
|
console.log(res)
|
|||
|
wx.showToast({
|
|||
|
title: '支付失败',
|
|||
|
icon: 'none',
|
|||
|
duration: 1000,
|
|||
|
mask: true,
|
|||
|
success() {
|
|||
|
setTimeout(() => {
|
|||
|
wx.showLoading({
|
|||
|
title: '跳转中..',
|
|||
|
mask: true
|
|||
|
})
|
|||
|
wx.redirectTo({
|
|||
|
url: '/pages/order_details/order_details?orderNumber=' + options.orderNumber,
|
|||
|
})
|
|||
|
}, 1000);
|
|||
|
}
|
|||
|
})
|
|||
|
}
|
|||
|
})
|
|||
|
} else if (res.data.code == 2) {
|
|||
|
//支付成功
|
|||
|
wx.showToast({
|
|||
|
title: '支付成功',
|
|||
|
icon: 'success',
|
|||
|
duration: 1000,
|
|||
|
mask: true,
|
|||
|
success() {
|
|||
|
setTimeout(() => {
|
|||
|
wx.showLoading({
|
|||
|
title: '跳转中..',
|
|||
|
mask: true
|
|||
|
})
|
|||
|
wx.redirectTo({
|
|||
|
url: '/pages/order_details/order_details?orderNumber=' + options.orderNumber,
|
|||
|
})
|
|||
|
}, 1000);
|
|||
|
}
|
|||
|
})
|
|||
|
} else {
|
|||
|
wx.showModal({
|
|||
|
title: '提示!',
|
|||
|
content: res.data.message,
|
|||
|
showCancel: false,
|
|||
|
success: sss => {
|
|||
|
if (sss.confirm) {
|
|||
|
// wx.redirectTo({
|
|||
|
// url: '/pages/order_details/order_details?orderNumber=' + options.orderNumber,
|
|||
|
// })
|
|||
|
wx.navigateBack()
|
|||
|
}
|
|||
|
}
|
|||
|
})
|
|||
|
}
|
|||
|
}
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
//优惠方式遮罩层
|
|||
|
reduceZzc() {
|
|||
|
this.setData({
|
|||
|
reduceType: false, //优惠方式
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
bindDateChange: function (e) {
|
|||
|
console.log('picker发送选择改变,携带值为', e.detail.value)
|
|||
|
this.setData({
|
|||
|
date: e.detail.value
|
|||
|
})
|
|||
|
},
|
|||
|
bindTimeChange: function (e) {
|
|||
|
console.log('picker发送选择改变,携带值为', e.detail.value)
|
|||
|
this.setData({
|
|||
|
time: e.detail.value
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面初次渲染完成
|
|||
|
*/
|
|||
|
onReady: function () {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面隐藏
|
|||
|
*/
|
|||
|
onHide: function () {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面卸载
|
|||
|
*/
|
|||
|
onUnload: function () {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 页面相关事件处理函数--监听用户下拉动作
|
|||
|
*/
|
|||
|
onPullDownRefresh: function () {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 页面上拉触底事件的处理函数
|
|||
|
*/
|
|||
|
onReachBottom: function () {
|
|||
|
|
|||
|
},
|
|||
|
})
|