123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- let Parse = getApp().Parse;
- const company = getApp().globalData.company
- const dateF = require('../../../../utils/date')
- const compute = require("../../../../utils/compute.js");
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- active: 0,
- id: null,
- shopstore: null,
- list: [],
- score: 4,
- comments: null,
- latitude: null,
- longitude: null,
- distance: null,
- activeColor: '#229293'
- },
- getLocation() {
- return new Promise((resolve, reject) => {
- wx.getLocation({
- type: 'gcj02',
- success: (res) => {
- console.log(res.latitude, res.longitude);
- resolve({
- latitude: res.latitude,
- longitude: res.longitude
- })
- },
- fail: () => { },
- complete: () => { }
- });
- })
- },
- async getComments() {
- let Order = new Parse.Query('ShopOrder')
- Order.equalTo("shopStore", this.data.id);
- Order.include("user");
- Order.include("goods");
- Order.greaterThanOrEqualTo("status", 800);
- Order.ascending('updatedAt')
- Order.notEqualTo('hiddenComment', true)
- Order.limit(10)
- Order.find().then(res => {
- let comments = []
- res.forEach(item => {
- let activitys = item.toJSON()
- if(activitys.goods) activitys.time = dateF.formatTime("YYYY-mm-dd HH:MM:SS", activitys.goods.updatedAt)
- comments.push(activitys)
- })
- this.setData({
- comments
- }),
- console.log(this.data.comments)
- })
- },
- onevaluation(event) {
- let active = event.detail.name
- console.log(active);
- this.setData({
- active: active
- })
- },
- taxi() {
- let latitude = this.data.shopstore.location.latitude;
- let longitude = this.data.shopstore.location.longitude;
- console.log(latitude, longitude);
- wx.getLocation({
- type: 'gcj02', //返回可以用于wx.openLocation的经纬度
- success(res) {
- wx.openLocation({
- latitude,
- longitude,
- scale: 18
- })
- },
- })
- },
- phone() {
- let phone = this.data.shopstore.mobile
- console.log(phone);
- wx.makePhoneCall({
- phoneNumber: phone
- })
- },
- async getShopgoods() {
- let Coupon = new Parse.Query('ShopGoods')
- Coupon.notEqualTo('isDeleted', "true")
- Coupon.equalTo('shopStore', this.data.id)
- Coupon.equalTo('status', 'true')
- Coupon.equalTo('type', 'meal')
- let coupon = await Coupon.find()
- if (coupon && coupon.length > 0) {
- let listJSON = []
- coupon.forEach(c => {
- listJSON.push(c.toJSON())
- })
- this.setData({
- list: listJSON
- })
- }
- console.log(this.data.list.length);
- },
- async getShopStore() {
- let id = this.data.id
- let ShopStore = new Parse.Query('ShopStore')
- let shopstore = await ShopStore.get(id)
- let distances = compute.computeDistance(
- this.data.latitude,
- this.data.longitude,
- shopstore.toJSON().location.latitude,
- shopstore.toJSON().location.longitude
- )
- let distance = distances.toFixed(2)
- this.setData({
- shopstore: shopstore.toJSON(),
- distance: distance
- })
- console.log(this.data.distance);
- },
- async tableList() {
- let TableList = new Parse.Query('TableNumber')
- TableList.equalTo('store', this.data.id)
- TableList.equalTo('company', company)
- TableList.equalTo('status', true)
- TableList.select('name', "objectId", "number")
- let tableList = await TableList.find()
- console.log(tableList);
- if (tableList && tableList.length > 0) {
- let tableArr = []
- console.log(tableList)
- tableList.forEach(li => {
- tableArr.push({
- id: li.id,
- name: li.get('name'),
- number: li.get('number')
- })
- })
- this.setData({
- tableList: tableArr,
- // table: tableArr[0]
- })
- console.log(this.data.tableList)
- }
- },
- comment() {
- let id = this.data.id
- console.log(id);
- wx.navigateTo({
- url: '/nova-tourism/pages/gourmet/store-package/comment/index?id=' + id
- });
- },
- goodsdetails(e) {
- let id = e.currentTarget.dataset.item.objectId
- console.log(id);
- wx.navigateTo({
- url: '/nova-tourism/pages/gourmet/store-package/goods-details/index?id=' + id
- });
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- activeColor:getApp().globalData.activeColor || '#229293'
- })
- let id = options.id
- console.log(id);
- this.setData({ id: id })
- this.getShopStore()
- this.getShopgoods()
- this.getComments()
- this.getLocation()
- this.tableList()
- },
- toOrder() {
- wx.navigateTo({
- url: '/nova-tourism/pages/gourmet/store-package/meal-order/index?storeid=' + this.data.id
- });
- },
- toWebView(e) {
- console.log(e)
- let path = e.currentTarget.dataset.path
- if (!path) {
- wx.showToast({
- title: 'VR素材收集中',
- duration: 1500,
- icon: "none",
- })
- return
- }
- wx.navigateTo({
- url: '/common-page/pages/web-view/index?path=' + path,
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- return {
- title: `${this.data.shopstore.storeName}`,
- }
- }
- })
|