优化退出登录

This commit is contained in:
gyq
2025-07-23 09:19:53 +08:00
parent 4dad65e0e0
commit c98eb7406a
2 changed files with 239 additions and 233 deletions

View File

@@ -7,9 +7,8 @@
uni.login({
provider: 'weixin',
success: async (data) => {
uni.cache.set('weixincode', data.code);
let res = await Api.getminiuserinfo({
code: uni.cache.get('weixincode') //临时登录凭证
code: data.code
})
uni.cache.set('open_id', res.data.openid)
this.$isResolve()

View File

@@ -1,18 +1,14 @@
<template>
<view class="content">
<view class="contentnav">
欢迎您登录开票系统
</view>
<view class="contentnav">欢迎您登录开票系统</view>
<view class="top_box">
<view class="top_box_one">
<text class="top_box_one_text">手机号码</text>
<input type="number" v-model="form.account" :adjust-position="false" placeholder="请输入手机号码" maxlength="-1"
data-key="mobile" />
<input type="number" v-model="form.account" :adjust-position="false" placeholder="请输入手机号码" maxlength="-1" data-key="mobile" />
</view>
<view class="top_box_one">
<text class="top_box_one_text">密码</text>
<input type="mobile" v-model="form.password" :adjust-position="false" placeholder="请输入密码"
maxlength="16" :password="!showPassword" />
<input type="mobile" v-model="form.password" :adjust-position="false" placeholder="请输入密码" maxlength="16" :password="!showPassword" />
<view class="repeat" @click="display">
<u-icon name="eye" v-if="showPassword"></u-icon>
<u-icon v-else name="eye-off"></u-icon>
@@ -40,20 +36,17 @@
<view class="agreement-Item" @click="Privacy(2)">隐私政策</view>
</view>-->
<view class="agreement" @click="clickpassword">
忘记密码
<view class="agreement" @click="clickpassword">忘记密码</view>
</view>
</view>
<view
style="margin-top:80rpx;text-align: center;color:#3088fd;position: fixed; bottom:40rpx;left: 50%;transform: translate(-50%,-50%);"
@click="quyonghu">
<view style="margin-top: 80rpx; text-align: center; color: #3088fd; position: fixed; bottom: 40rpx; left: 50%; transform: translate(-50%, -50%)" @click="quyonghu">
我是用户
</view>
</view>
</template>
<script>
export default {
import Api from '@/common/js/api.js';
export default {
data() {
return {
showPassword: false, //是否显示密码
@@ -65,30 +58,44 @@
// 注册定时器 初始值
second: 60,
showText: true,
Recapture: '发送验证码',
}
Recapture: '发送验证码'
};
},
async onLoad(e) {
uni.login({
provider: 'weixin',
success: async (data) => {
let openid = uni.cache.get('open_id');
if (!openid) {
let res = await Api.getminiuserinfo({
code: data.code
});
uni.cache.set('open_id', res.data.openid);
}
await this.$onLaunched;
if (e.userId) {
uni.showLoading({
title: '加载中',
mask: true
})
});
// this.onLoaduserId = e.userId
uni.cache.set('Type', e.type);
uni.cache.set('userId', e.userId);
let token = await this.api.h5encryption({
store_id: uni.cache.get('userId')
})
});
if (token.code == 1) {
uni.cache.set('token', token.data.token);
uni.cache.set('store_status', 1);
uni.navigateTo({
url: '/pages/index/index?restype=' + 1
})
});
}
}
}
});
},
methods: {
async CodeRegister() {
@@ -100,7 +107,8 @@
});
return false;
}
const res = await this.api.smssend({ // post 手机验证码
const res = await this.api.smssend({
// post 手机验证码
mobile: this.form.account,
event: 'mobilelogin'
});
@@ -137,8 +145,8 @@
},
clickpassword() {
uni.navigateTo({
url:'/pages/login/password'
})
url: '/pages/login/password'
});
},
async userlogin() {
if (this.form.account == null || this.form.account == '') {
@@ -165,8 +173,8 @@
let res = await this.api.userlogin({
account: this.form.account,
password: this.form.password,
open_id: uni.cache.get('open_id'),
})
open_id: uni.cache.get('open_id')
});
uni.cache.set('userId', res.data.userinfo.store_id);
uni.cache.set('logintoken', res.data.userinfo.token);
uni.cache.set('store_status', res.data.store_status);
@@ -176,20 +184,19 @@
if (res.data.set_pwd == 1) {
uni.navigateTo({
url: '/pages/login/repairpassword'
})
});
} else {
uni.reLaunch({
url: '/pages/index/index?restype=' + 1
});
}
}
}
}
};
</script>
<style lang="scss">
.content {
.content {
.contentnav {
padding-left: 48rpx;
padding-top: 200rpx;
@@ -289,5 +296,5 @@
}
}
}
}
}
</style>