|
|
@@ -94,15 +94,23 @@ const otherUtil = {
|
|
|
|
|
|
const token = uni.getStorageSync('access-token') || '';
|
|
|
const isLogin = !!token;
|
|
|
-
|
|
|
+
|
|
|
// 后退参数
|
|
|
let str = uni.$u.queryParams({ isBack: 1 });
|
|
|
// 跳转路由
|
|
|
let path = `/pages/login/wxLogin${str}`;
|
|
|
-
|
|
|
// 未登录时,根据 type 执行对应操作
|
|
|
if (!isLogin) {
|
|
|
switch (type) {
|
|
|
+ case 'navigate-webview':
|
|
|
+ // 跳转登录页内嵌
|
|
|
+ uni.navigateTo({
|
|
|
+ url: path+'&type=webview',
|
|
|
+ success: () => {
|
|
|
+ console.log('未登录,已跳转至登录页');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ break;
|
|
|
case 'navigate':
|
|
|
// 跳转登录页(带返回跳转,可返回原页面)
|
|
|
uni.navigateTo({
|
|
|
@@ -112,7 +120,7 @@ const otherUtil = {
|
|
|
}
|
|
|
});
|
|
|
break;
|
|
|
-
|
|
|
+
|
|
|
case 'modal':
|
|
|
// 弹窗提示,确认后跳转登录页
|
|
|
uni.showModal({
|
|
|
@@ -127,7 +135,7 @@ const otherUtil = {
|
|
|
}
|
|
|
});
|
|
|
break;
|
|
|
-
|
|
|
+
|
|
|
// 默认:仅返回登录状态,不执行额外操作
|
|
|
default:
|
|
|
console.log('未登录,仅返回登录状态');
|
|
|
@@ -155,21 +163,21 @@ const otherUtil = {
|
|
|
if (!e || typeof e !== 'string') {
|
|
|
return [];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 分割图片字符串为数组
|
|
|
const imgArr = e.split(',');
|
|
|
-
|
|
|
+
|
|
|
// 判断index是否为null/undefined(用户传空时),返回完整数组
|
|
|
if (index === null || index === undefined) {
|
|
|
return imgArr;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 处理索引:确保是整数,且在有效范围内(0 <= index < 数组长度)
|
|
|
const validIndex = Math.floor(Number(index)); // 转为整数(避免传入字符串/小数)
|
|
|
if (isNaN(validIndex) || validIndex < 0 || validIndex >= imgArr.length) {
|
|
|
return ''; // 索引无效时,返回空字符串(避免显示错误图片)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 返回指定索引的图片URL
|
|
|
return imgArr[validIndex];
|
|
|
},
|
|
|
@@ -187,4 +195,4 @@ const otherUtil = {
|
|
|
export default {
|
|
|
...formatUtil,
|
|
|
...otherUtil,
|
|
|
-};
|
|
|
+};
|