feat:支付问题

This commit is contained in:
qiaojiale 2025-07-18 15:55:39 +08:00
parent 3a5ff55440
commit 41ea48b154
17 changed files with 233 additions and 33 deletions

View File

@ -6,12 +6,11 @@ export const apiArr = {
getCarCount: "/api/v2/wechat/commodity/cart/all_count",//购物车数量 getCarCount: "/api/v2/wechat/commodity/cart/all_count",//购物车数量
addCar: "/api/v2/wechat/commodity/cart/add",//添加购物车 addCar: "/api/v2/wechat/commodity/cart/add",//添加购物车
deleteCar: "/api/v2/wechat/commodity/cart/delete",//删除购物车 deleteCar: "/api/v2/wechat/commodity/cart/delete",//删除购物车
addressList: '/api/v2/wechat/commodity/receiving_address', // 收货地址列表
addAddress: '/api/v2/wechat/commodity/receiving_address/add', // 收货地址添加
addressDel: '/api/v2/wechat/commodity/receiving_address/delete', // 收货地址删除
settingDefaultAddress: '/api/v2/wechat/commodity/receiving_address/default', // 收货地址设置默认
updateAddress: '/api/v2/wechat/commodity/receiving_address/update', // 收货地址修改
updateCar:"/api/v2/wechat/commodity/cart/update",
updateCar: "/api/v2/wechat/commodity/cart/update",//更新购物车信息 updateCar: "/api/v2/wechat/commodity/cart/update",//更新购物车信息
getUserDefAddress: "/api/v2/wechat/commodity/receiving_address/get_default",//获取用户默认地址 getUserDefAddress: "/api/v2/wechat/commodity/receiving_address/get_default",//获取用户默认地址
createOrder: "/api/v2/wechat/commodity/order/create",//创建商品订单
payOrder: "/api/v2/wechat/commodity/order/pay",//支付订单
settingDefaultAddress: '/api/v2/wechat/commodity/receiving_address/default', // 收货地址设置默认
updateAddress: '/api/v2/wechat/commodity/receiving_address/update', // 收货地址修改
queryOrder: '/api/v2/wechat/commodity/order/trade_query', // 查询订单
} }

View File

@ -19,7 +19,8 @@
/* 模块配置 */ /* 模块配置 */
"modules" : { "modules" : {
"Payment" : {}, "Payment" : {},
"OAuth" : {} "OAuth" : {},
"Share" : {}
}, },
/* 应用发布信息 */ /* 应用发布信息 */
"distribute" : { "distribute" : {
@ -51,7 +52,7 @@
"appleiap" : {}, "appleiap" : {},
"weixin" : { "weixin" : {
"__platform__" : [ "ios", "android" ], "__platform__" : [ "ios", "android" ],
"appid" : "", "appid" : "wxb4018c78fa143450",
"UniversalLinks" : "" "UniversalLinks" : ""
} }
}, },
@ -60,6 +61,12 @@
"appid" : "wxb4018c78fa143450", "appid" : "wxb4018c78fa143450",
"UniversalLinks" : "" "UniversalLinks" : ""
} }
},
"share" : {
"weixin" : {
"appid" : "wxb4018c78fa143450",
"UniversalLinks" : ""
}
} }
} }
} }

View File

@ -7,12 +7,12 @@
<div class="address_Info" @click="choseAddress" v-if="defAddress"> <div class="address_Info" @click="choseAddress" v-if="defAddress">
<div class="address_Info_left"> <div class="address_Info_left">
<div class="address_Info_left_tit">收货地址</div> <div class="address_Info_left_tit">收货地址</div>
<div class="address_Info_left_name">李佳 15901518415</div> <div class="address_Info_left_name">{{ defAddress.name }} {{ defAddress.phone }}</div>
<div class="address_Info_left_addr">北京北京市朝阳区珠江绿洲文化广场</div> <div class="address_Info_left_addr">{{ defAddress.address }}{{ defAddress.house_number }}</div>
</div> </div>
</div> </div>
<div class="address_Info" @click="choseAddress" v-if="!defAddress"> <div class="address_Info" @click="addAddress" v-if="!defAddress">
<div class="address_Info_left noneDef"> <div class="address_Info_left noneDef">
<div class="address_Info_btn">添加收货地址</div> <div class="address_Info_btn">添加收货地址</div>
</div> </div>
@ -62,7 +62,7 @@
<div class="footer"> <div class="footer">
<div class="btn">立即支付¥{{ totalMony }}</div> <div class="btn" @click="craeteOrder">立即支付¥{{ totalMony }}</div>
</div> </div>
</view> </view>
@ -89,13 +89,17 @@ export default {
carList: [], carList: [],
totalMony: 0, totalMony: 0,
defAddress: {}, defAddress: {},
order_id: ""
} }
}, },
methods: { methods: {
choseAddress() { choseAddress() {
NavgateTo('../address/index') NavgateTo('../address/index')
}, },
addAddress() {
NavgateTo('../addAddress/index')
},
calcTotal() { calcTotal() {
let total = 0 let total = 0
this.carList.forEach(item => { this.carList.forEach(item => {
@ -128,6 +132,91 @@ export default {
}) })
}, },
craeteOrder() {
uni.showLoading({
title: '加载中',
})
let goods_list = []
this.carList.forEach(item => {
goods_list.push({
goods_id: item.commodity_goods_info.id,
count: item.count,
})
})
request(apiArr.createOrder, "POST", {
goods_list,
address_id: this.defAddress.id
}).then(res => {
uni.hideLoading()
this.order_id = res.order_id
this.payOrder()
}).catch(err => {
uni.hideLoading()
})
},
payOrder() {
request(apiArr.payOrder, "POST", {
order_id: this.order_id
}).then(res => {
let that = this; // 保存组件实例的 this 引用
let resCopy = JSON.parse(JSON.stringify(res))
this.WxPay(resCopy)
})
},
WxPay(resCopy) {
let that = this
uni.requestPayment({
"provider": "wxpay",
"orderInfo": {
"appid": "wxb4018c78fa143450", //
"noncestr": resCopy.nonceStr, // 随机字符串
"package": resCopy.package, // 固定值
"prepayid":resCopy.prepayId,
"timestamp": resCopy.timeStamp, // 时间戳(单位:秒)
"paysign": resCopy.paySign,
"partnerid":resCopy.partnerId
},
timeStamp: resCopy.timeStamp,
nonceStr: resCopy.nonceStr,
package: resCopy.package,
signType: resCopy.signType,
paySign: resCopy.paySign,
success(res) {
console.log(res);
},
fail(e) {
console.log(e.errMsg);
}
})
// uni.requestPayment({
// provider: 'wxpay',
// timeStamp: resCopy.timeStamp,
// nonceStr: resCopy.nonceStr,
// package: resCopy.package,
// signType: resCopy.signType,
// paySign: resCopy.paySign,
// success: function (res) {
// console.log('success:' + JSON.stringify(res));
// that.queryOrder()
// },
// fail: function (err) {
// console.log('fail:' + JSON.stringify(err));
// }
// })
},
queryOrder() {
request(apiArr.queryOrder, "POST", {
order_id: this.order_id
}).then(res => {
console.log(res);
})
},
}, },
onShow() { onShow() {
this.getUserAddress() this.getUserAddress()

92
pages/test.vue Normal file
View File

@ -0,0 +1,92 @@
<template>
<div class="animation-container" @mouseenter="handleMouseEnter" @mouseleave="handleMouseLeave">
<img :src="spriteImage" :style="spriteStyle" alt="Animation sprite" />
</div>
</template>
<script>
export default {
name: 'SpriteAnimation',
data() {
return {
frame: 1, // 当前帧数 (1-60)
type: '外', // 动画类型 ('内'或'外')
running: false, // 是否正在执行动画
timer: null, // 动画定时器
spriteImage: 'http://192.168.0.172:5500/test1.png' // 示例base64图片
}
},
computed: {
spriteStyle() {
return {
position: 'absolute',
top: `-${(this.frame - 1) * 120}px`,
left: '0px',
width: '100%',
height: 'auto'
}
}
},
methods: {
clearAnimationTimer() {
if (this.timer) {
clearInterval(this.timer)
this.timer = null
}
},
startAnimation() {
this.clearAnimationTimer()
this.running = true
const targetFrame = this.type === '内' ? 60 : 1
const step = this.type === '内' ? 1 : -1
const frameDuration = 2000 / 60 // 2秒完成60帧动画
this.timer = setInterval(() => {
this.frame += step
if ((step > 0 && this.frame >= targetFrame) ||
(step < 0 && this.frame <= targetFrame)) {
this.frame = targetFrame
this.clearAnimationTimer()
this.running = false
this.checkAutoReverse()
}
}, frameDuration)
},
handleMouseEnter() {
this.type = '内'
if (!this.running) this.startAnimation()
},
handleMouseLeave() {
this.type = '外'
if (!this.running) this.startAnimation()
},
checkAutoReverse() {
if (this.type === '外' && this.frame === 60) {
this.type = '内'
this.startAnimation()
} else if (this.type === '内' && this.frame === 1) {
this.type = '外'
this.startAnimation()
}
}
},
beforeUnmount() {
this.clearAnimationTimer()
}
}
</script>
<style scoped>
.animation-container {
width: 120px;
height: 120px;
position: relative;
border: 1px solid pink;
overflow: hidden;
cursor: pointer;
left: 20%;
top: 200px;
}
</style>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -3,5 +3,18 @@
"projectname": "uniapp-ZHSQ", "projectname": "uniapp-ZHSQ",
"setting": { "setting": {
"compileHotReLoad": true "compileHotReLoad": true
},
"condition": {
"miniprogram": {
"list": [
{
"name": "packages/shop/shopCar/index",
"pathName": "packages/shop/shopCar/index",
"query": "",
"scene": null,
"launchMode": "default"
}
]
}
} }
} }