storeService.js 1.34 KB
import componentsMixin from "../../../../../mixins/componentsMixin";
import { defaultMerchantId } from "../../../../../api/environment";
import { equityApi } from "../../../../../api/api";
Component({
  behaviors: [componentsMixin],
  properties: {
    isHome:Boolean
  },
  data: {
    storePackageList: [],
    showMorePack: false,
  },

  methods: {
    // 获取门店套餐
    getShopPackage() {
      const merchantId = wx.$util.getStorageSync("srcm_shopmall_merchant_id");
      const {isHome} = this.data
      let newMerchantId = merchantId || defaultMerchantId;
      let para = {
        merchantId: newMerchantId,
      };
      equityApi.storePackage(para).then((res) => {
        let arr = []
        if(isHome&&res){
          arr = res.filter(item=>{
           return item.topFlag==1
          })
        }else{
          arr = res
        }
        this.setData({
          storePackageList: arr || [],
        });
      });
    },
    // 去套餐详情页
    toPackageDetail(e) {
      const { id } = e.currentTarget.dataset;
      wx.navigateTo({
        url: "/packageEquity/pages/package/package?id=" + id,
      });
    },
    openMorePack(e) {
      const { show } = e.currentTarget.dataset;
      this.setData({
        showMorePack: !show,
      });
    },
  },
  lifetimes: {
    attached() {
      this.getShopPackage();
    },
  },
});