调整代码

cz_dev
格调main 2026-02-28 17:10:51 +08:00
parent e1d05e5556
commit 656a3ac3fc
2 changed files with 124 additions and 96 deletions

View File

@ -54,4 +54,43 @@ export function getPaySign(params = {}){
method: 'GET',
data: params,
})
}
}
// 创建购买订单
export function appBuy (params = {}){
return request({
url: '/app-api/member/lu-order/buy',
method: 'POST',
data: params,
})
}
// 获取lu(司机公会简称) 订单信息
export function getLuOrder (id){
return request({
url: '/app-api/member/lu-order/get?id='+id,
method: 'GET',
})
}
/// 获取我的订单列表
export function getLuMyOrderPage (params = {}){
return request({
url: '/app-api/member/lu-order/myPage',
method: 'GET',
data: params
})
}
// 删除优惠卷购买 (暂时不用)
// export function delCouponPurchaseBuy(id){
// return request({
// url: '/app-api/member/labor-union-coupon-purchase/delete?id='+id,
// method: 'DELETE',
// })
// }
// // 取消优惠卷购买 (暂时不用)
// export function cancelCouponPurchaseBuy(id){
// return request({
// url: '/app-api/member/labor-union-coupon-purchase/cancel?id='+id,
// method: 'POST',
// })
// }

View File

@ -80,9 +80,7 @@
>-</view
>
<text class="quantity-number">{{ item.quantity || 0 }}</text>
<view
class="quantity-btn plus"
@click="increaseQuantity(index)"
<view class="quantity-btn plus" @click="increaseQuantity(index)"
>+</view
>
</view>
@ -118,12 +116,12 @@
</template>
<script>
import { getGuildStoreDetail, getGuildCoupon ,getPaySign } from "@/api/service";
import { getGuildStoreDetail, getGuildCoupon, getPaySign } from "@/api/service";
import NavHeader from "@/components/NavHeader/NavHeader.vue";
export default {
components: {
NavHeader
NavHeader,
},
data() {
return {
@ -142,7 +140,8 @@ export default {
return this.menuList.reduce((total, item) => {
if (item.selected && item.quantity > 0) {
//
const price = (item.salePrice || item.currentPrice || item.price || 0) / 100;
const price =
(item.salePrice || item.currentPrice || item.price || 0) / 100;
return total + price * item.quantity;
}
return total;
@ -154,14 +153,17 @@ export default {
},
// 访
memberLevelName() {
return (this.userInfo && this.userInfo.level && this.userInfo.level.name) || '普通会员';
return (
(this.userInfo && this.userInfo.level && this.userInfo.level.name) ||
"普通会员"
);
},
},
onLoad(options) {
// ID
this.shopId = options.id;
this.categoryLabel = options.categoryLabel;
this.userInfo = uni.getStorageSync('userInfo') || {};
this.userInfo = uni.getStorageSync("userInfo") || {};
if (this.shopId) {
this.loadStoreData();
} else {
@ -177,21 +179,26 @@ export default {
onShow() {
//
//
const token = uni.getStorageSync('token');
const newUserInfo = uni.getStorageSync('userInfo') || {};
const token = uni.getStorageSync("token");
const newUserInfo = uni.getStorageSync("userInfo") || {};
//
if (token && (!this.userInfo || !this.userInfo.id) && newUserInfo && newUserInfo.id) {
if (
token &&
(!this.userInfo || !this.userInfo.id) &&
newUserInfo &&
newUserInfo.id
) {
this.userInfo = newUserInfo;
this.isLoadingAfterLogin = true; //
// 401
uni.setStorageSync('justBackFromLogin', true);
uni.setStorageSync("justBackFromLogin", true);
// 5
setTimeout(() => {
uni.removeStorageSync('justBackFromLogin');
uni.removeStorageSync("justBackFromLogin");
}, 5000);
// token
setTimeout(() => {
// ID
@ -207,10 +214,9 @@ export default {
//
this.userInfo = newUserInfo;
}
//
this.hasCheckedLogin = true;
},
methods: {
//
@ -297,7 +303,7 @@ export default {
// 100
formatPrice(price) {
if (!price && price !== 0) {
return '0.00';
return "0.00";
}
//
const yuan = price / 100;
@ -323,83 +329,66 @@ export default {
});
return;
}
// uni.showToast({
// title: "",
// icon: "none",
// });
//
const reqsn = 'mini' + Date.now() + '' + Math.floor(Math.random() * 10000);
const randomstr = Math.floor(Math.random() * 10000000)+'';
//
//
// STring ,
let params = {
"appid": "00390105", // appid
"body": "body订单标题", //
"cusid": "56479107531MPMN", //
"notify_url": "http://e989c692.natappfree.cc/admin-api/member/labor-union-coupon-purchase/tlNotice", //
"orgid": "56479107392N35H",
"paytype": "W06",
"randomstr": randomstr,
"remark": "remark备注",
"reqsn": reqsn,
"sign": "",
"signtype": "RSA",
"trxamt": "1",
"version": "12",
//"asinfo":"56479107392MP4J:01:0.01" //(, ) , ,01 , ,0.01
};
const sign = await getPaySign(params)
console.log("测试返回的签名:"+sign)
params["sign"] = sign
console.log(params)
// params = this.sortObjectByKey(params);
console.log(params)
// 使 navigateToMiniProgram
uni.navigateToMiniProgram({
appId: 'wxef277996acc166c3', // appid
extraData: params, //
success(res) {
console.log('小程序跳转成功', res);
},
fail(err) {
console.error('小程序跳转失败', err);
//
uni.showToast({
title: '跳转失败,请稍后重试',
icon: 'none'
});
},
complete() {
//
}
});
//----
//
},
/**
* 将对象按键的字典序排序返回有序对象和Java TreeMap排序逻辑一致
* @param {Object} obj 原始参数对象
* @returns {Object} 按键排序后的新对象
*/
sortObjectByKey(obj) {
// 1. Java String
const sortedKeys = Object.keys(obj).sort();
// 2.
const sortedObj = {};
sortedKeys.forEach(key => {
sortedObj[key] = obj[key];
});
return sortedObj;
}
//
async handlePay(){
//
const reqsn =
"mini" + Date.now() + "" + Math.floor(Math.random() * 10000);
const randomstr = Math.floor(Math.random() * 10000000) + "";
//
//
// STring ,
let params = {
appid: "00390105", // appid
body: "body订单标题", //
cusid: "56479107531MPMN", //
notify_url:
"http://e989c692.natappfree.cc/admin-api/member/labor-union-coupon-purchase/tlNotice", //
orgid: "56479107392N35H",
paytype: "W06",
randomstr: randomstr,
remark: "remark备注",
reqsn: reqsn,
sign: "",
signtype: "RSA",
trxamt: "1",
version: "12",
//"asinfo":"56479107392MP4J:01:0.01" //(, ) , ,01 , ,0.01
};
const sign = await getPaySign(params);
console.log("测试返回的签名:" + sign);
params["sign"] = sign;
console.log(params);
// params = this.sortObjectByKey(params);
console.log(params);
// 使 navigateToMiniProgram
uni.navigateToMiniProgram({
appId: "wxef277996acc166c3", // appid
extraData: params, //
success(res) {
console.log("小程序跳转成功", res);
},
fail(err) {
console.error("小程序跳转失败", err);
//
uni.showToast({
title: "跳转失败,请稍后重试",
icon: "none",
});
},
complete() {
//
},
});
//----
}
},
};
</script>