feat(login): 优化登录逻辑及环境配置展示

- 修改环境变量配置,新增 VUE_APP_ENV_NAME 用于区分环境名称显示
- 调整登录接口请求,pdaLogin与pdaLogout改为相对路径调用
- 登录页面新增环境名称显示,区分不同环境使用状态
- 登录流程支持开发环境动态选择服务器地址,支持自定义地址输入及存储
- 增加请求和响应拦截器日志输出,方便调试接口请求问题
- 优化登录表单输入清除按钮显示与密码显示切换交互体验
- 修复和改善登录相关本地存储,自动保存账号密码和服务器地址
- 调整manifest包配置,禁用app-plus子包
- 格式化和规范登录页面样式调整,提升页面结构与样式一致性
This commit is contained in:
郭鸿轩 2025-12-26 15:11:37 +08:00
parent 8a9bb09c18
commit 7043a49206
9 changed files with 470 additions and 449 deletions

1
.env
View File

@ -1,4 +1,5 @@
NODE_ENV = development NODE_ENV = development
VUE_APP_ENV_NAME = 默认环境
VUE_APP_UPGRADE_NAME = erp_pda VUE_APP_UPGRADE_NAME = erp_pda
VUE_APP_PRODUCTION_API_URL = https://www.haotopai.com/hcscm/mes/server/pda/v1 VUE_APP_PRODUCTION_API_URL = https://www.haotopai.com/hcscm/mes/server/pda/v1
VUE_APP_DEV_API_URL = https://www.haotopai.com/hcscm/mes/server/pda/v1 VUE_APP_DEV_API_URL = https://www.haotopai.com/hcscm/mes/server/pda/v1

View File

@ -1,4 +1,5 @@
NODE_ENV = development NODE_ENV = development
VUE_APP_ENV_NAME = mes环境
VUE_APP_UPGRADE_NAME = erp_pda VUE_APP_UPGRADE_NAME = erp_pda
VUE_APP_PRODUCTION_API_URL = https://www.haotopai.com/hcscm/mes/server/pda/v1 VUE_APP_PRODUCTION_API_URL = https://www.haotopai.com/hcscm/mes/server/pda/v1
VUE_APP_DEV_API_URL = https://www.haotopai.com/hcscm/mes/server/pda/v1 VUE_APP_DEV_API_URL = https://www.haotopai.com/hcscm/mes/server/pda/v1

View File

@ -1,4 +1,5 @@
NODE_ENV = development NODE_ENV = development
VUE_APP_ENV_NAME = zhisheng环境
VUE_APP_UPGRADE_NAME = erp_pda_pre VUE_APP_UPGRADE_NAME = erp_pda_pre
VUE_APP_PRODUCTION_API_URL = https://hcscmpre.zzfzyc.com/hcscm/pda/v1 VUE_APP_PRODUCTION_API_URL = https://hcscmpre.zzfzyc.com/hcscm/pda/v1
VUE_APP_DEV_API_URL = https://hcscmpre.zzfzyc.com/hcscm/pda/v1 VUE_APP_DEV_API_URL = https://hcscmpre.zzfzyc.com/hcscm/pda/v1

View File

@ -1,3 +1,5 @@
# 不使用 pda项目以后的新需求或者修改 使用 本项目
# pda-cli # pda-cli
## Project setup ## Project setup

View File

@ -16,8 +16,8 @@ const install = (Vue, vm) => {
getUserInfo: (params = {}) => vm.$u.get(config.productionApiUrl+'/mobile/user/getUserInfo', params), getUserInfo: (params = {}) => vm.$u.get(config.productionApiUrl+'/mobile/user/getUserInfo', params),
login: (params = {}) => vm.$u.post(config.productionApiUrl+'/mobile/login/loginByPassword', params), login: (params = {}) => vm.$u.post(config.productionApiUrl+'/mobile/login/loginByPassword', params),
// PDA登录接口 // PDA登录接口
pdaLogin: (params = {}) => vm.$u.postJson(config.productionApiUrl+'/login', params), pdaLogin: (params = {}) => vm.$u.postJson('/login', params),
pdaLogout: (params = {}) => vm.$u.postJson(config.productionApiUrl+'/logout', params), pdaLogout: (params = {}) => vm.$u.postJson('/logout', params),
// 获取配布单列表 // 获取配布单列表
getFpmArrangeOrderList: (params = {}) => vm.$u.get('/product/fpmArrangeOrder/getFpmArrangeOrderList', params), getFpmArrangeOrderList: (params = {}) => vm.$u.get('/product/fpmArrangeOrder/getFpmArrangeOrderList', params),
// 获取成品配布单详情 // 获取成品配布单详情

View File

@ -22,6 +22,9 @@ const install = (Vue, vm) => {
// 请求拦截配置Token等参数 // 请求拦截配置Token等参数
Vue.prototype.$u.http.interceptor.request = (req) => { Vue.prototype.$u.http.interceptor.request = (req) => {
console.log('request', req);
console.log('baseUrl', vm.$store.state.apiurl);
console.log('完整URL', vm.$store.state.apiurl + req.url);
if (!req.header){ if (!req.header){
req.header = []; req.header = [];
} }
@ -42,13 +45,15 @@ const install = (Vue, vm) => {
req.header[rememberMeHeader] = vm.vuex_remember; req.header[rememberMeHeader] = vm.vuex_remember;
req.remember = false; req.remember = false;
} }
console.log('request', req);
return req; return req;
} }
// 响应拦截,判断状态码是否通过 // 响应拦截,判断状态码是否通过
Vue.prototype.$u.http.interceptor.response = async (res, req) => { Vue.prototype.$u.http.interceptor.response = async (res, req) => {
console.log('response', res); console.log('response', res);
console.log('response statusCode', res?.statusCode);
console.log('response data', res?.data);
console.log('response errMsg', res?.errMsg);
// 处理401未授权状态码 // 处理401未授权状态码
if (res.statusCode === 401) { if (res.statusCode === 401) {
@ -63,6 +68,7 @@ const install = (Vue, vm) => {
}); });
return false; return false;
} }
console.log('res',res)
if (!(res.data)){ if (!(res.data)){
vm.$u.toast('未连接到服务器') vm.$u.toast('未连接到服务器')
return Promise.reject(new Error('未连接到服务器')); return Promise.reject(new Error('未连接到服务器'));
@ -125,7 +131,7 @@ const install = (Vue, vm) => {
// 封装 post json 请求 // 封装 post json 请求
vm.$u.postJson = (url, data = {}, header = {}) => { vm.$u.postJson = (url, data = {}, header = {}) => {
console.log('header', header, url, vm.$u) console.log('header', header, url, vm.$store.state.apiurl)
header['content-type'] = 'application/json'; header['content-type'] = 'application/json';
return vm.$u.http.request({ return vm.$u.http.request({
url, url,

View File

@ -7,7 +7,7 @@
"transformPx" : false, "transformPx" : false,
"app-plus" : { "app-plus" : {
"optimization" : { "optimization" : {
"subPackages" : true "subPackages" : false
}, },
"safearea" : { "safearea" : {
"bottom" : { "bottom" : {

View File

@ -4,57 +4,52 @@
<view class="haotoplogo"> <view class="haotoplogo">
<image src="/static/haotop/image/logo/Start.jpg" mode="aspectFit" class="logoimg"></image> <image src="/static/haotop/image/logo/Start.jpg" mode="aspectFit" class="logoimg"></image>
</view> </view>
<!-- <div v-if="loginType === 'currentPhone'">--> <!-- <div v-if="loginType === 'currentPhone'">-->
<!-- <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"> <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 class="list-call" v-if="selectedApiUrl === 'custom'">
<!-- 当选择自定义时显示输入框 -->
<input
class="u-input"
type="text"
v-model="customApiUrl"
maxlength="100"
placeholder="请输入服务器地址"
@blur="handleBlurInputUrl"
/>
</view>
</template>
<view class="list-call">
<view class="iconfont icon-avatar" style="font-size: 22px;color:#5473e8;"></view>
<input class="u-input" type="text" v-model="login.username" maxlength="32"
:placeholder="$t('login.placeholderAccount')" value="admin" @input="clearInput"/>
<u-icon :size="50" v-if="showClearIcon" name="close-circle-fill" color="#c0c4cc" class="u-clear-icon" @click="clearIcon"/>
</view> </view>
<view class="list-call"> </view>
<view class="iconfont icon-key" style="font-size: 22px;color:#5473e8;"></view> <view class="list-call" v-if="selectedApiUrl === 'custom'">
<input class="u-input" type="text" v-model="login.password" maxlength="32" <!-- 当选择自定义时显示输入框 -->
:placeholder="$t('login.placeholderPassword')" :password="!showPassword" value="admin123" /> <input class="u-input" type="text" v-model="customApiUrl" maxlength="100" placeholder="请输入服务器地址"
<image class="u-icon-right" @blur="handleBlurInputUrl" />
:src="'/static/aidex/login/eye_' + (showPassword ? 'open' : 'close') + '.png'" </view>
@click="showPass()"></image> </template>
</view> <view class="list-call">
<div style="padding:15rpx 0 0;"> <view class="iconfont icon-avatar" style="font-size: 22px;color:#5473e8;"></view>
<!-- <view class="register"> <input class="u-input" type="text" v-model="login.username" maxlength="32"
:placeholder="$t('login.placeholderAccount')" value="admin" @input="clearInput" />
<u-icon :size="50" v-if="showClearIcon" name="close-circle-fill" color="#c0c4cc" class="u-clear-icon"
@click="clearIcon" />
</view>
<view class="list-call">
<view class="iconfont icon-key" style="font-size: 22px;color:#5473e8;"></view>
<input class="u-input" type="text" v-model="login.password" maxlength="32"
:placeholder="$t('login.placeholderPassword')" :password="!showPassword" value="admin123" />
<image class="u-icon-right" :src="'/static/aidex/login/eye_' + (showPassword ? 'open' : 'close') + '.png'"
@click="showPass()"></image>
</view>
<div style="padding:15rpx 0 0;">
<!-- <view class="register">
<navigator class="register-link" url="forget" open-type="navigate">{{$t('login.forget')}} <navigator class="register-link" url="forget" open-type="navigate">{{$t('login.forget')}}
</navigator> </navigator>
<navigator class="register-link" url="reg" open-type="navigate">{{$t('login.reg')}}</navigator> <navigator class="register-link" url="reg" open-type="navigate">{{$t('login.reg')}}</navigator>
</view> --> </view> -->
<u-checkbox v-model="remember" active-color="#5473e8">{{$t('login.autoLogin')}}</u-checkbox> <u-checkbox v-model="remember" active-color="#5473e8">{{ $t('login.autoLogin') }}</u-checkbox>
</div> </div>
</view> </view>
<button class="button" :disabled="login.loading" @click="submit('1')" :loading="login.loading"><text>登录</text></button> <button class="button" :disabled="login.loading" @click="submit('1')"
<!-- <view class="login-bottom-box"> :loading="login.loading"><text>登录</text></button>
<!-- <view class="login-bottom-box">
<u-divider> 更多登录方式 </u-divider> <u-divider> 更多登录方式 </u-divider>
<view class="oauth2"> <view class="oauth2">
<u-icon class="u-icon" size="100" color="#36c956" name="weixin-circle-fill" <u-icon class="u-icon" size="100" color="#36c956" name="weixin-circle-fill"
@ -66,8 +61,8 @@
登录即代表您已阅读并同意<u-link href="#">用户协议</u-link> <u-link href="#">隐私政策</u-link> 登录即代表您已阅读并同意<u-link href="#">用户协议</u-link> <u-link href="#">隐私政策</u-link>
</view> </view>
</view> --> </view> -->
<!-- </view> --> <!-- </view> -->
<!-- <view v-if="current === 1"> <!-- <view v-if="current === 1">
<view class="list"> <view class="list">
<view class="list-call"> <view class="list-call">
<view class="iconfont icon-shouji" style="font-size: 22px;color:#5473e8;"></view> <view class="iconfont icon-shouji" style="font-size: 22px;color:#5473e8;"></view>
@ -95,164 +90,294 @@
</view> </view>
</view> --> </view> -->
<!-- </div>--> <!-- </div>-->
<!-- <div v-if="loginType !== 'currentPhone'">--> <!-- <div v-if="loginType !== 'currentPhone'">-->
<!-- <view class="currentPhone-box">--> <!-- <view class="currentPhone-box">-->
<!-- <view class="number-text">183****1005</view>--> <!-- <view class="number-text">183****1005</view>-->
<!-- <view class="other-text">认证服务由中国移动提供</view>--> <!-- <view class="other-text">认证服务由中国移动提供</view>-->
<!-- <u-button type="primary" @click="submit('3')">本机号码一键登录</u-button>--> <!-- <u-button type="primary" @click="submit('3')">本机号码一键登录</u-button>-->
<!-- <u-button @click="qiehuanLogin()">其他登录方式</u-button>--> <!-- <u-button @click="qiehuanLogin()">其他登录方式</u-button>-->
<!-- </view>--> <!-- </view>-->
<!-- <view class="login-bottom-box">--> <!-- <view class="login-bottom-box">-->
<!-- <view class="copyright">--> <!-- <view class="copyright">-->
<!-- 登录即代表您已阅读并同意<u-link href="#">用户协议</u-link> <u-link href="#">隐私政策</u-link>--> <!-- 登录即代表您已阅读并同意<u-link href="#">用户协议</u-link> <u-link href="#">隐私政策</u-link>-->
<!-- </view>--> <!-- </view>-->
<!-- </view>--> <!-- </view>-->
<!-- </div>--> <!-- </div>-->
<u-picker <u-picker v-model="showApiUrlPicker" mode="selector" :range="apiUrlList" range-key="label"
v-model="showApiUrlPicker" @confirm="onApiUrlConfirm" @cancel="showApiUrlPicker = false"></u-picker>
mode="selector"
:range="apiUrlList"
range-key="label"
@confirm="onApiUrlConfirm"
@cancel="showApiUrlPicker = false"
></u-picker>
<!-- 版本信息显示 --> <!-- 版本信息显示 -->
<view class="version-info"> <view class="version-info">
<text class="version-text">版本: {{ appVersion }}</text> <text class="version-text">版本: {{ appVersion }}</text>
<text class="env-text" v-if="envName">{{ envName }}</text>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
/** /**
* Copyright (c) 2013-Now http://aidex.vip All rights reserved. * Copyright (c) 2013-Now http://aidex.vip All rights reserved.
*/ */
import config from '@/common/config.js'; import config from '@/common/config.js';
import base64 from '@/common/base64.js'; import base64 from '@/common/base64.js';
import util from '@/common/util.js'; import util from '@/common/util.js';
import md5 from '@/common/md5.js'; import md5 from '@/common/md5.js';
import manifest from '@/manifest.json'; import manifest from '@/manifest.json';
import { mapState } from 'vuex' import { mapState } from 'vuex'
export default { export default {
data() { data() {
return { return {
isDevelopment: config.isDevelopment, isDevelopment: config.isDevelopment,
showClearIcon: false, showClearIcon: false,
login: { login: {
loading: false, loading: false,
username: "", username: "",
password: "" password: ""
}, },
showApiUrlPicker: false, showApiUrlPicker: false,
// URL // URL
selectedApiUrl: config.isDevelopment ? config.devApiUrlOptions[0].value : config.productionApiUrl, selectedApiUrl: config.isDevelopment ? config.devApiUrlOptions[0].value : config.productionApiUrl,
customApiUrl: 'http://192.168.1.66:50002/hcscm/pda/v1', customApiUrl: 'http://192.168.1.66:50002/hcscm/pda/v1',
apiUrlList: config.isDevelopment ? config.devApiUrlOptions : [], apiUrlList: config.isDevelopment ? config.devApiUrlOptions : [],
phoneNo: '', phoneNo: '',
//username: '', //username: '',
//password: '', //password: '',
loginType: 'currentPhone', loginType: 'currentPhone',
showPassword: false, showPassword: false,
remember: true, remember: true,
isValidCodeLogin: false, isValidCodeLogin: false,
validCode: '', validCode: '',
imgValidCodeSrc: null, imgValidCodeSrc: null,
list: [{ list: [{
name: '用户名' name: '用户名'
}, { }, {
name: '手机号' name: '手机号'
}], }],
current: 0, current: 0,
activeColor: '#007aff', activeColor: '#007aff',
}; };
}, },
computed: { computed: {
appVersion() { appVersion() {
return manifest.versionName; return manifest.versionName;
}
}, },
envName() {
return process.env.VUE_APP_ENV_NAME || '';
}
},
onShow() { onShow() {
// URL // URL
if (config.isDevelopment) { if (config.isDevelopment) {
uni.getStorage({
key: 'ApiUrl',
success: (e) => {
util.updateApiUrl(e.data);
this.selectedApiUrl = e.data;
}
});
}
uni.getStorage({ uni.getStorage({
key: 'UserInfo', key: 'ApiUrl',
success: (e) => { success: (e) => {
console.log("---->>>" + e.data.username + '--->>' + e.data.password); util.updateApiUrl(e.data);
this.login.username = e.data.username; this.selectedApiUrl = e.data;
this.login.password = e.data.password;
}
})
},
onLoad() {
/*
this.$u.api.index({loginCheck: true}).then(res => {
if (res.code == '200'){
uni.reLaunch({
url: '/pages/sys/msg/index'
});
} }
}); });
*/ }
}, uni.getStorage({
methods: { key: 'UserInfo',
clearInput: function(event) { success: (e) => {
if (event.detail.value.length > 0) { console.log("---->>>" + e.data.username + '--->>' + e.data.password);
this.showClearIcon = true; this.login.username = e.data.username;
} else { this.login.password = e.data.password;
this.showClearIcon = false; }
} })
}, },
clearIcon: function() { onLoad() {
this.login.username = '' /*
this.$u.api.index({loginCheck: true}).then(res => {
if (res.code == '200'){
uni.reLaunch({
url: '/pages/sys/msg/index'
});
}
});
*/
},
methods: {
clearInput: function (event) {
if (event.detail.value.length > 0) {
this.showClearIcon = true;
} else {
this.showClearIcon = false; this.showClearIcon = false;
}, }
showServerPicker() { },
this.showApiUrlPicker = true; clearIcon: function () {
}, this.login.username = ''
getApiUrlLabel() { this.showClearIcon = false;
if (this.selectedApiUrl === 'custom') { },
return '自定义服务器'; showServerPicker() {
} this.showApiUrlPicker = true;
const option = this.apiUrlList.find(item => item.value === this.selectedApiUrl); },
return option ? option.label : '选择服务器'; getApiUrlLabel() {
}, if (this.selectedApiUrl === 'custom') {
return '自定义服务器';
}
const option = this.apiUrlList.find(item => item.value === this.selectedApiUrl);
return option ? option.label : '选择服务器';
},
onApiUrlConfirm(e) { onApiUrlConfirm(e) {
console.log('e',JSON.stringify(e)); console.log('e', JSON.stringify(e));
const selectedValue = this.apiUrlList[e[0]].value; const selectedValue = this.apiUrlList[e[0]].value;
console.log('selectedValue',selectedValue) console.log('selectedValue', selectedValue)
this.selectedApiUrl = selectedValue; this.selectedApiUrl = selectedValue;
this.showApiUrlPicker = false; this.showApiUrlPicker = false;
// store // store
if (selectedValue !== 'custom') { if (selectedValue !== 'custom') {
this.$store.dispatch('updateApiUrl', selectedValue); this.$store.dispatch('updateApiUrl', selectedValue);
} }
// store // store
else if (this.customApiUrl) { else if (this.customApiUrl) {
this.$store.dispatch('updateApiUrl', this.customApiUrl); this.$store.dispatch('updateApiUrl', this.customApiUrl);
} }
}, },
showPass() { showPass() {
this.showPassword = !this.showPassword; this.showPassword = !this.showPassword;
}, },
qiehuanLogin() { qiehuanLogin() {
this.loginType = 'other' this.loginType = 'other'
}, },
clickchecked() {
var that = this
this.remember = !this.remember
if (that.remember == true) {
if ((this.login.username.length > 0) && (this.login.password.length > 0)) {
uni.setStorage({
key: 'UserInfo',
data: that.login
})
}
}
},
onClickItem(index) {
this.current = index;
},
refreshImgValidCode(e) {
if (this.vuex_token == '') {
this.$u.api.index().then(res => {
this.imgValidCodeSrc = this.vuex_config.baseUrl + '/validCode?__sid=' +
res.sessionid + '&t=' + new Date().getTime();
});
} else {
this.imgValidCodeSrc = this.vuex_config.baseUrl + '/validCode?__sid=' +
this.vuex_token + '&t=' + new Date().getTime();
}
this.validCode = '';
},
nextStep() {
//
uni.showLoading({
title: '正在获取验证码',
mask: true
})
this.$u.api.sendCode({
phoneNo: this.phoneNo,
validCodeType: '2'
})
.then(res => {
if (res.code == '200') {
setTimeout(() => {
uni.navigateTo({
url: '/pages/sys/login/code?phoneNo=' + this.phoneNo
});
}, 500);
} else {
this.$u.toast(res.msg);
setTimeout(() => {
uni.navigateTo({
url: '/pages/sys/login/code?phoneNo=' + this.phoneNo
});
}, 500);
}
});
},
submit(loginType = '1') {
uni.showLoading({
title: '登录中...'
});
let currentApiUrl;
if (config.isDevelopment) {
// 使URL
currentApiUrl = this.selectedApiUrl === 'custom' ? this.customApiUrl : this.selectedApiUrl;
if (!currentApiUrl || currentApiUrl.length === 0) {
this.$u.toast('请输入服务器地址');
return;
}
// storeURL
this.$store.dispatch('updateApiUrl', currentApiUrl);
} else {
// 使URL
currentApiUrl = config.productionApiUrl;
}
if (this.login.username.length == 0) {
this.$u.toast('请输入账号');
return;
}
if (this.login.password.length == 0) {
this.$u.toast('请输入密码');
return;
}
console.log('开始请求', currentApiUrl)
this.login.loading = true
// baseUrlAPI URL
const originalBaseUrl = this.$u.http.config.baseUrl;
this.$u.http.setConfig({ baseUrl: currentApiUrl });
this.$u.api.pdaLogin({
'phone': this.login.username,
'password': this.login.password,
}).then((res) => {
console.log('login res', res)
var aLoginUserData = res;
//console.log('--aLoginUserData->>' + JSON.stringify(aLoginUserData));
// apiurl
if (config.isDevelopment) {
uni.setStorage({
key: 'ApiUrl',
data: currentApiUrl
});
util.updateApiUrl(currentApiUrl);
}
// token
uni.setStorageSync('RemoteTokenData', aLoginUserData);
uni.setStorage({
key: 'userToken',
data: {
Token: aLoginUserData.token,
}
});
getApp().globalData.Token = aLoginUserData.token;
getApp().globalData.EmployeeID = aLoginUserData.user_id;
getApp().globalData.IsSaleUserStatus = 0;
getApp().globalData.LoginID = aLoginUserData.user_id;
getApp().globalData.LoginName = aLoginUserData.user_name;
getApp().globalData.PlanDepartmentID = aLoginUserData.default_sale_system_id;
getApp().globalData.PlanDepartmentName = aLoginUserData.default_sale_system_name;
getApp().globalData.UserGroup = '';
getApp().globalData.StoreNameID = aLoginUserData.default_physical_warehouse_id;
getApp().globalData.StoreName = aLoginUserData.default_physical_warehouse_name;
getApp().globalData.StoreTypeNo = '';
setTimeout(() => {
uni.reLaunch({
url: '/pages/sys/workbench/index'
});
}, 500);
clickchecked() {
var that = this var that = this
this.remember = !this.remember
if (that.remember == true) { if (that.remember == true) {
if ((this.login.username.length > 0) && (this.login.password.length > 0)) { if ((this.login.username.length > 0) && (this.login.password.length > 0)) {
uni.setStorage({ uni.setStorage({
@ -260,283 +385,157 @@
data: that.login data: that.login
}) })
} }
}
},
onClickItem(index) {
this.current = index;
},
refreshImgValidCode(e) {
if (this.vuex_token == '') {
this.$u.api.index().then(res => {
this.imgValidCodeSrc = this.vuex_config.baseUrl + '/validCode?__sid=' +
res.sessionid + '&t=' + new Date().getTime();
});
} else {
this.imgValidCodeSrc = this.vuex_config.baseUrl + '/validCode?__sid=' +
this.vuex_token + '&t=' + new Date().getTime();
} }
this.validCode = '';
}, uni.showToast({
nextStep() { icon: 'none',
// title: '登录成功!'
uni.showLoading({
title: '正在获取验证码',
mask: true
})
this.$u.api.sendCode({
phoneNo: this.phoneNo,
validCodeType: '2'
})
.then(res => {
if (res.code == '200') {
setTimeout(() => {
uni.navigateTo({
url: '/pages/sys/login/code?phoneNo=' + this.phoneNo
});
}, 500);
} else {
this.$u.toast(res.msg);
setTimeout(() => {
uni.navigateTo({
url: '/pages/sys/login/code?phoneNo=' + this.phoneNo
});
}, 500);
}
});
},
submit(loginType = '1') {
uni.showLoading({
title: '登录中...'
}); });
this.$store.dispatch('initNotification');
let currentApiUrl; setTimeout(function () {
uni.hideLoading();
if (config.isDevelopment) { }, 1000);
// 使URL }).catch((error) => {
currentApiUrl = this.selectedApiUrl === 'custom' ? this.customApiUrl : this.selectedApiUrl; console.log('login error', error)
if (!currentApiUrl || currentApiUrl.length === 0) { uni.showToast({
this.$u.toast('请输入服务器地址'); icon: 'none',
return; title: '' + (error.msg || error.message || '')
} });
// storeURL setTimeout(function () {
this.$store.dispatch('updateApiUrl', currentApiUrl); uni.hideLoading();
} else { }, 5000);
// 使URL // baseUrl
currentApiUrl = config.productionApiUrl; this.$u.http.setConfig({ baseUrl: originalBaseUrl });
} }).finally(() => {
this.login.loading = false;
if (this.login.username.length == 0) { })
this.$u.toast('请输入账号'); },
return; wxLogin(res) {
} this.$u.toast('微信登录');
if (this.login.password.length == 0) { },
this.$u.toast('请输入密码'); qqLogin() {
return; this.$u.toast('QQ 登录');
} },
console.log('开始请求', currentApiUrl) handleBlurInputUrl(e) {
this.login.loading = true // URL
if (config.isDevelopment) {
// baseUrlAPI URL const url = e.detail.value.trim();
const originalBaseUrl = this.$u.http.config.baseUrl; if (url) {
this.$u.http.setConfig({ baseUrl: currentApiUrl }); this.customApiUrl = url;
//
this.$u.api.pdaLogin({
'phone': this.login.username,
'password': this.login.password,
}).then((res) => {
console.log('login res',res)
var aLoginUserData = res;
//console.log('--aLoginUserData->>' + JSON.stringify(aLoginUserData));
// apiurl
if (config.isDevelopment) {
uni.setStorage({
key: 'ApiUrl',
data: currentApiUrl
});
util.updateApiUrl(currentApiUrl);
}
// token
uni.setStorageSync('RemoteTokenData', aLoginUserData);
uni.setStorage({ uni.setStorage({
key:'userToken', key: 'ApiUrl',
data: { data: url
Token: aLoginUserData.token,
}
}); });
util.updateApiUrl(url);
getApp().globalData.Token = aLoginUserData.token;
getApp().globalData.EmployeeID = aLoginUserData.user_id;
getApp().globalData.IsSaleUserStatus = 0;
getApp().globalData.LoginID = aLoginUserData.user_id;
getApp().globalData.LoginName = aLoginUserData.user_name;
getApp().globalData.PlanDepartmentID = aLoginUserData.default_sale_system_id;
getApp().globalData.PlanDepartmentName = aLoginUserData.default_sale_system_name;
getApp().globalData.UserGroup = '';
getApp().globalData.StoreNameID = aLoginUserData.default_physical_warehouse_id;
getApp().globalData.StoreName = aLoginUserData.default_physical_warehouse_name;
getApp().globalData.StoreTypeNo = '';
setTimeout(() => {
uni.reLaunch({
url: '/pages/sys/workbench/index'
});
}, 500);
var that = this
if (that.remember == true) {
if ((this.login.username.length > 0) && (this.login.password.length > 0)) {
uni.setStorage({
key: 'UserInfo',
data: that.login
})
}
}
uni.showToast({
icon: 'none',
title: '登录成功!'
});
this.$store.dispatch('initNotification');
setTimeout(function() {
uni.hideLoading();
}, 1000);
}).catch((error) => {
console.log('login error', error)
uni.showToast({
icon: 'none',
title: '' + (error.msg || error.message || '')
});
setTimeout(function() {
uni.hideLoading();
}, 5000);
// baseUrl
this.$u.http.setConfig({ baseUrl: originalBaseUrl });
}).finally(() => {
this.login.loading = false;
})
},
wxLogin(res) {
this.$u.toast('微信登录');
},
qqLogin() {
this.$u.toast('QQ 登录');
},
handleBlurInputUrl(e) {
// URL
if (config.isDevelopment) {
const url = e.detail.value.trim();
if (url) {
this.customApiUrl = url;
//
uni.setStorage({
key: 'ApiUrl',
data: url
});
util.updateApiUrl(url);
}
} }
}, }
} },
}; }
};
</script> </script>
<style lang="scss"> <style lang="scss">
@import 'index.scss'; @import 'index.scss';
.server-selector {
display: flex; .server-selector {
justify-content: space-between; display: flex;
align-items: center; justify-content: space-between;
padding: 10rpx 0; align-items: center;
border-bottom: 1px solid #eee; padding: 10rpx 0;
} border-bottom: 1px solid #eee;
.list-call {
.u-select {
margin-bottom: 10rpx;
}
.u-input {
margin-top: 10rpx;
}
} }
.haotoplogo {
width: 300rpx; .list-call {
height: 150rpx; .u-select {
// max-width: 5%; margin-bottom: 10rpx;
// max-height: 5%;
margin: 10rpx auto 10rpx auto;
}
.logoimg{
width: 100%;
height: 100%;
} }
.logo { .u-input {
width: 80%; margin-top: 10rpx;
font-size: 64rpx; }
color: #5473e8; }
margin: 80rpx auto 80rpx auto;
.haotoplogo {
width: 300rpx;
height: 150rpx;
// max-width: 5%;
// max-height: 5%;
margin: 10rpx auto 10rpx auto;
}
.logoimg {
width: 100%;
height: 100%;
}
.logo {
width: 80%;
font-size: 64rpx;
color: #5473e8;
margin: 80rpx auto 80rpx auto;
}
.list-call-icon {
color: #ff0000;
}
.currentPhone-box {
text-align: center;
padding: 40rpx 80rpx;
.number-text {
color: #000000;
font-size: 60rpx;
} }
.list-call-icon { .other-text {
color: #ff0000; color: #999999;
font-size: 26rpx;
padding: 20rpx 0;
} }
.currentPhone-box { .u-btn {
text-align: center; margin: 30rpx auto;
padding: 40rpx 80rpx;
.number-text {
color: #000000;
font-size: 60rpx;
}
.other-text {
color: #999999;
font-size: 26rpx;
padding: 20rpx 0;
}
.u-btn {
margin: 30rpx auto;
}
.u-hairline-border {
border: 1px solid #fff;
}
} }
.register { .u-hairline-border {
display: inline-block; border: 1px solid #fff;
color: #5473e8;
height: 40rpx;
line-height: 40rpx;
font-size: 28rpx;
float: right;
margin-top: 6rpx;
} }
}
.register-link { .register {
float: right; display: inline-block;
padding: 0 16rpx; color: #5473e8;
height: 40rpx;
line-height: 40rpx;
font-size: 28rpx;
float: right;
margin-top: 6rpx;
}
.register-link {
float: right;
padding: 0 16rpx;
}
.reg-link {
display: inline-block;
color: #5473e8;
}
.oauth2 {
display: flex;
flex-direction: row;
justify-content: space-around;
margin: 0rpx 100rpx 30rpx;
image {
height: 80rpx;
width: 80rpx;
} }
}
.reg-link {
display: inline-block;
color: #5473e8;
}
.oauth2 {
display: flex;
flex-direction: row;
justify-content: space-around;
margin: 0rpx 100rpx 30rpx;
image {
height: 80rpx;
width: 80rpx;
}
}
.u-tabs { .u-tabs {
padding: 0 70rpx; padding: 0 70rpx;
} }
@ -544,11 +543,20 @@
.version-info { .version-info {
text-align: center; text-align: center;
margin-top: 30rpx; margin-top: 30rpx;
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
} }
.version-text { .version-text {
font-size: 24rpx; font-size: 24rpx;
color: #999999; color: #999999;
} }
</style>
.env-text {
font-size: 24rpx;
color: #5473e8;
margin-left: 10rpx;
}
</style>

View File

@ -9,12 +9,14 @@ module.exports = {
console.log('VUE_APP_UPGRADE_NAME',JSON.stringify(process.env.VUE_APP_UPGRADE_NAME)) console.log('VUE_APP_UPGRADE_NAME',JSON.stringify(process.env.VUE_APP_UPGRADE_NAME))
console.log('VUE_APP_PRODUCTION_API_URL',JSON.stringify(process.env.VUE_APP_PRODUCTION_API_URL)) console.log('VUE_APP_PRODUCTION_API_URL',JSON.stringify(process.env.VUE_APP_PRODUCTION_API_URL))
console.log('VUE_APP_DEV_API_URL',JSON.stringify(process.env.VUE_APP_DEV_API_URL)) console.log('VUE_APP_DEV_API_URL',JSON.stringify(process.env.VUE_APP_DEV_API_URL))
console.log('VUE_APP_ENV_NAME',JSON.stringify(process.env.VUE_APP_ENV_NAME))
Object.assign(definitions[0], { Object.assign(definitions[0], {
'process.env': { 'process.env': {
...definitions[0]['process.env'], ...definitions[0]['process.env'],
VUE_APP_UPGRADE_NAME: JSON.stringify(process.env.VUE_APP_UPGRADE_NAME), VUE_APP_UPGRADE_NAME: JSON.stringify(process.env.VUE_APP_UPGRADE_NAME),
VUE_APP_PRODUCTION_API_URL: JSON.stringify(process.env.VUE_APP_PRODUCTION_API_URL), VUE_APP_PRODUCTION_API_URL: JSON.stringify(process.env.VUE_APP_PRODUCTION_API_URL),
VUE_APP_DEV_API_URL: JSON.stringify(process.env.VUE_APP_DEV_API_URL), VUE_APP_DEV_API_URL: JSON.stringify(process.env.VUE_APP_DEV_API_URL),
VUE_APP_ENV_NAME: JSON.stringify(process.env.VUE_APP_ENV_NAME),
} }
}) })
return definitions return definitions