personorder.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. // pages/personorder/personorder.js
  2. const app = getApp()
  3. import orderApi from '../../api/order'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. activeTab: 0,
  10. orderHeight: 0,
  11. tabs: [],
  12. orderList: [],
  13. pageNo: 1,
  14. loadingEnd: false,
  15. tabs: [{
  16. title: '全部'
  17. },
  18. {
  19. title: '代消费'
  20. },
  21. {
  22. title: '待评价'
  23. },
  24. {
  25. title: '已完成'
  26. },
  27. ]
  28. },
  29. /**
  30. * 生命周期函数--监听页面加载
  31. */
  32. onLoad: async function () {
  33. console.log(this)
  34. const isAuth = await app.isAuth()
  35. if (!isAuth) {
  36. wx.redirectTo({
  37. url: '/pages/prompt/prompt?page=' + this.route,
  38. })
  39. }
  40. this.getOrderHeight();
  41. },
  42. //动态生成产品的父盒子高度
  43. getOrderHeight: function () {
  44. var h = wx.getSystemInfoSync().windowHeight * (750 / wx.getSystemInfoSync().windowWidth);
  45. var orderHeight = h - 95;
  46. this.setData({
  47. orderHeight
  48. })
  49. },
  50. getOrderList: async function (params) {
  51. var pageNo = this.data.pageNo;
  52. var orderList = await orderApi.getAllOrderList(pageNo, 3);
  53. var list = orderList.list;
  54. console.log(list)
  55. //代消费订单
  56. var writeOffOrderList = [];
  57. //待评价订单
  58. var commentOffOrderList = [];
  59. //已完成订单
  60. var finishOrderList = [];
  61. list.forEach(function (item, u, array) {
  62. if (item.status == 2 && item.writeOffStatus == 1) {
  63. writeOffOrderList.push(item)
  64. }
  65. if (item.status == 2 && item.writeOffStatus == 2 && item.discussId != '') {
  66. finishOrderList.push(item)
  67. }
  68. if (item.status == 2 && item.writeOffStatus == 2 && item.discussId == '') {
  69. commentOffOrderList.push(item)
  70. }
  71. })
  72. var tabs = this.data.tabs;
  73. tabs[0].list = list;
  74. tabs[1].list = writeOffOrderList;
  75. tabs[2].list = commentOffOrderList;
  76. tabs[3].list = finishOrderList;
  77. this.setData({
  78. tabs
  79. })
  80. },
  81. // 获取全部列表
  82. getAllOrderList: async function () {
  83. const self = this
  84. var pageNo = this.data.pageNo;
  85. // 获取全部订单
  86. var orderList = await orderApi.getAllOrderList(pageNo, 4);
  87. var tabs = this.data.tabs;
  88. tabs[0].list = orderList.list;
  89. this.setData({
  90. tabs
  91. })
  92. // return list;
  93. },
  94. // 获取代消费列表
  95. getwriteOffOrderList: async function () {
  96. const self = this
  97. var pageNo = this.data.pageNo;
  98. // 获取代消费订单
  99. var orderList = await orderApi.getOrderList(pageNo, 4, 2, 1);
  100. var tabs = this.data.tabs;
  101. tabs[1].list = orderList.list;
  102. this.setData({
  103. tabs
  104. })
  105. // return list;
  106. },
  107. // 获取待评价列表
  108. getcommentOffOrderList: async function () {
  109. const self = this
  110. var pageNo = this.data.pageNo;
  111. // 获取代消费订单
  112. var orderList = await orderApi.getOrderList(pageNo, 4, 2, 1);
  113. var tabs = this.data.tabs;
  114. tabs[2].list = orderList.list;
  115. this.setData({
  116. tabs
  117. })
  118. // return list;
  119. },
  120. // 获取已经完成的列表
  121. getfinishOrderList: async function () {
  122. const self = this
  123. var pageNo = this.data.pageNo;
  124. // 获取代消费订单
  125. var orderList = await orderApi.getOrderList(pageNo, 4, 2, 1);
  126. var tabs = this.data.tabs;
  127. tabs[3].list = orderList.list;
  128. this.setData({
  129. tabs
  130. })
  131. // return list;
  132. },
  133. onTabClick(e) {
  134. const index = e.detail.index
  135. this.setData({
  136. activeTab: index
  137. })
  138. },
  139. onChange(e) {
  140. const index = e.detail.index
  141. this.setData({
  142. activeTab: index
  143. })
  144. },
  145. handleClick(e) {
  146. },
  147. showOrderInfo: async function (e) {
  148. console.log(e.currentTarget)
  149. var orderId = e.currentTarget.dataset.orderid;
  150. var status = e.currentTarget.dataset.status;
  151. var writeStatus = e.currentTarget.dataset.writestatus;
  152. if(status==2&&writeStatus==1){
  153. wx.navigateTo({
  154. url: '../order/order?orderId='+orderId,
  155. })
  156. return
  157. }
  158. },
  159. /**
  160. * 生命周期函数--监听页面初次渲染完成
  161. */
  162. onReady: function () {
  163. },
  164. /**
  165. * 生命周期函数--监听页面显示
  166. */
  167. onShow: async function () {
  168. await this.getOrderList()
  169. },
  170. /**
  171. * 生命周期函数--监听页面隐藏
  172. */
  173. onHide: function () {
  174. },
  175. /**
  176. * 生命周期函数--监听页面卸载
  177. */
  178. onUnload: function () {
  179. },
  180. /**
  181. * 页面相关事件处理函数--监听用户下拉动作
  182. */
  183. onPullDownRefresh: function () {
  184. },
  185. /**
  186. * 页面上拉触底事件的处理函数
  187. */
  188. onReachBottom: function () {
  189. },
  190. /**
  191. * 用户点击右上角分享
  192. */
  193. onShareAppMessage: function () {
  194. },
  195. gotoComment: function (e) {
  196. var orderId = e.currentTarget.dataset.orderid;
  197. var shopId = e.currentTarget.dataset.shopid;
  198. var productId = e.currentTarget.dataset.productid;
  199. wx.navigateTo({
  200. url: '../commentinfo/commentinfo?id=' + orderId + '&shopId=' + shopId + '&productId=' + productId,
  201. })
  202. },
  203. // 再来一单
  204. buyAgain: function (e) {
  205. var shopId = e.currentTarget.dataset.shopid;
  206. var productId = e.currentTarget.dataset.productid;
  207. var productImg = e.currentTarget.dataset.productimg;
  208. var productName = e.currentTarget.dataset.productname;
  209. var price = e.currentTarget.dataset.price;
  210. wx.navigateTo({
  211. url: '../appointment/appointment?' + 'shopId=' + shopId + '&productId=' + productId + '&productImg=' + productImg + '&productName=' + productName + '&price=' + price,
  212. })
  213. }
  214. })