123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- // pages/repairs/repairs.js
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- screenHeight: '', //屏幕可视高度
- areaID: 0, //区域id
- value1: 0, //第一个显示什么
- option1: [], //区域选项
- curPage: 0, //tab切换 【1 已读 0未读】
- repairsList: [], //用户反馈列表
- page: 1, //页面加载
- bgColor: '#efefef',
- 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.lookRepairs();
- },
- goTop: function (e) { // 一键回到顶部
- if (wx.pageScrollTo) {
- wx.pageScrollTo({
- scrollTop: 0
- })
- }
- },
- choose(e) { //已读未读切换
- let idx = e.currentTarget.dataset.idx;
- this.setData({
- curPage: idx,
- repairsList:[]
- })
- this.lookRepairs();
- this.goTop();
- },
- lookRepairs() { //获取报修列表
- wx.showLoading({
- title: '加载中...',
- })
- let cur = this.data.curPage;
- let areaID = this.data.areaID;
- app.request('user/userRepaired?status=' + cur + '&area_id=' + areaID, '', 'GET').then(res => {
- wx.hideLoading();
- if (res.statusCode == 200) {
- console.log(res, '报修列表')
- let list = res.data.data;
- if (list.length == 0) {
- this.setData({
- repairsList: [],
- bgColor: '#fff'
- })
- } else {
- this.setData({
- repairsList: res.data.data,
- bgColor: '#efefef'
- })
- }
- }
- })
- },
- markRead(e) { //标记为已读
- let id = e.currentTarget.dataset.id
- app.request('user/userRepaired/status?id=' + id, '', 'GET').then(res => {
- if (res.statusCode == 200) {
- this.lookRepairs();
- }
- })
- },
- morkRepairs() { //上拉加载更多
- wx.showLoading({
- title: '加载中...',
- })
- let that = this;
- var page = that.data.page + 1;
- let state = this.data.curPage;
- let areaID = this.data.areaID;
- app.request('user/userRepaired?&status=' + state + '&page=' + page + '&area_id=' + areaID, '', 'GET').then(res => {
- wx.hideLoading();
- if (res.statusCode == 200) {
- let list = res.data.data;
- if (list.length > 0) {
- this.setData({
- repairsList: that.data.repairsList.concat(list),
- bgColor: '#efefef',
- page
- })
- } else {
- wx.showToast({
- title: '到底啦~',
- icon: 'none'
- })
- }
- }
- })
- },
- //选择区域
- 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.lookRepairs();
- this.goTop();
- },
- //点击可拨打电话
- phone(e){
- console.log(1111)
- wx.makePhoneCall({
- phoneNumber: e.currentTarget.dataset.phone
- })
- },
- //返回键
- back() {
- wx.navigateBack({
- delta: 1
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- this.morkRepairs();
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|