personorder.js 3.5 KB

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