From 2e4d56e2ed95cb0f336522216fedc37167fb446d Mon Sep 17 00:00:00 2001
From: liuwh <964324856@qq.com>
Date: Mon, 09 Sep 2024 15:26:15 +0800
Subject: [PATCH] 小程序代码提交
---
gz-wxparty/pages/homePage/index.js | 1061 ++++++++++++++++++++--------------------------------------
1 files changed, 368 insertions(+), 693 deletions(-)
diff --git a/gz-wxparty/pages/homePage/index.js b/gz-wxparty/pages/homePage/index.js
index 136872b..f101002 100644
--- a/gz-wxparty/pages/homePage/index.js
+++ b/gz-wxparty/pages/homePage/index.js
@@ -2,733 +2,408 @@
const $$ = require('../../utils/util');
const app = getApp();
-// 热门资讯 与 视频
+// 咨询动态
function getVideoAndMessageApi(param) {
- return $$.request({
- url: 'paHotNews/listShow',
- type: 'get',
- submitData: param || {},
- service: 'sys',
- noToken: true
- });
+ return $$.request({
+ url: 'paHotNews/listShow',
+ type: 'get',
+ submitData: param || {},
+ service: 'sys',
+ noToken: true
+ });
}
// 调解资源
function getResourseApi(param) {
- return $$.request({
- url: 'paCaseInfo/mediatePower',
- type: 'get',
- submitData: param || {},
- service: 'mediate',
- noToken: true
- });
-}
-
-// 消息提醒
-function getPopupMsgApi() {
- return $$.request({
- url: 'paCaseInfo/newsRemind',
- type: 'get',
- service: 'mediate'
- });
+ return $$.request({
+ url: 'ctUnit/countUnit',
+ type: 'get',
+ submitData: param || {},
+ service: 'cust'
+ });
}
function loginApi(submitData) {
- return $$.request({
- url: 'paAccount/tryRegister',
- type: 'post',
- submitData,
- service: 'cust',
- noToken: true
- });
+ return $$.request({
+ url: 'paAccount/tryRegister',
+ type: 'post',
+ submitData,
+ service: 'cust',
+ noToken: true
+ });
}
function registerApi(submitData) {
- return $$.request({ url: 'paAccount/empower', type: 'post', submitData, service: 'cust', noToken: true });
+ return $$.request({
+ url: 'paAccount/empower',
+ type: 'post',
+ submitData,
+ service: 'cust',
+ noToken: true
+ });
}
Page({
- /**
- * 页面的初始数据
- */
- msgCheckId: null, // 已经阅读过的提示不在弹出
- data: {
- visible: true,
- imgUrl: $$.url.img,
- agreementMsg: '', // 服务协议
- popupVisible: false,
- banner: [`${$$.url.img}banner-1.png`, `${$$.url.img}banner-2.jpg`, `${$$.url.img}banner-3.jpg`], // 轮播图
- resources: [{
- icon: `${$$.url.img}case.png`,
- num: '0',
- unit: '件',
- title: '累计调解案件',
- color: '#EB4D55',
- type: 'case',
- },
- {
- icon: `${$$.url.img}mediater.png`,
- num: '0',
- unit: '名',
- title: '注册调解员',
- color: '#D10269',
- type: 'mediater',
- },
- {
- icon: `${$$.url.img}organizations.png`,
- num: '0',
- unit: '家',
- title: '入驻调解组织',
- color: '#02D1D1',
- type: 'organization',
- },
- ], // 调解资源
- video: [], // 热门视频
- videoMore: false,
- newMessage: [], // 最新资讯
- newMessageMore: false,
- message: [{}], // 消息通知
- // 底部弹窗消息
- popupMsg: [{
- show: false,
- type: 1, // 1:实名认证提醒,2:调解中提醒,3:预约提醒,4:司法确认中提醒
- title: '',
- subTitle: '',
- content: [],
- buttonText: '',
- }, ],
- },
+ /**
+ * 页面的初始数据
+ */
+ msgCheckId: null, // 已经阅读过的提示不在弹出
+ data: {
+ visible: true,
+ imgUrl: $$.url.img,
+ agreementMsg: '', // 服务协议
+ popupVisible: false,
+ banner: [`${$$.url.img}banner-1.png`, `${$$.url.img}banner-2.jpg`, `${$$.url.img}banner-3.jpg`], // 轮播图
+ countUnitData: {}, //化解资源
+ userInfo: {}, //用户信息
+ video: [], // 热门视频
+ videoMore: false,
+ newMessage: [], // 最新资讯
+ newMessageMore: false,
+ message: [{}], // 消息通知
+ // 底部弹窗消息
+ popupMsg: [{
+ show: false,
+ type: 1,
+ title: '实名认证提醒',
+ subTitle: '您尚未通过实名认证,请尽快前往认证',
+ buttonText: '前往认证',
+ }],
+ },
- // 跳转资讯链接
- goSeeMessage(e) {
- let url = e.currentTarget.dataset.url;
- wx.navigateTo({
- url: '../webview/index?showUrl=' + url
- });
- },
+ // 跳转资讯链接
+ goSeeMessage(e) {
+ let url = e.currentTarget.dataset.url;
+ wx.navigateTo({
+ url: '../webview/index?showUrl=' + url
+ });
+ },
- // 校验登录 or 实名
- userTest(type) {
- if (!app.globalData.token && (type === 'login' || type === 'all')) {
- $$.showModal({
- content: '抱歉您未登录,是否前往登录?',
- success: (res) => {
- if (res.confirm) {
- wx.navigateTo({
- url: '../../pages/login/index',
- });
- }
- },
- });
- return false;
- }
- $$.hideLoading();
- },
-
- // 调解资源去看看
- handleNavigateTo(e) {
- let type = e.currentTarget.dataset.type;
- if (type === 'case') {
- $$.showToast({
- title: '功能暂未开启,敬请期待'
- });
- } else if (type === 'register') {
- if ($$.userTest('all')) {
- wx.navigateTo({
- url: '../../pages/register/index',
- });
- }
- } else {
- if ($$.userTest('login')) {
- wx.navigateTo({
- url: '../../pages/findAdjust/index?type=' + (type === 'mediater' ? '1' : '2'),
- });
- }
- }
- },
-
- // 查看更多
- handleGetMore(e) {
- let type = e.currentTarget.dataset.type;
- wx.navigateTo({
- url: `../../pages/homePageInfo/index?type=${type}`,
- });
- },
-
- // 平台协议操作
- handleAgree(e) {
- let type = e.currentTarget.dataset.type;
- if (type === 'noAgree') {
- this.selectComponent('#tabbar-page').loginOut();
- $$.loginOutClearData();
- } else {
- // 同意协议之后退出登录后不重复弹出
- wx.setStorage({
- key: 'agreement',
- data: 1
- });
- }
+ // 调解资源去看看
+ handleNavigateTo(e) {
+ let type = e.currentTarget.dataset.type;
+ let url = e.currentTarget.dataset.url;
+ if (type === 'register') {
+ if (!$$.userTest('all', 'bottom')) {
this.setData({
- popupVisible: false
+ popupMsg: [{
+ show: true,
+ type: 1,
+ title: '实名认证提醒',
+ subTitle: '您尚未通过实名认证,请尽快前往认证',
+ buttonText: '前往认证',
+ }, ],
});
- },
-
- // 跳转至我的消息
- handleGoToMessageCenter() {
+ return;
+ }
+ wx.navigateTo({
+ url: url,
+ });
+ } else {
+ if ($$.userTest('login')) {
wx.navigateTo({
- url: '../../pages/messageCenter/index',
+ url: '../../pages/findAdjust/index?type=' + (type === 'mediater' ? '1' : '2'),
});
- },
+ }
+ }
+ },
- // 关闭消息弹窗
- handleClosePopupMsg(e) {
- let index = e.currentTarget.dataset.index;
- this.data.popupMsg[index].show = false;
- this.data.popupMsg[index].content?.forEach((x) => {
- this.msgCheckId = [...(this.msgCheckId || []), x.caseId];
- });
- this.setData({
- popupMsg: this.data.popupMsg
- });
- },
+ // 查看更多
+ handleGetMore(e) {
+ let type = e.currentTarget.dataset.type;
+ wx.navigateTo({
+ url: `../../pages/homePageInfo/index?type=${type}`,
+ });
+ },
- // 消息弹窗操作, TODO:跳转至详情页面的代码屏蔽,暂无用到,后续不用可删除
- handleClickPopupMsg(e) {
- let value = e.currentTarget.dataset.item;
- // let t = e.currentTarget.dataset.t;
- if (e.currentTarget.dataset.type === 'more' && value.content.length === 1) {
- return;
- }
- this.handleClosePopupMsg(e);
- if (value.type === 1) {
- wx.navigateTo({
- url: '../../pages/realNameAuthentication/index'
- });
- return;
- }
- if (value.type === 2 || (value.type === 3 && value.content[t].meetType === '22_00020-1')) {
- wx.navigateTo({
- url: '../../pages/myMediate/index'
- });
- return;
- }
- if (value.type === 4 || (value.type === 3 && value.content[t].meetType === '22_00020-2')) {
- wx.navigateTo({
- url: '../../pages/myJudicialConfirmation/index'
- });
- return;
- }
- // let caseId = value.content[t][value.type === 2 ? 'caseId' : 'id'];
- // let pageType = '1';
- // if (value.type === 2 || (value.type === 3 && value.content[t].meetType === '22_00020-1')) {
- // pageType = '1'; // 调解
- // }
- // if (value.type === 4 || (value.type === 3 && value.content[t].meetType === '22_00020-2')) {
- // pageType = '2'; // 司法确认
- // }
- },
+ // 跳转
+ _handleGoPage(e) {
+ let url = e.currentTarget.dataset.url;
+ wx.navigateTo({
+ url: url,
+ });
+ },
- // 获取底部弹窗消息提醒
- async getPopupMsg() {
- const res = await getPopupMsgApi();
- if (res.type) {
- let homePageMsgOut = [];
- try {
- let obj = wx.getStorageSync('homePageMsgOut');
- if (obj.time === $$.timeFormat(new Date(), 'YYYY-MM-DD')) {
- homePageMsgOut = obj.value;
- }
- } catch (e) {}
- let meetRemind = {
- show: false,
- type: 3,
- title: '预约提醒',
- content: [],
- buttonText: '了解详情'
- };
- let meetRemindVisible = false;
- if (res.data.meetRemind) {
- res.data.meetRemind.forEach((x) => {
- if (homePageMsgOut.includes(x.caseId)) {
- return;
- }
- let nowTime = $$.moment();
- let startTime = $$.moment(x.orderStartTime);
- let diffTime = startTime.diff(nowTime, 'hours');
- // 距离预约开始时间小于一个小时并且未过期的时候提醒
- if (diffTime > 0 && diffTime <= 1) {
- meetRemind.content.push(x);
- meetRemindVisible = true;
- }
- });
- if (meetRemindVisible) {
- meetRemind.show = true;
- }
- }
- let caseRemind = {
- show: false,
- type: 2,
- title: '调解中提醒',
- content: [],
- buttonText: '进入调解'
- };
- let caseRemindVisible = false;
- if (res.data.caseRemind) {
- res.data.caseRemind.forEach((x) => {
- if (homePageMsgOut.includes(x.caseId)) {
- return;
- }
- caseRemind.content.push(x);
- caseRemindVisible = true;
- });
- if (caseRemindVisible) {
- caseRemind.show = true;
- }
- }
- let judicRemind = {
- show: false,
- type: 4,
- title: '司法确认中提醒',
- content: [],
- buttonText: '进入司法确认'
- };
- let judicRemindVisible = false;
- if (res.data.judicRemind) {
- res.data.judicRemind.forEach((x) => {
- if (homePageMsgOut.includes(x.caseId)) {
- return;
- }
- judicRemind.content.push(x);
- judicRemindVisible = true;
- });
- if (judicRemindVisible) {
- judicRemind.show = true;
- }
- }
- this.msgCheckId = homePageMsgOut;
- this.setData({
- popupMsg: [meetRemind, caseRemind, judicRemind]
- });
- }
- },
+ // 平台协议操作
+ handleAgree(e) {
+ let type = e.currentTarget.dataset.type;
+ if (type === 'noAgree') {
+ this.selectComponent('#tabbar-page').loginOut();
+ $$.loginOutClearData();
+ } else {
+ // 同意协议之后退出登录后不重复弹出
+ wx.setStorage({
+ key: 'agreement',
+ data: 1
+ });
+ }
+ this.setData({
+ popupVisible: false
+ });
+ },
- // 获取首页视频资讯数据
- async getVideoAndMessage(param) {
- const res = await getVideoAndMessageApi(param);
- if (res.type) {
- let hotVideoList = res.data.hotVideoList || [];
- let hotNewsList = res.data.hotNewsList || [];
- wx.setStorage({
- key: 'homePageNewMsgTime',
- data: $$.timeFormat(new Date(), 'YYYY-MM-DD HH:mm:ss'),
- });
- this.setData({
- video: hotVideoList.filter((item, index) => index < 2),
- videoMore: hotVideoList.length > 2 ? true : false,
- newMessage: hotNewsList.filter((item, index) => index < 2),
- newMessageMore: hotNewsList.length > 2 ? true : false,
- });
- }
- },
+ // 跳转至我的消息
+ handleGoToMessageCenter() {
+ wx.navigateTo({
+ url: '../../pages/messageCenter/index',
+ });
+ },
- // 获取首页调解资源数量
- async getResourse(param) {
- const res = await getResourseApi(param);
- let resources = {
- ...this.data.resources
- };
- if (res.type) {
- resources[0].num = res.data.caseNum || 0; //累计案件
- resources[1].num = res.data.mediatorNum || 0; //调解员
- resources[2].num = res.data.unitNum || 0; //调解组织
- this.setData({
- resources
- });
- }
- },
+ // 关闭消息弹窗
+ handleClosePopupMsg(e) {
+ let index = e.currentTarget.dataset.index;
+ this.data.popupMsg[index].show = false;
+ this.data.popupMsg[index].content?.forEach((x) => {
+ this.msgCheckId = [...(this.msgCheckId || []), x.caseId];
+ });
+ this.setData({
+ popupMsg: this.data.popupMsg
+ });
+ },
- // 获取服务协议
- async getAgreement() {
- const res = await $$.commonRequest({
- url: `${$$.url.txt}agree.txt`,
- type: 'get'
- });
- if (res) {
- this.data.popupVisible = true;
- this.setData({
- popupVisible: true,
- agreementMsg: `<pre class="pre">${res || '-'}</pre>`
- });
- }
- },
-
- // getLogin(formData) {
- // $$.showLoading();
- // wx.login({
- // async success(res) {
- // const submitData = {
- // ...formData,
- // code: res.code
- // }
- // const res1 = await getjumpApi(submitData)
- // $$.hideLoading();
- // if (res1.resp_code === "000000000000") {
- // 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 {
- // $$.showModal({
- // title: '提示',
- // content: '您尚未注册,是否前往注册?',
- // cancelText: '取消',
- // confirmText: '前往',
- // success: (res) => {
- // if (res.confirm) {
- // wx.navigateTo({
- // url: '../../pages/realNameAuthentication/index?backNum=2',
- // });
- // } else {
- // wx.navigateBack({
- // delta: 1,
- // });
- // }
- // },
- // });
- // }
-
- // }
- // })
- // },
-
- 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,
- });
- }
- },
- });
- }
-
- }
-
- // app.globalData.access_token = wx.getStorageSync('access_token');
- // console.log(res, 'res')
- // console.log(app.globalData.access_token, 'app.globalData.access_token')
- // $$.showModal({
- // title: '提示',
- // content: '您尚未注册,是否前往注册?',
- // cancelText: '取消',
- // confirmText: '前往',
- // success: (res) => {
- // if (res.confirm) {
- // wx.navigateTo({
- // url: '../../pages/login/index',
- // });
- // } else {
- // wx.navigateBack({
- // delta: 1,
- // });
- // }
- // },
- // });
-
- // const accountInfo = wx.getAccountInfoSync();
- // const submitData = {
- // appid: accountInfo.miniProgram.appId,
- // code: res.code,
- // }
- // app.globalData.access_token = wx.getStorageSync('access_token');
- // const res1 = await loginApi(submitData);
- // console.log(res1, 'res1')
- // $$.hideLoading();
- // console.log(res1, 'res1');
- // if (res1.type) {
- // 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();
- $$.showToast('登录失败,请稍后重试');
- }
- }
- })
- },
-
- aa() {
- wx.navigateTo({
- url: '../../pages/homePage/index?access_token=2',
- });
- },
-
- cc() {
- wx.navigateTo({
- url: '../../pages/realNameAuthentication/index',
- });
- },
-
- bb() {
- wx.request({
- url: 'https://xcx.pinganbaiyun.cn/p_060_cs_intf/api_001/sv_002_get_paby_login_info', //仅为示例,并非真实的接口地址
- data: {
- "access_token": "测试token",
- "app_id": "测试",
- "secret": "测试"
- },
- method: 'post',
- success(res) {
- console.log(res.data, '平安白云')
- }
- })
- },
+ // 消息弹窗操作, TODO:跳转至详情页面的代码屏蔽,暂无用到,后续不用可删除
+ handleClickPopupMsg(e) {
+ let value = e.currentTarget.dataset.item;
+ // let t = e.currentTarget.dataset.t;
+ if (e.currentTarget.dataset.type === 'more' && value.content.length === 1) {
+ return;
+ }
+ this.handleClosePopupMsg(e);
+ if (value.type === 1) {
+ wx.navigateTo({
+ url: '../../pages/realNameAuthentication/index'
+ });
+ return;
+ }
+ if (value.type === 2 || (value.type === 3 && value.content[t].meetType === '22_00020-1')) {
+ wx.navigateTo({
+ url: '../../pages/myMediate/index'
+ });
+ return;
+ }
+ if (value.type === 4 || (value.type === 3 && value.content[t].meetType === '22_00020-2')) {
+ wx.navigateTo({
+ url: '../../pages/myJudicialConfirmation/index'
+ });
+ return;
+ }
+ },
+ // 获取首页视频资讯数据
+ async getVideoAndMessage(param) {
+ const res = await getVideoAndMessageApi(param);
+ if (res.type) {
+ let hotVideoList = res.data.hotVideoList || [];
+ let hotNewsList = res.data.hotNewsList || [];
+ wx.setStorage({
+ key: 'homePageNewMsgTime',
+ data: $$.timeFormat(new Date(), 'YYYY-MM-DD HH:mm:ss'),
+ });
+ this.setData({
+ video: hotVideoList.filter((item, index) => index < 2),
+ videoMore: hotVideoList.length > 2 ? true : false,
+ newMessage: hotNewsList.filter((item, index) => index < 2),
+ newMessageMore: hotNewsList.length > 2 ? true : false,
+ });
+ }
+ },
- // 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 loginApi(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: '抱歉!授权失败'
- // });
- // }
- // },
- // });
- // },
+ // 获取首页调解资源数量
+ async getResourse(param) {
+ const res = await getResourseApi(param);
+ this.setData({
+ countUnitData: res.data
+ });
+ },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- // const formData = {
- // access_token: options.access_token,
- // appid: options.appid,
- // secret: options.secret
- // // }
+ // 获取服务协议
+ async getAgreement() {
+ const res = await $$.commonRequest({
+ url: `${$$.url.txt}agree.txt`,
+ type: 'get'
+ });
+ if (res) {
+ this.data.popupVisible = true;
+ this.setData({
+ popupVisible: true,
+ agreementMsg: `<pre class="pre">${res || '-'}</pre>`
+ });
+ }
+ },
- // this.dd();
- // this.handleGetUserInfo()
- // 当登录后返回时弹出协议
- let agreement = wx.getStorageSync('agreement');
- if (!agreement && app.globalData.token) this.getAgreement();
- },
-
- onShow(options) {
- console.log(options,'options')
- if (options.extraData.access_token && !app.globalData.token) {
- wx.setStorage({
- key: 'access_token',
- data: options.extraData.access_token
- });
- this.dd();
- $$.showToast({
- title: '已监测到平安白云传入的access_token',
+ 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'
- });
- }
- let appid = wx.getAccountInfoSync().miniProgram.appId;
- this.getResourse({
- appid
- });
- let that = this;
- wx.getStorage({
- key: 'homePageNewMsgTime',
- complete: (res) => {
- if (that.data.video.length === 0 || that.data.newMessage.length == 0) {
- this.getVideoAndMessage({
- appid
- });
- return;
- }
- if (res.data && $$.moment().diff($$.moment(res.data), 'minute') > 60) {
- this.getVideoAndMessage({
- appid
- });
- }
- },
- });
- // 获取弹窗信息提醒
- if (app.globalData.token) {
- if (!$$.userTest('realName', 'bottom')) {
- this.setData({
- popupMsg: [{
- show: true,
- type: 1,
- title: '实名认证提醒',
- subTitle: '您尚未通过实名认证,根据调解实名制规定,建议您尽快前往认证。',
- buttonText: '前往认证',
- }, ],
- });
- return;
- }
- this.getPopupMsg();
- }
- },
+ });
+ await $$.sleep();
+ wx.reLaunch({
+ url: '../../pages/homePage/index',
+ });
- onHide() {
- if (!!this.msgCheckId) {
- wx.setStorage({
- key: 'homePageMsgOut',
- data: {
- time: $$.timeFormat(new Date(), 'YYYY-MM-DD'),
- value: this.msgCheckId,
+ } 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('登录失败,请稍后重试');
}
- },
+ }
+ })
+ },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {},
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad: function (options) {},
+
+ onShow(options) {
+ if (!$$.userTest('login')) {
+ return
+ }
+ let userInfo = wx.getStorageSync('userInfo') || {};
+ let appid = wx.getAccountInfoSync().miniProgram.appId;
+ this.setData({
+ userInfo
+ });
+
+
+ let that = this;
+ wx.getStorage({
+ key: 'homePageNewMsgTime',
+ complete: (res) => {
+ if (that.data.video.length === 0 || !that.data.countUnitData) {
+ this.getVideoAndMessage({
+ appid
+ });
+ this.getResourse({
+ appid
+ });
+ return;
+ }
+ if (res.data && $$.moment().diff($$.moment(res.data), 'minute') > 60) {
+ this.getVideoAndMessage({
+ appid
+ });
+ this.getResourse({
+ appid
+ });
+ }
+ },
+ });
+
+ // 获取弹窗信息提醒
+ if (app.globalData.token) {
+
+ if (!$$.userTest('realName', 'bottom')) {
+ this.setData({
+ popupMsg: [{
+ show: true,
+ type: 1,
+ title: '实名认证提醒',
+ subTitle: '您尚未通过实名认证,请尽快前往认证',
+ buttonText: '前往认证',
+ }, ],
+ });
+ return;
+ }
+ }
+ },
+
+ onHide() {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage: function () {},
});
\ No newline at end of file
--
Gitblit v1.8.0