index.js 7.6 KB

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