You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
150 lines
3.0 KiB
150 lines
3.0 KiB
// subpages/points/pages/demand/list.js
|
|
// @ts-nocheck
|
|
import {
|
|
wxRequestPost,
|
|
wxNavigateTo
|
|
} from "@utils/promise-wx-api";
|
|
const app = getApp()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
iniLoaded: false,
|
|
current: 0,
|
|
cateList: [
|
|
{
|
|
categoryName: '最近预约',
|
|
categoryId: '0',
|
|
categoryCode: '',
|
|
parentCategoryCode: '',
|
|
children: []
|
|
}
|
|
],
|
|
rightList: []
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: async function (options) {
|
|
await app.doAfterLogin()
|
|
await this.getList()
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: async function () {
|
|
await app.doAfterLogin()
|
|
await this.getLastList()
|
|
this.setData({
|
|
iniLoaded: true
|
|
})
|
|
|
|
},
|
|
handleTabs(e) {
|
|
const index = e.currentTarget.dataset.index
|
|
const { cateList } = this.data
|
|
this.setData({
|
|
current: index,
|
|
rightList: cateList[index].children
|
|
})
|
|
},
|
|
handleAppoint(e) {
|
|
const index = e.currentTarget.dataset.index
|
|
const { rightList } = this.data
|
|
const item = rightList[index]
|
|
console.log('item', item)
|
|
wxNavigateTo('/subpages/points/pages/demand/crate', {
|
|
...item
|
|
})
|
|
},
|
|
async getList() {
|
|
let {
|
|
data: {
|
|
data: { code, data },
|
|
},
|
|
msg,
|
|
} = await wxRequestPost('heart/icresidemanddict/category-list', {}, { isMock: false });
|
|
console.log('getInfo', data)
|
|
if (msg == 'success' && code == 0) {
|
|
let { cateList, rightList, current } = this.data
|
|
if (current != 0) rightList = data[current - 1].children
|
|
if (rightList.length === 0) {
|
|
rightList = data[current].children
|
|
current = 1
|
|
}
|
|
|
|
this.setData({
|
|
cateList: [...cateList, ...data],
|
|
rightList: rightList,
|
|
current
|
|
})
|
|
|
|
}
|
|
},
|
|
async getLastList() {
|
|
let {
|
|
data: {
|
|
data: { code, data },
|
|
},
|
|
msg,
|
|
} = await wxRequestPost('heart/icresidemanddict/latest-order', {}, { isMock: false });
|
|
console.log('getInfo', data)
|
|
if (msg == 'success' && code == 0) {
|
|
let { rightList, cateList } = this.data
|
|
if (data && data.length > 0) {
|
|
rightList = data
|
|
cateList[0].children = data
|
|
}
|
|
this.setData({
|
|
rightList: rightList,
|
|
cateList
|
|
})
|
|
|
|
}
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
})
|