From cf88306b1f6aade9f0c6c4fa5859872d3f177c4a Mon Sep 17 00:00:00 2001
From: zhangyongtian <1181606322@qq.com>
Date: Fri, 13 Sep 2024 14:56:29 +0800
Subject: [PATCH] Merge branch 'master' of http://120.79.193.119:9090/r/gzzfw/frontEnd/gzDyh
---
gz-wxparty/pages/homePage/index.js | 181 +++++++++++++++++---------------------------
1 files changed, 70 insertions(+), 111 deletions(-)
diff --git a/gz-wxparty/pages/homePage/index.js b/gz-wxparty/pages/homePage/index.js
index 4418f55..6cb4859 100644
--- a/gz-wxparty/pages/homePage/index.js
+++ b/gz-wxparty/pages/homePage/index.js
@@ -53,7 +53,13 @@
imgUrl: $$.url.img,
agreementMsg: '', // 服务协议
popupVisible: false,
- banner: [`${$$.url.img}Banner1.png`, `${$$.url.img}Banner2.png`], // 轮播图
+ banner: [{
+ image: `${$$.url.img}Banner1.png`,
+ image1: `${$$.url.img}banner4.png`
+ }, {
+ image: `${$$.url.img}Banner2.png`,
+ image1: `${$$.url.img}banner3.png`
+ }], // 轮播图
// banner: [`${$$.url.img}Banner1.png`, `${$$.url.img}Banner2.png`, `${$$.url.img}banner3.png`, `${$$.url.img}banner4.png`], // 轮播图
countUnitData: {}, //化解资源
userInfo: {}, //用户信息
@@ -75,6 +81,7 @@
// 跳转资讯链接
goSeeMessage(e) {
let url = e.currentTarget.dataset.url;
+ console.log('url', url);
wx.navigateTo({
url: '../webview/index?showUrl=' + url
});
@@ -233,114 +240,6 @@
}
},
- async dd() {
- $$.showLoading();
- wx.login({
- async success(res) {
- if (res.code) {
- const accountInfo = wx.getAccountInfoSync();
- const submitData = {
- appid: accountInfo.miniProgram.appId,
- code: res.code,
- }
- const res1 = await loginApi(submitData);
- if (res1.type) {
- console.log(res1.data, 'res1111')
- if (res1.data.state === '1') {
- $$.hideLoading();
- console.log(res1, 'res1');
- wx.setStorage({
- key: 'userInfo',
- data: res1.data
- });
- app.globalData.token = res1.data.token;
- $$.showToast({
- title: '登录成功',
- icon: 'success'
- });
- await $$.sleep();
- wx.reLaunch({
- url: '../../pages/homePage/index',
- });
-
- } else {
- $$.hideLoading();
- app.globalData.access_token = wx.getStorageSync('access_token');
- $$.showModal({
- title: '提示',
- content: '您尚未注册,是否前往注册?',
- cancelText: '取消',
- confirmText: '前往',
- success: (res) => {
- if (res.confirm) {
- $$.showLoading();
- wx.getUserProfile({
- desc: '完善用户信息',
- complete(res) {
- if (res.errMsg === 'getUserProfile:ok') {
- wx.login({
- async success(res2) {
- if (res2.code) {
- const accountInfo = wx.getAccountInfoSync();
- const submitData = {
- appid: accountInfo.miniProgram.appId,
- code: res2.code,
- avatar: res?.userInfo.avatarUrl,
- encryptedData: res.encryptedData,
- ivStr: res.iv,
- };
- const res3 = await registerApi(submitData);
- $$.hideLoading();
- if (res3.type) {
- wx.setStorage({
- key: 'userInfo',
- data: res3.data
- });
- app.globalData.token = res3.data.token;
- $$.showToast({
- title: '登录成功',
- icon: 'success'
- });
- await $$.sleep();
- wx.reLaunch({
- url: '../../pages/homePage/index',
- });
- }
- } else {
- $$.hideLoading();
- $$.showToast('登录失败,请稍后重试');
- }
- },
- });
- } else {
- $$.hideLoading();
- $$.showToast({
- title: '抱歉!授权失败'
- });
- }
- },
- });
-
- // wx.navigateTo({
- // url: '../../pages/login/index',
- // });
- } else {
- wx.navigateBack({
- delta: 1,
- });
- }
- },
- });
- }
- }
- } else {
- $$.hideLoading();
- $$.showToast('登录失败,请稍后重试');
- }
- }
- })
- },
-
// 前往查看
AiModalClick(e) {
let item = e.currentTarget.dataset.item;
@@ -359,15 +258,75 @@
})
},
+ // 登录,获取用户信息
+ async handleGetUserInfo() {
+ $$.showLoading();
+ wx.getUserProfile({
+ desc: '完善用户信息',
+ complete(res) {
+ if (res.errMsg === 'getUserProfile:ok') {
+ wx.login({
+ async success(res2) {
+ if (res2.code) {
+ const accountInfo = wx.getAccountInfoSync();
+ const submitData = {
+ appid: accountInfo.miniProgram.appId,
+ code: res2.code,
+ avatar: res?.userInfo.avatarUrl,
+ encryptedData: res.encryptedData,
+ ivStr: res.iv,
+ };
+ const res3 = await registerApi(submitData);
+ $$.hideLoading();
+ if (res3.type) {
+ wx.setStorage({
+ key: 'userInfo',
+ data: res3.data
+ });
+ app.globalData.token = res3.data.token;
+ $$.showToast({
+ title: '登录成功',
+ icon: 'success'
+ });
+ await $$.sleep();
+ wx.reLaunch({
+ url: '../../pages/homePage/index',
+ });
+ }
+ } else {
+ $$.hideLoading();
+ $$.showToast('登录失败,请稍后重试');
+ }
+ },
+ });
+ } else {
+ $$.hideLoading();
+ $$.showToast({
+ title: '抱歉!授权失败'
+ });
+ }
+ },
+ });
+ },
+
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {},
onShow(options) {
- if (!$$.userTest('login')) {
- return
+ if (!app.globalData.token) {
+ $$.showModal({
+ content: '抱歉您未登录,是否前往登录?',
+ success: (res) => {
+ if (res.confirm) {
+ this.handleGetUserInfo();
+ }
+ },
+ });
+ return;
}
+ // this.getUserInfo()
let userInfo = wx.getStorageSync('userInfo') || {};
let AICase = wx.getStorageSync('AICase') || '';
if (AICase) {
--
Gitblit v1.8.0