fix:修改小程序的条件编译

This commit is contained in:
ctw committed 2025-12-10 11:18:58 +08:00
1 parent 67e3d856ab
commit 4e9de1454e
4 files changed
+259 -219

No files matched your search

+4 -1
View File
@@ -21,6 +21,7 @@
groupMessagesBuffer: [],
};
},
// #ifndef MP-WEIXIN
methods: {
init() {
this.reconnecting = false;
@@ -483,7 +484,7 @@
// #endif
},
},
/** ↑↑↑ 以上为app启动聊天相关模块初始化,WebSocket链接,加载聊天消息,加载离线消息,加载群组消息,初始化聊天相关的全局状态仓库 */
// #endif
onLaunch() {
// 隐藏原生导航栏 使用自定义底部导航
@@ -511,6 +512,7 @@
},
});
// #ifndef MP-WEIXIN
this.$mountStore();
this.closeSplashscreen(1000); // 延迟1s,避免用户看到页面跳转
// 登录状态校验
@@ -525,6 +527,7 @@
// 跳转到登录页
uni.redirectTo({ url: '/pages/login/login' });
});
// #endif
},
onShow() {
// #ifdef APP-PLUS
+2 -1
View File
@@ -155,9 +155,10 @@
</view>
<moment-card
v-else-if="listData.length"
v-for="item in listData"
v-for="(item, index) in listData"
:data="item"
:show-chat="false"
:key="index"
/>
<wd-status-tip v-else image="content" tip="暂无内容" />
</scroll-list>
+7
View File
@@ -121,8 +121,15 @@
const { code } = await AuthUtil.smsRegister({ mobile: phone.value, code: smsCode.value });
if (code === 0) {
// #ifdef MP-WEIXIN
uni.reLaunch({ url: '/pages/wechat-tabbar/index' });
// #endif
// #ifndef MP-WEIXIN
uni.reLaunch({ url: '/pages/tabbar/home' });
getApp().$vm.init();
// #endif
return;
}
// 清理数据,防止缓存未失效
+246 -217
View File
@@ -1,267 +1,296 @@
<template>
<!-- 顶部导航 -->
<wd-config-provider theme="dark">
<wd-navbar title="福利中心" safeAreaInsetTop :bordered="false">
<template #left>
<navigator open-type="navigateBack" hover-class="navigator-hover">
<uni-icons type="back" size="30" color="#D29E52"></uni-icons>
</navigator>
</template>
</wd-navbar>
<!-- 用户信息 -->
<view class="mx-20rpx mt-30rpx bg-color-dark rounded-12rpx flex justify-between items-center px-6 py-4">
<view class="flex items-center">
<image :src="userInfo.avatar" class="size-50px rounded-full bg-#333 border border-amber border-solid"
mode="aspectFill" />
<view class="flex-1 ml-20rpx">
<view class="mb-1 text-base">{{ userInfo.nickname }}</view>
<view class="mb-2 text-xs text-#ffffff80 flex items-center">
<text>ID: {{ userInfo.id }}</text>
<image class="size-24rpx ml-4" :src="userGenderImageSrc" mode="scaleToFill" />
</view>
</view>
</view>
<view
class="text-color-theme-dark border-color-theme border-1px border-solid active_cl_bg-color-theme text-xs text-center px-2 py-8rpx rounded-full">
退出登录
</view>
<!-- 顶部导航 -->
<wd-config-provider theme="dark">
<wd-navbar title="福利中心" safeAreaInsetTop :bordered="false">
<template #left>
<navigator open-type="navigateBack" hover-class="navigator-hover">
<uni-icons type="back" size="30" color="#D29E52"></uni-icons>
</navigator>
</template>
</wd-navbar>
<!-- 用户信息 -->
<view
class="mx-20rpx mt-30rpx bg-color-dark rounded-12rpx flex justify-between items-center px-6 py-4"
>
<view class="flex items-center">
<image
:src="userInfo.avatar"
class="size-50px rounded-full bg-#333 border border-amber border-solid"
mode="aspectFill"
/>
<view class="flex-1 ml-20rpx">
<view class="mb-1 text-base">{{ userInfo.nickname }}</view>
<view class="mb-2 text-xs text-#ffffff80 flex items-center">
<text>ID: {{ userInfo.id }}</text>
<image class="size-24rpx ml-4" :src="userGenderImageSrc" mode="scaleToFill" />
</view>
</view>
<!-- 提现相关 -->
<view class="mx-20rpx mt-30rpx bg-color-dark rounded-12rpx px-6 py-4">
<view class="flex items-center justify-center">
<view class="flex-1 flex-col justify-center items-center" v-for="(v, i) in state.txTab" :key="i"
@tap="doTxItem(v)">
<text class="text-color-theme text-2xl"> {{ v.value }}</text>
<text class="mt-10rpx">{{ v.title }}</text>
</view>
</view>
<view class="flex justify-center items-center mt-30rpx">
<text
class="bg-color-theme-dark active_cl_bg-color-theme text-base text-center px-80rpx py-12rpx rounded-full">
立即提现
</text>
</view>
</view>
<view
class="text-color-theme-dark border-color-theme border-1px border-solid active_cl_bg-color-theme text-xs text-center px-2 py-8rpx rounded-full"
>
退出登录
</view>
</view>
<!-- 提现相关 -->
<view class="mx-20rpx mt-30rpx bg-color-dark rounded-12rpx px-6 py-4">
<view class="flex items-center justify-center">
<view
class="flex-1 flex-col justify-center items-center"
v-for="(v, i) in state.txTab"
:key="i"
@tap="doTxItem(v)"
>
<text class="text-color-theme text-2xl"> {{ v.value }}</text>
<text class="mt-10rpx">{{ v.title }}</text>
</view>
<!-- tab -->
<view class="mx-20rpx mt-30rpx bg-color-dark rounded-12rpx py-4 flex justify-evenly items-center">
<view class="flex-1 flex-col justify-center items-center" v-for="(v, i) in data.menuTab" :key="i"
@tap="doItem(v)">
<div class="size-100rpx flex justify-center items-center rounded-full"
:style="{ backgroundColor: v.bgColor }">
<text class="iconfont text-2xl" :class="v.icon" />
</div>
<text class="mt-10rpx">{{ v.title }}</text>
</view>
</view>
<view class="flex justify-center items-center mt-30rpx">
<text
class="bg-color-theme-dark active_cl_bg-color-theme text-base text-center px-80rpx py-12rpx rounded-full"
>
立即提现
</text>
</view>
</view>
<!-- tab -->
<view
class="mx-20rpx mt-30rpx bg-color-dark rounded-12rpx py-4 flex justify-evenly items-center"
>
<view
class="flex-1 flex-col justify-center items-center"
v-for="(v, i) in data.menuTab"
:key="i"
@tap="doItem(v)"
>
<div
class="size-100rpx flex justify-center items-center rounded-full"
:style="{ backgroundColor: v.bgColor }"
>
<text class="iconfont text-2xl" :class="v.icon" />
</div>
<text class="mt-10rpx">{{ v.title }}</text>
</view>
</view>
<!-- 规则 -->
<view class="mx-20rpx mt-30rpx bg-color-dark rounded-12rpx px-6 py-4">
<view class="text-lg">邀请奖励规则</view>
<view class="mt-30rpx">
<view
class="card-thin flex items-start px-16rpx py-12rpx mb-15rpx"
v-for="(v, i) in state.rule"
:key="i"
>
<view
class="size-40rpx flex justify-center items-center bg-color-theme-dark rounded-8rpx"
>
<text class="text-base">{{ i + 1 }}</text>
</view>
<text class="ml-20rpx text-xs">{{ v.title }}</text>
</view>
<!-- 规则 -->
<view class="mx-20rpx mt-30rpx bg-color-dark rounded-12rpx px-6 py-4">
<view class="text-lg">邀请奖励规则</view>
<view class="mt-30rpx">
<view class="card-thin flex items-start px-16rpx py-12rpx mb-15rpx" v-for="(v, i) in state.rule">
<view class="size-40rpx flex justify-center items-center bg-color-theme-dark rounded-8rpx">
<text class="text-base">{{ i + 1 }}</text>
</view>
<text class="ml-20rpx text-xs">{{ v.title }}</text>
</view>
</view>
</view>
</view>
<!-- 海报 -->
<view class="mx-20rpx mt-30rpx bg-color-dark rounded-12rpx px-6 py-4">
<view class="text-lg">我的邀请海报</view>
<image class="mt-30rpx" :src="state.posterPic" mode="widthFix" />
<view class="mt-30rpx flex justify-between items-center text-xs">
<view
class="flex-1 text-center px-2 py-8rpx border-1px border-solid rounded-full border-color-theme active_cl_bg-color-theme"
@tap="copyLink"
>
复制链接
</view>
<!-- 海报 -->
<view class="mx-20rpx mt-30rpx bg-color-dark rounded-12rpx px-6 py-4">
<view class="text-lg">我的邀请海报</view>
<image class="mt-30rpx" :src="state.posterPic" mode="widthFix" />
<view class="mt-30rpx flex justify-between items-center text-xs">
<view
class="flex-1 text-center px-2 py-8rpx border-1px border-solid rounded-full border-color-theme active_cl_bg-color-theme"
@tap="copyLink">
复制链接
</view>
<view class="w-30rpx" />
<view
class="flex-1 text-center px-2 py-8rpx border-1px border-solid rounded-full border-color-theme-dark bg-color-theme-dark active_cl_bg-color-theme"
@tap="savePoster">
保存海报
</view>
</view>
<view class="w-30rpx" />
<view
class="flex-1 text-center px-2 py-8rpx border-1px border-solid rounded-full border-color-theme-dark bg-color-theme-dark active_cl_bg-color-theme"
@tap="savePoster"
>
保存海报
</view>
<view class="h-30rpx" />
</wd-config-provider>
</view>
</view>
<view class="h-30rpx" />
</wd-config-provider>
</template>
<script setup>
import { computed, reactive, ref } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { computed, reactive, ref } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import { fen2yuan } from '@/sheep/hooks/useGoods';
import BrokerageApi from '@/sheep/api/trade/brokerage';
import TradeConfigApi from '@/sheep/api/trade/config.js'
import SocialApi from "@/sheep/api/member/social"
import sheep from '@/sheep';
import { fen2yuan } from '@/sheep/hooks/useGoods';
import BrokerageApi from '@/sheep/api/trade/brokerage';
import TradeConfigApi from '@/sheep/api/trade/config.js';
import SocialApi from '@/sheep/api/member/social';
const userInfo = computed(() => sheep.$store('user').userInfo);
const userInfo = computed(() => sheep.$store('user').userInfo);
const data = {
const data = {
menuTab: [
{
title: '礼物奖励',
icon: 'icon-liwu',
bgColor: '#fad34a',
path: "/pages/wechat/pages/gift/index",
},
{
title: '钻石充值',
icon: 'icon-lv_zuanshi_fill',
bgColor: '#ff5081',
path: "/pages/profile/recharge",
},
{
title: '会员中心',
icon: 'icon-huiyuan',
bgColor: '#ebc26a',
path: "/pages/profile/apply-vip",
},
{
title: '邀请好友',
icon: 'icon-tianjiahaoyou',
bgColor: '#a4e55a',
path: "",
},
{
title: '礼物奖励',
icon: 'icon-liwu',
bgColor: '#fad34a',
path: '/pages/wechat/pages/gift/index',
},
{
title: '钻石充值',
icon: 'icon-lv_zuanshi_fill',
bgColor: '#ff5081',
path: '/pages/profile/recharge',
},
{
title: '会员中心',
icon: 'icon-huiyuan',
bgColor: '#ebc26a',
path: '/pages/profile/apply-vip',
},
{
title: '邀请好友',
icon: 'icon-tianjiahaoyou',
bgColor: '#a4e55a',
path: '',
},
],
}
};
const state = reactive({
const state = reactive({
txTab: [
{
title: '累计收益',
value: '0',
path: "/pages/wechat/pages/gift/history",
},
{
title: '可提现',
value: '0',
path: "/pages/wechat/pages/gift/index",
},
{
title: '成功邀请',
value: '0',
path: "/pages/wechat/pages/inviter/index",
},
{
title: '累计收益',
value: '0',
path: '/pages/wechat/pages/gift/history',
},
{
title: '可提现',
value: '0',
path: '/pages/wechat/pages/gift/index',
},
{
title: '成功邀请',
value: '0',
path: '/pages/wechat/pages/inviter/index',
},
],
rule: [
{
title: '通过链接/二维码邀请用户首次充值,可获得**%现金奖励',
},
{
title: '邀请奖励满***元可提现,3个月工作日内到账',
},
{
title: '通过链接/二维码邀请用户首次充值,可获得**%现金奖励',
},
{
title: '邀请奖励满***元可提现,3个月工作日内到账',
},
],
summary: {},
posterPic: "",
posterUrl: "",
});
posterPic: '',
posterUrl: '',
});
onShow(async () => {
onShow(async () => {
// await getTradeConfig()
// await getBrokerageUserSummary()
// getMiniProgramPoster()
})
});
// 获取分销配置
const getTradeConfig = async () => {
// 获取分销配置
const getTradeConfig = async () => {
try {
let { code, data } = await TradeConfigApi.getTradeConfig();
if (code != 0) {
throw new Error()
}
if (data.brokerageWithdrawMinPrice !== undefined) {
state.rule[1].title = `邀请奖励满${fen2yuan(data.brokerageWithdrawMinPrice)}元可提现,3个月工作日内到账`
}
if (data.brokerageFirstPercent !== undefined) {
state.rule[0].title = `通过链接/二维码邀请用户首次充值,可获得${data.brokerageFirstPercent || 50}%现金奖励`
}
let { code, data } = await TradeConfigApi.getTradeConfig();
if (code != 0) {
throw new Error();
}
if (data.brokerageWithdrawMinPrice !== undefined) {
state.rule[1].title = `邀请奖励满${fen2yuan(
data.brokerageWithdrawMinPrice,
)}元可提现,3个月工作日内到账`;
}
if (data.brokerageFirstPercent !== undefined) {
state.rule[0].title = `通过链接/二维码邀请用户首次充值,可获得${
data.brokerageFirstPercent || 50
}%现金奖励`;
}
} catch (error) {
console.error("|获取分销配置|,意外的错误:", error);
console.error('|获取分销配置|,意外的错误:', error);
}
}
};
// 获取收益统计
const getBrokerageUserSummary = async () => {
// 获取收益统计
const getBrokerageUserSummary = async () => {
let { code, data } = await BrokerageApi.getBrokerageUserSummary();
if (code === 0) {
state.summary = data || {}
// 累计收益
if (state.summary.withdrawPrice !== undefined) {
state.txTab[0].value = fen2yuan(state.summary.withdrawPrice)
}
// 可提现
if (state.summary.brokeragePrice !== undefined) {
state.txTab[1].value = fen2yuan(state.summary.brokeragePrice)
}
// 成功邀请用户
const firstBrokerageUserCount = state.summary.firstBrokerageUserCount ?? 0;
const secondBrokerageUserCount = state.summary.secondBrokerageUserCount ?? 0;
state.txTab[2].value = firstBrokerageUserCount + secondBrokerageUserCount
state.summary = data || {};
// 累计收益
if (state.summary.withdrawPrice !== undefined) {
state.txTab[0].value = fen2yuan(state.summary.withdrawPrice);
}
// 可提现
if (state.summary.brokeragePrice !== undefined) {
state.txTab[1].value = fen2yuan(state.summary.brokeragePrice);
}
// 成功邀请用户
const firstBrokerageUserCount = state.summary.firstBrokerageUserCount ?? 0;
const secondBrokerageUserCount = state.summary.secondBrokerageUserCount ?? 0;
state.txTab[2].value = firstBrokerageUserCount + secondBrokerageUserCount;
}
}
};
// 获取分销海报
const getMiniProgramPoster = async () => {
// 获取分销海报
const getMiniProgramPoster = async () => {
try {
let { code, data } = await BrokerageApi.getBrokerageCode();
if (code != 0) throw new Error()
state.posterPic = data?.posterPic || ''
state.posterUrl = data?.url || ''
let { code, data } = await BrokerageApi.getBrokerageCode();
if (code != 0) throw new Error();
state.posterPic = data?.posterPic || '';
state.posterUrl = data?.url || '';
} catch (error) {
console.error("|获取分销海报|,意外的错误:", error);
console.error('|获取分销海报|,意外的错误:', error);
}
}
};
// 复制海报
const copyLink = () => {
// 复制海报
const copyLink = () => {
uni.setClipboardData({
data: state.posterUrl,
success: () => {
uni.showToast({ title: '复制成功', icon: 'success' });
},
fail: (err) => {
uni.showToast({ title: '复制失败', icon: 'none' });
console.error("|复制链接|,意外的错误:", err);
}
data: state.posterUrl,
success: () => {
uni.showToast({ title: '复制成功', icon: 'success' });
},
fail: (err) => {
uni.showToast({ title: '复制失败', icon: 'none' });
console.error('|复制链接|,意外的错误:', err);
},
});
}
};
// 保存海报
const savePoster = () => {
// 保存海报
const savePoster = () => {
if (!state.posterPic) {
uni.showToast({ title: '海报不存在', icon: 'none' });
return;
uni.showToast({ title: '海报不存在', icon: 'none' });
return;
}
uni.saveImageToPhotosAlbum({
filePath: state.posterPic,
success: () => {
uni.showToast({ title: '保存成功', icon: 'success' });
},
fail: (err) => {
uni.showToast({ title: '保存失败', icon: 'none' });
console.error("|保存海报|,意外的错误:", err);
}
filePath: state.posterPic,
success: () => {
uni.showToast({ title: '保存成功', icon: 'success' });
},
fail: (err) => {
uni.showToast({ title: '保存失败', icon: 'none' });
console.error('|保存海报|,意外的错误:', err);
},
});
}
};
const doTxItem = (item) => {
const doTxItem = (item) => {
if (item.path) {
uni.navigateTo({
url: item.path,
});
uni.navigateTo({
url: item.path,
});
}
}
};
const doItem = (item) => {
const doItem = (item) => {
if (item.path) {
uni.navigateTo({
url: item.path,
});
uni.navigateTo({
url: item.path,
});
}
}
</script>
};
</script>