index.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. const Parse = getApp().Parse;
  2. const company = getApp().globalData.company
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. active: 0,
  9. meal: null,
  10. goods: null,
  11. room: null,
  12. },
  13. async getShopOrder() {
  14. let ShopOrder = new Parse.Query('ShopOrder')
  15. ShopOrder.equalTo('company', company)
  16. ShopOrder.equalTo('user', Parse.User.current().id)
  17. ShopOrder.equalTo('status', 800)
  18. ShopOrder.exists('score')
  19. ShopOrder.equalTo('type', 'meal')
  20. ShopOrder.include('shopStore')
  21. let shopOrder = await ShopOrder.find()
  22. let listJSON = []
  23. if (shopOrder && shopOrder.length > 0) {
  24. shopOrder.forEach(c => {
  25. listJSON.push(c.toJSON())
  26. })
  27. }
  28. this.setData({
  29. meal: listJSON
  30. })
  31. console.log(this.data.meal);
  32. },
  33. look(e) {
  34. let id = e.currentTarget.dataset.item.objectId
  35. console.log(id);
  36. wx.navigateTo({
  37. url: '/nova-tourism/pages/my/comments/look/index?id=' + id
  38. });
  39. },
  40. looks(e) {
  41. let id = e.currentTarget.dataset.item.objectId
  42. console.log(id);
  43. wx.navigateTo({
  44. url: '/nova-tourism/pages/my/comments/look2/index?id=' + id
  45. });
  46. },
  47. onChange(event) {
  48. active = event.detail.name
  49. this.setData({ active: active })
  50. },
  51. async getGoods() {
  52. let ShopOrder = new Parse.Query('ShopOrder')
  53. ShopOrder.equalTo('company', company)
  54. ShopOrder.equalTo('user', Parse.User.current().id)
  55. ShopOrder.equalTo('status', 800)
  56. ShopOrder.exists('score')
  57. ShopOrder.equalTo('type', 'goods')
  58. ShopOrder.include('shopStore')
  59. let shopOrder = await ShopOrder.find()
  60. let listJSON = []
  61. if (shopOrder && shopOrder.length > 0) {
  62. shopOrder.forEach(c => {
  63. listJSON.push(c.toJSON())
  64. })
  65. }
  66. this.setData({
  67. goods: listJSON
  68. })
  69. console.log(this.data.goods);
  70. },
  71. async getRoom() {
  72. let ShopOrder = new Parse.Query('RoomOrder')
  73. ShopOrder.equalTo('company', company)
  74. ShopOrder.equalTo('user', Parse.User.current().id)
  75. ShopOrder.equalTo('status', 800)
  76. ShopOrder.exists('score')
  77. ShopOrder.include('room')
  78. let shopOrder = await ShopOrder.find()
  79. let listJSON = []
  80. if (shopOrder && shopOrder.length > 0) {
  81. shopOrder.forEach(c => {
  82. listJSON.push(c.toJSON())
  83. })
  84. }
  85. this.setData({
  86. room: listJSON
  87. })
  88. console.log(this.data.room);
  89. },
  90. onChange(event) {
  91. let active = event.detail.name
  92. this.setData({ active: active })
  93. },
  94. async submit(e) {
  95. let that = this
  96. let id = e.currentTarget.dataset.item.objectId
  97. console.log(id);
  98. wx.showModal({
  99. title: '提示',
  100. content: '是否删除评论',
  101. success(res) {
  102. that.confirm(id)
  103. if (res.confirm) {
  104. console.log('确定')
  105. } else if (res.cancel) {
  106. console.log('取消')
  107. return
  108. }
  109. }
  110. })
  111. },
  112. async submits(e) {
  113. let that = this
  114. let id = e.currentTarget.dataset.item.objectId
  115. console.log(id);
  116. wx.showModal({
  117. title: '提示',
  118. content: '是否删除评论',
  119. success(res) {
  120. that.confirms(id)
  121. if (res.confirm) {
  122. console.log('确定')
  123. } else if (res.cancel) {
  124. console.log('取消')
  125. return
  126. }
  127. }
  128. })
  129. },
  130. async confirms(id) {
  131. let shopOrder
  132. let query = new Parse.Query("RoomOrder")
  133. shopOrder = await query.get(id)
  134. console.log(shopOrder);
  135. shopOrder.set("content", null)
  136. shopOrder.set("images", null)
  137. shopOrder.set("score", null)
  138. shopOrder.save().then(res => {
  139. console.log(res)
  140. wx.showToast({
  141. title: '删除成功',
  142. icon: 'none'
  143. })
  144. wx.navigateBack({
  145. delta: 1,
  146. });
  147. })
  148. console.log(shopOrder);
  149. },
  150. async confirm(id) {
  151. let shopOrder
  152. let query = new Parse.Query("ShopOrder")
  153. shopOrder = await query.get(id)
  154. console.log(shopOrder);
  155. shopOrder.set("content", null)
  156. shopOrder.set("images", null)
  157. shopOrder.set("score", null)
  158. shopOrder.save().then(res => {
  159. console.log(res)
  160. wx.showToast({
  161. title: '删除成功',
  162. icon: 'none'
  163. })
  164. wx.navigateBack({
  165. delta: 1,
  166. });
  167. })
  168. console.log(shopOrder);
  169. },
  170. /**
  171. * 生命周期函数--监听页面加载
  172. */
  173. onLoad: function(options) {
  174. this.setData({
  175. activeColor:getApp().globalData.activeColor || '#229293'
  176. })
  177. this.getShopOrder()
  178. this.getGoods()
  179. this.getRoom()
  180. },
  181. /**
  182. * 生命周期函数--监听页面初次渲染完成
  183. */
  184. onReady: function() {
  185. },
  186. /**
  187. * 生命周期函数--监听页面显示
  188. */
  189. onShow: function() {
  190. },
  191. /**
  192. * 生命周期函数--监听页面隐藏
  193. */
  194. onHide: function() {
  195. },
  196. /**
  197. * 生命周期函数--监听页面卸载
  198. */
  199. onUnload: function() {
  200. },
  201. /**
  202. * 页面相关事件处理函数--监听用户下拉动作
  203. */
  204. onPullDownRefresh: function() {
  205. },
  206. /**
  207. * 页面上拉触底事件的处理函数
  208. */
  209. onReachBottom: function() {
  210. },
  211. /**
  212. * 用户点击右上角分享
  213. */
  214. onShareAppMessage: function() {
  215. }
  216. })