| | |
| | | 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: {}, //用户信息 |
| | |
| | | // 跳转资讯链接 |
| | | goSeeMessage(e) { |
| | | let url = e.currentTarget.dataset.url; |
| | | console.log('url', url); |
| | | wx.navigateTo({ |
| | | url: '../webview/index?showUrl=' + url |
| | | }); |
| | |
| | | } |
| | | }, |
| | | |
| | | 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; |
| | |
| | | }) |
| | | }, |
| | | |
| | | // 登录,获取用户信息 |
| | | async handleGetUserInfo() { |
| | | |
| | | 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, |
| | | }; |
| | | $$.showLoading(); |
| | | 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) { |