index.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. const Parse = getApp().Parse;
  2. const app = getApp();
  3. const company = getApp().globalData.company
  4. const dateF = require('../../../../../../utils/date')
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. active: 0,
  11. list: [],
  12. price: null,
  13. storeId:null
  14. },
  15. onChange(event) {
  16. let active = event.detail.name
  17. this.setData({
  18. active: active
  19. })
  20. console.log(active);
  21. this.getShopOrder()
  22. },
  23. storepackage(e) {
  24. let price = e.currentTarget.dataset.item.price
  25. console.log(price);
  26. this.setData({
  27. show: true,
  28. price: price
  29. })
  30. },
  31. async acceptResult(e) {
  32. let {
  33. order,
  34. } = this.data
  35. let that = this
  36. let {
  37. params,
  38. no
  39. } = e.detail;
  40. that.setData({
  41. show: false
  42. })
  43. try {
  44. if (params == "ok") {
  45. order.set("isPay", true)
  46. await order.save()
  47. this.setData({
  48. isPay: true
  49. })
  50. wx.showToast({
  51. title: '报名成功',
  52. icon: 'none',
  53. image: '',
  54. duration: 1500,
  55. mask: false,
  56. });
  57. } else {
  58. wx.showToast({
  59. title: '支付失败,取消订单',
  60. icon: 'none',
  61. image: '',
  62. duration: 1500,
  63. mask: false,
  64. });
  65. }
  66. } catch (error) {
  67. console.log(error)
  68. wx.showToast({
  69. title: "支付失败",
  70. icon: "error",
  71. duration: 1500,
  72. });
  73. wx.hideLoading()
  74. }
  75. },
  76. //删除
  77. evaluation(e) {
  78. let id = e.currentTarget.dataset.item.objectId
  79. console.log(id);
  80. wx.navigateTo({
  81. url: '/nova-tourism/pages/my/homestay-order/evaluation/index?id=' + id
  82. });
  83. },
  84. orderpay(e) {
  85. let id = e.currentTarget.dataset.item.objectId
  86. console.log(id);
  87. wx.navigateTo({
  88. url: '/nova-tourism/pages/my/homestay-order/homestay-details/index?id=' + id
  89. });
  90. },
  91. phone(e) {
  92. let phone = e.currentTarget.dataset.item.shopStore.mobile
  93. console.log(phone);
  94. wx.makePhoneCall({
  95. phoneNumber: phone
  96. })
  97. },
  98. async getShopOrder() {
  99. let ShopOrder = new Parse.Query('RoomOrder')
  100. ShopOrder.equalTo('company', company)
  101. ShopOrder.include('room')
  102. ShopOrder.equalTo('shopStore', this.data.storeId)
  103. if (this.data.active == 1) {
  104. ShopOrder.equalTo('status', 100)
  105. }
  106. if (this.data.active == 2) {
  107. ShopOrder.equalTo('status', 200)
  108. }
  109. if (this.data.active == 3) {
  110. console.log(this.data.active)
  111. ShopOrder.equalTo('status', 400)
  112. }
  113. ShopOrder.include('room')
  114. ShopOrder.exists('status')
  115. ShopOrder.find().then(res => {
  116. let list = []
  117. res.forEach(item => {
  118. let activitys = item.toJSON()
  119. activitys.orderTime = dateF.formatTime("mm-dd", activitys.startTime.iso)
  120. activitys.Time = dateF.formatTime("mm-dd", activitys.endTime.iso)
  121. activitys.a = dateF.formatTime("YYYY-mm-dd HH:MM:SS", activitys.startTime.iso)
  122. activitys.e = dateF.formatTime("YYYY-mm-dd HH:MM:SS", activitys.endTime.iso)
  123. //计算天数
  124. activitys.day = parseInt((new Date(activitys.e.replace(/-/g, '/')).getTime() - new Date(activitys.a.replace(/-/g, '/')).getTime()) / (1000 * 60 * 60 * 24));
  125. list.push(activitys)
  126. })
  127. this.setData({
  128. list
  129. }),
  130. console.log(this.data.list)
  131. })
  132. },
  133. orderdeils(e) {
  134. let id = e.currentTarget.dataset.item.objectId
  135. console.log(id);
  136. wx.navigateTo({
  137. url: '/nova-tourism/pages/my/merchant/merchant-home/order2-list/order-deils/index?id=' + id,
  138. });
  139. },
  140. /**
  141. * 生命周期函数--监听页面加载
  142. */
  143. onLoad: function(options) {
  144. let storeId = options.storeId;
  145. console.log(storeId);
  146. this.setData({ storeId: storeId })
  147. this.getShopOrder()
  148. // this.getDayAll()
  149. },
  150. /**
  151. * 生命周期函数--监听页面初次渲染完成
  152. */
  153. onReady: function() {
  154. },
  155. /**
  156. * 生命周期函数--监听页面显示
  157. */
  158. onShow: function() {
  159. },
  160. /**
  161. * 生命周期函数--监听页面隐藏
  162. */
  163. onHide: function() {
  164. },
  165. /**
  166. * 生命周期函数--监听页面卸载
  167. */
  168. onUnload: function() {
  169. },
  170. /**
  171. * 页面相关事件处理函数--监听用户下拉动作
  172. */
  173. onPullDownRefresh: function() {
  174. },
  175. /**
  176. * 页面上拉触底事件的处理函数
  177. */
  178. onReachBottom: function() {
  179. },
  180. /**
  181. * 用户点击右上角分享
  182. */
  183. onShareAppMessage: function() {
  184. }
  185. })