personorder.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. // pages/personorder/personorder.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. activeTab: 0,
  9. orderHeight: 0,
  10. tabs:[]
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: async function () {
  16. console.log(this)
  17. const isAuth = await app.isAuth()
  18. if (!isAuth){
  19. wx.redirectTo({
  20. url: '/pages/prompt/prompt?page='+this.route,
  21. })
  22. }
  23. var tabs = await this.getOrderList();
  24. this.setData({
  25. tabs
  26. });
  27. this.getOrderHeight()
  28. },
  29. //动态生成产品的父盒子高度
  30. getOrderHeight: function () {
  31. var h = wx.getSystemInfoSync().windowHeight * (750 / wx.getSystemInfoSync().windowWidth);
  32. var orderHeight = h - 95;
  33. this.setData({
  34. orderHeight
  35. })
  36. },
  37. getOrderList: async function () {
  38. const self = this
  39. var titles = ["全部", "代消费", "待评价", "已完成"];
  40. const tabs = [];
  41. // 订单的三个状态,0是未付款,是未完成订单,1是未评价,待评价订单,2是已评价的完成订单
  42. var list = [{
  43. id: "1",
  44. orderId: "20200625118",
  45. orderStatus:1,
  46. title: "中式古法推拿",
  47. price: "1299",
  48. orderTime: "8-26 16:26",
  49. shopAddress: "上海市普陀区中江路3600号",
  50. distance: ">6km",
  51. imgurl: "../../images/order-img01.jpg"
  52. },
  53. {
  54. id: "2",
  55. orderId: "20200625118",
  56. orderStatus:0,
  57. title: "中式古法推拿",
  58. price: "1299",
  59. orderTime: "8-26 16:26",
  60. shopAddress: "上海市普陀区中江路3600号",
  61. distance: ">6km",
  62. imgurl: "../../images/order-img02.jpg"
  63. },
  64. {
  65. id: "3",
  66. orderId: "20200625118",
  67. orderStatus:2,
  68. title: "中式古法推拿",
  69. price: "1299",
  70. orderTime: "8-26 16:26",
  71. shopAddress: "上海市普陀区中江路3600号",
  72. distance: ">6km",
  73. imgurl: "../../images/order-img01.jpg"
  74. },
  75. {
  76. id: "4",
  77. orderId: "20200625118",
  78. orderStatus:1,
  79. title: "中式古法推拿",
  80. price: "1299",
  81. orderTime: "8-26 16:26",
  82. shopAddress: "上海市普陀区中江路3600号",
  83. distance: ">6km",
  84. imgurl: "../../images/order-img02.jpg"
  85. }
  86. ];
  87. for (let i = 0; i < titles.length; i++) {
  88. let title = titles[i];
  89. tabs.push({
  90. title,
  91. list
  92. })
  93. }
  94. tabs[2].list = [{
  95. id: "1",
  96. orderId: "20200625118",
  97. title: "中式古法推拿",
  98. price: "1299",
  99. orderTime: "8-26 16:26",
  100. shopAddress: "上海市普陀区中江路3600号",
  101. distance: ">6km",
  102. imgurl: "../../images/order-img02.jpg"
  103. }];
  104. return tabs;
  105. },
  106. onTabClick(e) {
  107. const index = e.detail.index
  108. this.setData({
  109. activeTab: index
  110. })
  111. },
  112. onChange(e) {
  113. const index = e.detail.index
  114. this.setData({
  115. activeTab: index
  116. })
  117. },
  118. handleClick(e) {
  119. },
  120. /**
  121. * 生命周期函数--监听页面初次渲染完成
  122. */
  123. onReady: function () {
  124. },
  125. /**
  126. * 生命周期函数--监听页面显示
  127. */
  128. onShow: function () {
  129. },
  130. /**
  131. * 生命周期函数--监听页面隐藏
  132. */
  133. onHide: function () {
  134. },
  135. /**
  136. * 生命周期函数--监听页面卸载
  137. */
  138. onUnload: function () {
  139. },
  140. /**
  141. * 页面相关事件处理函数--监听用户下拉动作
  142. */
  143. onPullDownRefresh: function () {
  144. },
  145. /**
  146. * 页面上拉触底事件的处理函数
  147. */
  148. onReachBottom: function () {
  149. },
  150. /**
  151. * 用户点击右上角分享
  152. */
  153. onShareAppMessage: function () {
  154. },
  155. gotoComment:function (e) {
  156. wx.navigateTo({
  157. url: '../commentinfo/commentinfo',
  158. })
  159. }
  160. })