From f2e04f70c143860c49c7962526b4d09dc681a7e9 Mon Sep 17 00:00:00 2001 From: wangdong <1551135706@qq.com> Date: Mon, 4 Mar 2024 23:40:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/BaseLogin/index.vue | 75 ++++++++++++---- pages/course/special_cate.vue | 68 ++++++++------ pages/index/index.vue | 160 ++++++++++++++++++--------------- pages/store/index.vue | 38 +++++--- utils/utils.js | 9 +- 5 files changed, 219 insertions(+), 131 deletions(-) diff --git a/components/BaseLogin/index.vue b/components/BaseLogin/index.vue index 530bebb..bc420df 100644 --- a/components/BaseLogin/index.vue +++ b/components/BaseLogin/index.vue @@ -220,21 +220,64 @@ export default { if (!this.agree) { return this.$util.showMsg("请勾选用户协议"); } + const that = this; + // #ifdef MP-WEIXIN + let provider = 'weixin'; + uni.login({ + provider: provider, + success: function (loginRes) { + // 获取用户信息 + uni.getUserInfo({ + provider: provider, + success: function (infoRes) { + let userInfo = {}; + userInfo.encryptedData = JSON.stringify(infoRes.userInfo) + userInfo.ucode = loginRes.code; + userInfo.type = 'weixin'; + console.log(userInfo); + that.type == 1 ? that.pwdLogin(userInfo) : that.smsLogin(userInfo); + }, + fail() { + uni.showToast({ + title: `获取用户信息失败`, + icon: 'none', + duration: 2000 + }) + }, + complete() { + uni.hideLoading() + } + }); + }, + fail: function (err) { + console.log(err); + uni.showToast({ + title: err.msg, + icon: 'none', + duration: 2000 + }); + } + }); + // #endif + + // #ifndef MP-WEIXIN this.type == 1 ? this.pwdLogin() : this.smsLogin(); + // #endif }, // 账号登录 - async pwdLogin() { + async pwdLogin(userInfo = {}) { const app = getApp(); uni.showLoading({ mask: true, }); - + const sendData = { + account: this.phone, + pwd: this.$util.hexMd5(this.pwd), + agent_id: app.globalData.agent_id || 0, + ...userInfo + }; try { - const { data } = await userLogin({ - account: this.phone, - pwd: this.$util.hexMd5(this.pwd), - agent_id: app.globalData.agent_id || 0 - }); + const { data } = await userLogin(sendData); uni.hideLoading(); @@ -256,7 +299,7 @@ export default { }, //绑定手机号 // 手机登录 - async smsLogin() { + async smsLogin(userInfo = {}) { const app = getApp(); if (this.timer) { clearInterval(this.timer); @@ -266,14 +309,14 @@ export default { uni.showLoading({ mask: true, }); - + const sendData = { + phone: this.phone, + code: this.code, + agent_id: app.globalData.agent_id || 0, + ...userInfo + }; try { - const { data, msg } = await smsLogin( - { - phone: this.phone, - code: this.code, - agent_id: app.globalData.agent_id || 0 - }); + const { data, msg } = await smsLogin(sendData); uni.hideLoading(); this.$util.showMsg(msg); @@ -462,7 +505,7 @@ export default { box-sizing: border-box; vertical-align: middle; font-size: 0; - line-height: 30rpx; + line-height: 40rpx; text-align: center; color: #c3c3c3; diff --git a/pages/course/special_cate.vue b/pages/course/special_cate.vue index a16b291..2f6373e 100644 --- a/pages/course/special_cate.vue +++ b/pages/course/special_cate.vue @@ -1,20 +1,23 @@