// packageE/title/title.js
var app = getApp();
Component({
  properties: {
    datas: {
      type: null,
    },
    storeList: {
      type: null,
    },
    showMun: {
      type: null,
    },
    plugin_active: String
  },
  // 私有数据，可用于模板渲染
  data: {
    emptyImage: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/image.png",
    clientWidth: "375",
  },

  lifetimes: {
    // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
    attached() {},
    moved() {},
    detached() {},
  },

  // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
  attached() {},
  // 此处attached的声明会被lifetimes字段中的声明覆盖
  ready() {
    this.setData({
      clientWidth: wx.getSystemInfoSync().windowWidth,
    });
  },
  observers: {
    'storeList,datas': function (list, datas) {}
  },
  pageLifetimes: {
    // 组件所在页面的生命周期函数
    show() {},
    hide() {},
    resize() {},
  },
  methods: { // 跳转到店铺
    toRouter(e) {
      let item = e.currentTarget.dataset.item;
      if (item.specify_show == 1) {
        wx.navigateTo({
          url: "/packageC/o2o/o2oStore/o2oStore?store_id=" +
						item.id +
						"&fromHome=1",
        });
      } else {
        if (item.store_decorate == 1) {
          wx.navigateTo({
            url: "/packageG/o2o/HomeSeller/HomeSeller?store_id=" + item.id,
          });
        } else {
          wx.navigateTo({
            url: "/packageC/o2o/HomeSeller/HomeSeller?store_id=" + item.id,
          });
        }

      }
    },
    toClassify(e) {
      let id = e.currentTarget.dataset.id;
      wx.navigateTo({
        url: "/packageC/o2o/o2oCategory/o2oCategory?id=" +
					id +
					"&city=" +
					this.data.city +
					"&point=" +
					JSON.stringify(this.data.point),
      });
    },
    toGoods(e) {
      let item = e.currentTarget.dataset.item;
      wx.navigateTo({
        url: "/packageA/detail_v2/detail_v2?id=" + item.goods_id,
      });
    },
    // 打开地图
    goToAdress(e) {
      let latitude = e.currentTarget.dataset.items.latitude;
      let longitude = e.currentTarget.dataset.items.longitude;
      let store_name = e.currentTarget.dataset.items.store_name;
      let point = app.BMapTransqqMap(
        parseFloat(longitude),
        parseFloat(latitude)
      );
      wx.openLocation({
        latitude: point.lat,
        longitude: point.lng,
        scale: 18,
        name: store_name,
      });
    },
  },
});