From bb72fc0bf309b84fe2a98e025b9accbf7fc2c449 Mon Sep 17 00:00:00 2001 From: xpz2018 <107107461@qq.com> Date: Mon, 11 Oct 2021 16:50:10 +0800 Subject: [PATCH] no message --- pages/agent/factory/index.js | 38 +++++++++-------------------------- pages/article/detail/index.js | 29 +++++++++++--------------- 2 files changed, 22 insertions(+), 45 deletions(-) diff --git a/pages/agent/factory/index.js b/pages/agent/factory/index.js index 1383778..7ce7281 100644 --- a/pages/agent/factory/index.js +++ b/pages/agent/factory/index.js @@ -66,7 +66,6 @@ Page({ wx.hideLoading() }).catch(err => { wx.hideLoading() - console.log(err) util.showToast(err) }) } @@ -74,6 +73,8 @@ Page({ onEvent: function (message) { if (message.what == 570 || message.what == 571 || message.what == 572 || message.what == 573) { this.onRefreshList() + } else if(message.what == 200){ + this.setData({ visible: false }) } }, onFixedChange: function ({ detail }) { @@ -140,11 +141,7 @@ Page({ if (this.data.requesting) { return } - this.setData({ - momentList: [], - ['form.pageNum']: 1, - finished: false - }) + this.setData({ momentList: [], ['form.pageNum']: 1, finished: false }) this.fetchMomentList() }, fetchMomentList: function () { @@ -158,22 +155,12 @@ Page({ let nowList = `momentList[${this.data.momentList.length}]` var num = this.data.form.pageNum var finished = this.data.form.pageNum >= result.data.pages - this.setData({ - [nowList]: respList, - ['form.pageNum']: (num + 1), - requesting: false, - finished - }) + this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), requesting: false, finished }) } else { - this.setData({ - finished: true, - requesting: false - }) + this.setData({ finished: true, requesting: false }) } }).catch(err => { - this.setData({ - requesting: false - }) + this.setData({ requesting: false }) }) }, //分享至朋友 @@ -185,10 +172,9 @@ Page({ }, //分享至朋友圈 onShareTimeline(res){ - console.log(res) return { - title: this.data.factoryDetail.name + '废纸报价', - path: 'pages/index/index?url=/pages/agent/factory/index&key=id&value=' + this.data.factoryDetail.paperMillId + title: this.data.factoryDetail.name + '废纸报价', + path: 'pages/index/index?url=/pages/agent/factory/index&key=id&value=' + this.data.factoryDetail.paperMillId } }, toService: function () { @@ -235,15 +221,11 @@ Page({ if (result.data.paperCategoryList && result.data.paperCategoryList.length) { this.data.cateId = result.data.paperCategoryList[this.data.cateIndex].categoryId } - this.setData({ - factoryDetail: result.data, - hasFollowed:result.data.hasFollowed - }) + this.setData({ factoryDetail: result.data, hasFollowed:result.data.hasFollowed }) wx.hideLoading() }).catch(err => { wx.hideLoading() util.showToast(err) }) - }, - + } }) \ No newline at end of file diff --git a/pages/article/detail/index.js b/pages/article/detail/index.js index 0a03124..b7ee3f6 100644 --- a/pages/article/detail/index.js +++ b/pages/article/detail/index.js @@ -1,6 +1,7 @@ import { getMomentDetail, getCommentList, likeMoment, likeComment, commentMoment } from "../../../api/moment" const util = require('../../../utils/util') const tdsdk = require('../../../libs/tdweapp') +const event = require('../../../utils/event.js') const app = getApp() Page({ @@ -34,11 +35,8 @@ Page({ if (options.type) { this.data.type = Number(options.type) } - this.setData({ - type: this.data.type, - safeBottom: app.globalData.safeBottom, - height: app.globalData.safeFragmentHeight - 100 - }) + event.on('EventMessage', this, this.onEvent) + this.setData({ type: this.data.type, safeBottom: app.globalData.safeBottom, height: app.globalData.safeFragmentHeight - 100 }) if (options.id) { this.data.id = options.id this.data.form.articleId = options.id @@ -68,11 +66,7 @@ Page({ if (this.data.requesting) { return } - this.setData({ - commentList: [], - ['form.pageNum']: 1, - finished: false - }) + this.setData({ commentList: [], ['form.pageNum']: 1, finished: false }) this.fetchCommentList() }, fetchCommentList: function () { @@ -107,15 +101,10 @@ Page({ }) } } else { - this.setData({ - requesting: false, - finished: true - }) + this.setData({ requesting: false, finished: true }) } }).catch(err => { - this.setData({ - requesting: false - }) + this.setData({ requesting: false }) }) }, onTabChange: function (e) { @@ -421,10 +410,16 @@ Page({ onShow: function () { tdsdk.Page.onShow() }, + onEvent: function (message) { + if(message.what == 200){ + this.setData({ visible: false }) + } + }, onHide: function(){ tdsdk.Page.onHide() }, onUnload: function () { + event.remove('EventMessage', this) tdsdk.Page.onUnload() } }) \ No newline at end of file