index.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. show: false,
  15. showid:null,
  16. },
  17. async getUserInfo(e) {
  18. console.log(e.currentTarget.dataset.item.objectId);
  19. let objectId = e.currentTarget.dataset.item.objectId
  20. let newOrder = new Parse.Query('RoomOrder');
  21. newOrder.equalTo('company', company);
  22. newOrder.equalTo('objectId', objectId);
  23. newOrder.notEqualTo('isDeleted', true);
  24. let order = await newOrder.first();
  25. console.log(order);
  26. order.set('status',200)
  27. try{
  28. let saveDate = await order.save();
  29. console.log('保存成功');
  30. this.setData({
  31. showid:null
  32. })
  33. this.getShopOrder()
  34. }catch (error) {
  35. console.error("保存数据时出现错误:", error);
  36. }
  37. },
  38. onClose() {
  39. this.setData({
  40. show: false,
  41. }); // 关闭弹窗并重置标志位
  42. },
  43. ONShow(e) {
  44. const id =e.currentTarget.dataset.item.objectId
  45. this.setData({
  46. showid:id,
  47. show: true,
  48. }); // 设置弹窗显示
  49. console.log(this.data.showid);
  50. },
  51. onChange(event) {
  52. let active = event.detail.name
  53. this.setData({
  54. active: active
  55. })
  56. console.log(active);
  57. this.getShopOrder()
  58. },
  59. storepackage(e) {
  60. let price = e.currentTarget.dataset.item.price
  61. console.log(price);
  62. this.setData({
  63. show: true,
  64. price: price
  65. })
  66. },
  67. async acceptResult(e) {
  68. let {
  69. order,
  70. } = this.data
  71. let that = this
  72. let {
  73. params,
  74. no
  75. } = e.detail;
  76. that.setData({
  77. show: false
  78. })
  79. try {
  80. if (params == "ok") {
  81. order.set("isPay", true)
  82. await order.save()
  83. this.setData({
  84. isPay: true
  85. })
  86. wx.showToast({
  87. title: '报名成功',
  88. icon: 'none',
  89. image: '',
  90. duration: 1500,
  91. mask: false,
  92. });
  93. } else {
  94. wx.showToast({
  95. title: '支付失败,取消订单',
  96. icon: 'none',
  97. image: '',
  98. duration: 1500,
  99. mask: false,
  100. });
  101. }
  102. } catch (error) {
  103. console.log(error)
  104. wx.showToast({
  105. title: "支付失败",
  106. icon: "error",
  107. duration: 1500,
  108. });
  109. wx.hideLoading()
  110. }
  111. },
  112. //删除
  113. // evaluation(e) {
  114. // let id = e.currentTarget.dataset.item.objectId
  115. // console.log(id);
  116. // wx.navigateTo({
  117. // url: '/nova-tourism/pages/my/homestay-order/evaluation/index?id=' + id
  118. // });
  119. // },
  120. // orderpay(e) {
  121. // let id = e.currentTarget.dataset.item.objectId
  122. // console.log(id);
  123. // wx.navigateTo({
  124. // url: '/nova-tourism/pages/my/homestay-order/homestay-details/index?id=' + id
  125. // });
  126. // },
  127. phone(e) {
  128. let phone = e.currentTarget.dataset.item.shopStore.mobile
  129. console.log(phone);
  130. wx.makePhoneCall({
  131. phoneNumber: phone
  132. })
  133. },
  134. async getShopOrder() {
  135. let ShopOrder = new Parse.Query('RoomOrder');
  136. ShopOrder.equalTo('company', company);
  137. ShopOrder.include('room');
  138. ShopOrder.equalTo('shopStore', this.data.storeId);
  139. if (this.data.active == 1) {
  140. ShopOrder.equalTo('status', 100);
  141. }
  142. if (this.data.active == 2) {
  143. ShopOrder.equalTo('status', 200);
  144. }
  145. if (this.data.active == 3) {
  146. console.log(this.data.active);
  147. ShopOrder.equalTo('status', 400);
  148. }
  149. ShopOrder.include('room');
  150. ShopOrder.include('user');
  151. ShopOrder.exists('status');
  152. ShopOrder.find().then(res => {
  153. let list = [];
  154. res.forEach(item => {
  155. let activitys = item.toJSON();
  156. activitys.orderTime = dateF.formatTime("mm-dd", activitys.startTime.iso);
  157. activitys.Time = dateF.formatTime("mm-dd", activitys.endTime.iso);
  158. activitys.a = dateF.formatTime("YYYY-mm-dd", activitys.startTime.iso); // 只保留日期部分
  159. activitys.e = dateF.formatTime("YYYY-mm-dd", activitys.endTime.iso); // 只保留日期部分
  160. // 计算天数,只考虑日期部分
  161. activitys.day = parseInt((new Date(activitys.e).getTime() - new Date(activitys.a).getTime()) / (1000 * 60 * 60 * 24));
  162. list.push(activitys);
  163. });
  164. this.setData({
  165. list
  166. });
  167. console.log(this.data.list);
  168. });
  169. },
  170. orderdeils(e) {
  171. let id = e.currentTarget.dataset.item.objectId
  172. console.log(id);
  173. wx.navigateTo({
  174. url: '../order2-list/order-deils/index?id=' + id,
  175. });
  176. },
  177. /**
  178. * 生命周期函数--监听页面加载
  179. */
  180. onLoad: function (options) {
  181. let storeId = options.storeId;
  182. console.log(storeId);
  183. this.setData({
  184. storeId: storeId
  185. })
  186. this.getShopOrder()
  187. // this.getDayAll()
  188. },
  189. /**
  190. * 生命周期函数--监听页面初次渲染完成
  191. */
  192. onReady: function () {
  193. },
  194. /**
  195. * 生命周期函数--监听页面显示
  196. */
  197. onShow: function () {
  198. },
  199. /**
  200. * 生命周期函数--监听页面隐藏
  201. */
  202. onHide: function () {
  203. },
  204. /**
  205. * 生命周期函数--监听页面卸载
  206. */
  207. onUnload: function () {
  208. },
  209. /**
  210. * 页面相关事件处理函数--监听用户下拉动作
  211. */
  212. onPullDownRefresh: function () {
  213. },
  214. /**
  215. * 页面上拉触底事件的处理函数
  216. */
  217. onReachBottom: function () {
  218. },
  219. /**
  220. * 用户点击右上角分享
  221. */
  222. onShareAppMessage: function () {
  223. }
  224. })