2025-06-14 18:23:32 +08:00

230 lines
5.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.

let util = require("../../../../../utils/util")
const apiArr = require('../../../../../api/water_filter')
const apiArr2 = require('../../../../../api/partner')
// packages/WaterPurifier/pages/device/deviceList/deviceList.js
Page({
/**
* 页面的初始数据
*/
data: {
option1: [
{ text: '全部', value: 0 },
{ text: '已安装', value: 1 },
{ text: '空闲', value: 2 },
{ text: '已拆机', value: 3 },
],
option2: [
{ text: '全部', value: 0 },
{ text: '正常', value: 1 },
{ text: '报废', value: 2 },
{ text: '待启用', value: 3 },
{ text: '已拆机', value: 4 },
{ text: '漏水', value: 5 },
{ text: '制水故障', value: 6 },
{ text: '关机', value: 7 },
{ text: '已欠费', value: 8 },
{ text: '在库', value: 9 },
{ text: '激活失败', value: 10 },
],
stateType: {
1: '正常',
2: '报废',
3: '待启用',
4: '已拆机',
5: '漏水',
6: '制水故障',
7: '关机',
8: '已欠费',
9: '在库',
},
value1: 0,
value2: 'a',
nav_list: {},
foot_width: "",
searchText: "",//搜索文字
page_num: 1,
page_size: 10,
flag: false,
total: '',
deviceList: []
},
ipt1(e) {
let that = this
that.setData({
searchText: e.detail.value,
page_num: 1,
deviceList: [],
})
that.getDeviceList()
},
deviceDesc(e) {
wx.navigateTo({
url: `../deviceDesc/deviceDesc?device_id=${e.currentTarget.dataset.device_id}`,
})
},
addWorkOrders() {
console.log(123123);
wx.navigateTo({
url: '/packages/partner/pages/newWorkOrder/newWorkOrder',
})
},
// 网络状态选择
headerNetWorkClick(e) {
console.log('e', e);
this.setData({
value1: e.detail,
value2: 0,
page_num: 1,
deviceList: []
});
if (e.detail == 0) {
this.getDeviceList();
return;
}
this.getDeviceList(e.detail, '');
},
// 设备管理选择
headerEquipmentClick(e) {
this.setData({
value2: e.detail,
value1: 0,
page_num: 1,
deviceList: []
});
if (e.detail == 0) {
this.getDeviceList();
return;
}
this.getDeviceList('', e.detail);
},
getDeviceList(networkStatus, status) {
wx.showLoading({
title: '加载中',
mask: true
})
let that = this
let admin = wx.getStorageSync('admin')
let param = {
page_size: that.data.page_size,
page_num: that.data.page_num,
search: that.data.searchText,
dealer_id: admin.shop_id
};
if (networkStatus) {
param = {
...param,
install_status: networkStatus
}
}
if (status) {
param = {
...param,
status: Number(status),
}
}
util.postUrl4(apiArr2.deviceList, param, res => {
wx.hideLoading()
let flag = false
if (res.list && res.list.length == that.data.page_size) {
console.log(123);
flag = true
} else {
console.log(456);
flag = false
}
that.setData({
deviceList: that.data.deviceList.concat(res.list || []),
total: res.total,
flag,
page_num: that.data.page_num + 1
})
console.log(that.data.flag);
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getDeviceList();
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
let that = this
console.log(123, that.data.flag);
if (that.data.flag) {
that.getDeviceList('', that.data.value2)
}
},
/**
* 用户点击右上角分享
*/
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' // 自定义分享图片路径
}
},
})