登录保存商户信息

This commit is contained in:
duan
2024-10-21 16:55:26 +08:00
parent 9c97a912a7
commit c6b4e503dc
11 changed files with 129 additions and 68 deletions

View File

@@ -14,7 +14,8 @@
<!-- 不需要label, 需要修改 label-width="0" -->
<uni-forms ref="loginFormRef" label-width="0" :model="vdata.formData" :rules="rules">
<view class="u-p-b-30">
<my-tabs size="large" @change="accountTypeChange" v-model="accountType.sel" :list="accountType.list" textKey="label"></my-tabs>
<my-tabs size="large" @change="accountTypeChange" v-model="accountType.sel" :list="accountType.list"
textKey="label"></my-tabs>
</view>
<view v-if="vdata.loginType == 'pwd' ">
<template v-if="accountType.sel==1">
@@ -27,7 +28,7 @@
</uni-easyinput>
</uni-forms-item>
</template>
<uni-forms-item name="username">
<uni-easyinput class='jeepay-easyinput' placeholder="请输入登录名/手机号"
v-model="vdata.formData.username" :clearable="false">
@@ -173,15 +174,20 @@
login,
getCodeImg
} from '@/http/yskApi/login.js';
const accountType=reactive({
list:[
{label:'商户',value:'merchant'},
{label:'员工',value:'staff'},
const accountType = reactive({
list: [{
label: '商户',
value: 'merchant'
},
{
label: '员工',
value: 'staff'
},
],
sel:0
sel: 0
})
const loginFormRef = ref()
const envChangeTipsRef = ref()
const refAgr = ref()
@@ -192,7 +198,7 @@
} from "@/commons/utils/pushmsg/wxTextToSpeach.js"
// #endif
const rules = {
merchantName:{
merchantName: {
rules: [formUtil.rules.requiredInputShowToast('商户号')],
},
username: {
@@ -239,21 +245,24 @@
})
// #ifdef H5
// vdata.formData.username = '18049104914'
// vdata.formData.username = '15699991111'
// vdata.formData.pwd = '123456'
vdata.formData.username = '15699991111'
vdata.formData.pwd = 'qwer1234'
vdata.formData.username = ''
vdata.formData.pwd = ''
// #endif
// #ifdef MP-WEIXIN
vdata.formData.username = '15699991111'
vdata.formData.pwd = 'qwer1234'
vdata.formData.username = ''
vdata.formData.pwd = ''
// vdata.formData.username = '15699991111'
// vdata.formData.pwd = 'qwer1234'
// #endif
function accountTypeChange(e){
function accountTypeChange(e) {
// #ifdef H5
if(e==1){
vdata.formData.merchantName = '18049104914'
vdata.formData.username = '13666666666'
if (e == 1) {
// vdata.formData.merchantName = '18049104914'
// vdata.formData.merchantName = ''
// vdata.formData.username = ''
}
// #endif
}
@@ -277,7 +286,13 @@
// vdata.siteInfos = storageManage.siteInfos(bizData)
// })
// }
// 获取商户信息,有就回显
let info = uni.getStorageSync('MerchantId')
// console.log(info.merchantName,'调试121')
if (info.merchantName) {
vdata.formData.merchantName = info.merchantName
vdata.formData.username = info.username
}
})
// 切换登录方式
@@ -297,7 +312,7 @@
// loginPromise = $loginByPwd(vdata.formData.username, vdata.formData.pwd, vdata.formData.safetyCode)
loginPromise = login({
username: vdata.formData.username,
password: encrypt(vdata.formData.pwd) ,
password: encrypt(vdata.formData.pwd),
rememberMe: false,
code: vdata.formData.code,
uuid: vdata.formData.uuid,
@@ -312,13 +327,18 @@
if (loginPromise == null) {
return false;
}
// 请求后的操作
loginPromise.then(res=> {
console.log(res);
loginPromise.then(res => {
// 登录成功
loginFinishFunc(res)
}).catch(e=>{
// 保存商户号
uni.setStorageSync('MerchantId', {
merchantName: vdata.formData.merchantName,
username: vdata.formData.username,
})
}).catch(e => {
getCode()
})
})
@@ -340,11 +360,11 @@
})
// #endif
}
watch(()=>accountType.sel,(newval)=>{
if(newval==1){
vdata.formData.merchantName=uni.getStorageSync('merchantName')||''
}else{
vdata.formData.username=''
watch(() => accountType.sel, (newval) => {
if (newval == 1) {
vdata.formData.merchantName = uni.getStorageSync('merchantName') || ''
} else {
vdata.formData.username = ''
}
})
// 封装登录成功后的操作
@@ -355,6 +375,7 @@
storageManage.shopId(loginBizData.shopId)
storageManage.shopUserId(loginBizData.user.user.id)
storageManage.userInfo(loginBizData)
// 跳转到首页
go.to("PAGES_INDEX", {
isGetCid: true