源文件
This commit is contained in:
151
jeepay-ui-uapp-face/pages/login/components/EnvChangeTips.vue
Normal file
151
jeepay-ui-uapp-face/pages/login/components/EnvChangeTips.vue
Normal file
@@ -0,0 +1,151 @@
|
||||
<!--
|
||||
环境变量切换组件
|
||||
|
||||
@author terrfly
|
||||
@site https://www.jeequan.com
|
||||
@date 2022/04/12 10:14
|
||||
-->
|
||||
<template>
|
||||
<view>
|
||||
<!-- 当包含环境变量 && 不是生产环境时 -->
|
||||
<view
|
||||
class="login-test"
|
||||
v-if="
|
||||
vdata.currentEnvEnum &&
|
||||
vdata.currentEnvEnum != appConfig.ENV_ENUM.PRODUCTION
|
||||
"
|
||||
><text>{{ vdata.currentEnvEnum }}</text></view
|
||||
>
|
||||
<!-- 切换环境提示 -->
|
||||
<uni-popup ref="uniPopupRef" :mask-click="false" :open="true">
|
||||
<view class="uni-popup-dialog">
|
||||
<image
|
||||
@tap="uniClose"
|
||||
class="uni-dialog-close"
|
||||
src="/static/indexImg/del.svg"
|
||||
mode="scaleToFill"
|
||||
/>
|
||||
<view class="uni-dialog-button-box">
|
||||
<view
|
||||
class="uni-dialog-button"
|
||||
style="border-bottom: 2rpx solid #e1e1e1"
|
||||
@click="changeEnvFunc(appConfig.ENV_ENUM.DEVELOPMENT)"
|
||||
><text>开发环境</text></view
|
||||
>
|
||||
<view
|
||||
class="uni-dialog-button"
|
||||
style="border-bottom: 2rpx solid #e1e1e1"
|
||||
@click="changeEnvFunc(appConfig.ENV_ENUM.TEST)"
|
||||
><text>测试环境</text></view
|
||||
>
|
||||
<view
|
||||
class="uni-dialog-button"
|
||||
style="border-bottom: 2rpx solid #e1e1e1"
|
||||
@click="changeEnvFunc(appConfig.ENV_ENUM.DEMO)"
|
||||
><text>演示环境</text></view
|
||||
>
|
||||
<view
|
||||
class="uni-dialog-button"
|
||||
@click="changeEnvFunc(appConfig.ENV_ENUM.PRODUCTION)"
|
||||
><text>生产环境</text></view
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import { reactive, ref, onMounted } from 'vue'
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
import envConfig from '@/env/config.js'
|
||||
import storageManage from '@/commons/utils/storageManage.js'
|
||||
|
||||
|
||||
const uniPopupRef = ref()
|
||||
|
||||
// emit
|
||||
const emit = defineEmits(['change'])
|
||||
|
||||
const vdata = reactive({
|
||||
currentEnvEnum: '', // 当前环境变量
|
||||
count: 0, // 当前点击次数
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
vdata.currentEnvEnum = storageManage.env()
|
||||
})
|
||||
|
||||
// 父组件的点击事件
|
||||
function tapFunc() {
|
||||
vdata.count++
|
||||
if (vdata.count >= 10) {
|
||||
vdata.count = 0
|
||||
uniPopupRef.value.open()
|
||||
}
|
||||
}
|
||||
|
||||
// 改变环境函数
|
||||
function changeEnvFunc(envMode) {
|
||||
vdata.currentEnvEnum = envMode //显示信息
|
||||
envConfig.changeEnv(envMode) //更改请求包
|
||||
storageManage.env(envMode) // 改变存储
|
||||
|
||||
|
||||
|
||||
uniPopupRef.value.close() //弹层关闭
|
||||
}
|
||||
// 关闭弹窗
|
||||
function uniClose() {
|
||||
uniPopupRef.value.close()
|
||||
}
|
||||
defineExpose({ tapFunc })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.uni-popup-dialog {
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
width: 500rpx;
|
||||
height: 600rpx;
|
||||
overflow: hidden;
|
||||
border-radius: 30rpx;
|
||||
background-color: #ffffff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
.uni-dialog-close {
|
||||
position: absolute;
|
||||
top: 20rpx;
|
||||
right: 20rpx;
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
}
|
||||
.uni-dialog-button-box {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
padding: 0 40rpx;
|
||||
.uni-dialog-button {
|
||||
width: 100%;
|
||||
height: 150rpx;
|
||||
line-height: 150rpx;
|
||||
text {
|
||||
font-size: 40rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.login-test {
|
||||
position: absolute;
|
||||
bottom: 70rpx;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
text {
|
||||
color: #666f80;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
115
jeepay-ui-uapp-face/pages/login/login.vue
Normal file
115
jeepay-ui-uapp-face/pages/login/login.vue
Normal file
@@ -0,0 +1,115 @@
|
||||
<template>
|
||||
<view class="login-header">
|
||||
<image src="/static/logo.png" mode="scaleToFill" @tap="switchEnv" />
|
||||
<view class="login-title">计全收银Pro</view>
|
||||
</view>
|
||||
<LoginInput title="账号" place="请输入登录名/手机号" require ref="refAccount" v-model:value="vdata.username" />
|
||||
<LoginInput title="密码" password place="请输入密码" require type="password" ref="refPwd" v-model:value="vdata.pwd" />
|
||||
<view class="button-main">
|
||||
<JButton @click="submit">登录</JButton>
|
||||
</view>
|
||||
<!-- #ifdef MP-ALIPAY -->
|
||||
<view class="support-content">
|
||||
<view class="sup-title">技术支持:</view>
|
||||
<view class="phone-number">{{ vdata.phone || '18611727422' }}</view>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
<EnvChangeTips ref="refEnv" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { $login, $userInfo, $getCompanyInfos } from '@/http/apiManager'
|
||||
import EnvChangeTips from './components/EnvChangeTips.vue'
|
||||
import storageManage from '@/commons/utils/storageManage.js'
|
||||
const refAccount = ref(null)
|
||||
const refPwd = ref(null)
|
||||
const refEnv = ref(null)
|
||||
const vdata = reactive({})
|
||||
onMounted(() => {
|
||||
// #ifdef MP-WEIXIN
|
||||
wxfaceapp.checkWxFacePayOsInfo({
|
||||
success(res) {
|
||||
console.log('success [checkWxFacePayOsInfo]', res)
|
||||
storageManage.deviceNo(res.osSerialNumber) //本地存储写入 设备号
|
||||
console.log(storageManage.deviceNo())
|
||||
},
|
||||
fail(err) {
|
||||
console.log('fail [checkWxFacePayOsInfo]', err)
|
||||
},
|
||||
})
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
my.ix.getSysProp({
|
||||
key: 'ro.serialno',
|
||||
success: (r) => {
|
||||
console.log('r', r)
|
||||
storageManage.deviceNo(r.value) //本地存储写入 设备号
|
||||
},
|
||||
})
|
||||
// #endif
|
||||
$getCompanyInfos().then(({ bizData }) => {
|
||||
const { siteInfo } = bizData
|
||||
vdata.phone = siteInfo.companyTel
|
||||
})
|
||||
})
|
||||
const submit = () => {
|
||||
console.log('submit')
|
||||
if (refAccount.value.check() && refPwd.value.check()) {
|
||||
$login(vdata).then(({ bizData }) => {
|
||||
// 保存 token
|
||||
storageManage.token(bizData.iToken)
|
||||
// 请求用户信息
|
||||
return $userInfo().then(({ bizData }) => {
|
||||
// 保存用户数据
|
||||
storageManage.userInfo(bizData)
|
||||
// 存储设备号
|
||||
// #ifdef MP-WEIXIN
|
||||
//跳转首页
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index',
|
||||
})
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
console.log('执行')
|
||||
uni.reLaunch({
|
||||
url: '/pages/aliIndex/index',
|
||||
})
|
||||
// #endif
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
const switchEnv = () => refEnv.value.tapFunc()
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.login-header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
image {
|
||||
margin-top: 80rpx;
|
||||
width: 260rpx;
|
||||
height: 260rpx;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
margin-bottom: 50rpx;
|
||||
font-weight: 700;
|
||||
font-size: 46rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.button-main {
|
||||
margin-top: 80rpx;
|
||||
}
|
||||
.support-content {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 50rpx;
|
||||
font-size: 30rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user