2025-04-22 14:39:59 +08:00

160 lines
3.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const apiArr = require("~/api/water_filter");
import util, { postUrl } from '../../../../utils/util';
const app = getApp()
// pages/water_filter/Maintenance/Maintenance.js
Page({
/**
* 页面的初始数据
*/
data: {
s: app.system.statusBarHeight, // 状态栏高度
n: (app.menu.top - app.system.statusBarHeight) * 2 + app.menu.height, // 导航栏高度
t: app.menu.top, // 胶囊局顶部距离
h: app.menu.height, // 胶囊高度
tabIndex:1,
status:'0', //0全部1待处理 2处理中 3已完成
page_num:1,
page_size:10,
isLoading: false, // 是否正在加载
hasMore: true, // 是否还有更多数据
statusType:"",
BxList:[] //报修列表
},
async changeTab(e){
console.log(e);
let that = this
that.setData({
status:e.target.dataset.index
})
const statusType = e.target.dataset.index;
this.setData({
BxList: [],
page_num: 1,
statusType
})
that.getBxList(statusType);
},
repair(){
let that = this
wx.navigateTo({
url: '../repair/repair',
})
},
handleInfoClick(e) {
wx.navigateTo({
url: `../MaintenanceInfo/MaintenanceInfo?repairId=${e.currentTarget.dataset.id}`,
})
},
//报修列表
getBxList(statusType){
let that = this
const { page_size, page_num, BxList } = this.data;
let params = {};
if (statusType === '0') {
params = {
page_size: page_size,
page_num: page_num,
user_id:Number(wx.getStorageSync('userId'))
}
} else {
params = {
page_size: page_size,
page_num: page_num,
status: Number(statusType),
user_id:Number(wx.getStorageSync('userId'))
}
}
postUrl(apiArr.BXList,params,res=>{
res.rows.forEach(item=>{
item.product_icon = util.img_url + item.product_icon
item.create_time = item.create_time.slice(0,16)
})
if(that.data.page_num == 1){
that.setData({
BxList:[]
})
}
this.setData({
BxList: BxList.concat(res.rows || []),
total:res.total,
page_num: page_num + 1,
isLoading: false,
hasMore: res.total === this.data.page_size,
})
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// let that = this
// that.getBxList()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
let that = this;
that.setData({
page_num: 1,
flag:false,
BxList:[]
})
console.log(that.data.page_num,that.data.BxList);
setTimeout(()=>{
that.getBxList(that.data.statusType)
},10)
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})