| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- // pages/my-order/my-order.js
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- list: [], //订单列表
- show: false, //展示无数据页面
- pageNo: 1, //页码
- isLast: false, //是否是最后一页
- },
- /**
- * 跳转详情页
- * @id {string} 订单ID
- */
- toDetail(e) {
- const id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: `/pages/detail/detail?id=${id}&&status=3`,
- })
- },
- /**
- * 查看合同
- * @contract {string} 合同
- *
- */
- checkContract(e) {
- const contract = e.currentTarget.dataset.contract;
- if (contract) {
- wx.downloadFile({
- url: contract,
- success: (res) => {
- wx.openDocument({
- filePath: res.tempFilePath,
- })
- }
- })
- } else {
- }
- },
- /**
- * 确认订单
- * @orderId {string} 订单ID
- */
- confirm(e) {
- const id = e.currentTarget.dataset.id;
- const index = e.currentTarget.dataset.index;
- wx.kx_request({
- url: wx.kx_api.hwOrder.confirmOrder,
- type: 'post',
- data: {
- orderId: id
- },
- success: res => {
- if (res.errcode === 0) {
- wx.showToast({
- title: '订单已确认',
- success: res => {
- // 确认成功 更改页面订单状态
- const list = this.data.list;
- list[index].status = 2;
- list[index].serviceStage = 1;
- this.setData({
- list
- })
- }
- })
- }
- }
- })
- },
- /**
- * 获取订单列表
- * @pageNo {number} 页码
- * @pageSize {number} 页面条数
- */
- getList(pageNo = this.data.pageNo) {
- wx.kx_request({
- url: wx.kx_api.hwOrder.getOrders,
- data: {
- pageNo,
- pageSize: 10
- },
- success: res => {
- if (res.errcode === 0) {
- if (pageNo === 1 && res.data.hwOrderList && res.data.hwOrderList.length === 0) {
- this.setData({
- show: true
- })
- } else {
- pageNo++;
- this.setData({
- list: [...this.data.list, ...res.data.hwOrderList],
- isLast: res.data.isLast,
- pageNo
- })
- }
- }
- },
- complete: () => {
- wx.stopPullDownRefresh();
- }
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- // 获取订单列表
- this.getList()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
- this.setData({
- list: [],
- pageNo: 1
- }, _ => {
- this.getList()
- })
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
- const isLast = this.data.isLast;
- if (isLast) {
- // wx.showToast({
- // icon: 'none',
- // title: '已经是最后一页了',
- // })
- } else {
- this.getList()
- }
- }
- })
|