From 52d463e03c1f074099ed8e8a6b7c3ddde52d2708 Mon Sep 17 00:00:00 2001 From: quanyawei <401863037@qq.com> Date: Fri, 27 Oct 2023 14:50:28 +0800 Subject: [PATCH] fix:小程序初版 --- pages/login/login.vue | 41 ++++++++++++++++++++++++++--------------- 1 files changed, 26 insertions(+), 15 deletions(-) diff --git a/pages/login/login.vue b/pages/login/login.vue index 147529c..04a8c27 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -21,11 +21,11 @@ </u-form> </view> <view class="loginContent"> - <p> + <!-- <p> <navigator style="display: inline-block;" url="/pages/login/register/register"> <text style="text-decoration: underline">������������</text> </navigator> - </p> + </p> --> <u-button @click="submit">������</u-button> </view> </view> @@ -34,19 +34,20 @@ <script> import { login, - getUserInfor, getDic } from '@/utils/login.js' // ������������ import { httpPost, httpGet } from '@/utils/http.js' + import store from '@/store/index.js' export default { data() { return { labelStyle: { color: '#fff' }, + title: '������������', passwordIcon: false, form: { account: '', @@ -71,38 +72,48 @@ //onReady ���uni-app��������������������������� this.$refs.uForm.setRules(this.rules) }, + async onLoad(option) { + //������������������ + await this.$onLaunched + // ������������������ + }, + async onShow() { + uni.hideHomeButton() + }, methods: { submit() { this.$refs.uForm.validate().then(res => { this.getlogin() - }).catch(errors => { - uni.$u.toast('������������') - }) + }).catch(errors => {}) }, //������ getlogin() { - let openId = this.$storage.get('openId') + const value = uni.getStorageSync('openId') + console.log('openId', value) + if (value) { + this.logining(value) + console.log('openId', openId) + } + }, + logining(openId) { login({ ...this.form, openId }).then(response => { - this.$storage.set('token', response.data.token) + uni.setStorageSync('userInfor', JSON.stringify(response.data)) + uni.setStorageSync('tonken', response.data.token) getDic() - getUserInfor(response.data.token) uni.hideLoading() - uni.switchTab({ - url: '/pages/actionChange/agencyPage/index', + uni.navigateTo({ + url: '/pages/index/index', }) - // this.$storage.setJson("accountInFor", this.form); - // console.log('this.$store', this.$store) - // this.$store.commit('token', token) }).catch(errors => { uni.showToast({ title: errors, icon: 'none', }) }) - }, + } }, } </script> -- Gitblit v1.8.0