Initial Commit

This commit is contained in:
quantulr
2024-05-06 15:34:15 +08:00
commit e3a0666d5a
307 changed files with 28969 additions and 0 deletions

View File

@ -0,0 +1,441 @@
// pages/cartPay/cartPay.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
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,//购物车进入
date: '',
time: '',
startTime: '',
},
/**
* 生命周期函数--监听页面显示
*/
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,
})
//运费获取
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)).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).toFixed(2),
})
console.log(this.data.address)
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let myDate = new Date();
this.setData({
startTime: myDate.getFullYear() + '-' + (parseFloat(myDate.getMonth()) + 1) + '-' + (parseFloat(myDate.getDate()) + 3)
})
//购物车进入
if (options.isCar) {
console.log(options.isCar)
this.setData({
isCar: options.isCar
})
}
if (options.goods) {
let goods = JSON.parse(options.goods)
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.specPromotionPrice) * parseFloat(goods[i].num)
numAll = numAll + parseFloat(goods[i].num);
specPriceArr.push(parseFloat(goods[i].specs.specPromotionPrice));
}
this.setData({
goods: goods,
total: total.toFixed(2),
total_int: parseInt(total),
specPriceArr: specPriceArr,
numAll: numAll,
payActual: (parseFloat(total) + parseFloat(this.data.freight)).toFixed(2),
})
//订单个人信息获取
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,
})
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)).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,//优惠
})
},
//立即支付
pay(e) {
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
}
}
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)
//支付方式
orderActualPay = parseFloat(this.data.payActual)
if (this.data.reduceTypeXz == 0) {
//1纯微信支付
orderPayWay = 1;
orderOtherPay = 0;
}
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,
},
success: res => {
wx.hideLoading();
console.log(res)
if (res.data.code == 1) {
//支付
this.payM({
orderNumber: res.data.value
})
} 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,
success() {
setTimeout(() => {
wx.redirectTo({
url: '/pages/order_details/order_details?orderNumber=' + options.orderNumber,
})
}, 1000);
}
})
},
fail(res) {
console.log(res)
wx.showToast({
title: '支付失败',
icon: 'none',
duration: 1000,
success() {
setTimeout(() => {
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.navigateBack()
}
}
})
}
}
})
},
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
})
},
})

View File

@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "订单支付"
}

View File

@ -0,0 +1,110 @@
<!--pages/cartPay/cartPay.wxml-->
<!-- 选择收货类型 -->
<view class="address display_J_B" catchtap="addressType">
<view class="address-l display_J_S display_A_C">
<image src="/icon/order-addrass.png"></image>
<view class="address-cont GStitleOne">{{address}}</view>
</view>
<view class="address-r display_A_C">
<image src="/icon/right.png"></image>
</view>
</view>
<view class="goods">
<view class="cont display_J_B" wx:for='{{goods}}' wx:key='index'>
<view class="cont-l">
<image src="{{item.goodsPhoto}}"></image>
</view>
<view class="cont-m">
<view class="name GStitleOne">{{item.goodsName}}</view>
<view class="spec">规格:{{item.specs.specName}}</view>
<!-- 普通 -->
<view class="price">¥{{item.specs.specPromotionPrice}}
<text>¥{{item.specs.originalPrice}}</text>
</view>
</view>
<view class="cont-r">x{{item.num}}</view>
</view>
</view>
<view class="data">
<view class="data-t display_J_B display_A_C">
<view class="t-l">商品合计<text>(预计获得{{total_int}}积分)</text></view>
</view>
<view class="data-t display_J_B display_A_C">
<view class="t-l">运费</view>
<view class="t-r t-r__2">{{orderPick==1?'自提':freight==0?'包邮':('¥'+freight)}}</view>
</view>
<view class="data-t display_J_B display_A_C">
<view class="t-l">备注</view>
<view class="t-r t-r__2">
<input type="text" value="{{note}}" bindinput="note" placeholder="请填写备注"></input>
</view>
</view>
<view class="data-t data-t_last display_J_B display_A_C">
<view class="t-l">实际支付</view>
<view class="t-r t-r__4">{{'¥'+payActual}}</view>
</view>
</view>
<view class="pay-type display_J_B">
<view class="pay-type__l display_A_C">
<image src="/icon/wx.png"></image>微信支付
</view>
<view class="pay-type__r display_A_C">
<image src="/icon/wx-checked.png"></image>
</view>
</view>
<!-- 自提时间 -->
<view class="ztTime display_J_B" wx:if="{{orderPick==1}}">
<view class="ztt_l">自提时间<text>*</text></view>
<view class="ztt_r display_J_E display_A_C">
<picker mode="date" value="{{date}}" start="{{startTime}}" bindchange="bindDateChange">
<view class="display_A_C display_J_E" style="width:250rpx;">
<text class="{{date!=''?'ztt_r_time':''}}">{{date==''?'选择提货日期':date}}</text>
<image src="/icon/c-down.png"></image>
</view>
</picker>
<picker mode="time" value="{{time}}" bindchange="bindTimeChange">
<view class="display_A_C display_J_E" style="width:250rpx;">
<text style="margin-left: 30rpx;" class="{{time!=''?'ztt_r_time':''}}">{{time==''?'选择提货时间':time}}</text>
<image src="/icon/c-down.png"></image>
</view>
</picker>
</view>
</view>
<view class="ztTimeTs" wx:if="{{orderPick==1}}">由于进货和配货需要时间您的提货时间要3天后开始选择</view>
<view class="height100"></view>
<view class="height100"></view>
<view class="pay display_J_B display_A_C">
<view class="pay-l"><i>共计{{numAll}}件</i>合计:¥<text>{{payActual}}</text></view>
<view class="pay-r" catchtap="pay">立即支付</view>
</view>
<!-- 收货方式 -->
<view wx:if='{{addressType}}'>
<view class="reduce-zzc" catchtap="addressZzc"></view>
<view class="reduce-cont">
<view class="reduce-title">选择收货方式</view>
<view class="reduce-c display_J_B" catchtap="address">
<view class="reduce-c__l display_A_C">
<image src="/icon/order-addrass.png"></image>我的收货地址
</view>
<view class="reduce-c__r display_A_C">
<image src="/icon/right.png"></image>
</view>
</view>
<view class="reduce-c display_J_B" catchtap="ztd">
<view class="reduce-c__l display_A_C">
<image src="/icon/address.png" style="width:30rpx;margin:0 66rpx 0 7rpx;"></image>自提点
</view>
<view class="reduce-c__r display_A_C">
<image src="/icon/right.png"></image>
</view>
</view>
</view>
</view>

View File

@ -0,0 +1,355 @@
/* pages/cartPay/cartPay.wxss */
page{
background-color: #f5f5f5;
}
.djs{
font-size: 28rpx;
color: #333333;
width: 750rpx;
height: 80rpx;
background-color: #f7e0cd;
text-align: center;
line-height: 80rpx;
}
.djs text{
color: #ff372d;
margin-left: 10rpx;
}
.address{
margin-top: 34rpx;
width: 690rpx;
padding: 0 30rpx;
height: 156rpx;
background-color: #ffffff;
border-radius: 20rpx;
}
.address-l{
height: 100%;
}
.address-l image{
width: 46rpx;
height: 46rpx;
margin:0 55rpx 0 15rpx;
}
.address-cont{
font-size: 32rpx;
color: #ee7b1e;
width: 500rpx;
}
.address-r{
height: 100%;
}
.address-r image{
width:30rpx;
height:30rpx;
}
.goods{
width: 690rpx;
padding: 0 30rpx;
background-color: #ffffff;
border-radius: 20rpx;
margin: 30rpx 0;
}
.cont{
padding: 30rpx 0;
border-bottom: 1rpx #dcdcdc solid;
}
.cont:last-child{
border-bottom: none;
}
.cont-l image{
width: 160rpx;
height: 160rpx;
}
.cont-m{
width: 400rpx;
padding: 10rpx 0;
display: flex;
flex-wrap: wrap;
align-content: space-between;
}
.name{
font-size: 28rpx;
color: #333333;
}
.spec{
width:100%;
font-size: 24rpx;
color: #999999;
}
.price{
width:100%;
font-size: 36rpx;
color: #ee7b1e;
}
.price text{
font-size: 24rpx;
color: #999999;
text-decoration: line-through;
margin-left: 11rpx;
}
.cont-r{
display: flex;
align-items : flex-end;
font-size: 32rpx;
color: #0b0b0b;
height: 130rpx;
}
.data{
width: 690rpx;
padding:10rpx 30rpx 0;
background-color: #ffffff;
border-radius: 20rpx;
}
.data-t{
height: 70rpx;
}
.data-t_last{
padding-top:20rpx;
border-top: 1rpx #d9d9d9 solid;
margin-top: 30rpx;
}
.t-l{
font-size: 28rpx;
letter-spacing: 1rpx;
color: #444444;
}
.t-l text{
color: #ff291e;
font-size: 24rpx;
}
.t-r{
font-size: 28rpx;
letter-spacing: 1rpx;
height: 70rpx;
line-height: 70rpx;
}
.t-r__1{
color: #333333;
font-weight: bold;
}
.t-r__2{
color: #999999;
}
.t-r__3{
color: #ee7b1e;
}
.t-r__4{
color: #333333;
font-weight: bold;
font-size: 34rpx;
}
t-r__5{
color: #ee7b1e;
font-weight: bold;
font-size: 34rpx;
}
.t-r input{
font-size: 28rpx;
letter-spacing: 1rpx;
color: #999999;
width: 500rpx;
text-align: right;
line-height: 70rpx;
height: 70rpx;
border: none;
}
.t-r image{
width: 30rpx;
height: 30rpx;
}
.pay-type{
width: 690rpx;
padding: 0 30rpx;
height: 100rpx;
background-color: #ffffff;
border-radius: 20rpx;
margin-top:20rpx;
}
.pay-type__l{
height: 100%;
font-size: 28rpx;
color: #333333;
}
.pay-type__l image{
width: 50rpx;
height: 50rpx;
margin-right: 20rpx;
}
.pay-type__r{
height: 100%;
font-size: 24rpx;
letter-spacing: 1rpx;
color: #ee7b1e;
}
.pay-type__r image{
width: 30rpx;
height: 30rpx;
margin-left: 20rpx;
}
.pay{
width: 690rpx;
padding: 0 30rpx;
height: 100rpx;
background-color: #ffffff;
line-height: 56rpx;
position: fixed;
bottom: 0;
left: 0;
}
.pay-l i{
padding-right: 32rpx;
font-size: 28rpx;
color: #333333;
}
.pay-l{
padding-left: 90rpx;
font-size: 28rpx;
color: #ee7b1e;
}
.pay-l text{
font-size: 40rpx;
color: #ee7b1e;
}
.pay-r{
width: 180rpx;
height: 56rpx;
background-image: linear-gradient(-90deg,
#ee7b1e 0%,
#fdae03 100%);
border-radius: 28rpx;
font-size: 28rpx;
color: #ffffff;
text-align: center;
}
.pay-r_bz{
width: 180rpx;
height: 56rpx;
background-color: #999999;
border-radius: 28rpx;
font-size: 28rpx;
color: #ffffff;
text-align: center;
}
.reduce-zzc{
width: 100vw;
height: 100vh;
position: fixed;
left: 0;
top: 0;
z-index: 9;
background-color: rgba(0, 0, 0, 0.6);
}
.reduce-cont{
position: fixed;
left: 0;
bottom: 0;
z-index: 9;
width: 690rpx;
padding: 0 30rpx 50rpx;
background-color: #ffffff;
border-radius: 20rpx 20rpx 0px 0px;
}
.reduce-title{
font-size: 36rpx;
color: #333333;
border-bottom: 1rpx solid #d2d2d2;
height: 106rpx;
line-height: 106rpx;
text-align: center;
margin-bottom: 40rpx;
padding-left: 70rpx;
}
.titlezk{
font-size: 28rpx;
color: #ff0000;
margin-left: 15rpx;
}
.reduce-c{
width: 690rpx;
height: 100rpx;
background-color: #ffffff;
border-radius: 20rpx;
margin-bottom: 30rpx;
}
.reduce-c__l{
font-size: 36rpx;
color: #333333;
}
.reduce-c__l text{
color: #ee7b1e;
}
.reduce-c__l text text{
font-size: 24rpx;
}
.reduce-c__l .zk{
font-size: 36rpx;
color: #ff0000;
margin-left: 15rpx;
}
.reduce-c__l{
height: 100%;
}
.reduce-c__l image{
width: 46rpx;
height: 46rpx;
margin-right: 58rpx;
}
.reduce-c__r{
height: 100%;
}
.reduce-c__r image{
width: 42rpx;
height: 42rpx;
}
.ztTime{
box-sizing: border-box;
padding: 0 30rpx;
margin-top: 30rpx;
width: 750rpx;
height: 100rpx;
background-color: #ffffff;
border-radius: 20rpx;
}
.ztt_l{
font-size: 28rpx;
line-height: 100rpx;
letter-spacing: 1rpx;
color: #333333;
}
.ztt_l text{
color: #ff0000;
margin-left: 20rpx;
display: inline-block;
position: relative;
top: 6rpx;
}
.ztt_r{
font-size: 28rpx;
line-height: 100rpx;
letter-spacing: 1rpx;
color: #999999;
width:500rpx;
}
.ztt_r_time{
color: #333333;
}
.ztt_r image{
width: 14rpx;
height: 8rpx;
margin-left: 20rpx;
}
.ztTimeTs{
font-size: 24rpx;
line-height: 35rpx;
letter-spacing: 1rpx;
color: #ff0000;
text-align: center;
margin-top: 20rpx;
}