ll
liukangdong
2024-09-29 5e57deb4c7a53c3307f59b2267127b4dd7fd0b02
wechat_jiaxuan/components/authCard/authCard.js
@@ -1,4 +1,6 @@
// components/authCard/authCard.js
import {
  getShopPage
} from '../../api/index'
Component({
  /**
   * 组件的属性列表
@@ -6,21 +8,63 @@
  properties: {
    type: { // 属性名
      type: String,
      value: '0'
      value: '0',
      observer(val) {
        if (val === '1') {
          let that = this
          wx.getLocation({
            type: 'wgs84',
            success(res) {
              const latitude = res.latitude
              const longitude = res.longitude
              that.getShops(latitude, longitude)
            }
          })
        }
      }
    },
  },
  /**
   * 组件的初始数据
   */
  data: {
    shopList: []
  },
  /**
   * 组件的方法列表
   */
  methods: {
    getShops(latitude, longitude) {
      getShopPage({
        model: {
          longitude,
          latitude
        },
        capacity: 3,
        page: 1
      }).then(res => {
        if (res.data && res.data.records) {
          this.setData({
            shopList: res.data.records || []
          })
        }
      })
    },
    shopDetail(e) {
      const id = e.currentTarget.dataset.id
      wx.navigateTo({
        url: `/pages/store/info?id=${id}`,
      })
    },
    jumpStaff() {
      wx.navigateTo({
        url: '/pages/store/staffList',
      })
    },
    jumpAuth() {
      wx.navigateTo({
        url: '/pages/auth/auth',
      })
    },
    jumpStore() {
      wx.navigateTo({
        url: '/pages/store/store',
      })
    }
  }
})
})