personorder.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. wx.navigateTo({
  120. url: './webview',
  121. })
  122. },
  123. /**
  124. * 生命周期函数--监听页面初次渲染完成
  125. */
  126. onReady: function () {
  127. },
  128. /**
  129. * 生命周期函数--监听页面显示
  130. */
  131. onShow: function () {
  132. },
  133. /**
  134. * 生命周期函数--监听页面隐藏
  135. */
  136. onHide: function () {
  137. },
  138. /**
  139. * 生命周期函数--监听页面卸载
  140. */
  141. onUnload: function () {
  142. },
  143. /**
  144. * 页面相关事件处理函数--监听用户下拉动作
  145. */
  146. onPullDownRefresh: function () {
  147. },
  148. /**
  149. * 页面上拉触底事件的处理函数
  150. */
  151. onReachBottom: function () {
  152. },
  153. /**
  154. * 用户点击右上角分享
  155. */
  156. onShareAppMessage: function () {
  157. }
  158. })