2025-06-06 15:07:26 +08:00

184 lines
4.9 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'))
}
}
wx.showLoading({
title: '加载中...',
mask: true
})
postUrl(apiArr.BXList, params, res => {
wx.hideLoading()
if (res.rows) {
res.rows.forEach(item => {
item.product_icon = util.img_url + item.product_icon
item.create_time = item.create_time.slice(0, 16)
if (item.fault_imgs) {
item.fault_imgs = util.img_url + item.fault_imgs
}
})
}
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()
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
let that = this;
that.setData({
page_num: 1,
flag: false,
BxList: []
})
setTimeout(() => {
that.getBxList(that.data.statusType)
}, 10)
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
return {
title: '人人爱净水', // 分享卡片标题(必填)
path: '/pages/water_filter/water_filter', // 用户点击后跳转的路径(可选,默认当前页)
imageUrl: 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com/share.png' // 自定义图片(可选,比例建议 5:4
}
},
onShareTimeline() {
return {
title: '人人爱净水', // 自定义标题
query: '', // 自定义页面路径中的参数
imageUrl: 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com/share.png' // 自定义分享图片路径
}
},
})