Compare commits

...

23 Commits

Author SHA1 Message Date
YunaiV b6b0ca3dbd fix: 修复 H5 公众号微信 JSSDK 签名 URL 错用 location.origin 导致 wx.config invalid signature,改用 location.href.split('#')[0] 2026-05-02 23:20:49 +08:00
YunaiV 0d0017eac7 Merge branch 'master' of https://github.com/yudaocode/yudao-mall-uniapp 2026-04-18 13:38:46 +08:00
YunaiV 5c2377b482 (〃'▽'〃)_v2026_03_发布:新增 MES 制造执行系统,IoT 接入 Modbus 协议 2026-04-18 13:38:25 +08:00
YunaiV 1346f8bf3b fix: 修复团队列表分页重置和订单数字段显示问题 2026-03-08 10:02:59 +08:00
芋道源码 d18d67dd62
Merge pull request #33 from greyfilm/master
fix:修复分销提现页银行名称存储问题,兼容管理端回显
2026-02-07 12:41:22 +08:00
greyfilm f2bfb2d79b fix:修复分销提现页银行名称存储问题,兼容管理端回显 2026-02-01 17:49:49 +08:00
YunaiV 3c3ee616fd (〃'▽'〃) v2026.01 发布:大大大大完善 vben5 的 antd、vben 版本的功能,新增 IoT 各种接入协议 2026-01-29 23:47:10 +08:00
YunaiV beca206592 feat:初始化默认选中规格中的第一个(代码优化) 2026-01-18 12:10:14 +08:00
芋道源码 becfc58eca
!175 feat: 初始化默认选中规格中的第一个
Merge pull request !175 from steven/feat-新增购买商品默认选中规格
2026-01-18 04:08:02 +00:00
沈文杰 d2f29362a0 feat: 初始化默认选中规格中的第一个 2026-01-14 13:13:20 +08:00
YunaiV a5aae8480b (〃'▽'〃) v2025.12 发布:极大极大完善 vben5 的 antd、vben 版本的功能,新增 admin uniapp vue3 版本 2025-12-28 11:10:53 +08:00
YunaiV 1d2e9bcdb5 review:tabbar不能传参问题 2025-12-25 23:02:50 +08:00
芋道源码 1cadcaac5e
!172 fix:修复 tabbar不能传参问题
Merge pull request !172 from steven/hotfix_tabbar_not_allow_query
2025-12-25 15:00:01 +00:00
8614095 18802f863c fix:修复 tabbar不能传参问题 2025-12-25 21:09:44 +08:00
YunaiV a6a5117b0c fix:richtext-block 的高度问题 2025-12-13 12:24:03 +08:00
芋道源码 aa83e4aa51
!171 fix(app): iOS网络权限处理逻辑从app.vue迁移到首页page/index/index
Merge pull request !171 from wuKong/fix(app)-iOS网络权限检查
2025-12-09 01:15:49 +00:00
wuKong ecf74aa8f8 feat(app): 调整iOS网络权限初始化逻辑
- 将iOS网络权限检查从app.vue迁移至当前页面
- 减轻app.vue初始加载负担
- 添加注释说明首页需自行迁移代码
- 优化uni-app平台网络状态处理逻辑
2025-12-08 19:01:53 +08:00
wuKong f95432918c fix(app): iOS网络权限处理逻辑从app.vue迁移到首页page/index/index
- 在首页添加 onShow 生命周期钩子
- 检测iOS设备首次网络授权情况
- 授权通过后重新初始化应用状态
- 移除App.vue中重复的网络检测逻辑
- 优化页面滚动和下拉刷新功能
- 增强平台兼容性处理
2025-12-08 18:56:03 +08:00
wuKong ee25d77d58 feat(app): 初始化逻辑中增加iOS网络权限检查
- 在onShow生命周期中添加异步处理
- 引入sheep对象用于平台判断和网络检测
- iOS平台下网络授权后重新加载应用初始化
- 优化应用启动时的网络状态处理逻辑
2025-12-08 18:45:48 +08:00
YunaiV 5724bc61b0 fix:“登录中”文案错误 2025-11-29 09:35:16 +08:00
芋道源码 8e6ed9d63b
!170 支付宝小程序适配
Merge pull request !170 from 云扬四海/master-alipaymini
2025-11-29 01:30:05 +00:00
yunlongn e6e24f9935 支付宝小程序适配 2025-11-27 11:10:42 +08:00
yunlongn 9c509c6f15 支付宝小程序适配 2025-11-27 10:51:29 +08:00
30 changed files with 421 additions and 44 deletions

View File

@ -2,7 +2,7 @@
"name": "芋道商城",
"appid": "__UNI__460BC4C",
"description": "基于 uni-app + Vue3 技术驱动的在线商城系统,内含诸多功能与丰富的活动,期待您的使用和反馈。",
"versionName": "2025.11",
"versionName": "2026.03",
"versionCode": "183",
"transformPx": false,
"app-plus": {
@ -185,7 +185,9 @@
"requiredPrivateInfos": ["chooseAddress"]
},
"mp-alipay": {
"usingComponents": true
"usingComponents": true,
"styleIsolation": "shared",
"mergeVirtualHostAttributes": true
},
"mp-baidu": {
"usingComponents": true

9
mini.project.json Normal file
View File

@ -0,0 +1,9 @@
{
"format": 2,
"compileOptions": {
"component2": true,
"enableNodeModuleBabelTransform": true,
"transpile": {},
"globalObjectMode": "enable"
}
}

View File

@ -2,7 +2,7 @@
"id": "shopro",
"name": "shopro",
"displayName": "芋道商城",
"version": "2025.11",
"version": "2026.03",
"description": "芋道商城一套代码同时发行到iOS、Android、H5、微信小程序多个平台请使用手机扫码快速体验强大功能",
"scripts": {
"prettier": "prettier --write \"{pages,sheep}/**/*.{js,json,tsx,css,less,scss,vue,html,md}\""

View File

@ -675,7 +675,15 @@
"navigationBarTitleText": "芋道商城",
"navigationBarBackgroundColor": "#FFFFFF",
"backgroundColor": "#FFFFFF",
"navigationStyle": "custom"
"navigationStyle": "custom",
"mp-alipay": {
"titleImage": "",
"gestureBack": "YES",
"allowsBounceVertical": "NO",
"transparentTitle": "always",
"navigationStyle": "custom",
"titlePenetrate": "YES"
}
},
"tabBar": {
"list": [{

View File

@ -163,7 +163,7 @@
<text class="num font-color">{{ item.brokerageUserCount || 0 }} </text>
</view>
<view>
<text class="num">{{ item.orderCount || 0 }}</text
<text class="num">{{ item.brokerageOrderCount || 0 }}</text
></view
>
<view>
@ -320,6 +320,7 @@
function setType(e) {
state.pagination.list = [];
state.pagination.pageNo = 1;
state.level = e + '';
getTeamList();
}

View File

@ -115,7 +115,7 @@
>
<uni-easyinput
:inputBorder="false"
:value="state.accountInfo.bankName"
:value="bankNameLabel"
placeholder="请选择银行"
suffixIcon="right"
disabled
@ -164,7 +164,7 @@
</template>
<script setup>
import { onBeforeMount, reactive } from 'vue';
import { onBeforeMount, reactive, computed } from 'vue';
import sheep from '@/sheep';
import accountTypeSelect from './components/account-type-select.vue';
import { fen2yuan } from '@/sheep/hooks/useGoods';
@ -199,6 +199,14 @@
bankListSelectedIndex: '', // bankList index
});
const bankNameLabel = computed(() => {
if (!state.accountInfo.bankName || !state.bankList || state.bankList.length === 0) {
return '';
}
const item = state.bankList.find((it) => it.value === state.accountInfo.bankName);
return item ? item.label : '';
});
//
const onAccountSelect = (e) => {
state.accountSelect = e;
@ -300,7 +308,8 @@
function bankChange(e) {
const value = e.detail.value;
state.bankListSelectedIndex = value;
state.accountInfo.bankName = state.bankList[value].label;
const item = state.bankList[value];
state.accountInfo.bankName = item ? item.value : undefined;
}
onBeforeMount(() => {

View File

@ -3,7 +3,10 @@
<su-fixed alway :bgStyles="{ background: '#fff' }" :val="0" noNav opacity :placeholder="false">
<su-status-bar />
<view
class="ui-bar ss-flex ss-col-center ss-row-between ss-p-x-20"
class="ui-bar ss-flex ss-col-center ss-row-between"
:class="[{
'ss-p-x-20': sheep.$platform.provider !== 'alipay'
}]"
:style="[{ height: sys_navBar - sys_statusBar + 'px' }]"
>
<!-- -->

View File

@ -11,7 +11,10 @@
>
<su-status-bar />
<view
class="ui-bar ss-flex ss-col-center ss-row-between ss-p-x-20"
class="ui-bar ss-flex ss-col-center ss-row-between"
:class="[{
'ss-p-x-20': sheep.$platform.provider !== 'alipay'
}]"
:style="[{ height: sys_navBar - sys_statusBar + 'px' }]"
>
<!-- -->

View File

@ -245,7 +245,7 @@
isDay: true,
};
const isLogin = computed(() => sheep.$store('user').isLogin);
const state = reactive({
let state = reactive({
goodsId: 0,
skeletonLoading: true, // SPU
goodsInfo: {}, // SPU

View File

@ -60,7 +60,7 @@
import sheep from '@/sheep';
import CategoryApi from '@/sheep/api/product/category';
import SpuApi from '@/sheep/api/product/spu';
import { onLoad } from '@dcloudio/uni-app';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { computed, reactive } from 'vue';
import { concat } from 'lodash-es';
import { handleTree } from '@/sheep/helper/utils';
@ -130,14 +130,21 @@
state.pagination.pageNo++;
getGoodsList();
}
onLoad(async (params) => {
await getList();
function initMenuIndex() {
// TODO @AI params.id
const appStore = sheep.$store('app');
// tabbar
const tabbarParams = appStore.paramsForTabbar || {};
const id = tabbarParams.id;
appStore.clearParamsForTabbar(); // 使
//
const foundCategory = state.categoryList.find((category) => category.id === Number(params.id));
const foundCategory = state.categoryList.find((category) => category.id === Number(id));
// onMenu onMenu(0)
onMenu(foundCategory ? state.categoryList.indexOf(foundCategory) : 0);
}
onShow(async () => {
await getList();
initMenuIndex();
});
function handleScrollToLower() {

View File

@ -22,7 +22,7 @@
<script setup>
import { computed } from 'vue';
import { onLoad, onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app';
import { onLoad, onShow, onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import $share from '@/sheep/platform/share';
// tabBar
@ -79,6 +79,20 @@
}
});
onShow(async() => {
// #ifdef APP-PLUS
// ios
// uni.onNetworkStatusChangeuni.offNetworkStatusChange
// app.vue
//
if (sheep.$platform.os === 'ios') {
if (await sheep.$platform.checkNetwork()) {
await sheep.$store('app').init();
}
}
// #endif
});
//
onPullDownRefresh(() => {
sheep.$store('app').init();

View File

@ -75,7 +75,7 @@ const AuthUtil = {
},
custom: {
showSuccess: true,
loadingMsg: '登中',
loadingMsg: '登中',
},
});
},
@ -91,7 +91,7 @@ const AuthUtil = {
},
custom: {
showSuccess: true,
loadingMsg: '登中',
loadingMsg: '登中',
},
});
},
@ -107,7 +107,7 @@ const AuthUtil = {
},
custom: {
showSuccess: true,
loadingMsg: '登中',
loadingMsg: '登中',
successMsg: '登录成功',
},
});

View File

@ -11,7 +11,7 @@ export default {
data,
custom: {
showSuccess: true,
loadingMsg: '登中',
loadingMsg: '登中',
},
}),
},

View File

@ -72,6 +72,18 @@
:src="sheep.$url.static('/static/img/shop/platform/apple.png')"
/>
</button>
<!-- 7.4 支付宝小程序登录 -->
<button
v-if="sheep.$platform.name === 'alipayMiniProgram'"
@tap="thirdLogin('alipay')"
class="ss-reset-button auto-login-btn"
>
<image
class="auto-login-img"
:src="sheep.$url.static('/static/img/shop/pay/alipay.png')"
/>
</button>
</view>
<!-- 用户协议的勾选 -->
@ -85,7 +97,7 @@
<view class="agreement-options-container">
<!-- 同意选项 -->
<view class="agreement-option ss-m-b-20">
<label class="radio ss-flex ss-col-center" @tap="onAgree">
<view class="radio ss-flex ss-col-center" @tap="onAgree">
<radio
:checked="state.protocol === true"
color="var(--ui-BG-Main)"
@ -98,12 +110,12 @@
<view class="agreement-text"></view>
<view class="tcp-text" @tap.stop="onProtocol('隐私协议')"> 隐私协议 </view>
</view>
</label>
</view>
</view>
<!-- 拒绝选项 -->
<view class="agreement-option">
<label class="radio ss-flex ss-col-center" @tap="onRefuse">
<view class="radio ss-flex ss-col-center" @tap="onRefuse">
<radio
:checked="state.protocol === false"
color="#ff4d4f"
@ -116,7 +128,7 @@
<view class="agreement-text"></view>
<view class="tcp-text" @tap.stop="onProtocol('隐私协议')"> 隐私协议 </view>
</view>
</label>
</view>
</view>
</view>
</view>

View File

@ -214,6 +214,11 @@
// 使 onMounted 使 onShow
onMounted(()=>{
// #ifdef MP-ALIPAY
uni.setNavigationBarTitle({
title: "",
});
// #endif
if (!isEmpty(shareInfo.value)) {
sheep.$platform.share.updateShareInfo(shareInfo.value);
}

View File

@ -2,8 +2,8 @@
<template>
<view :style="[bgStyle, { marginLeft: `${data.space}px` }]">
<uni-grid :showBorder="Boolean(data.border)" :column="data.column">
<uni-grid-item v-for="(item, index) in data.list" :key="index" @tap="sheep.$router.go(item.url)">
<view class="grid-item-box ss-flex ss-flex-col ss-row-center ss-col-center">
<uni-grid-item v-for="(item, index) in data.list" :key="index" >
<view class="grid-item-box ss-flex ss-flex-col ss-row-center ss-col-center" @tap="sheep.$router.go(item.url)">
<view class="img-box">
<view class="tag-box" v-if="item.badge.show"
:style="[{ background: item.badge.bgColor, color: item.badge.textColor }]">

View File

@ -40,7 +40,9 @@
});
</script>
<style lang="scss" scoped>
// https://t.zsxq.com/8v0JG richtext height
.richtext {
line-height: 0;
width: 100%;
height: auto;
}
</style>

View File

@ -109,7 +109,7 @@
<script setup>
import { computed, reactive, watch } from 'vue';
import sheep from '@/sheep';
import { convertProductPropertyList, fen2yuan } from '@/sheep/hooks/useGoods';
import { convertProductPropertyList, initDefaultSelect, fen2yuan } from '@/sheep/hooks/useGoods';
const headerBg = sheep.$url.css('/static/img/shop/goods/groupon-btn-long.png');
const emits = defineEmits(['change', 'addCart', 'buy', 'close', 'ladder']);
@ -315,7 +315,8 @@
}
changeDisabled(false);
// TODO 12
//
initDefaultSelect(propertyList, onSelectSku);
</script>
<style lang="scss" scoped>

View File

@ -95,7 +95,12 @@
<script setup>
import { computed, reactive, watch } from 'vue';
import sheep from '@/sheep';
import { formatStock, convertProductPropertyList, fen2yuan } from '@/sheep/hooks/useGoods';
import {
formatStock,
convertProductPropertyList,
fen2yuan,
initDefaultSelect,
} from '@/sheep/hooks/useGoods';
const emits = defineEmits(['change', 'addCart', 'buy', 'close']);
const props = defineProps({
@ -305,7 +310,8 @@
}
changeDisabled(false);
// TODO 12
//
initDefaultSelect(propertyList, onSelectSku);
</script>
<style lang="scss" scoped>

View File

@ -20,7 +20,7 @@
:badgeStyle="tabbar.badgeStyle"
:isCenter="getTabbarCenter(index)"
:centerImage="sheep.$url.cdn(item.iconUrl)"
@tap="sheep.$router.go(item.url)"
@click="sheep.$router.go(item.url)"
>
<template v-slot:active-icon>
<image class="u-page__item__slot-icon" :src="sheep.$url.cdn(item.activeIconUrl)"></image>

View File

@ -497,3 +497,18 @@ export function getRewardActivityRuleItemDescriptions(activity) {
});
return result;
}
/** 单规格,要默认选中 */
export function initDefaultSelect(propertyList, onSelectSku) {
if (propertyList.length === 0) {
return;
}
// 遍历每一个属性
for (const property of propertyList) {
const firstValue = (property.values || [])[0];
// 不是禁用直接选中
if (firstValue && !firstValue.disabled) {
onSelectSku(property.id, firstValue.id);
}
}
}

View File

@ -30,8 +30,9 @@ export default {
}
// 调用后端接口,获得 JSSDK 初始化所需的签名
const url = location.origin;
const { code, data } = await AuthUtil.createWeixinMpJsapiSignature(url);
// 微信要求签名 URL 与当前页面去掉 hash 后完全一致;不能直接用 location.origin会丢子路径与 query
const signUrl = location.href.split('#')[0];
const { code, data } = await AuthUtil.createWeixinMpJsapiSignature(signUrl);
if (code === 0) {
jweixin.config({
debug: false,
@ -57,7 +58,11 @@ export default {
configSuccess = true;
jweixin.error((err) => {
configSuccess = false;
console.error('微信 JSSDK 初始化失败', err);
console.error('[wx-jssdk] config error', err, {
href: location.href,
signUrl,
data,
});
$helper.toast('微信JSSDK:' + err.errMsg);
});
jweixin.ready(() => {

View File

@ -14,6 +14,7 @@ import { isEmpty } from 'lodash-es';
import { isWxBrowser } from '@/sheep/helper/utils';
// #endif
import wechat from './provider/wechat/index.js';
import alipay from './provider/alipay/index';
import apple from './provider/apple';
import share from './share';
import Pay from './pay';
@ -53,6 +54,19 @@ platform = 'miniProgram';
provider = 'wechat';
// #endif
// #ifdef MP-ALIPAY
name = 'alipayMiniProgram';
platform = 'alipayMiniProgram';
provider = 'alipay';
if (!device.safeAreaInsets) {
device.safeAreaInsets = uni.getSystemInfoSync().safeAreaInsets
}
// 兜底一下。还是没有值时候,就给个默认值
if (!device.safeAreaInsets) {
device.safeAreaInsets = {}
}
// #endif
if (isEmpty(name)) {
uni.showToast({
title: '暂不支持该平台',
@ -64,6 +78,8 @@ if (isEmpty(name)) {
const load = () => {
if (provider === 'wechat') {
wechat.load();
} else if (provider === 'alipay') {
alipay.load();
}
};
@ -72,6 +88,7 @@ const useProvider = (_provider = '') => {
if (_provider === '') _provider = provider;
if (_provider === 'wechat') return wechat;
if (_provider === 'apple') return apple;
if (_provider === 'alipay') return alipay;
};
// 支付服务转发

View File

@ -0,0 +1,6 @@
// 这里 特指支付宝小程序,后面如果需要拓展什么阿里云小程序、淘宝小程序之类的,就自己新建
import service from './miniProgram';
const alipay = service;
export default alipay;

View File

@ -0,0 +1,220 @@
import SocialApi from '@/sheep/api/member/social';
import AuthUtil from '@/sheep/api/member/auth';
import UserApi from '@/sheep/api/member/user';
const socialType = 40; // 社交类型 - 支付宝小程序
let subscribeEventList = []
function load() {
checkUpdate()
getSubscribeTemplate()
}
// ================= 登录相关逻辑===================
// 基本上的登录逻辑是和微信小程序一样的
//支付宝小程序静默授权登录
const login = async () => {
return new Promise(async (resolve,reject)=>{
// 1. 获取支付宝的code
const codeResult = await uni.login({
provider: 'alipay',
scopes: 'auth_user',
});
if(codeResult.errMsg !== 'login:ok'){
return resolve(false);
}
// 2. 社交登录
const loginResult = await AuthUtil.socialLogin(socialType, codeResult.code, 'default');
if (loginResult.code === 0) {
setOpenid(loginResult.data.openid);
return resolve(true);
} else {
return resolve(false);
}
})
}
// 支付宝小程序手机号授权登录
const mobileLogin = async (e) =>{
return new Promise(async (resolve, reject) => {
if (e.errMsg !== 'getPhoneNumber:ok') {
return resolve(false);
}
// 1. 获得支付宝 code
const codeResult = await uni.login();
if (codeResult.errMsg !== 'login:ok') {
return resolve(false);
}
// TODO 2. 一键登录
// const loginResult = await AuthUtil.weixinMiniAppLogin(e.code, codeResult.code, 'default');
// if (loginResult.code === 0) {
// setOpenid(loginResult.data.openid);
// return resolve(true);
// } else {
// return resolve(false);
// }
// TODO 芋艿shareInfo: uni.getStorageSync('shareLog') || {},
});
}
// 支付宝小程序绑定
const bind = () => {
return new Promise(async (resolve, reject) => {
// 1. 获得支付宝小程序 code
const codeResult = await uni.login({
provider: 'alipay',
scopes: 'auth_user',
});
if (codeResult.errMsg !== 'login:ok') {
return resolve(false);
}
// 2. 绑定账号
const bindResult = await SocialApi.socialBind(socialType, codeResult.code, 'default');
if (bindResult.code === 0) {
setOpenid(bindResult.data);
return resolve(true);
} else {
return resolve(false);
}
});
};
// 支付宝小程序解除绑定
const unbind = async (openid) => {
const { code } = await SocialApi.socialUnbind(socialType, openid);
return code === 0;
};
// 绑定用户手机号
const bindUserPhoneNumber = (e) => {
return new Promise(async (resolve, reject) => {
// todo 待完善
// const { code } = await UserApi.updateUserMobileByWeixin(e.code);
// if (code === 0) {
// resolve(true);
// }
resolve(false);
});
};
// 设置 openid 到本地存储,目前只有 pay 支付时会使用
function setOpenid(openid) {
uni.setStorageSync('openid', openid);
}
// 获得 openid
async function getOpenid(force = false) {
let openid = uni.getStorageSync('openid');
if (!openid && force) {
const info = await getInfo();
if (info && info.openid) {
openid = info.openid;
setOpenid(openid);
}
}
return openid;
}
// 获得社交信息
async function getInfo() {
const { code, data } = await SocialApi.getSocialUser(socialType);
if (code !== 0) {
return undefined;
}
return data;
}
// ========== 非登录相关的逻辑 ==========
// 小程序更新
const checkUpdate = (silence = true) => {
if (uni.canIUse('getUpdateManager')) {
const updateManager = uni.getUpdateManager();
updateManager.onCheckForUpdate(function(res) {
// 请求完新版本信息的回调
if (res.hasUpdate) {
updateManager.onUpdateReady(function() {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success: function(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate();
}
},
});
})
}
});
} else {
if(!silence) {
uni.showToast({
title: '当前为最新版本',
icon: 'none',
});
}
}
}
// 获取订阅消息模板
async function getSubscribeTemplate(){
const { code, data } = await SocialApi.getSubscribeTemplateList();
if (code === 0) {
subscribeEventList = data;
}
}
// 订阅消息
function subscribeMessage(event, callback = undefined){
let tmplIds = [];
if (typeof event === 'string') {
const temp = subscribeEventList.find(item => item.title.includes(event));
}
if (temp) {
tmplIds.push(temp.id);
}
if (typeof event === 'object') {
event.forEach((e) => {
const temp = subscribeEventList.find(item => item.title.includes(e));
if (temp) {
tmplIds.push(temp.id);
}
});
}
if (tmplIds.length === 0) return;
uni.requestSubscribeMessage({
tmplIds,
success: ()=>{
// 不管是拒绝还是同意都触发
callback && callback()
},
fail: (err) => {
console.log(err);
},
});
}
export default {
load,
login,
bind,
unbind,
bindUserPhoneNumber,
mobileLogin,
getInfo,
getOpenid,
subscribeMessage,
checkUpdate,
};

View File

@ -10,6 +10,8 @@ import service from './miniProgram';
import service from './openPlatform';
// #endif
const wechat = service;
let wechat = {};
if (typeof service !== 'undefined') {
wechat = service;
}
export default wechat;

View File

@ -70,8 +70,13 @@ const _go = (
// 跳转底部导航
if (TABBAR.includes(page)) {
// wx.switchTab: url 不支持 queryString
// 设置全局变量
const params = queryToParams(query);
$store('app').setParamsForTabbar(params);
// 请记得在业务代码里使用完后,清理掉全局状态,避免影响下次跳转
uni.switchTab({
url,
url: page,
});
return;
}
@ -109,6 +114,19 @@ function paramsToQuery(params) {
return query.join('&');
}
function queryToParams(query) {
if (isEmpty(query)) {
return {};
}
let params = {};
let pairs = query.split('&');
for (let i = 0; i < pairs.length; i++) {
let pair = pairs[i].split('=');
params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');
}
return params;
}
function back() {
// #ifdef H5
history.back();

View File

@ -11,6 +11,7 @@ import { baseUrl, h5Url } from '@/sheep/config';
const app = defineStore({
id: 'app',
state: () => ({
paramsForTabbar: {}, // 为全局tabbar跳转传参用。原因是 tabbar 无法传参,只能通过全局状态传递
info: {
// 应用信息
name: '', // 商城名称
@ -73,7 +74,7 @@ const app = defineStore({
this.info = {
name: '芋道商城',
logo: 'https://static.iocoder.cn/ruoyi-vue-pro-logo.png',
version: '2025.11',
version: '2026.03',
copyright: '全部开源,个人与企业可 100% 免费使用',
copytime: 'Copyright© 2018-2025',
@ -113,6 +114,13 @@ const app = defineStore({
$router.error('InitError', res.msg || '加载失败');
}
},
// 设置 paramsForTabbar
setParamsForTabbar(params = {}) {
this.paramsForTabbar = params;
},
clearParamsForTabbar() {
this.paramsForTabbar = {};
},
},
persist: {
enabled: true,

View File

@ -17,8 +17,12 @@
-->
<view class="ui-navbar-box">
<view
class="ui-bar ss-p-x-20"
:class="state.isDark ? 'text-white' : 'text-black'"
class="ui-bar"
:class="[{
'text-white': state.isDark,
'text-black': !state.isDark,
'ss-p-x-20': sheep.$platform.provider !== 'alipay'
}]"
:style="[{ height: sys_navBar - sys_statusBar + 'px' }]"
>
<view class="icon-box ss-flex">

View File

@ -1,6 +1,6 @@
<!-- 自定义底部导航项 -->
<template>
<view class="u-tabbar-item" :style="[addStyle(customStyle)]">
<view class="u-tabbar-item" :style="[addStyle(customStyle)]" @click="clickHandler">
<view v-if="isCenter" class="tabbar-center-item">
<image class="center-image" :src="centerImage" mode="aspectFill"></image>
</view>