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.
114 lines
2.3 KiB
114 lines
2.3 KiB
const app = getApp<IAppOption>(); |
|
|
|
Page({ |
|
data: { |
|
bottom: 0, |
|
selfScore: { |
|
expire: {}, |
|
}, |
|
cateList: [], |
|
|
|
cateId: "", |
|
list: [], |
|
pagination: { |
|
page: 1, |
|
pages: 1, |
|
count: 1, |
|
}, |
|
}, |
|
onLoad() { |
|
const SystemInfo = app.globalSystemInfo; |
|
if (SystemInfo) { |
|
const { bottom } = SystemInfo.capsulePosition; |
|
this.setData({ |
|
bottom: bottom, |
|
}); |
|
} |
|
app.waitLogin().then(() => { |
|
app.getZdUserInfo(this, true); |
|
this.getScore(); |
|
this.getList(); |
|
this.getCateList(); |
|
}); |
|
}, |
|
getScore() { |
|
wx.ajax({ |
|
method: "GET", |
|
url: "?r=zd/patient-score/get-self-score", |
|
data: {}, |
|
}).then((res) => { |
|
this.setData({ |
|
selfScore: res, |
|
}); |
|
}); |
|
}, |
|
getCateList() { |
|
wx.ajax({ |
|
method: "GET", |
|
url: "?r=zd/gift-spu/get-cate-all-list", |
|
data: {}, |
|
}).then((res) => { |
|
this.setData({ |
|
cateList: res, |
|
}); |
|
}); |
|
}, |
|
handleCate(e) { |
|
const { id } = e.currentTarget.dataset; |
|
this.setData({ |
|
cateId: id, |
|
}); |
|
this.getList(); |
|
}, |
|
getList(newPage = 1) { |
|
wx.ajax({ |
|
method: "POST", |
|
url: `?r=zd/gift-spu/get-list&page=${newPage}`, |
|
data: { |
|
cateId: this.data.cateId ? [this.data.cateId] : [], |
|
}, |
|
}).then((res) => { |
|
let list = res.page == 1 ? res.list : [...this.data.list, ...res.list]; |
|
this.setData({ |
|
list: list, |
|
pagination: { |
|
page: res.page, |
|
pages: res.pages, |
|
count: res.count, |
|
}, |
|
}); |
|
}); |
|
}, |
|
handlePirceDetail() { |
|
wx.navigateTo({ |
|
url: "/gift/pages/priceDetail/index", |
|
}); |
|
}, |
|
handleMyGift() { |
|
wx.navigateTo({ |
|
url: "/gift/pages/myGift/index", |
|
}); |
|
}, |
|
handleDetail(e) { |
|
const { id } = e.currentTarget.dataset; |
|
wx.navigateTo({ |
|
url: `/gift/pages/giftDetail/index?id=${id}`, |
|
}); |
|
}, |
|
handleRule() { |
|
wx.navigateTo({ |
|
url: `/gift/pages/scoreRule/index`, |
|
}); |
|
}, |
|
handleBack() { |
|
wx.reLaunch({ |
|
url: "/pages/my/index", |
|
}); |
|
}, |
|
onReachBottom() { |
|
const { page, pages } = this.data.pagination; |
|
if (pages > page) { |
|
this.getList(page + 1); |
|
} |
|
}, |
|
});
|
|
|