index.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. let Parse = getApp().Parse;
  2. const company = getApp().globalData.company
  3. const dateF = require('../../../../utils/date')
  4. const compute = require("../../../../utils/compute.js");
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. active: 0,
  11. id: null,
  12. shopstore: null,
  13. list: [],
  14. score: 4,
  15. comments: null,
  16. latitude: null,
  17. longitude: null,
  18. distance: null,
  19. activeColor: '#229293'
  20. },
  21. getLocation() {
  22. return new Promise((resolve, reject) => {
  23. wx.getLocation({
  24. type: 'gcj02',
  25. success: (res) => {
  26. console.log(res.latitude, res.longitude);
  27. resolve({
  28. latitude: res.latitude,
  29. longitude: res.longitude
  30. })
  31. },
  32. fail: () => { },
  33. complete: () => { }
  34. });
  35. })
  36. },
  37. async getComments() {
  38. let Order = new Parse.Query('ShopOrder')
  39. Order.equalTo("shopStore", this.data.id);
  40. Order.include("user");
  41. Order.include("goods");
  42. Order.greaterThanOrEqualTo("status", 800);
  43. Order.ascending('updatedAt')
  44. Order.notEqualTo('hiddenComment', true)
  45. Order.limit(10)
  46. Order.find().then(res => {
  47. let comments = []
  48. res.forEach(item => {
  49. let activitys = item.toJSON()
  50. if(activitys.goods) activitys.time = dateF.formatTime("YYYY-mm-dd HH:MM:SS", activitys.goods.updatedAt)
  51. comments.push(activitys)
  52. })
  53. this.setData({
  54. comments
  55. }),
  56. console.log(this.data.comments)
  57. })
  58. },
  59. onevaluation(event) {
  60. let active = event.detail.name
  61. console.log(active);
  62. this.setData({
  63. active: active
  64. })
  65. },
  66. taxi() {
  67. let latitude = this.data.shopstore.location.latitude;
  68. let longitude = this.data.shopstore.location.longitude;
  69. console.log(latitude, longitude);
  70. wx.getLocation({
  71. type: 'gcj02', //返回可以用于wx.openLocation的经纬度
  72. success(res) {
  73. wx.openLocation({
  74. latitude,
  75. longitude,
  76. scale: 18
  77. })
  78. },
  79. })
  80. },
  81. phone() {
  82. let phone = this.data.shopstore.mobile
  83. console.log(phone);
  84. wx.makePhoneCall({
  85. phoneNumber: phone
  86. })
  87. },
  88. async getShopgoods() {
  89. let Coupon = new Parse.Query('ShopGoods')
  90. Coupon.notEqualTo('isDeleted', "true")
  91. Coupon.equalTo('shopStore', this.data.id)
  92. Coupon.equalTo('status', 'true')
  93. Coupon.equalTo('type', 'meal')
  94. let coupon = await Coupon.find()
  95. if (coupon && coupon.length > 0) {
  96. let listJSON = []
  97. coupon.forEach(c => {
  98. listJSON.push(c.toJSON())
  99. })
  100. this.setData({
  101. list: listJSON
  102. })
  103. }
  104. console.log(this.data.list.length);
  105. },
  106. async getShopStore() {
  107. let id = this.data.id
  108. let ShopStore = new Parse.Query('ShopStore')
  109. let shopstore = await ShopStore.get(id)
  110. let distances = compute.computeDistance(
  111. this.data.latitude,
  112. this.data.longitude,
  113. shopstore.toJSON().location.latitude,
  114. shopstore.toJSON().location.longitude
  115. )
  116. let distance = distances.toFixed(2)
  117. this.setData({
  118. shopstore: shopstore.toJSON(),
  119. distance: distance
  120. })
  121. console.log(this.data.distance);
  122. },
  123. async tableList() {
  124. let TableList = new Parse.Query('TableNumber')
  125. TableList.equalTo('store', this.data.id)
  126. TableList.equalTo('company', company)
  127. TableList.equalTo('status', true)
  128. TableList.select('name', "objectId", "number")
  129. let tableList = await TableList.find()
  130. console.log(tableList);
  131. if (tableList && tableList.length > 0) {
  132. let tableArr = []
  133. console.log(tableList)
  134. tableList.forEach(li => {
  135. tableArr.push({
  136. id: li.id,
  137. name: li.get('name'),
  138. number: li.get('number')
  139. })
  140. })
  141. this.setData({
  142. tableList: tableArr,
  143. // table: tableArr[0]
  144. })
  145. console.log(this.data.tableList)
  146. }
  147. },
  148. comment() {
  149. let id = this.data.id
  150. console.log(id);
  151. wx.navigateTo({
  152. url: '/nova-tourism/pages/gourmet/store-package/comment/index?id=' + id
  153. });
  154. },
  155. goodsdetails(e) {
  156. let id = e.currentTarget.dataset.item.objectId
  157. console.log(id);
  158. wx.navigateTo({
  159. url: '/nova-tourism/pages/gourmet/store-package/goods-details/index?id=' + id
  160. });
  161. },
  162. /**
  163. * 生命周期函数--监听页面加载
  164. */
  165. onLoad: function (options) {
  166. this.setData({
  167. activeColor:getApp().globalData.activeColor || '#229293'
  168. })
  169. let id = options.id
  170. console.log(id);
  171. this.setData({ id: id })
  172. this.getShopStore()
  173. this.getShopgoods()
  174. this.getComments()
  175. this.getLocation()
  176. this.tableList()
  177. },
  178. toOrder() {
  179. wx.navigateTo({
  180. url: '/nova-tourism/pages/gourmet/store-package/meal-order/index?storeid=' + this.data.id
  181. });
  182. },
  183. toWebView(e) {
  184. console.log(e)
  185. let path = e.currentTarget.dataset.path
  186. if (!path) {
  187. wx.showToast({
  188. title: 'VR素材收集中',
  189. duration: 1500,
  190. icon: "none",
  191. })
  192. return
  193. }
  194. wx.navigateTo({
  195. url: '/common-page/pages/web-view/index?path=' + path,
  196. })
  197. },
  198. /**
  199. * 生命周期函数--监听页面初次渲染完成
  200. */
  201. onReady: function () {
  202. },
  203. /**
  204. * 生命周期函数--监听页面显示
  205. */
  206. onShow: function () {
  207. },
  208. /**
  209. * 生命周期函数--监听页面隐藏
  210. */
  211. onHide: function () {
  212. },
  213. /**
  214. * 生命周期函数--监听页面卸载
  215. */
  216. onUnload: function () {
  217. },
  218. /**
  219. * 页面相关事件处理函数--监听用户下拉动作
  220. */
  221. onPullDownRefresh: function () {
  222. },
  223. /**
  224. * 页面上拉触底事件的处理函数
  225. */
  226. onReachBottom: function () {
  227. },
  228. /**
  229. * 用户点击右上角分享
  230. */
  231. onShareAppMessage: function () {
  232. return {
  233. title: `${this.data.shopstore.storeName}`,
  234. }
  235. }
  236. })