From 6d9652287b1aaf1fbb2423921b4ea036839c5a74 Mon Sep 17 00:00:00 2001 From: quanyawei <401863037@qq.com> Date: Tue, 31 Oct 2023 14:26:06 +0800 Subject: [PATCH] fix:小程序分享功能 --- pages/login/login.vue | 58 ++++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 42 insertions(+), 16 deletions(-) diff --git a/pages/login/login.vue b/pages/login/login.vue index 147529c..4a89982 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -21,32 +21,35 @@ </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> + <ws-wx-privacy id="privacy-popup" enableAutoProtocol></ws-wx-privacy> </view> </template> <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 { + titlePrivacy: '������������������������', labelStyle: { color: '#fff' }, + title: '������������', passwordIcon: false, form: { account: '', @@ -71,38 +74,61 @@ //onReady ���uni-app��������������������������� this.$refs.uForm.setRules(this.rules) }, + async onLoad(option) { + //������������������ + await this.$onLaunched + // ������������������ + }, + async onShow() { + uni.hideHomeButton() + }, methods: { + doRequire() { + uni.requirePrivacyAuthorize({ + success: () => { + console.log('������') + // ������������������ + // ��������������������� + this.getlogin() + }, + fail: () => { + console.log('������') + }, // ������������������ + complete: () => {} + }) + }, submit() { this.$refs.uForm.validate().then(res => { - this.getlogin() - }).catch(errors => { - uni.$u.toast('������������') - }) + this.doRequire() + }).catch(errors => {}) }, //������ getlogin() { - let openId = this.$storage.get('openId') + const value = uni.getStorageSync('openId') + console.log('openId', value) + if (value) { + this.logining(value) + } + }, + 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