123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- // pages/feedback/feedback.js
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- screenHeight: '', //屏幕可视高度
- areaID: 0, //区域id
- value1: 0, //第一个显示什么
- option1: [],
- curPage: 0, //tab切换 【1 已读 0未读】
- feedList: [], //用户反馈列表
- page: 1,
- option1: [],
- navBarHeight: app.globalData.navBarHeight, // 导航栏高度
- menuRight: app.globalData.menuRight, // 胶囊距右方间距(方保持左、右间距一致)
- menuTop: app.globalData.menuTop, // 胶囊距底部间距(保持底部间距一致)
- menuHeight: app.globalData.menuHeight, // 胶囊高度(自定义内容可与胶囊高度保证一致)
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let that = this;
- that.setData({
- screenHeight: app.globalData.screenHeight,
- option1: wx.getStorageSync('allArea'),
- })
- let curVal = wx.getStorageSync('curVal');
- if (curVal) {
- that.setData({
- value1: curVal
- })
- }
- let areaID = wx.getStorageSync('curId')
- if (areaID) {
- that.setData({
- areaID
- })
- } else {
- let id = that.data.option1[0].areaID
- that.setData({
- areaID: id
- })
- }
- that.menu = that.selectComponent("#menu");
- that.menu.changeTitle(that.data.option1[that.data.value1].text);
- this.getFeed();
- },
- goTop: function (e) { // 一键回到顶部
- if (wx.pageScrollTo) {
- wx.pageScrollTo({
- scrollTop: 0
- })
- }
- },
- //获取反馈列表
- getFeed() {
- wx.showLoading({
- title: '加载中',
- })
- let areaID = this.data.areaID;
- let is_read = this.data.curPage;
- app.request('user/feedback?is_read=' + is_read + '&area_id=' + areaID, '', 'GET').then(res => {
- wx.hideLoading()
- console.log(res.data.data);
- let feed = res.data.data;
- if (feed) {
- this.setData({
- feedList: res.data.data
- })
- } else {
- wx.showToast({
- title: '暂无反馈信息~',
- icon: 'none'
- })
- }
- })
- },
- //标记为已读
- markRead(e) {
- let id = e.currentTarget.dataset.id;
- app.request('user/feedback/read?id=' + id, '', 'GET').then(res => {
- console.log(res);
- if (res.statusCode == 200) {
- this.getFeed();
- }
- })
- },
- //返回键
- back() {
- wx.navigateBack({
- delta: 1
- })
- },
- //选择区域
- change: function (e) {
- let that = this;
- let index = e.detail.value
- wx.setStorageSync('curVal', index)
- wx.setStorageSync('curId', that.data.option1[index].areaID)
- this.setData({
- areaID: that.data.option1[index].areaID,
- value1:index
- })
- this.getFeed();
- this.goTop();
- },
- //tab 切换
- choose(e) {
- let idx = e.currentTarget.dataset.idx;
- this.setData({
- curPage: idx
- })
- this.getFeed();
- this.goTop();
- },
- moreFeed() {
- wx.showLoading({
- title: '加载中...',
- })
- let that = this;
- var page = that.data.page + 1;
- let read = that.data.curPage;
- let areaID = that.data.areaID;
- app.request('user/feedback?is_read=' + read + '&page=' + page + '&area_id=' + areaID, '', 'GET').then(res => {
- wx.hideLoading();
- if (res.statusCode == 200) {
- wx.hideLoading();
- if (res.data.data.length > 0) {
- console.log(res)
- this.setData({
- feedList: this.data.feedList.concat(res.data.data)
- })
- } else {
- wx.showToast({
- title: '没有更多数据了~',
- icon: 'none'
- })
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- wx.showLoading({
- title: '加载中',
- })
- this.moreFeed();
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|