会员展示问题修复,本地开发工具增加环境切换判断

This commit is contained in:
2025-11-17 10:30:14 +08:00
parent 9ee6586e9e
commit 26f5beb660
4 changed files with 117 additions and 14 deletions

View File

@@ -34,6 +34,14 @@
>
<view class="popup-arrow"></view>
<view class="popup-content">
<view
class="popup-item"
>
<text class="item-text">
<text> 当前环境:</text>
<text style="color: rgb(255, 0, 0);"> {{ uni.conf.debug ? "测试环境" : "生产环境" }}</text>
</text>
</view>
<view
class="popup-item"
v-for="(item, index) in operations"
@@ -52,14 +60,15 @@
<script setup>
import { ref, defineProps, defineEmits, computed } from "vue";
import { changeEnv } from "@/common/config.js";
import { Storelogin } from "@/stores/user.js";
const show = computed(() => {
// trial
const sysInfo = uni.getAccountInfoSync();
if (
sysInfo &&
sysInfo.miniProgram &&
(
sysInfo.miniProgram.envVersion == "develop")
sysInfo.miniProgram.envVersion == "develop"
) {
return true;
}
@@ -109,6 +118,18 @@ const props = defineProps({
operations: {
type: Array,
default: () => [
{
name: "切换为测试环境",
icon: "arrowup",
action: "test",
color: "#007aff",
},
{
name: "切换为正式环境",
icon: "arrowup",
action: "prod",
color: "#007aff",
},
{
name: "复制token",
icon: "arrowup",
@@ -201,9 +222,31 @@ async function getWxloginCode() {
});
});
}
const storelogin = Storelogin();
// 处理操作选择
const handleOperation = async (action) => {
let data = "";
if (action == "prod" || action == "test") {
changeEnv(action);
emit("onOperation", action);
uni.showToast({
title: "切换成功",
icon: "success",
});
uni.clearStorageSync();
await storelogin.actionslogin();
setTimeout(() => {
uni.reLaunch({
url: "/pages/index/index",
});
}, 1500);
closePopup();
return;
}
if (action == "token") {
data = uni.cache.get("token");
}
@@ -220,10 +263,13 @@ const handleOperation = async (action) => {
data = JSON.stringify(uni.cache.get("shopUserInfo"));
}
console.log("data", data);
uni.setClipboardData({
data: data,
success: function () {},
});
if (data) {
uni.setClipboardData({
data: data,
success: function () {},
});
}
emit("onOperation", action);
closePopup();
};
@@ -269,7 +315,7 @@ const handleOperation = async (action) => {
position: absolute;
bottom: calc(100% + 15px);
right: 0;
min-width: 160px;
min-width: 180px;
background-color: #ffffff;
border-radius: 12px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
@@ -318,7 +364,6 @@ const handleOperation = async (action) => {
}
.item-text {
margin-left: 12px;
font-size: 14px;
color: #333333;
line-height: 1;