feat: 开放服务器切换并修复扫码方式列表
This commit is contained in:
parent
3f2481d1eb
commit
fa0ff1614b
@ -55,6 +55,13 @@ export default {
|
|||||||
dataKey: 'barcode_string',
|
dataKey: 'barcode_string',
|
||||||
needSetup: false
|
needSetup: false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
brand: 'nlscan',
|
||||||
|
name: '新大陆',
|
||||||
|
action: 'nlscan.action.SCANNER_RESULT',
|
||||||
|
dataKey: 'SCAN_BARCODE1',
|
||||||
|
needSetup: false
|
||||||
|
},
|
||||||
{ ...PHONE_SCAN_CONFIG },
|
{ ...PHONE_SCAN_CONFIG },
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|||||||
@ -8,22 +8,20 @@
|
|||||||
<!-- <u-tabs :list="list" :is-scroll="false" :current="current" @change="onClickItem"></u-tabs> -->
|
<!-- <u-tabs :list="list" :is-scroll="false" :current="current" @change="onClickItem"></u-tabs> -->
|
||||||
<!-- <view v-if="current === 0"> -->
|
<!-- <view v-if="current === 0"> -->
|
||||||
<view class="list">
|
<view class="list">
|
||||||
<template v-if="isDevelopment">
|
<view class="list-call">
|
||||||
<view class="list-call">
|
<view class="iconfont icon-link" style="font-size: 22px;color:#5473e8;"></view>
|
||||||
<view class="iconfont icon-link" style="font-size: 22px;color:#5473e8;"></view>
|
<view style="width: 100%;">
|
||||||
<view style="width: 100%;">
|
<view class="server-selector" @click="showServerPicker">
|
||||||
<view class="server-selector" @click="showServerPicker">
|
<text>{{ getApiUrlLabel() }}</text>
|
||||||
<text>{{ getApiUrlLabel() }}</text>
|
<view class="iconfont icon-arrow-down" style="font-size: 16px;"></view>
|
||||||
<view class="iconfont icon-arrow-down" style="font-size: 16px;"></view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="list-call" v-if="selectedApiUrl === 'custom'">
|
</view>
|
||||||
<!-- 当选择自定义时显示输入框 -->
|
<view class="list-call" v-if="selectedApiUrl === 'custom'">
|
||||||
<input class="u-input" type="text" v-model="customApiUrl" maxlength="100" placeholder="请输入服务器地址"
|
<!-- 当选择自定义时显示输入框 -->
|
||||||
@blur="handleBlurInputUrl" />
|
<input class="u-input" type="text" v-model="customApiUrl" maxlength="100" placeholder="请输入服务器地址"
|
||||||
</view>
|
@blur="handleBlurInputUrl" />
|
||||||
</template>
|
</view>
|
||||||
<view class="list-call">
|
<view class="list-call">
|
||||||
<view class="iconfont icon-avatar" style="font-size: 22px;color:#5473e8;"></view>
|
<view class="iconfont icon-avatar" style="font-size: 22px;color:#5473e8;"></view>
|
||||||
<input class="u-input" type="text" v-model="login.username" maxlength="32"
|
<input class="u-input" type="text" v-model="login.username" maxlength="32"
|
||||||
@ -136,10 +134,12 @@ export default {
|
|||||||
password: ""
|
password: ""
|
||||||
},
|
},
|
||||||
showApiUrlPicker: false,
|
showApiUrlPicker: false,
|
||||||
// 根据环境设置默认URL和选项
|
// 暂时在打包后也展示服务器选项;生产包默认正式环境
|
||||||
selectedApiUrl: config.isDevelopment ? config.devApiUrlOptions[0].value : config.productionApiUrl,
|
selectedApiUrl: config.isDevelopment
|
||||||
|
? config.devApiUrlOptions[0].value
|
||||||
|
: ((config.devApiUrlOptions.find(item => item.label === '正式环境') || {}).value || config.productionApiUrl),
|
||||||
customApiUrl: 'http://192.168.1.66:50002/hcscm_weave/pda/v1',
|
customApiUrl: 'http://192.168.1.66:50002/hcscm_weave/pda/v1',
|
||||||
apiUrlList: config.isDevelopment ? config.devApiUrlOptions : [],
|
apiUrlList: config.devApiUrlOptions,
|
||||||
phoneNo: '',
|
phoneNo: '',
|
||||||
//username: '',
|
//username: '',
|
||||||
//password: '',
|
//password: '',
|
||||||
@ -168,16 +168,13 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onShow() {
|
onShow() {
|
||||||
// 只在开发环境读取存储的URL
|
uni.getStorage({
|
||||||
if (config.isDevelopment) {
|
key: 'ApiUrl',
|
||||||
uni.getStorage({
|
success: (e) => {
|
||||||
key: 'ApiUrl',
|
util.updateApiUrl(e.data);
|
||||||
success: (e) => {
|
this.selectedApiUrl = e.data;
|
||||||
util.updateApiUrl(e.data);
|
}
|
||||||
this.selectedApiUrl = e.data;
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
uni.getStorage({
|
uni.getStorage({
|
||||||
key: 'UserInfo',
|
key: 'UserInfo',
|
||||||
@ -300,21 +297,12 @@ export default {
|
|||||||
title: '登录中...'
|
title: '登录中...'
|
||||||
});
|
});
|
||||||
|
|
||||||
let currentApiUrl;
|
const currentApiUrl = this.selectedApiUrl === 'custom' ? this.customApiUrl : this.selectedApiUrl;
|
||||||
|
if (!currentApiUrl || currentApiUrl.length === 0) {
|
||||||
if (config.isDevelopment) {
|
this.$u.toast('请输入服务器地址');
|
||||||
// 开发环境:使用选择的URL
|
return;
|
||||||
currentApiUrl = this.selectedApiUrl === 'custom' ? this.customApiUrl : this.selectedApiUrl;
|
|
||||||
if (!currentApiUrl || currentApiUrl.length === 0) {
|
|
||||||
this.$u.toast('请输入服务器地址');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 更新store中的URL
|
|
||||||
this.$store.dispatch('updateApiUrl', currentApiUrl);
|
|
||||||
} else {
|
|
||||||
// 生产环境:使用固定的生产URL
|
|
||||||
currentApiUrl = config.productionApiUrl;
|
|
||||||
}
|
}
|
||||||
|
this.$store.dispatch('updateApiUrl', currentApiUrl);
|
||||||
|
|
||||||
if (this.login.username.length == 0) {
|
if (this.login.username.length == 0) {
|
||||||
this.$u.toast('请输入账号');
|
this.$u.toast('请输入账号');
|
||||||
@ -339,14 +327,11 @@ export default {
|
|||||||
var aLoginUserData = res;
|
var aLoginUserData = res;
|
||||||
|
|
||||||
//console.log('--aLoginUserData->>' + JSON.stringify(aLoginUserData));
|
//console.log('--aLoginUserData->>' + JSON.stringify(aLoginUserData));
|
||||||
// 只在开发环境保存 apiurl 到本地存储
|
uni.setStorage({
|
||||||
if (config.isDevelopment) {
|
key: 'ApiUrl',
|
||||||
uni.setStorage({
|
data: currentApiUrl
|
||||||
key: 'ApiUrl',
|
});
|
||||||
data: currentApiUrl
|
util.updateApiUrl(currentApiUrl);
|
||||||
});
|
|
||||||
util.updateApiUrl(currentApiUrl);
|
|
||||||
}
|
|
||||||
// 保存 token 到本地存储
|
// 保存 token 到本地存储
|
||||||
uni.setStorageSync('RemoteTokenData', aLoginUserData);
|
uni.setStorageSync('RemoteTokenData', aLoginUserData);
|
||||||
|
|
||||||
@ -456,18 +441,14 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleBlurInputUrl(e) {
|
handleBlurInputUrl(e) {
|
||||||
// 只在开发环境处理自定义URL
|
const url = e.detail.value.trim();
|
||||||
if (config.isDevelopment) {
|
if (url) {
|
||||||
const url = e.detail.value.trim();
|
this.customApiUrl = url;
|
||||||
if (url) {
|
uni.setStorage({
|
||||||
this.customApiUrl = url;
|
key: 'ApiUrl',
|
||||||
// 保存到本地存储
|
data: url
|
||||||
uni.setStorage({
|
});
|
||||||
key: 'ApiUrl',
|
util.updateApiUrl(url);
|
||||||
data: url
|
|
||||||
});
|
|
||||||
util.updateApiUrl(url);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,7 +83,7 @@ export default {
|
|||||||
const res = await this.$u.api.dictionary.getDetailEnumList({
|
const res = await this.$u.api.dictionary.getDetailEnumList({
|
||||||
dictionary_id: DICTIONARY_TYPE_SCANNER,
|
dictionary_id: DICTIONARY_TYPE_SCANNER,
|
||||||
});
|
});
|
||||||
const list = Array.isArray(res) ? res : [];
|
const list = Array.isArray(res) ? res : (Array.isArray(res && res.list) ? res.list : []);
|
||||||
const builtinConfigs = this.getScannerConfigs();
|
const builtinConfigs = this.getScannerConfigs();
|
||||||
if (list.length) {
|
if (list.length) {
|
||||||
this.configList = list
|
this.configList = list
|
||||||
@ -98,6 +98,7 @@ export default {
|
|||||||
this.useFallbackConfigList();
|
this.useFallbackConfigList();
|
||||||
}
|
}
|
||||||
this.ensurePhoneScanOption();
|
this.ensurePhoneScanOption();
|
||||||
|
this.ensureNlscanOption();
|
||||||
this.initFormFromSaved();
|
this.initFormFromSaved();
|
||||||
},
|
},
|
||||||
useFallbackConfigList() {
|
useFallbackConfigList() {
|
||||||
@ -110,6 +111,24 @@ export default {
|
|||||||
this.configList.push(phoneConfig);
|
this.configList.push(phoneConfig);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
ensureNlscanOption() {
|
||||||
|
const nlscanConfig = this.getScannerConfigs().find((item) => item.brand === 'nlscan');
|
||||||
|
if (!nlscanConfig) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const exists = this.configList.some((item) => {
|
||||||
|
return item.brand === nlscanConfig.brand || item.action === nlscanConfig.action;
|
||||||
|
});
|
||||||
|
if (exists) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const phoneIndex = this.configList.findIndex((item) => item.brand === PHONE_SCAN_BRAND);
|
||||||
|
if (phoneIndex >= 0) {
|
||||||
|
this.configList.splice(phoneIndex, 0, nlscanConfig);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.configList.push(nlscanConfig);
|
||||||
|
},
|
||||||
initFormFromSaved() {
|
initFormFromSaved() {
|
||||||
const savedConfig = getScanConfig(this.getScannerConfigs());
|
const savedConfig = getScanConfig(this.getScannerConfigs());
|
||||||
if (savedConfig) {
|
if (savedConfig) {
|
||||||
|
|||||||
@ -21,18 +21,15 @@ try{
|
|||||||
|
|
||||||
// 初始化API URL
|
// 初始化API URL
|
||||||
function initApiUrl() {
|
function initApiUrl() {
|
||||||
if (config.isDevelopment) {
|
const fallbackUrl = config.isDevelopment
|
||||||
// 开发环境:从存储读取,如果没有则使用测试环境
|
? config.devApiUrlOptions[0].value
|
||||||
try {
|
: ((config.devApiUrlOptions.find(item => item.label === '正式环境') || {}).value || config.productionApiUrl);
|
||||||
const savedApiUrl = uni.getStorageSync('ApiUrl');
|
try {
|
||||||
return savedApiUrl || config.devApiUrlOptions[0].value;
|
const savedApiUrl = uni.getStorageSync('ApiUrl');
|
||||||
} catch (e) {
|
return savedApiUrl || fallbackUrl;
|
||||||
console.log('读取存储的 apiurl 失败', e);
|
} catch (e) {
|
||||||
return config.devApiUrlOptions[0].value;
|
console.log('读取存储的 apiurl 失败', e);
|
||||||
}
|
return fallbackUrl;
|
||||||
} else {
|
|
||||||
// 生产环境:使用固定的生产URL
|
|
||||||
return config.productionApiUrl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,13 +102,7 @@ const store = new Vuex.Store({
|
|||||||
state.vuex_notificationAudio = audio;
|
state.vuex_notificationAudio = audio;
|
||||||
},
|
},
|
||||||
SET_API_URL(state, url) {
|
SET_API_URL(state, url) {
|
||||||
// 生产环境不允许修改URL
|
|
||||||
if (!config.isDevelopment) {
|
|
||||||
console.warn('生产环境不允许修改API URL');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
state.apiurl = url
|
state.apiurl = url
|
||||||
// 同时保存到本地存储
|
|
||||||
uni.setStorageSync('ApiUrl', url)
|
uni.setStorageSync('ApiUrl', url)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user