xusd
7 days ago 998218675eb243d43912c203174a6b72b299c0f8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
// pages/homePage/index.js
const $$ = require('../../utils/util');
const app = getApp();
 
// 咨询动态
function getVideoAndMessageApi(param) {
  return $$.request({
    url: 'paHotNews/listShow',
    type: 'get',
    submitData: param || {},
    service: 'sys',
    noToken: true
  });
}
 
// 调解资源
function getResourseApi(param) {
  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
  });
}
 
function registerApi(submitData) {
  return $$.request({
    url: 'paAccount/empower',
    type: 'post',
    submitData,
    service: 'cust',
    noToken: true
  });
}
 
Page({
  /**
   * 页面的初始数据
   */
  msgCheckId: null, // 已经阅读过的提示不在弹出
  data: {
    visible: true,
    imgUrl: $$.url.img,
    demoImgUrl: $$.url.img + 'Aimge.png',
    agreementMsg: '', // 服务协议
    popupVisible: false,
    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: {}, //用户信息
    video: [], // 热门视频
    videoMore: false,
    newMessage: [], // 最新资讯
    newMessageMore: false,
    message: [{}], // 消息通知
    // 底部弹窗消息
    popupMsg: [{
      show: false,
      type: 1,
      title: '实名认证提醒',
      subTitle: '您尚未通过实名认证,请尽快前往认证',
      buttonText: '前往认证',
    }],
  },
 
  // 跳转资讯链接
  goSeeMessage(e) {
    let url = e.currentTarget.dataset.url;
    console.log('url', url);
    wx.navigateTo({
      url: '../webview/index?showUrl=' + url
    });
  },
 
  // 调解资源去看看
  handleNavigateTo(e) {
    let type = e.currentTarget.dataset.type;
    let url = e.currentTarget.dataset.url;
    if (type === 'register') {
      if (!$$.userTest('all', 'bottom')) {
        this.setData({
          popupMsg: [{
            show: true,
            type: 1,
            title: '实名认证提醒',
            subTitle: '您尚未通过实名认证,请尽快前往认证',
            buttonText: '前往认证',
          }, ],
        });
        return;
      }
      wx.navigateTo({
        url: url,
      });
    } 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}`,
    });
  },
 
  // 跳转
  _handleGoPage(e) {
    let url = e.currentTarget.dataset.url;
    wx.navigateTo({
      url: url,
    });
  },
 
  // 平台协议操作
  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
    });
  },
 
  // 跳转至我的消息
  handleGoToMessageCenter() {
    wx.navigateTo({
      url: '../../pages/messageCenter/index',
    });
  },
 
  // 关闭消息弹窗
  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
    });
  },
 
  // 消息弹窗操作, 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 getResourse(param) {
    const res = await getResourseApi(param);
    this.setData({
      countUnitData: res.data
    });
  },
 
  // 获取服务协议
  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>`
      });
    }
  },
 
  // 前往查看
  AiModalClick(e) {
    let item = e.currentTarget.dataset.item;
    wx.navigateTo({
      url: '../../pages/AIAide/index?caseDes=' + item.caseDes + '&caseClaim=' + item.caseClaim + '&caseId=' + item.caseId
    });
    this.setData({
      AiModal: false
    })
  },
 
  // 关闭AI弹窗
  addClosePopup() {
    this.setData({
      AiModal: false
    })
  },
 
  // 登录,获取用户信息
  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 (!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) {
      this.setData({
        AiModal: AICase
      })
      wx.removeStorage({
        key: 'AICase'
      })
    }
    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 () {},
 
 
});