会员展示问题修复,本地开发工具增加环境切换判断
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-arrow"></view>
|
||||||
<view class="popup-content">
|
<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
|
<view
|
||||||
class="popup-item"
|
class="popup-item"
|
||||||
v-for="(item, index) in operations"
|
v-for="(item, index) in operations"
|
||||||
@@ -52,14 +60,15 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, defineProps, defineEmits, computed } from "vue";
|
import { ref, defineProps, defineEmits, computed } from "vue";
|
||||||
|
import { changeEnv } from "@/common/config.js";
|
||||||
|
import { Storelogin } from "@/stores/user.js";
|
||||||
const show = computed(() => {
|
const show = computed(() => {
|
||||||
// trial
|
// trial
|
||||||
const sysInfo = uni.getAccountInfoSync();
|
const sysInfo = uni.getAccountInfoSync();
|
||||||
if (
|
if (
|
||||||
sysInfo &&
|
sysInfo &&
|
||||||
sysInfo.miniProgram &&
|
sysInfo.miniProgram &&
|
||||||
(
|
sysInfo.miniProgram.envVersion == "develop"
|
||||||
sysInfo.miniProgram.envVersion == "develop")
|
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -109,6 +118,18 @@ const props = defineProps({
|
|||||||
operations: {
|
operations: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [
|
default: () => [
|
||||||
|
{
|
||||||
|
name: "切换为测试环境",
|
||||||
|
icon: "arrowup",
|
||||||
|
action: "test",
|
||||||
|
color: "#007aff",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "切换为正式环境",
|
||||||
|
icon: "arrowup",
|
||||||
|
action: "prod",
|
||||||
|
color: "#007aff",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "复制token",
|
name: "复制token",
|
||||||
icon: "arrowup",
|
icon: "arrowup",
|
||||||
@@ -201,9 +222,31 @@ async function getWxloginCode() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
const storelogin = Storelogin();
|
||||||
|
|
||||||
// 处理操作选择
|
// 处理操作选择
|
||||||
const handleOperation = async (action) => {
|
const handleOperation = async (action) => {
|
||||||
let data = "";
|
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") {
|
if (action == "token") {
|
||||||
data = uni.cache.get("token");
|
data = uni.cache.get("token");
|
||||||
}
|
}
|
||||||
@@ -220,10 +263,13 @@ const handleOperation = async (action) => {
|
|||||||
data = JSON.stringify(uni.cache.get("shopUserInfo"));
|
data = JSON.stringify(uni.cache.get("shopUserInfo"));
|
||||||
}
|
}
|
||||||
console.log("data", data);
|
console.log("data", data);
|
||||||
uni.setClipboardData({
|
if (data) {
|
||||||
data: data,
|
uni.setClipboardData({
|
||||||
success: function () {},
|
data: data,
|
||||||
});
|
success: function () {},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
emit("onOperation", action);
|
emit("onOperation", action);
|
||||||
closePopup();
|
closePopup();
|
||||||
};
|
};
|
||||||
@@ -269,7 +315,7 @@ const handleOperation = async (action) => {
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: calc(100% + 15px);
|
bottom: calc(100% + 15px);
|
||||||
right: 0;
|
right: 0;
|
||||||
min-width: 160px;
|
min-width: 180px;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
|
||||||
@@ -318,7 +364,6 @@ const handleOperation = async (action) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.item-text {
|
.item-text {
|
||||||
margin-left: 12px;
|
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #333333;
|
color: #333333;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
|
|||||||
@@ -118,6 +118,10 @@
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
|
shopId: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// 定义事件发射器
|
// 定义事件发射器
|
||||||
@@ -145,11 +149,11 @@
|
|||||||
|
|
||||||
const init = async () => {
|
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');
|
// shopUserInfo = uni.cache.get('shopUserInfo');
|
||||||
// } else {
|
// } else {
|
||||||
// let res = await this.api.shopUserInfo({
|
// let res = await this.api.shopUserInfo({
|
||||||
// "shopId": uni.cache.get('shopId'),
|
// "shopId": props.shopId||uni.cache.get('shopId'),
|
||||||
// "userId": uni.cache.get('userInfo').id,
|
// "userId": uni.cache.get('userInfo').id,
|
||||||
// })
|
// })
|
||||||
// if (res.code == 0) {
|
// if (res.code == 0) {
|
||||||
@@ -192,7 +196,7 @@
|
|||||||
url: uni.conf.baseUrl + '/account/user/common/upload',
|
url: uni.conf.baseUrl + '/account/user/common/upload',
|
||||||
filePath: avatarUrl,
|
filePath: avatarUrl,
|
||||||
header: {
|
header: {
|
||||||
shopId: uni.cache.get('shopId'),
|
shopId: props.shopId||uni.cache.get('shopId'),
|
||||||
token: uni.cache.get('token') || '',
|
token: uni.cache.get('token') || '',
|
||||||
'content-type': 'multipart/form-data'
|
'content-type': 'multipart/form-data'
|
||||||
},
|
},
|
||||||
@@ -339,7 +343,7 @@
|
|||||||
}
|
}
|
||||||
const submitForm={
|
const submitForm={
|
||||||
// id: uni.cache.get('userInfo').id,
|
// id: uni.cache.get('userInfo').id,
|
||||||
// shopId: uni.cache.get('shopId'),
|
shopId: props.shopId||uni.cache.get('shopId'),
|
||||||
nickName: formInfo.nickName,
|
nickName: formInfo.nickName,
|
||||||
headImg: userHeadImg.value,
|
headImg: userHeadImg.value,
|
||||||
phone: formInfo.telephone,
|
phone: formInfo.telephone,
|
||||||
@@ -348,7 +352,7 @@
|
|||||||
}
|
}
|
||||||
await APIshopUser(submitForm)
|
await APIshopUser(submitForm)
|
||||||
let APIshopUserInfores = await APIshopUserInfo({
|
let APIshopUserInfores = await APIshopUserInfo({
|
||||||
shopId: uni.cache.get('shopId')
|
shopId: props.shopId||uni.cache.get('shopId')
|
||||||
})
|
})
|
||||||
uni.cache.set('orderVIP', APIshopUserInfores)
|
uni.cache.set('orderVIP', APIshopUserInfores)
|
||||||
uni.cache.set('ordershopUserInfo', APIshopUserInfores.shopInfo)
|
uni.cache.set('ordershopUserInfo', APIshopUserInfores.shopInfo)
|
||||||
|
|||||||
@@ -137,7 +137,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</up-popup>
|
</up-popup>
|
||||||
<registermember :memberOpen="memberOpen" :shopUserInfo="shopInfo" @emitsmemberOpen="emitsmemberOpen">
|
<registermember :memberOpen="memberOpen" :shopUserInfo="shopInfo" @emitsmemberOpen="emitsmemberOpen" :shopId="option.shopId">
|
||||||
</registermember>
|
</registermember>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user