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.
95 lines
2.1 KiB
95 lines
2.1 KiB
import { getDemandCategoryList, getLatestOrder } from "../../utils/demand"
|
|
Page({
|
|
data: {
|
|
iniLoaded: false,
|
|
current: 0,
|
|
cateList: [
|
|
{
|
|
categoryName: "最近预约",
|
|
categoryId: "0",
|
|
categoryCode: "",
|
|
parentCategoryCode: "",
|
|
children: []
|
|
}
|
|
],
|
|
rightList: []
|
|
},
|
|
|
|
onShow: function () {
|
|
this.getLastList()
|
|
this.getList()
|
|
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)
|
|
let url = "/subpages/demand/pages/demandCreate/demandCreate"
|
|
let paramsStr = Object.keys(item)
|
|
.map((k) => k + "=" + item[k])
|
|
.join("&")
|
|
if (paramsStr !== "") {
|
|
url += "?" + paramsStr;
|
|
}
|
|
console.log(url)
|
|
wx.navigateTo({
|
|
url
|
|
})
|
|
},
|
|
getList() {
|
|
getDemandCategoryList().then(res => {
|
|
this.setData({
|
|
cateList: [],
|
|
rightList: [],
|
|
current:0
|
|
})
|
|
if (res.msg == "success" && res.code == 0) {
|
|
let { cateList, rightList, current } = this.data
|
|
if (current != 0) rightList = res.data[current - 1].children
|
|
if (rightList.length === 0) {
|
|
rightList = res.data[current].children
|
|
current = 1
|
|
}
|
|
this.setData({
|
|
cateList: [...cateList, ...res.data],
|
|
rightList: rightList,
|
|
current
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
|
|
})
|
|
},
|
|
getLastList() {
|
|
this.setData({
|
|
rightList: [],
|
|
cateList:[]
|
|
})
|
|
getLatestOrder().then(res => {
|
|
if (res.msg == "success" && res.code == 0) {
|
|
let { rightList, cateList } = this.data
|
|
if (res.data && res.data.length > 0) {
|
|
rightList = res.data
|
|
cateList[0].children = res.data
|
|
}
|
|
this.setData({
|
|
rightList: rightList,
|
|
cateList
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
|
|
})
|
|
},
|
|
})
|