# Conflicts:
#	src/pages/profile/recharge.vue
This commit is contained in:
dzc committed 2025-12-10 18:07:29 +08:00
commit 056594e809
7 files changed
+224 -144

No files matched your search

-19
View File
@@ -1,7 +1,6 @@
<script>
import { onLaunch, onShow, onError } from '@dcloudio/uni-app';
import { ShoproInit } from './sheep';
import RecentApi from './sheep/api/member/recent';
// 与聊天相关的导入
import http from './common/request';
@@ -493,24 +492,6 @@
// });
// 加载Shopro底层依赖
ShoproInit();
// app启动时更新用户位置
uni.getLocation({
geocode: true,
success: (res) => {
const params = {
lat: String(res.latitude),
lon: String(res.longitude),
province: res.address?.province ?? '',
city: res.address?.city ?? '',
district: res.address?.district ?? '',
address: res.address?.street ?? '',
};
RecentApi.updateUserLocation(params);
},
fail: (err) => {
// uni.showToast({ title: '位置信息获取失败,请打开系统定位', icon: 'none' });
},
});
// #ifndef MP-WEIXIN
this.$mountStore();
+4
View File
@@ -89,6 +89,7 @@
// "group": "商城"
// }
// },
// #ifdef MP-WEIXIN
{
"path": "pages/wechat-tabbar/index",
"style": {
@@ -103,6 +104,8 @@
"navigationStyle": "custom"
}
},
// #endif
// #ifndef MP-WEIXIN
{
"path": "pages/tabbar/home",
"style": {
@@ -131,6 +134,7 @@
"navigationStyle": "custom"
}
}
// #endif
],
"subPackages": [
{
+4 -1
View File
@@ -14,7 +14,10 @@
</template>
<template #right>
<view class="flex items-center">
<view class="py-1 px-2 text-xs bg-color-theme-dark rounded-full mr-3">
<view
v-if="userDetail?.member?.memberId"
class="py-1 px-2 text-xs bg-color-theme-dark rounded-full mr-3"
>
{{ userDetail.member?.memberCity ? userDetail.member?.memberCity + ' · ' : '' }}
{{ userDetail.distance?.toFixed(2) }}km
</view>
+9 -6
View File
@@ -120,7 +120,9 @@
import { useMessage } from '@/uni_modules/wot-design-uni';
// @ts-ignore
import $store from '@/sheep/store';
// import PayOrderApi from '@/sheep/api/pay/order';
// @ts-ignore
import PayOrderApi from '@/sheep/api/pay/order';
// @ts-ignore
import sheep from '@/sheep';
const messageBox = useMessage();
@@ -174,12 +176,13 @@
const { code, data } = await RecentApi.memberOpenTypePay({
openTypeId: curOpenTypeId.value,
});
if (code !== 0) return uni.showToast({ title: '开通失败', icon: 'fail' });
uni.showToast({ title: '开通成功', icon: 'success' });
$store('user').getInfo();
if (code !== 0) return uni.showToast({ title: '创建订单失败', icon: 'fail' });
// const { data: a } = await PayOrderApi.getOrder(data, true);
sheep.$platform.pay('alipay', 'recharge', data);
// const { data } = await PayOrderApi.getOrder(data, true);
sheep.$platform.pay(payMethod.value, 'recharge', data.payOrderId);
// uni.showToast({ title: '开通成功', icon: 'success' });
$store('user').getInfo();
// setTimeout(() => {
// uni.navigateBack();
+74 -102
View File
@@ -7,8 +7,14 @@
</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>
@@ -17,7 +23,8 @@
<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">
@@ -28,7 +35,13 @@
</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>
@@ -39,28 +52,40 @@
<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>
@@ -72,104 +97,51 @@
</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 OrderApi from '@/sheep/api/trade/order'
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';
// @ts-ignore
import PayOrderApi from '@/sheep/api/pay/order';
import { useMessage } from '@/uni_modules/wot-design-uni';
import { onLoad } from '@dcloudio/uni-app';
// @ts-ignore
import sheep from '@/sheep';
const messageBox = useMessage();
const messageBox = useMessage();
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 payMethodMap = [
{
title: "支付宝",
key: "alipay",
channelCode: "",
},
{
title: "微信支付",
key: "wechat",
channelCode: "wx_lite",
}
]
onLoad(async () => {
const { data } = await RecentApi.getWalletRechargePackage();
rechargePackag.value = data ?? [];
});
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 getWallet = () => {
sheep.$store('user').getWallet();
};
onLoad(async () => {
const { data } = await RecentApi.getWalletRechargePackage();
rechargePackag.value = data ?? [];
});
const handleRecharge = (item: any) => {
if (!item.id) return uni.showToast({ title: '请选择会员类型', icon: 'none' });
messageBox
.confirm({
msg: `确认购买套餐 ${fen2yuanSimple(item.payPrice)} 元?`,
title: '提示',
})
.then(async () => {
const { code, data } = await RecentApi.walletRecharge({ packageId: item.id });
if (code !== 0) return uni.showToast({ title: '创建订单失败', icon: 'fail' });
// const { data } = await PayOrderApi.getOrder(data.payOrderId, true);
sheep.$platform.pay(payMethod.value, 'recharge', data.payOrderId);
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);
// }
// }
// uni.showToast({ title: '购买成功', icon: 'success' });
getWallet();
})
.catch(() => {});
};
</script>
+41 -11
View File
@@ -8,8 +8,8 @@
</template>
</wd-navbar>
<wd-cell-group>
<wd-cell title="手机号" :value="mobile" />
<wd-cell-group v-if="!loading">
<wd-cell title="手机号" :value="userInfo?.mobile" />
<wd-cell title="设置微信" is-link ellipsis to="/pages/profile/set-wechat" />
<wd-cell title="黑名单" is-link ellipsis to="/pages/profile/black-list" />
<wd-cell title="客服邮箱" value="1@1.com" is-link ellipsis />
@@ -21,13 +21,17 @@
size="20"
/>
</wd-cell>
<wd-cell title="首页隐身" value="首页隐身" ellipsis>
<wd-switch
v-model="params.homeHide"
inactive-color="#777"
@change="settingChange"
size="20"
/>
<wd-cell title="首页隐身" value="首页隐身" ellipsis title-width="120rpx">
<view class="flex justify-end">
<view class="text-18rpx mr-2">打开后用户将无法在首页列表中看到你</view>
<wd-switch
v-model="params.homeHide"
inactive-color="#777"
@change="settingChange"
:beforeChange="beforeChange"
size="20"
/>
</view>
</wd-cell>
<wd-cell title="隐私保护" value="隐私保护" ellipsis>
<wd-switch
@@ -49,6 +53,7 @@
</wd-cell-group>
<view
v-if="!loading"
class="mt-40rpx rounded-full bg-color-theme-dark text-base text-center py-2 mx-8 active:bg-color-theme"
@click="handleLogout"
>
@@ -61,7 +66,7 @@
<script setup lang="ts">
import RecentApi from '@/sheep/api/member/recent';
import { onLoad } from '@dcloudio/uni-app';
import { computed, reactive } from 'vue';
import { computed, reactive, ref } from 'vue';
import { useMessage } from '@/uni_modules/wot-design-uni';
// @ts-ignore
import sheep from '@/sheep';
@@ -74,21 +79,46 @@
privacySecure: true,
shortNote: true,
});
const mobile = computed(() => sheep.$store('user').userInfo?.mobile);
const loading = ref(false);
const userInfo = computed(() => sheep.$store('user').userInfo);
onLoad(async () => {
loading.value = true;
const { code, data } = await RecentApi.getSetting();
if (code !== 0) return;
params.isPush = data.isPush;
params.homeHide = data.homeHide;
params.privacySecure = data.privacySecure;
params.shortNote = data.shortNote;
loading.value = false;
});
const settingChange = async () => {
await RecentApi.updateSetting(params);
};
const beforeChange = ({ value, resolve }: any) => {
if (value && !userInfo.value.memberVip?.vip) {
resolve(false);
message
.confirm({
title: '获取VIP特权',
msg: '请先开通VIP会员',
confirmButtonText: '获取会员',
})
.then(() => {
uni.navigateTo({
url: '/pages/profile/apply-vip',
});
})
.catch(() => {});
return;
}
resolve(true);
};
// 退出登录
const handleLogout = () => {
message
+92 -5
View File
@@ -29,12 +29,34 @@
<navigator url="/pages/wechat-tabbar/index" open-type="navigate" hover-class="navigator-hover">
<image
class="size-120rpx fixed right-0 bottom-160"
class="size-120rpx fixed right-0 bottom-260"
src="@/static/invitation-activity.png"
mode="aspectFit"
/>
</navigator>
<!-- #ifdef H5 -->
<view
v-if="!isOpenGPS"
class="w-full h-100rpx bg-color-theme-dark fixed bottom-100 left-0 right-0 c-#222 flex items-center px-2"
@click="openSystemGPS"
>
<uni-icons type="location-filled" color="black" size="24" />
<text>点击开启位置权限,匹配您附近的那个Ta~</text>
</view>
<!-- #endif -->
<!-- #ifndef H5 -->
<view
v-if="!isOpenGPS"
class="w-full h-100rpx bg-color-theme-dark fixed bottom-0 left-0 right-0 c-#222 flex items-center px-2"
@click="openSystemGPS"
>
<uni-icons type="location-filled" color="black" size="24" />
<text>点击开启位置权限,匹配您附近的那个Ta~</text>
</view>
<!-- #endif -->
<s-auth-modal />
</template>
@@ -45,10 +67,11 @@
import ScrollUser from './components/scroll-user.vue';
// @ts-ignore
import sheep from '@/sheep';
import { onLoad } from '@dcloudio/uni-app';
import { onLoad, onShow } from '@dcloudio/uni-app';
const current = ref(0);
const segmentedItems = ref([]);
const isOpenGPS = ref(true);
const userCity = computed(() => sheep.$store('user').userCity);
onLoad(async () => {
@@ -57,15 +80,79 @@
if (data && data.length > 0) {
segmentedItems.value = data;
}
getLocation();
});
onShow(() => {
getLocation();
});
const getLocation = () => {
uni.getLocation({
geocode: true,
success: (res) => {
const params = {
lat: String(res.latitude),
lon: String(res.longitude),
province: res.address?.province ?? '',
city: res.address?.city ?? '',
district: res.address?.district ?? '',
address: res.address?.street ?? '',
};
RecentApi.updateUserLocation(params);
isOpenGPS.value = true;
},
fail: (err) => {
isOpenGPS.value = false;
},
});
};
const openSystemGPS = () => {
// #ifdef APP-PLUS || MP-WEIXIN
const system = uni.getSystemInfoSync();
if (system.platform === 'android') {
// 安卓手机授权之后还需打开定位服务功能GPS
const context: any = plus.android.importClass('android.content.Context');
const locationManager: any = plus.android.importClass('android.location.LocationManager');
const main: any = plus.android.runtimeMainActivity();
const mainSvr = main.getSystemService(context.LOCATION_SERVICE);
if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
const Intent: any = plus.android.importClass('android.content.Intent');
const Settings: any = plus.android.importClass('android.provider.Settings');
const intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
main.startActivity(intent); // 打开系统设置GPS服务页面
}
}
} else if (system.platform == 'ios') {
// ios打开对应的通知栏
uni.showModal({
title: '定位权限开启提醒',
content: '未开启定位,请前往设置!',
confirmText: '去设置',
success: function (res) {
if (res.confirm) {
var app = plus.ios.invoke('UIApplication', 'sharedApplication');
var setting = plus.ios.invoke('NSURL', 'URLWithString:', 'app-settings:');
plus.ios.invoke(app, 'openURL:', setting);
plus.ios.deleteObject(setting);
plus.ios.deleteObject(app);
}
},
});
}
// #endif
// #ifdef H5
uni.showToast({ title: '不支持', icon: 'none' });
// #endif
};
const goSelectAddress = () => {
uni.navigateTo({
url: '/pages/home/city',
events: {
changeCity: async () => {
// await refreshList();
},
changeCity: async () => {},
},
});
};