const app = getApp(); Page({ data: { show: false, cateList: [] as any, remark: '', feedbackCount: 0, bannerList: [], userInfo: {}, }, onLoad() { app.waitLogin().then(() => { this.getCateList(); this.getBanner(); this.getRemarkCount(); app.getUserInfo(this, (res) => { if (res.showQuestion === 1) { this.setData({ show: true, }); } }); }); }, getBanner() { wx.ajax({ method: 'GET', url: '?r=shizhong/index/index', data: {}, }).then((res) => { this.setData({ bannerList: res, }); }); }, handleBanner(e) { const { index } = e.currentTarget.dataset; const bannerItem: any = this.data.bannerList[index]; if (bannerItem.configType === '1') { wx.navigateTo({ url: `/pages/article/index?id=${bannerItem.configContent}`, }); } else if (bannerItem.configType === '2') { wx.navigateTo({ url: `/pages/article/index?id=${bannerItem.configContentBookId}&cid=${bannerItem.configContent}`, }); } else if (bannerItem.configType === '3') { wx.navigateTo({ url: `/pages/longPicture/index?url=${encodeURIComponent(bannerItem.configContent)}`, }); } }, getCateList() { wx.ajax({ method: 'GET', url: '?r=shizhong/book/cate-list', data: {}, }).then((res) => { this.setData({ cateList: res, }); }); }, handleDetail(e) { const { index } = e.currentTarget.dataset; const item = this.data.cateList[index]; wx.navigateTo({ url: `/pages/classify/index?id=${item.Id}`, }); }, handleSearch() { wx.navigateTo({ url: '/pages/search/index', }); }, getRemarkCount() { wx.ajax({ method: 'GET', url: '?r=shizhong/account/get-can-feedback-count', data: {}, showMsg: false, }).then((res) => { this.setData({ feedbackCount: res, }); }); }, handleRemark() { const { remark } = this.data; wx.ajax({ method: 'POST', url: '?r=shizhong/account/send-feedback', data: { content: remark, }, loading: true, }).then(() => { wx.showToast({ title: '提交成功', icon: 'none', }); this.setData({ remark: '', }); }); }, handleNotRemark() { wx.showToast({ icon: 'none', title: '今日留言次数已达上限,欢迎明天再来留言吧', }); }, handleTopic() { wx.navigateTo({ url: '/pages/topic/index?back=1', }); this.handleCancelTopic(); }, handleCancelTopic() { this.setData({ show: false, }); wx.ajax({ method: 'POST', url: '?r=shizhong/account/visit', data: { type: 1, }, }); }, }); export {};