会员展示问题修复,本地开发工具增加环境切换判断
This commit is contained in:
54
common/config.js
Normal file
54
common/config.js
Normal file
@@ -0,0 +1,54 @@
|
||||
// const debug = process.env.NODE_ENV == 'development' ? true : false;
|
||||
const debug = false;
|
||||
// #ifdef H5
|
||||
const proxyApi = "/api";
|
||||
// #endif
|
||||
|
||||
// #ifdef MP-WEIXIN || APP || MP-ALIPAY
|
||||
const proxyApi = "http://192.168.1.42"; // 调试地址
|
||||
const proxyApiwws = "ws://192.168.1.42:2348"; // 调试地址
|
||||
// #endif
|
||||
|
||||
// #ifdef H5
|
||||
const baseUrl = debug ? proxyApi : "http://192.168.1.42";
|
||||
const baseUrlwws = "ws://192.168.1.42:2348";
|
||||
// #endif
|
||||
|
||||
// #ifdef APP || MP-WEIXIN || MP-ALIPAY
|
||||
const baseUrl = debug ? proxyApi : "https://cashier.sxczgkj.com"; // 线上
|
||||
const baseUrlwws = debug ? proxyApiwws : "wss://czgeatws.sxczgkj.com/wss"; // 线上
|
||||
// #endif
|
||||
|
||||
const version = "100";
|
||||
const autoRemoveCache = {
|
||||
count: 100000,
|
||||
size: 100000,
|
||||
};
|
||||
uni.conf = {
|
||||
debug,
|
||||
baseUrl,
|
||||
version,
|
||||
autoRemoveCache,
|
||||
baseUrlwws,
|
||||
};
|
||||
|
||||
export const changeEnv = (env) => {
|
||||
if (env === "test") {
|
||||
uni.conf = {
|
||||
debug: true,
|
||||
baseUrl: "http://192.168.1.42",
|
||||
version: 100,
|
||||
autoRemoveCache,
|
||||
baseUrlwws: "ws://192.168.1.42:2348",
|
||||
};
|
||||
}
|
||||
if (env === "prod") {
|
||||
uni.conf = {
|
||||
debug: false,
|
||||
baseUrl: "https://cashier.sxczgkj.com",
|
||||
version: 100,
|
||||
autoRemoveCache,
|
||||
baseUrlwws: "wss://czgeatws.sxczgkj.com/wss",
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -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);
|
||||
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;
|
||||
|
||||
@@ -118,6 +118,10 @@
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
shopId: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
});
|
||||
|
||||
// 定义事件发射器
|
||||
@@ -145,11 +149,11 @@
|
||||
|
||||
const init = async () => {
|
||||
|
||||
// if (uni.cache.get('shopUserInfo') && uni.cache.get('shopId') == uni.cache.get('shopUserInfo').id) {
|
||||
// if (uni.cache.get('shopUserInfo') && props.shopId||uni.cache.get('shopId') == uni.cache.get('shopUserInfo').id) {
|
||||
// shopUserInfo = uni.cache.get('shopUserInfo');
|
||||
// } else {
|
||||
// let res = await this.api.shopUserInfo({
|
||||
// "shopId": uni.cache.get('shopId'),
|
||||
// "shopId": props.shopId||uni.cache.get('shopId'),
|
||||
// "userId": uni.cache.get('userInfo').id,
|
||||
// })
|
||||
// if (res.code == 0) {
|
||||
@@ -192,7 +196,7 @@
|
||||
url: uni.conf.baseUrl + '/account/user/common/upload',
|
||||
filePath: avatarUrl,
|
||||
header: {
|
||||
shopId: uni.cache.get('shopId'),
|
||||
shopId: props.shopId||uni.cache.get('shopId'),
|
||||
token: uni.cache.get('token') || '',
|
||||
'content-type': 'multipart/form-data'
|
||||
},
|
||||
@@ -339,7 +343,7 @@
|
||||
}
|
||||
const submitForm={
|
||||
// id: uni.cache.get('userInfo').id,
|
||||
// shopId: uni.cache.get('shopId'),
|
||||
shopId: props.shopId||uni.cache.get('shopId'),
|
||||
nickName: formInfo.nickName,
|
||||
headImg: userHeadImg.value,
|
||||
phone: formInfo.telephone,
|
||||
@@ -348,7 +352,7 @@
|
||||
}
|
||||
await APIshopUser(submitForm)
|
||||
let APIshopUserInfores = await APIshopUserInfo({
|
||||
shopId: uni.cache.get('shopId')
|
||||
shopId: props.shopId||uni.cache.get('shopId')
|
||||
})
|
||||
uni.cache.set('orderVIP', APIshopUserInfores)
|
||||
uni.cache.set('ordershopUserInfo', APIshopUserInfores.shopInfo)
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</up-popup>
|
||||
<registermember :memberOpen="memberOpen" :shopUserInfo="shopInfo" @emitsmemberOpen="emitsmemberOpen">
|
||||
<registermember :memberOpen="memberOpen" :shopUserInfo="shopInfo" @emitsmemberOpen="emitsmemberOpen" :shopId="option.shopId">
|
||||
</registermember>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user