This commit is contained in:
dzc committed 2025-12-10 18:06:07 +08:00
1 parent 4e9de1454e
commit da93fe0695
4 files changed
+107 -73

No files matched your search

+1 -1
View File
@@ -86,4 +86,4 @@
"vite-plugin-compression": "^0.5.1",
"vue-tsc": "^1.0.24"
}
}
}
+1 -1
View File
@@ -1014,4 +1014,4 @@
]
// #endif
}
}
}
+103 -70
View File
@@ -7,14 +7,8 @@
</navigator>
</template>
<template #right>
<navigator
url="/pages/profile/recharge-record"
open-type="navigate"
hover-class="navigator-hover"
>
<view
class="flex items-center rounded-full h-44rpx bg-color-theme py-1 px-2 text-black text-sm"
>
<navigator url="/pages/profile/recharge-record" open-type="navigate" hover-class="navigator-hover">
<view class="flex items-center rounded-full h-44rpx bg-color-theme py-1 px-2 text-black text-sm">
历史记录
</view>
</navigator>
@@ -23,8 +17,7 @@
<scroll-view style="height: calc(100dvh - 88px)" scroll-y>
<view
class="mx-4 p-4 rounded-2 bg-gradient-to-b from-#111 to-#222 b-4 b-solid b-t-#D29E52/60 b-l-#D29E52/40 b-r-#D29E52/40 b-b-#D29E52/20"
>
class="mx-4 p-4 rounded-2 bg-gradient-to-b from-#111 to-#222 b-4 b-solid b-t-#D29E52/60 b-l-#D29E52/40 b-r-#D29E52/40 b-b-#D29E52/20">
<view class="text-color-theme-dark font-900 font-italic text-xl mb-1">VIP</view>
<view class="flex-col-center mb-4">
<view class="text-gray mb-2 text-xl font-900 font-italic tracking-1.5">
@@ -35,13 +28,7 @@
</view>
<view class="flex-col-center gap-6 my-8 relative">
<uni-icons
class="absolute right-80 -top-10"
type="reload"
color="#D29E52"
size="24"
@click="getWallet"
/>
<uni-icons class="absolute right-80 -top-10" type="reload" color="#D29E52" size="24" @click="getWallet" />
<view>余额(宝石)</view>
<view class="font-bold text-xl">{{ fen2yuan(userWallet.balance) }}</view>
</view>
@@ -52,40 +39,28 @@
<view class="flex justify-between gap-3">
<view
class="flex-1 rounded-full flex-row-center px-4 py-2 b-3 b-solid b-#222 bg-#333 transition-all duration-200"
:style="{ borderColor: payMethod === 'alipay' ? '#D29E52' : '' }"
@click="payMethod = 'alipay'"
>
:style="{ borderColor: payMethod === 'alipay' ? '#D29E52' : '' }" @click="payMethod = 'alipay'">
<image class="size-40rpx mr-2" src="@/static/alipay.png" mode="aspectFill" />
<text>支付宝</text>
</view>
<view
class="flex-1 rounded-full flex-row-center px-4 py-2 b-3 b-solid b-#222 bg-#333 transition-all duration-200"
:style="{ borderColor: payMethod === 'wechat' ? '#D29E52' : '' }"
@click="payMethod = 'wechat'"
>
:style="{ borderColor: payMethod === 'wechat' ? '#D29E52' : '' }" @click="payMethod = 'wechat'">
<image class="size-40rpx mr-2" src="@/static/weixin.png" mode="aspectFill" />
<text>微信支付</text>
</view>
</view>
</view>
<view
v-if="rechargePackag.length"
v-for="item in rechargePackag"
:key="item.id"
class="mx-4 text-base"
>
<view v-if="rechargePackag.length" v-for="item in rechargePackag" :key="item.id" class="mx-4 text-base">
<view class="flex justify-between items-center my-4">
<view class="flex-row-center">
<image class="size-60rpx mr-2" src="@/static/diamond.png" mode="scaleToFill" />
<text>{{ fen2yuanSimple(item.bonusPrice) }}</text>
<text class="text-xs ml-2">({{ item.name }})</text>
</view>
<text
class="px-2 py-1 rounded-2 bg-color-theme-dark active:bg-color-theme"
@click="handleRecharge(item)"
>
<text class="px-2 py-1 rounded-2 bg-color-theme-dark active:bg-color-theme" @click="handleRecharge(item)">
¥{{ fen2yuanSimple(item.payPrice) }}
</text>
</view>
@@ -97,46 +72,104 @@
</template>
<script setup lang="ts">
import { computed, ref } from 'vue';
// @ts-ignore
import { fen2yuan, fen2yuanSimple } from '@/sheep/hooks/useGoods';
import RecentApi from '@/sheep/api/member/recent';
import { useMessage } from '@/uni_modules/wot-design-uni';
import { onLoad } from '@dcloudio/uni-app';
// @ts-ignore
import sheep from '@/sheep';
import { computed, ref } from 'vue';
// @ts-ignore
import { fen2yuan, fen2yuanSimple } from '@/sheep/hooks/useGoods';
import RecentApi from '@/sheep/api/member/recent';
import OrderApi from '@/sheep/api/trade/order'
const messageBox = useMessage();
import { useMessage } from '@/uni_modules/wot-design-uni';
import { onLoad } from '@dcloudio/uni-app';
// @ts-ignore
import sheep from '@/sheep';
const payMethod = ref<'alipay' | 'wechat'>('alipay'); // 支付方式:alipay / wechat
// 充值套餐列表
const rechargePackag = ref<{ id: number; name: string; payPrice: number; bonusPrice: number }[]>(
[],
);
const userWallet = computed(() => sheep.$store('user').userWallet);
const messageBox = useMessage();
onLoad(async () => {
const { data } = await RecentApi.getWalletRechargePackage();
rechargePackag.value = data ?? [];
});
const payMethodMap = [
{
title: "支付宝",
key: "alipay",
channelCode: "",
},
{
title: "微信支付",
key: "wechat",
channelCode: "wx_lite",
}
]
const getWallet = () => {
sheep.$store('user').getWallet();
};
const payMethod = ref<'alipay' | 'wechat'>('alipay'); // 支付方式:alipay / wechat
// 充值套餐列表
const rechargePackag = ref<{ id: number; name: string; payPrice: number; bonusPrice: number }[]>(
[],
);
const userWallet = computed(() => sheep.$store('user').userWallet);
const handleRecharge = (item: any) => {
if (!item.id) return uni.showToast({ title: '请选择会员类型', icon: 'none' });
messageBox
.confirm({
msg: `确认购买套餐 ${fen2yuanSimple(item.payPrice)} 元?`,
title: '提示',
})
.then(async () => {
const { code } = await RecentApi.walletRecharge({ packageId: item.id });
if (code !== 0) return uni.showToast({ title: '购买失败', icon: 'fail' });
uni.showToast({ title: '购买成功', icon: 'success' });
getWallet();
})
.catch(() => {});
};
onLoad(async () => {
const { data } = await RecentApi.getWalletRechargePackage();
rechargePackag.value = data ?? [];
});
const getWallet = () => {
sheep.$store('user').getWallet();
};
const handleRecharge = (item: any) => {
if (!item.id) return uni.showToast({ title: '请选择会员类型', icon: 'none' });
messageBox
.confirm({
msg: `确认购买套餐 ${fen2yuanSimple(item.payPrice)} 元?`,
title: '提示',
})
.then(async () => {
// 判断是否为微信
// #ifdef MP-WEIXIN
await wechatPay(item.id);
getWallet();
// #endif
// 跳转到微信
// #ifdef MP-WEIXIN
// #endif
})
.catch(() => { });
};
// 微信支付
// const wechatPay = async (packageId: any) => {
// try {
// const { code, data } = await RecentApi.walletRecharge({ packageId: packageId });
// console.log("data:", data);
// if (code !== 0) {
// uni.showToast({ title: '购买失败', icon: 'none' });
// throw new Error('购买失败')
// }
// // 开始支付
// const payMethodObj = payMethodMap.find((item) => item.key === payMethod.value)
// if (!payMethodObj) {
// uni.showToast({ title: '支付方式不存在', icon: 'none' });
// throw new Error('支付方式不存在')
// }
// if (!payMethodObj.channelCode) {
// uni.showToast({ title: `暂不支持${payMethodObj.title}支付`, icon: 'none' });
// throw new Error(`暂不支持${payMethodObj.title}支付`)
// }
// const _params: any = {
// channelCode: payMethodObj?.channelCode,
// channelExtras: {
// openid: "",
// },
// id: data,
// }
// const { code: payCode, data: payData } = await OrderApi.submitOrder(_params)
// console.log("payData:", payData);
// if (payCode !== 0) {
// uni.showToast({ title: '购买失败', icon: 'fail' });
// throw new Error('购买失败')
// }
// uni.showToast({ title: '购买成功', icon: 'success' });
// } catch (error) {
// console.error("|微信支付|,意外的错误error:", error);
// }
// }
</script>
+2 -1
View File
@@ -33,7 +33,8 @@
"src/**/*.tsx",
"src/**/*.vue",
"*.d.ts",
"src/components/**/*.vue"
"src/components/**/*.vue",
"src/sheep/api/pay/order.js"
],
"exclude": ["node_modules", "unpackage", "src/**/*.nvue"]
}