index.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. const Parse = getApp().Parse;
  2. const app = getApp();
  3. const company = getApp().globalData.company;
  4. const dateF = require('../../../../utils/date');
  5. let navigationBarHeight = getApp().globalData.statusBarHeight + 44;
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. active: 0,
  12. list: [],
  13. price: null,
  14. navigationBarHeight,
  15. activeColor:""
  16. },
  17. onChange(event) {
  18. let active = event.detail.name;
  19. this.setData({
  20. active: active
  21. });
  22. console.log(active);
  23. this.getRoomOrder();
  24. },
  25. storepackage(e) {
  26. let price = e.currentTarget.dataset.item.price;
  27. console.log(price);
  28. this.setData({
  29. show: true,
  30. price: price
  31. });
  32. },
  33. async acceptResult(e) {
  34. let { order } = this.data;
  35. let that = this;
  36. let { params, no } = e.detail;
  37. that.setData({
  38. show: false
  39. });
  40. try {
  41. if (params == 'ok') {
  42. order.set('isPay', true);
  43. await order.save();
  44. this.setData({
  45. isPay: true
  46. });
  47. wx.showToast({
  48. title: '支付成功',
  49. icon: 'none',
  50. image: '',
  51. duration: 1500,
  52. mask: false
  53. });
  54. } else {
  55. wx.showToast({
  56. title: '支付失败,取消订单',
  57. icon: 'none',
  58. image: '',
  59. duration: 1500,
  60. mask: false
  61. });
  62. }
  63. } catch (error) {
  64. console.log(error);
  65. wx.showToast({
  66. title: '支付失败',
  67. icon: 'error',
  68. duration: 1500
  69. });
  70. wx.hideLoading();
  71. }
  72. },
  73. //删除
  74. delOrder(e) {
  75. console.log(e);
  76. let { index } = e.currentTarget.dataset;
  77. let { list } = this.data;
  78. let _this = this;
  79. wx.showModal({
  80. title: '',
  81. content: '你确定删除该订单吗?',
  82. showCancel: true,
  83. cancelText: '取消',
  84. cancelColor: '#000000',
  85. confirmText: '确定',
  86. confirmColor: '#3CC51F',
  87. success: async result => {
  88. if (result.confirm) {
  89. await this.upDel(list[index].objectId);
  90. list.splice(index, 1);
  91. _this.setData({
  92. list
  93. });
  94. wx.showToast({
  95. title: '已取消',
  96. icon: 'none',
  97. image: '',
  98. duration: 1500
  99. });
  100. }
  101. },
  102. fail: () => {},
  103. complete: () => {}
  104. });
  105. },
  106. async upDel(id) {
  107. let ShopOrder = new Parse.Query('RoomOrder');
  108. let order = await ShopOrder.get(id);
  109. if (order && order.id) {
  110. console.log(order);
  111. await order.destroy();
  112. }
  113. },
  114. evaluation(e) {
  115. let id = e.currentTarget.dataset.item.objectId;
  116. console.log(id);
  117. wx.navigateTo({
  118. url: '/nova-tourism/pages/my/homestay-order/evaluation/index?id=' + id
  119. });
  120. },
  121. orderpay(e) {
  122. let id = e.currentTarget.dataset.item.objectId;
  123. console.log(id);
  124. wx.navigateTo({
  125. url:
  126. '/nova-tourism/pages/my/homestay-order/homestay-details/index?id=' + id
  127. });
  128. },
  129. replyRefund(e) {
  130. let id = e.currentTarget.dataset.item.objectId;
  131. console.log(id);
  132. wx.navigateTo({
  133. url:
  134. '/nova-tourism/pages/my/refund/reply-refund/index?schema=RoomOrder&id=' +
  135. id
  136. });
  137. },
  138. phone(e) {
  139. let phone = e.currentTarget.dataset.item.shopStore.mobile;
  140. console.log(phone);
  141. wx.makePhoneCall({
  142. phoneNumber: phone
  143. });
  144. },
  145. async getRoomOrder() {
  146. let Order = new Parse.Query('RoomOrder');
  147. Order.equalTo('company', company);
  148. Order.include('room');
  149. Order.equalTo('user', Parse.User.current().id);
  150. if (this.data.active == 0) {
  151. Order.exists('status');
  152. }
  153. if (this.data.active == 1) {
  154. Order.equalTo('status', 100);
  155. }
  156. if (this.data.active == 2) {
  157. Order.equalTo('status', 200);
  158. }
  159. if (this.data.active == 3) {
  160. console.log(this.data.active);
  161. Order.equalTo('status', 800);
  162. }
  163. Order.include('room');
  164. Order.find().then(res => {
  165. let list = [];
  166. res.forEach(item => {
  167. let activitys = item.toJSON();
  168. activitys.orderTime = dateF.formatTime(
  169. 'mm-dd',
  170. activitys.startTime.iso
  171. );
  172. activitys.Time = dateF.formatTime('mm-dd', activitys.endTime.iso);
  173. activitys.a = dateF.formatTime(
  174. 'YYYY-mm-dd HH:MM:SS',
  175. activitys.startTime.iso
  176. );
  177. activitys.e = dateF.formatTime(
  178. 'YYYY-mm-dd HH:MM:SS',
  179. activitys.endTime.iso
  180. );
  181. //计算天数
  182. activitys.day = parseInt(
  183. (new Date(activitys.e.replace(/-/g, '/')).getTime() -
  184. new Date(activitys.a.replace(/-/g, '/')).getTime()) /
  185. (1000 * 60 * 60 * 24)
  186. );
  187. list.push(activitys);
  188. });
  189. this.setData({
  190. list
  191. });
  192. console.log(this.data.list);
  193. });
  194. },
  195. /**
  196. * 生命周期函数--监听页面加载
  197. */
  198. onLoad: function (options) {
  199. this.setData({
  200. activeColor:getApp().globalData.activeColor || '#229293'
  201. })
  202. this.getRoomOrder();
  203. // this.getDayAll()
  204. },
  205. /**
  206. * 生命周期函数--监听页面初次渲染完成
  207. */
  208. onReady: function () {},
  209. /**
  210. * 生命周期函数--监听页面显示
  211. */
  212. onShow: function () {},
  213. /**
  214. * 生命周期函数--监听页面隐藏
  215. */
  216. onHide: function () {},
  217. /**
  218. * 生命周期函数--监听页面卸载
  219. */
  220. onUnload: function () {},
  221. /**
  222. * 页面相关事件处理函数--监听用户下拉动作
  223. */
  224. onPullDownRefresh: function () {},
  225. /**
  226. * 页面上拉触底事件的处理函数
  227. */
  228. onReachBottom: function () {},
  229. /**
  230. * 用户点击右上角分享
  231. */
  232. onShareAppMessage: function () {}
  233. });