调整代码

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

@ -55,3 +55,42 @@ export function getPaySign(params = {}){
data: params, 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 >-</view
> >
<text class="quantity-number">{{ item.quantity || 0 }}</text> <text class="quantity-number">{{ item.quantity || 0 }}</text>
<view <view class="quantity-btn plus" @click="increaseQuantity(index)"
class="quantity-btn plus"
@click="increaseQuantity(index)"
>+</view >+</view
> >
</view> </view>
@ -118,12 +116,12 @@
</template> </template>
<script> <script>
import { getGuildStoreDetail, getGuildCoupon ,getPaySign } from "@/api/service"; import { getGuildStoreDetail, getGuildCoupon, getPaySign } from "@/api/service";
import NavHeader from "@/components/NavHeader/NavHeader.vue"; import NavHeader from "@/components/NavHeader/NavHeader.vue";
export default { export default {
components: { components: {
NavHeader NavHeader,
}, },
data() { data() {
return { return {
@ -142,7 +140,8 @@ export default {
return this.menuList.reduce((total, item) => { return this.menuList.reduce((total, item) => {
if (item.selected && item.quantity > 0) { 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 + price * item.quantity;
} }
return total; return total;
@ -154,14 +153,17 @@ export default {
}, },
// 访 // 访
memberLevelName() { memberLevelName() {
return (this.userInfo && this.userInfo.level && this.userInfo.level.name) || '普通会员'; return (
(this.userInfo && this.userInfo.level && this.userInfo.level.name) ||
"普通会员"
);
}, },
}, },
onLoad(options) { onLoad(options) {
// ID // ID
this.shopId = options.id; this.shopId = options.id;
this.categoryLabel = options.categoryLabel; this.categoryLabel = options.categoryLabel;
this.userInfo = uni.getStorageSync('userInfo') || {}; this.userInfo = uni.getStorageSync("userInfo") || {};
if (this.shopId) { if (this.shopId) {
this.loadStoreData(); this.loadStoreData();
} else { } else {
@ -177,19 +179,24 @@ export default {
onShow() { onShow() {
// //
// //
const token = uni.getStorageSync('token'); const token = uni.getStorageSync("token");
const newUserInfo = uni.getStorageSync('userInfo') || {}; 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.userInfo = newUserInfo;
this.isLoadingAfterLogin = true; // this.isLoadingAfterLogin = true; //
// 401 // 401
uni.setStorageSync('justBackFromLogin', true); uni.setStorageSync("justBackFromLogin", true);
// 5 // 5
setTimeout(() => { setTimeout(() => {
uni.removeStorageSync('justBackFromLogin'); uni.removeStorageSync("justBackFromLogin");
}, 5000); }, 5000);
// token // token
@ -210,7 +217,6 @@ export default {
// //
this.hasCheckedLogin = true; this.hasCheckedLogin = true;
}, },
methods: { methods: {
// //
@ -297,7 +303,7 @@ export default {
// 100 // 100
formatPrice(price) { formatPrice(price) {
if (!price && price !== 0) { if (!price && price !== 0) {
return '0.00'; return "0.00";
} }
// //
const yuan = price / 100; const yuan = price / 100;
@ -323,83 +329,66 @@ export default {
}); });
return; return;
} }
//
// uni.showToast({
// title: "", },
// icon: "none", //
// }); async handlePay(){
// //
const reqsn = 'mini' + Date.now() + '' + Math.floor(Math.random() * 10000); const reqsn =
const randomstr = Math.floor(Math.random() * 10000000)+''; "mini" + Date.now() + "" + Math.floor(Math.random() * 10000);
const randomstr = Math.floor(Math.random() * 10000000) + "";
// //
// //
// STring , // STring ,
let params = { let params = {
"appid": "00390105", // appid appid: "00390105", // appid
"body": "body订单标题", // body: "body订单标题", //
"cusid": "56479107531MPMN", // cusid: "56479107531MPMN", //
"notify_url": "http://e989c692.natappfree.cc/admin-api/member/labor-union-coupon-purchase/tlNotice", // notify_url:
"orgid": "56479107392N35H", "http://e989c692.natappfree.cc/admin-api/member/labor-union-coupon-purchase/tlNotice", //
"paytype": "W06", orgid: "56479107392N35H",
"randomstr": randomstr, paytype: "W06",
"remark": "remark备注", randomstr: randomstr,
"reqsn": reqsn, remark: "remark备注",
"sign": "", reqsn: reqsn,
"signtype": "RSA", sign: "",
"trxamt": "1", signtype: "RSA",
"version": "12", trxamt: "1",
version: "12",
//"asinfo":"56479107392MP4J:01:0.01" //(, ) , ,01 , ,0.01 //"asinfo":"56479107392MP4J:01:0.01" //(, ) , ,01 , ,0.01
}; };
const sign = await getPaySign(params) const sign = await getPaySign(params);
console.log("测试返回的签名:"+sign) console.log("测试返回的签名:" + sign);
params["sign"] = sign params["sign"] = sign;
console.log(params) console.log(params);
// params = this.sortObjectByKey(params); // params = this.sortObjectByKey(params);
console.log(params) console.log(params);
// 使 navigateToMiniProgram // 使 navigateToMiniProgram
uni.navigateToMiniProgram({ uni.navigateToMiniProgram({
appId: 'wxef277996acc166c3', // appid appId: "wxef277996acc166c3", // appid
extraData: params, // extraData: params, //
success(res) { success(res) {
console.log('小程序跳转成功', res); console.log("小程序跳转成功", res);
}, },
fail(err) { fail(err) {
console.error('小程序跳转失败', err); console.error("小程序跳转失败", err);
// //
uni.showToast({ uni.showToast({
title: '跳转失败,请稍后重试', title: "跳转失败,请稍后重试",
icon: 'none' icon: "none",
}); });
}, },
complete() { 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; //----
} }
}, },
}; };
</script> </script>