代码更新
This commit is contained in:
@@ -1,13 +1,8 @@
|
||||
<template>
|
||||
<view class="login-wrapper">
|
||||
|
||||
<!-- 切换环境提示 -->
|
||||
<EnvChangeTips ref="envChangeTipsRef" @change="vdata.siteInfos = storageManage.siteInfos()" />
|
||||
|
||||
<view class="login-top">
|
||||
<text>欢迎回来,请登录</text>
|
||||
<image @tap="envChangeTipsRef.tapFunc()" style="width: 320rpx; height: 76rpx"
|
||||
:src="vdata.siteInfos.appTopImgUrl" />
|
||||
</view>
|
||||
<view class="login-bottom jeepay-form">
|
||||
|
||||
@@ -111,47 +106,20 @@
|
||||
</uni-forms>
|
||||
|
||||
<view class="agreement-policy">
|
||||
<JeepayCheckbox v-model:checked="vdata.isSelectedAgreement" />
|
||||
<up-checkbox label="" name="agree" usedAlone v-model:checked="vdata.isSelectedAgreement" />
|
||||
同意
|
||||
<text class="agreement" @click="toPrivacy">《用户服务协议》</text>
|
||||
<text>与</text>
|
||||
<text class="policy" @click="toPrivacy">《隐私政策》</text>
|
||||
</view>
|
||||
|
||||
|
||||
<!-- <view class="agreement-policy">
|
||||
<JeepayCheckbox v-model:checked="vdata.isSelectedAgreement" />
|
||||
同意
|
||||
<text class="agreement" @click="go.to('PAGES_STATIC_AGREEMENT')">《用户服务协议》</text>
|
||||
<text>与</text>
|
||||
<text class="policy" @click="toPrivacy">《隐私政策》</text>
|
||||
<text class="policy" @click="go.to('PAGES_STATIC_POLICY')">《隐私政策》</text>
|
||||
</view> -->
|
||||
|
||||
|
||||
<Button @tap="loginFunc">登录</Button>
|
||||
|
||||
<!-- <view class="register-box">
|
||||
<view class="register">
|
||||
<text>还没有账号?</text> <text @tap="go.to('PAGES_REGISTER')">去注册></text>
|
||||
</view>
|
||||
<view class="forget" @tap="go.to('PAGES_FORGET_PASSWORD')">忘记密码</view>
|
||||
</view>
|
||||
<view class="swidth-login" @click="changeLoginType">
|
||||
{{ vdata.loginType == 'pwd' ? '短信验证码登录' : '账号密码登录' }}
|
||||
<image src="@/static/login/icon-arrow-left.svg"></image>
|
||||
</view> -->
|
||||
<button class="btn" hover-class="hover-button" @tap="loginFunc">登录</button>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<JAgree service="PAGES_STATIC_AGREEMENT" privacy="PAGES_FORGET_PASSWORD" ref="refAgr"
|
||||
@agree="vdata.isSelectedAgreement = true" />
|
||||
</template>
|
||||
<script setup>
|
||||
import {
|
||||
encrypt
|
||||
} from '@/commons/utils/rsaEncrypt.js'
|
||||
|
||||
import { encrypt } from '@/commons/utils/rsaEncrypt.js'
|
||||
import {
|
||||
ref,
|
||||
reactive,
|
||||
@@ -159,48 +127,34 @@
|
||||
watch
|
||||
} from 'vue';
|
||||
import {
|
||||
$loginByPwd,
|
||||
$phoneCodeLogin,
|
||||
$userInfo,
|
||||
$sendSms,
|
||||
$getSiteInfos,
|
||||
$getUploadImgSize,
|
||||
$isCode
|
||||
$sendSms
|
||||
} from '@/http/apiManager.js';
|
||||
import { login, authCaptcha } from '@/api/login.js';
|
||||
import storageManage from '@/commons/utils/storageManage.js'
|
||||
import infoBox from '@/commons/utils/infoBox.js';
|
||||
import go from '@/commons/utils/go.js'
|
||||
import timer from '@/commons/utils/timer.js'
|
||||
import formUtil from '@/commons/utils/formUtil.js'
|
||||
import EnvChangeTips from './components/EnvChangeTips.vue'
|
||||
import dayjs from 'dayjs' //时间格式库
|
||||
import {
|
||||
getExtStoreId
|
||||
} from "@/commons/utils/versionManage.js"
|
||||
import {
|
||||
$login
|
||||
} from '@/http/newApi/login.js';
|
||||
import {
|
||||
login,
|
||||
getCodeImg
|
||||
} from '@/http/yskApi/login.js';
|
||||
|
||||
|
||||
const accountType = reactive({
|
||||
list: [{
|
||||
label: '商户',
|
||||
value: 'merchant'
|
||||
value: 0
|
||||
},
|
||||
{
|
||||
label: '员工',
|
||||
value: 'staff'
|
||||
value: 1
|
||||
},
|
||||
],
|
||||
sel: 0
|
||||
})
|
||||
|
||||
const loginFormRef = ref()
|
||||
const envChangeTipsRef = ref()
|
||||
const refAgr = ref()
|
||||
const rules = {
|
||||
merchantName: {
|
||||
rules: [formUtil.rules.requiredInputShowToast('商户号')],
|
||||
@@ -227,7 +181,6 @@
|
||||
}
|
||||
|
||||
const vdata = reactive({
|
||||
|
||||
isShowPwd: false, // 是否显示密码
|
||||
loginType: 'pwd', // 类型切换: pwd or sms
|
||||
isShowSafetyCode: false, // 是否显示安全码输入框
|
||||
@@ -235,16 +188,13 @@
|
||||
sendMsgText: '发送验证码',
|
||||
isSelectedAgreement: false, // 勾选隐私协议
|
||||
|
||||
siteInfos: storageManage.siteInfos() || {},
|
||||
|
||||
formData: {
|
||||
username: '', // 账密登录: 用户名
|
||||
pwd: '', // 账密登录: 密码
|
||||
rememberMe: false,
|
||||
code: '',
|
||||
uuid: '',
|
||||
merchantName: '',
|
||||
loginType: 'merchant'
|
||||
loginType: 1
|
||||
},
|
||||
|
||||
})
|
||||
@@ -268,26 +218,15 @@
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
|
||||
const getCode = () => {
|
||||
getCodeImg().then(res => {
|
||||
vdata.formData.img = res.img
|
||||
vdata.formData.uuid = res.uuid
|
||||
})
|
||||
}
|
||||
|
||||
getCode()
|
||||
|
||||
watch(() => accountType.sel, (newval) => {
|
||||
if (newval == 1) {
|
||||
vdata.formData.merchantName = uni.getStorageSync('merchantName') || ''
|
||||
} else {
|
||||
vdata.formData.username = ''
|
||||
}
|
||||
})
|
||||
onMounted(() => {
|
||||
// getExtStoreId()
|
||||
|
||||
// 查询是否包含网站信息, 否则更新
|
||||
|
||||
// if(!vdata.siteInfos || Object.keys(vdata.siteInfos) <= 0){
|
||||
// $getSiteInfos().then( ( { bizData } ) => {
|
||||
// vdata.siteInfos = storageManage.siteInfos(bizData)
|
||||
// })
|
||||
// }
|
||||
getCode()
|
||||
// 获取商户信息,有就回显
|
||||
let info = uni.getStorageSync('MerchantId')
|
||||
if (info.merchantName) {
|
||||
@@ -295,12 +234,21 @@
|
||||
vdata.formData.username = info.username
|
||||
}
|
||||
})
|
||||
|
||||
// 切换登录方式
|
||||
function changeLoginType() {
|
||||
vdata.loginType = vdata.loginType == 'pwd' ? 'sms' : 'pwd';
|
||||
|
||||
/**
|
||||
* 获取验证码
|
||||
*/
|
||||
const getCode = () => {
|
||||
authCaptcha().then(res => {
|
||||
console.log(res)
|
||||
vdata.formData.img = res.code
|
||||
vdata.formData.uuid = res.uuid
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
function loginFunc() {
|
||||
|
||||
// 表单验证
|
||||
@@ -311,17 +259,20 @@
|
||||
}
|
||||
let loginPromise = null;
|
||||
if (vdata.loginType == 'pwd') { // 用户名密码登录
|
||||
// loginPromise = $loginByPwd(vdata.formData.username, vdata.formData.pwd, vdata.formData.safetyCode)
|
||||
loginPromise = login({
|
||||
let params = {
|
||||
username: vdata.formData.username,
|
||||
password: encrypt(vdata.formData.pwd),
|
||||
rememberMe: false,
|
||||
password: vdata.formData.pwd,
|
||||
// password: encrypt(vdata.formData.pwd),
|
||||
code: vdata.formData.code,
|
||||
uuid: vdata.formData.uuid,
|
||||
merchantName: vdata.formData.merchantName,
|
||||
loginType: accountType.list[accountType.sel].value
|
||||
})
|
||||
|
||||
}
|
||||
//商户号参数
|
||||
if ( accountType.sel == 1 ) {
|
||||
params.merchantName = vdata.formData.merchantName
|
||||
}
|
||||
loginPromise = login(params)
|
||||
|
||||
} else if (vdata.loginType == 'sms') { // 短信验证码登录
|
||||
loginPromise = $phoneCodeLogin(vdata.formData.loginPhone, vdata.formData.smsCode)
|
||||
}
|
||||
@@ -333,6 +284,7 @@
|
||||
|
||||
// 请求后的操作
|
||||
loginPromise.then(res => {
|
||||
console.log(res)
|
||||
// 登录成功
|
||||
loginFinishFunc(res)
|
||||
// 保存商户号
|
||||
@@ -362,28 +314,23 @@
|
||||
})
|
||||
// #endif
|
||||
}
|
||||
watch(() => accountType.sel, (newval) => {
|
||||
if (newval == 1) {
|
||||
vdata.formData.merchantName = uni.getStorageSync('merchantName') || ''
|
||||
} else {
|
||||
vdata.formData.username = ''
|
||||
}
|
||||
})
|
||||
// 封装登录成功后的操作
|
||||
|
||||
/**
|
||||
* 封装登录成功后的操作
|
||||
* @param {Object} loginBizData
|
||||
*/
|
||||
async function loginFinishFunc(loginBizData) {
|
||||
// 保存 token
|
||||
storageManage.setLogin(loginBizData)
|
||||
storageManage.token(loginBizData.token)
|
||||
storageManage.shopId(loginBizData.shopId)
|
||||
storageManage.shopUserId(loginBizData.user.user.id)
|
||||
storageManage.userInfo(loginBizData)
|
||||
var time1 = new Date();
|
||||
var time2 = new Date(loginBizData.expireDate);
|
||||
let les = (time1.getTime() - time2.getTime()) / 86400000;
|
||||
uni.showToast({
|
||||
title: '店铺账号有限期至' + loginBizData.expireDate + ',店铺账号到期剩余' + Math.abs(les.toFixed(0)) + '天!',
|
||||
icon: 'none'
|
||||
});
|
||||
storageManage.token(loginBizData.tokenInfo)
|
||||
|
||||
// var time1 = new Date();
|
||||
// var time2 = new Date(loginBizData.expireDate);
|
||||
// let les = (time1.getTime() - time2.getTime()) / 86400000;
|
||||
// uni.showToast({
|
||||
// title: '店铺账号有限期至' + loginBizData.expireDate + ',店铺账号到期剩余' + Math.abs(les.toFixed(0)) + '天!',
|
||||
// icon: 'none'
|
||||
// });
|
||||
|
||||
setTimeout(() => {
|
||||
// 跳转到首页
|
||||
@@ -394,7 +341,9 @@
|
||||
|
||||
}
|
||||
|
||||
// 点击发送验证码的函数
|
||||
/**
|
||||
* 点击发送验证码的函数
|
||||
*/
|
||||
function sendSmscodeFunc() {
|
||||
// 按钮禁用
|
||||
if (!vdata.allowSendMsgFlag) {
|
||||
@@ -455,18 +404,12 @@
|
||||
background: url("/static/indexImg/user-bg.svg") center center no-repeat;
|
||||
background-size: cover;
|
||||
|
||||
text:first-child {
|
||||
text{
|
||||
margin-bottom: 30rpx;
|
||||
font-size: 38rpx;
|
||||
font-weight: 500;
|
||||
color: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
|
||||
text:last-child {
|
||||
font-size: 50rpx;
|
||||
font-weight: 600;
|
||||
color: #48C0FF;
|
||||
}
|
||||
}
|
||||
|
||||
.login-bottom {
|
||||
@@ -542,5 +485,20 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
.btn {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 110rpx;
|
||||
font-size: 33rpx;
|
||||
font-weight: 500;
|
||||
color: $J-color-tff;
|
||||
border-radius: 20rpx;
|
||||
background: $jeepay-bg-primary;
|
||||
box-shadow: 0 20rpx 60rpx -20rpx rgba(0,84,210,0.5);
|
||||
&.hover-button {
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user