index.vue 48.4 KB
Newer Older
f  
程默 committed
1
<template>
李嘉林 committed
2
  <div class="domain" :style="{'--main-color':themeColor['--main-color'],'--minor-color':themeColor['--minor-color']}">
李嘉林 committed
3
    <!-- 自定义导航头 -->
李嘉林 committed
4
    <div style="position:relative;">
李嘉林 committed
5
      <!-- <div v-if="showSpokesManHome">
李嘉林 committed
6
        <get-index-homepage class="getIndexHomePage"></get-index-homepage>
李嘉林 committed
7
      </div> -->
李嘉林 committed
8
      <CustomNav :customBgOpacity="customBgOpacity"></CustomNav>
李嘉林 committed
9
      <StoreAddr v-if="showStoreAddr" @toUpdate="reloadEnterShopRule" @toPageLoading="toPageLoading" ref="StoreAddr"></StoreAddr>
李嘉林 committed
10
      <ThemeDataPlant></ThemeDataPlant>
李嘉林 committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
      <div v-for="(item,index) in pageData" :key="index">
        <div v-if="item.componentCode=='banner' && item.componentInfo.visible == 1">
          <banner :datas="item"></banner>
        </div>
        <div v-else-if="item.componentCode=='goods-list' && item.componentInfo.visible == 1" style="height:100%;">
          <!-- ***这个商品列表组件中需要对数据做缓存,可能有多个地方同时引用此组件
                必须在缓存前加个唯一标识不然所有组件全部操作同一个缓存
            -->
          <goods-list :storageKey="'home'+index" :class="['goodsListItem' + index,'goodsListItemIndex0']" :datas="item" :datasIndex="0" :goodsListIndex="0"></goods-list>
        </div>
        <div v-else-if="item.componentCode == 'ranking-list' && item.componentInfo.visible == 1">
          <ranking-list :datas="item"></ranking-list>
        </div>
        <div v-else-if="item.componentCode == 'area-navigation' && item.componentInfo.visible == 1">
          <area-navigation :datas="item" :changeLocation="changeLocation"></area-navigation>
        </div>
        <div v-else-if="item.componentCode == 'cube-nav' && item.componentInfo.visible == 1">
          <cube-nav :datas="item"></cube-nav>
        </div>
        <!-- 五粮液的餐厅推荐 -->
        <div v-else-if="item.componentCode == 'restaurant-list' && item.componentInfo.visible == 1">
          <restaurant-list :datas="item"></restaurant-list>
        </div>
        <div v-else-if="item.componentCode == 'time-limited-discount' && item.componentInfo.visible == 1">
          <time-limited-discount :class="'time-limited-discount'+index" :datas="item" :k="index"></time-limited-discount>
        </div>
        <div v-if="item.componentCode == 'links' && item.componentInfo.visible == 1">
          <links :datas="item"></links>
        </div>
        <div v-if="item.componentCode == 'interval' && item.componentInfo.visible == 1">
          <interval :datas="item"></interval>
        </div>
        <div v-if="item.componentCode == 'partition' && item.componentInfo.visible == 1">
          <partition :datas="item"></partition>
        </div>
        <div v-if="item.componentCode == 'shop-popup' && item.componentInfo.visible == 1">
          <shop-popup :datas="item"></shop-popup>
        </div>
        <div v-if="item.componentCode == 'float-button' && item.componentInfo.visible == 1">
          <float-button :datas="item"></float-button>
        </div>
        <div v-if="item.componentCode == 'text-text' && item.componentInfo.visible == 1">
          <text-text :datas="item"></text-text>
        </div>
        <div v-if="item.componentCode == 'img-text' && item.componentInfo.visible == 1">
          <img-text :datas="item"></img-text>
        </div>
        <div v-if="item.componentCode == 'goods-search' && item.componentInfo.visible == 1">
          <goods-search :datas="item"></goods-search>
        </div>
        <div v-if="item.componentCode == 'notice' && item.componentInfo.visible == 1">
          <notice :datas="item"></notice>
        </div>
        <div v-if="item.componentCode == 'pop-up' && item.componentInfo.visible == 1">
          <pop-up :datas="item"></pop-up>
        </div>
        <div v-if="item.componentCode == 'coupon' && item.componentInfo.visible == 1">
          <coupon :datas="item"></coupon>
        </div>
        <div v-if="item.componentCode == 'integral-turntable' && item.componentInfo.visible == 1">
          <integralTurntable :datas="item"></integralTurntable>
        </div>
        <div v-if="item.componentCode == 'speedy-nav' && item.componentInfo.visible == 1">
          <speedy-nav :datas="item"></speedy-nav>
        </div>
        <div v-if="item.componentCode == 'video-player' && item.componentInfo.visible == 1" >
          <video-player :class="'VideoPlayer' + index" :datas="item" :indexs="index"></video-player>
        </div>
        <div v-if="item.componentCode == 'official-account' && item.componentInfo.visible == 1">
          <official-account></official-account>
        </div>
        <div v-if="item.componentCode == 'transverse-label' && item.componentInfo.visible == 1">
          <transverse-label :datas="item" :componentIndex="index"></transverse-label>
        </div>
        <div v-if="item.componentCode == 'photo-gallery' && item.componentInfo.visible == 1">
          <photo-gallery :datas="item"></photo-gallery>
        </div>
        <div v-if="item.componentCode == 'live-broadcast' && item.componentInfo.visible == 1">
          <live-broadcast :datas="item"></live-broadcast>
        </div>
        <div v-if="item.componentCode == 'information' && item.componentInfo.visible == 1">
          <information :datas="item"></information>
        </div>
        <div v-if="item.componentCode == 'share-picture' && item.componentInfo.visible == 1">
          <share-picture :datas="item"></share-picture>
        </div>
        <div v-if="item.componentCode == 'merchants-list' && item.componentInfo.visible == 1">
          <merchants-list :class="'merchants-list' +index" :datas="item"></merchants-list>
        </div>
        <div v-if="item.componentCode == 'spell-group' && item.componentInfo.visible == 1">
          <spell-group :datas="item"></spell-group>
        </div>
        <div v-if="item.componentCode == 'wo-timeout' && item.componentInfo.visible == 1">
          <wo-timeout :datas="item"></wo-timeout>
        </div>
        <div v-if="item.componentCode == 'custom-list' && item.componentInfo.visible == 1">
          <custom-list :datas="item"></custom-list>
        </div>
        <div v-if="item.componentCode == 'rich-text' && item.componentInfo.visible == 1">
          <rich-text :datas="item"></rich-text>
        </div>
        <div v-if="item.componentCode == 'member-info' && item.componentInfo.visible == 1">
          <member-info :datas="item"></member-info>
        </div>
        <div v-if="item.componentCode == 'brand-list' && item.componentInfo.visible == 1">
          <brandList :datas="item"></brandList>
        </div>
李嘉林 committed
118 119 120
        <div v-if="item.componentCode == 'embed-module' && item.componentInfo.visible == 1">
          <embedModule :datas="item" :componentIndex="index"></embedModule>
        </div>
李嘉林 committed
121 122
      </div>
      <template>
李嘉林 committed
123
      </template>
李嘉林 committed
124 125
      <bottomCont v-if="showbottomCont"></bottomCont>
      <template>
李嘉林 committed
126 127
      </template>
    </div>
李嘉林 committed
128
    <pageLoading v-if="pageLoading"></pageLoading>
李嘉林 committed
129 130 131 132 133 134 135 136 137 138 139 140 141 142
    <share-popup></share-popup>
    <div v-if="showMyCard">
      <my-card></my-card>
    </div>
    <div v-if="showHomepage">
      <set-my-homepage :getDistributorHomepageName="getDistributorHomepageName"></set-my-homepage>
    </div>
    <div v-if="applySucessEntry && applySucessEntryFlag">
      <apply-sucess-entry></apply-sucess-entry>
    </div>
    <NewUser :showNewUser="showNewUser" @togiftbag="togiftbag"></NewUser>
    <new-polite :showgiftBag="showgiftBag" @closeHandle="closeHandle" :MyNewGiftList="newGiftList"></new-polite>
    <!-- 底部栏 -->
    <custom-tab-bar class="custom-tab-bar" :selected="active"></custom-tab-bar>
chengzhichun committed
143

李嘉林 committed
144 145 146 147
    <!-- 生日弹窗 -->
    <keep-alive>
      <birth-popup :birthGifts="birthGifts" :isShowBirth="isShowBirth" v-show="true"></birth-popup>
    </keep-alive>
148

李嘉林 committed
149 150 151 152 153 154 155
    <couponPopup></couponPopup>
    <!-- 商品筛选 -->
    <GoodsFliters></GoodsFliters>
    <!-- 选规格 -->
    <SelectGoods></SelectGoods>
    <!-- 选规格(开启了企业要货) -->
    <TwoBAddCart></TwoBAddCart>
156 157
    <!-- 麦贝思-客户选择标签 -->
    <SWQUserSelectTag ref="SWQUserSelectTag"></SWQUserSelectTag>
程默 committed
158
  </div>
f  
程默 committed
159 160 161
</template>

<script>
李嘉林 committed
162
import shop from "@/api/shop";
李嘉林 committed
163 164 165
import promote from "@/api/promote";
import index from "@/api/index";
import live from "@/api/live";
liujinsa committed
166 167
import bottomCont from "../../components/bottomCont"
import ThemeDataPlant from "../../components/ThemeDataPlant"
程智春 committed
168 169 170 171
import links from '@/components/basicTool/link/index.vue'
import interval from '@/components/basicTool/interval/index.vue'
import partition from '@/components/basicTool/partition/index.vue'
import shopPopup from '@/components/basicTool/shop-popup/index.vue'
李嘉林 committed
172
import woTimeout from '@/components/basicTool/wo-timeout/index.vue'
李嘉林 committed
173
import transverseLabel from '@/components/basicTool/transverse-label/index.vue'
李嘉林 committed
174
import embedModule from '@/components/basicTool/embed-module/index.vue'
李嘉林 committed
175
import information from '@/components/content/information/index.vue'
liujinsa committed
176 177
import text from '@/components/content/text'
import imgText from '@/components/content/imgText'
liujinsa committed
178 179
import coupon from '@/components/activity/coupon'
import integralTurntable from '@/components/activity/integralTurntable'
李嘉林 committed
180
import spellGroup from '@/components/activity/spellGroup'
181 182
import birthPopup from '@/components/birthPopup/birthPopup.vue'
import birth from '@/api/popup'
chengzhichun committed
183
import couponPopup from '@/components/couponPopup.vue'
李嘉林 committed
184
import brandList from '@/components/brandList/index.vue'
李嘉林 committed
185 186
import NewUser from "../../components/newCustomer/newUser";
import NewPolite from "../../components/newCustomer/newPolite";
187
import customList from "../../components/custom-list";
李嘉林 committed
188
import richText from "../../components/basicTool/rich-text";
刘奕 committed
189
import memberInfo from "../../components/basicTool/member-info";
李嘉林 committed
190
import GoodsFliters from "../../components/common/GoodsFliters";
李嘉林 committed
191 192
import SelectGoods from "../../components/common/SelectGoods";
import TwoBAddCart from "../../components/common/TwoBAddCart";
193
import SWQUserSelectTag from "../../components/common/SWQUserSelectTag";
李嘉林 committed
194
import { setTabBarActive, checkTabbarPage,themeColor, checkShowConditionIds, setStoreInfo, getStoreInfo } from "../../utils/mayi.js";
张卓 committed
195
import indexApi from "@/api/index.js";
张卓 committed
196
import { throttle, concatUrl } from "../../utils/index.js"
李嘉林 committed
197
import mpvueCropper from '@/components/mpvue-cropper'
198
import tool from '../../utils/tool.js'
李嘉林 committed
199
import StoreAddr from "@/components/common/StoreAddr.vue";
李嘉林 committed
200
import pageLoading from "@/components/common/pageLoading.vue";
李嘉林 committed
201
import CustomNav from "@/components/common/CustomNav.vue";
李嘉林 committed
202
const app = getApp();
203
const { log } = app;
f  
程默 committed
204
export default {
程默 committed
205 206 207
  data() {
    return {
      pageInfo: {},
李嘉林 committed
208 209
      pageData: [],
      contentList: [],
李嘉林 committed
210 211 212
      themeColor:{
        '--main-color':"",
        '--minor-color':"",
1  
程智春 committed
213
      },
李嘉林 committed
214 215
      changeLocation : '',
      beforeScrollTop:0,
张卓 committed
216 217 218 219 220
      showSpokesManHome: false,//分销商货架是否展示
      showMyCard: false,
      showHomepage: false,//分销商首页入口
      applySucessEntry: false,//成为分销弹框
      getDistributorHomepageName: '',//小店入口名称
221
      active:-1,
张卓 committed
222
      toHomePage: false,//是否分销隔断
223
      options: 1,
李嘉林 committed
224 225 226 227 228 229
      // 新人有礼
      newGiftList:[],
      newCustomerGiftActivityId: "", //新客活动id
      showNewUser: false, //新客有礼入口
      showgiftBag: false, //新客礼包弹框
      timer: null,
230 231

      isShowBirth: false, // 是否展示生日礼品
李嘉林 committed
232
      birthGifts: "",
233
      showbottomCont: false, //展示底部logo
李嘉林 committed
234
      showSpe: false,
李嘉林 committed
235
      pageLoading: true,
李嘉林 committed
236
      firstOpenPage: true,  //首次打开页面
李嘉林 committed
237
      h5Params: {}, //params
李嘉林 committed
238
      pageOptions: {},
李嘉林 committed
239
      fromPage: "",
李嘉林 committed
240
      customBgOpacity: true, // 沉浸式风格
241
      reloadPage: false, // 切换门店进入首页重新获取相关配置
李嘉林 committed
242
      showStoreAddr: false,
程默 committed
243 244
    };
  },
程智春 committed
245 246 247 248 249
  components:{
    links,
    interval,
    partition,
    shopPopup,
程默 committed
250
    bottomCont,
liujinsa committed
251
    ThemeDataPlant,
李嘉林 committed
252 253
    "text-text": text,
    "img-text": imgText,
liujinsa committed
254
    coupon,
李嘉林 committed
255
    integralTurntable,
李嘉林 committed
256
    transverseLabel,
李嘉林 committed
257
    embedModule,
李嘉林 committed
258
    information,
chengzhichun committed
259
    spellGroup,
260
    couponPopup,
李嘉林 committed
261
    NewUser,
262
    NewPolite,
李嘉林 committed
263 264
    birthPopup,
    mpvueCropper,
265
    woTimeout,
李嘉林 committed
266 267 268
    "custom-list": customList,
    "rich-text": richText,
    "member-info": memberInfo,
李嘉林 committed
269 270
    GoodsFliters,
    SelectGoods,
李嘉林 committed
271
    TwoBAddCart,
李嘉林 committed
272
    brandList,
李嘉林 committed
273
    StoreAddr,
李嘉林 committed
274
    pageLoading,
275 276
    CustomNav,
    SWQUserSelectTag
李嘉林 committed
277
},
278 279 280 281 282 283 284 285 286 287 288 289 290 291
  computed: {
    applySucessEntryFlag() {
      // 高意匠不展示
      return !this.GYJFlag;
    },
    GYJFlag() {
      // 高意匠
      let {mixid} = this.$store.state;
      if(mixid == "GYJ") {
        return true;
      }
      return false;
    },
  },
李嘉林 committed
292
  onShareAppMessage(res) {
李嘉林 committed
293
    let {shopCode} = app.globalData.shopInfo;
李嘉林 committed
294

李嘉林 committed
295
    if (res.from === "button") {
李嘉林 committed
296
      return new Promise((resolve,reject)=>{
李嘉林 committed
297
        shop.getShopInfo({ shopMixId: shopCode }).then(res=>{
李嘉林 committed
298 299 300 301 302
          if(res.data.code ==200){
            let {shopName} = res.data.data;
            let logoUrl = app.DFSImg(res.data.data.logoUrl,500,400,0);
            resolve({
              title: shopName,
李嘉林 committed
303
              path: "/pages/home/main",
李嘉林 committed
304 305
              imageUrl:logoUrl,
              success: function(res) {
306
                log.info("成功", res);
李嘉林 committed
307 308 309 310 311 312 313 314 315
              }
            });
          }
        })
      }).then(res=>{
        return {
          ...res,
        }
      })
李嘉林 committed
316
    }
李嘉林 committed
317 318 319 320 321
    // return {
    //   title: shareVal.title,
    //   path: "page/home/main",
    //   imageUrl:shareVal.imageUrl,
    //   success: function(res) {
322
    //     log.info("成功", res);
李嘉林 committed
323 324
    //   }
    // };
李嘉林 committed
325
  },
326
  onReady() {
李嘉林 committed
327
    log.info('home-onReady');
328
    console.log(new Date().getTime(),'load-----home-onReady')
程默 committed
329 330 331 332 333 334
    // 上报首页打开时间
    if (wx.canIUse('reportPerformance')) {
      const performance = wx.getPerformance()
      const observer = performance.createObserver((entryList) => {
        let getEntries=entryList.getEntries()
        wx.reportPerformance(2001, getEntries[0]['duration'])
侯体倬 committed
335
        this.$mpBehavior.monitorPerformance(getEntries[0])
程默 committed
336
      })
侯体倬 committed
337
      observer.observe({ entryTypes: ['render'] })
程默 committed
338
    }
339 340 341 342
    wx.showShareMenu({
      withShareTicket: true,
      menus: ['shareAppMessage', 'shareTimeline']
    })
343 344 345 346 347 348

    // 查询是否展示生日礼品
    // this.isShowBirth = true // 测试
    wx.getStorage({
      key: 'sessionid',
      success: res => {
349
        log.info('tz登录', res);
350 351 352 353
        this.getBirthGift(this)
      },
      fail: err => {
        this.isShowBirth = false
354 355
        log.info('tz未登录', err, this.isShowBirth);
        log.info('未登录状态=====================', err)
356 357
      }
    })
李嘉林 committed
358 359
    console.log('----onReady')
    this.firstOpenPage = false;
程默 committed
360
  },
李嘉林 committed
361
  async onLoad(options) {
李嘉林 committed
362
    log.info('home-onLoad')
363 364 365
    if(this.$options) {
      Object.assign(this.$data, this.$options.data());
    }
李嘉林 committed
366
    this.pageOptions = options;
李嘉林 committed
367
    console.log(new Date().getTime(),'load-----home-onLoad')
李嘉林 committed
368
    console.log(options,this.firstOpenPage,'---------home----options')
李嘉林 committed
369
    this.pageInit(options);
程默 committed
370
  },
李嘉林 committed
371
  onShow() {
李嘉林 committed
372
    log.info('home-onShow')
李嘉林 committed
373
    console.log(new Date().getTime(),'load-----home-onShow')
374
    console.log(this.reloadPage,'-reloadPage2')
李嘉林 committed
375 376 377 378 379
    // if (this.reloadPage) {
    //   console.log("refreshInit--------1")
    //   this.refreshInit();
    //   this.reloadPage = false;
    // }
李嘉林 committed
380
    // 设置显示条件
张卓 committed
381
    //分销隔流
张卓 committed
382 383 384 385 386 387 388
    if(this.toHomePage) {
      let linkVal = '/personalCenter/spokesmanCenter/mine/spokesmanHomePage?from=_goodsInfo'
      app.$themeToLink({
        type: 1,
        link:linkVal,
      });
    }
389
    this.getCartNum();
程默 committed
390 391 392 393 394

    if(checkTabbarPage('/')!=-1){
      this.active=checkTabbarPage('/')
    }

395 396 397
    // this.$mp.page.onPageScroll= (el)=>{
    //   throttle(this.scrolls(el),100)
    // };
李嘉林 committed
398 399
    // 调绑定导购
    this.ShopCodeDistributionOrg();
程默 committed
400
  },
401 402 403
  // 滚动节流方法
  onPageScroll: tool.throttle(function (el) {
    // console.log(el);
李嘉林 committed
404
    this.scrolls(el[0])
405 406
  },200),

程默 committed
407
  methods: {
李嘉林 committed
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423
    async pageInit(options) {
      log.info(options, '---------home----options')
      let h5Params = options && options.params ? JSON.parse(decodeURIComponent(options.params)) : {};
      this.h5Params = h5Params;
      console.log(h5Params,'--h5Params')
      if (Object.keys(h5Params).length > 0 && h5Params.offlineShopCode) {
        console.log("设置切换的门店", h5Params.offlineShopCode, getStoreInfo().offlineShopCode);
        // 判断是否等于缓存门店,非缓存门店重新设置并初始化
        if (h5Params.offlineShopCode != getStoreInfo().offlineShopCode) { 
          // 存储h5url门店信息
          setStoreInfo({
            offlineShopCode:h5Params.offlineShopCode,
            offlineShopName:h5Params.offlineShopName,
          });
          this.reloadPage = true;
        }
424 425 426
        // 每次切换门店都删除导购数据
        wx.removeStorageSync(this.$store.state.mixid+'setGuideEmployeeId');
        wx.removeStorageSync(this.$store.state.mixid+'guide_QRCodeType');
侯体倬 committed
427
        wx.removeStorageSync(this.$store.state.mixid+'temp_QRCodeType');
李嘉林 committed
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464
      } else {
        this.reloadPage = false;
      }
      console.log(this.reloadPage,'-reloadPage1')
      //进页面存储需要绑定的信息
      if(options.userId||options.spokesmanRelId) {
        wx.setStorage({
          key: "becomeInfo",
          data: JSON.stringify(options)
        });
        log.info(wx.getStorageSync("becomeInfo"),'home---wx.getStorageSync("becomeInfo")')
      }
      if(options.scene){
        wx.setStorageSync("firstView", 1);
        this.reloadPage = true;
        //新二维码扫码进入
        let res = await indexApi.getShareSceneRecord(options.scene);
        log.info(res,'onLoad-getShareSceneRecord');
        if(res.data.code == '200'){
          this.page = res.data.data.pageUri;
          let sceneObj = JSON.parse(res.data.data.scene);
          if(sceneObj.spokesmanRelId){
            wx.setStorage({
              key: "becomeInfo",
              data: JSON.stringify(sceneObj)
            });
          }
          let paramsObj = sceneObj && sceneObj.params ? JSON.parse(decodeURIComponent(sceneObj.params)) : sceneObj;
          this.h5Params = paramsObj;
          console.log('app-mounted-paramsObj', paramsObj)
          if (paramsObj.offlineShopCode) {
            // 存在门店参数
            setStoreInfo({
              offlineShopCode:paramsObj.offlineShopCode,
              offlineShopName:paramsObj.offlineShopName,
            });
          }
465 466 467
          // 判断是否为导购分享进入
          if (paramsObj.setGuideEmployeeId) {
            wx.setStorageSync(this.$store.state.mixid+'setGuideEmployeeId', paramsObj.setGuideEmployeeId);
李嘉林 committed
468 469 470 471 472 473 474
            // 有导购参数调接口绑关系
            console.log('setGuideEmployeeId', paramsObj.setGuideEmployeeId)
            if (wx.getStorageSync("sessionid")) {
              indexApi.allocation({
                employeeId: paramsObj.setGuideEmployeeId,
              })
            }
475
          }
李嘉林 committed
476 477
          if (paramsObj.QRCodeType) {
            wx.setStorageSync(this.$store.state.mixid+'guide_QRCodeType', paramsObj.QRCodeType);
侯体倬 committed
478
            wx.setStorageSync(this.$store.state.mixid+'temp_QRCodeType', paramsObj.QRCodeType);
李嘉林 committed
479
          }
李嘉林 committed
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516
          this.showStoreAddr = true;
          wx.setStorageSync('attractingCustomerChannelId',sceneObj.attractingCustomerChannelId);
          wx.setStorageSync(this.$store.state.mixid+'storeId',sceneObj.storeId);
          wx.setStorageSync(this.$store.state.mixid+'sellerId',sceneObj.sellerId);
          log.info(res.data.data,'getShareSceneRecord')
          console.log(res.data.data,'----getShareSceneRecord')
          log.info(wx.getStorageSync("openid"),'onLoad-openid');
          if(wx.getStorageSync("openid")) {
            indexApi.addRecord(
              {
                attractingCustomersChannelId: paramsObj.attractingCustomerChannelId,
                miniOpenId: wx.getStorageSync("openid"),
                registerFlag: 1,
                newRegisterFlag: 0,
              }
            ).then(ele=>{
              //清空引客渠道id
              if(ele.data.data) {
                wx.setStorageSync('attractingCustomerChannelId','');
              }
            })
          }
        }
      } else {
        this.showStoreAddr = true;
      }
      if (options.from && options.from == "logout") {
        //来自用户登出
        wx.removeStorage({
          key: "sessionid"
        });
        wx.removeStorage({
          key: "openid"
        });
        wx.removeStorage({
          key: "enterpriseAccount"
        });
517 518 519
        // 每次退出登录都删除导购数据
        wx.removeStorage({ key: this.$store.state.mixid+'setGuideEmployeeId' });
        wx.removeStorage({ key: this.$store.state.mixid+'guide_QRCodeType' });
侯体倬 committed
520
        wx.removeStorage({ key: this.$store.state.mixid+'temp_QRCodeType' });
李嘉林 committed
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551
      }
      this.options = wx.getStorageSync("becomeInfo");
      this.changeLocation = options.changeLocation || ''

      if(this.changeLocation == 1){
        log.info('this.$store.state.extConfig',this.$store.state.extConfig)
        app.getShopInfo(this.$store.state.extConfig);
        this.getThemeList();
      }
      let that = this;
      if(wx.getStorageSync("sessionid")) {
        //获取个人名片入口
        app.fenxiaoModel.getHomePageQuickAccess().then(res=>{
          that.showMyCard = res;
        })
        //获取分销信息
        log.info(wx.getStorageSync("becomeInfo")?JSON.parse(wx.getStorageSync("becomeInfo")):'','becomeInfo--358')
        this.getSpokesmanInit(wx.getStorageSync("becomeInfo")?JSON.parse(wx.getStorageSync("becomeInfo")):'')
      }
      // 来源
      if (options.from == "logout") {
        //来自用户登出
        wx.removeStorage({
          key: "sessionid"
        });
        wx.removeStorage({
          key: "openid"
        });
        wx.removeStorage({
          key: "enterpriseAccount"
        });
552 553 554
        // 每次退出登录都删除导购数据
        wx.removeStorage({ key: this.$store.state.mixid+'setGuideEmployeeId' });
        wx.removeStorage({ key: this.$store.state.mixid+'guide_QRCodeType' });
侯体倬 committed
555
        wx.removeStorage({ key: this.$store.state.mixid+'temp_QRCodeType' });
李嘉林 committed
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597
      }
      // 获取页面数据
      if (this.mpApp.globalData.pageList && !this.reloadPage) {
        console.log("获取页面数据-1")
        that.init(this.mpApp.globalData.pageList);
      } else {
        this.mpApp.pageCallBack = function (params) {
          console.log("获取页面数据-2",params)
          that.init(params);
        };
      }
      if(themeColor['--main-color']!='#ffffff'){
        this.themeColor = themeColor
      }else {
        this.mpApp.themeColorCallBack=(res)=>{
          this.themeColor = res
        }
      }
      // 新人有礼弹窗
      this.newUserFun();
      // 新店调试
      this.debugShopFun();

      //清除商品列表组件懒加载缓存
      // 需清除的缓存keyList
      let keyList = ['pageGoodsList','storageDatasList','datasIndex','ids','loadingFlag','pageNumList'];
      wx.getStorageInfo({
        success (res) {
          if(res.keys) {
            res.keys.forEach((item,index)=>{
              keyList.forEach((item1,index1)=>{
                if(item.includes(item1)){
                  wx.removeStorage({
                    key: item
                  })
                }
              })
            })
          }
        }
      })
    },
李嘉林 committed
598 599 600
    setPageLoading() {
      setTimeout(() => {
        this.pageLoading = false;
李嘉林 committed
601
      }, 700);
李嘉林 committed
602
    },
李嘉林 committed
603
    reloadEnterShopRule() {
李嘉林 committed
604
      console.log('eloadEnterShopRule', this.h5Params)
李嘉林 committed
605
      if (this.h5Params && this.h5Params.offlineShopCode) {
李嘉林 committed
606
        console.log("refreshInit--------2")
李嘉林 committed
607 608 609
        this.refreshInit();
        wx.removeStorageSync("firstView");
        return;
李嘉林 committed
610
      };
李嘉林 committed
611
      console.log('home-methods-reloadEnterShopRule')
李嘉林 committed
612
      // 进店规则--首次进店调用
李嘉林 committed
613
      if (wx.getStorageSync("firstView") == 1) {
李嘉林 committed
614 615 616 617 618
        console.log('reloadEnterShopRule-------1')
        wx.removeStorageSync("firstView");
        this.enterStoreRule();
      } else {
        console.log('reloadEnterShopRule-------2')
李嘉林 committed
619
        this.setPageLoading();
李嘉林 committed
620 621 622
      }
    },
    async enterStoreRule() {
李嘉林 committed
623
      try {
李嘉林 committed
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
        console.log(wx.getStorageSync("locationObj"),'--locationObj')
        let locationObj = wx.getStorageSync("locationObj") ? JSON.parse(wx.getStorageSync("locationObj")) : {};
        let query = {
          channelType: 2, //设备类型(0:pc,1:app,2:小程序)
          consumerLongitude: locationObj.longitude?locationObj.longitude.toString() : "", //经度,小程序和app可以获取到就要传,没有不传
          consumerLatitude: locationObj.latitude?locationObj.latitude.toString() : "", //纬度,小程序和app可以获取到就要传,没有不传
          distributionOfficerShopCode: this.h5Params.offlineShopCode || "" //分销员门店id,没有不传
        }
        console.log(`%cgetEnterShopId---query${JSON.stringify(query)}`,'color:yellow;font-size:20px;')
        let res = await shop.getEnterShopId(query);
        console.log(`%cgetEnterShopId${JSON.stringify(res)}`,'color:yellow;font-size:20px;')
        if (res.data.code == 200) {
          let enterShopId = res.data.data;
          console.log(enterShopId,'--enterShopId')
          if (enterShopId) {
            let storeDetail = await shop.getOfflineStoreDetail({
              shopId: enterShopId,
            });
            if (storeDetail.data.code == 200) {
              setStoreInfo({
                offlineShopCode: storeDetail.data.data.shopCode,
                offlineShopName: storeDetail.data.data.shopName,
李嘉林 committed
646
              });
李嘉林 committed
647
              this.$refs.StoreAddr.reloadName();
李嘉林 committed
648
              console.log("refreshInit--------3")
李嘉林 committed
649
              this.refreshInit();
李嘉林 committed
650
            }
李嘉林 committed
651 652 653 654 655 656 657 658 659 660 661 662
            console.log(storeDetail, '-------storeDetail');
            let loginUserInfo = wx.getStorageSync("loginUserInfo") || null;
            let query2 = {
              telephoneNum: loginUserInfo && loginUserInfo.mobilephone,
              enterShopSource: "买家直接进入",
              hitRule: "首页进入",
              shopName: storeDetail.data.data.shopName,
            }
            log.info("进店规则-----",query2)
            shop.saveEnterShopRecord(query2);
          }
        }        
李嘉林 committed
663 664
      } catch (error) {
        
李嘉林 committed
665
      }
李嘉林 committed
666
      // this.setPageLoading();
李嘉林 committed
667
    },
李嘉林 committed
668 669
    toPageLoading() {
    },
李嘉林 committed
670 671 672 673 674 675 676 677 678 679 680 681 682 683 684
    async setVisible(pageList, cb) {
      // 首页显示条件
      let pageInfo = pageList.filter((item) => item.pageCode == 1)[0];
      let pageData = JSON.parse(pageInfo.pageData);
      // 查询显示条件id
      let showConditionIds = checkShowConditionIds(pageData);
      // 查询可显示的条件
      let { data: ids ,isAreaNavigation} = await this.checkCondition(showConditionIds);
      // 没有定位组件
      // if (!isAreaNavigation) {
      //   cb()
      //   return
      // }
      // 设置visible
      pageInfo.pageData = this.updateCondition(pageData, ids);
685
      log.info(showConditionIds, "--------------5454", ids, pageInfo);
李嘉林 committed
686
      console.log(showConditionIds, "--------------5454", ids, pageInfo);
李嘉林 committed
687 688 689 690 691 692 693 694 695
      cb(pageInfo)
    },
    checkCondition({ allCondition }) {
      return new Promise((resolve, reject) => {
        // 获取
        let params = { showConditionIds:allCondition, region: "" };
        shop
          .checkShowCondition(params)
          .then((res) => {
696
            log.info(params, "check显示条件", res.data);
李嘉林 committed
697 698 699 700 701
            if (res.data.code == 200) {
              resolve(res.data);
            }
          })
          .catch((err) => {
702
            log.info("check显示条件失败", err);
李嘉林 committed
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717
          });
      });
    },
    updateCondition(pageData, ids) {
      pageData.forEach((item) => {
        pollCondition(item);
      });
      function pollCondition(data) {
        if (Object.prototype.toString.call(data) === "[object Object]") {

          // 如果等于2(仅登录显示)且登录时显示  visible重新赋值1
          // 如果等于2且未登录不展示  visible重新赋值0
          // 如果等于3(仅登录隐藏)且登录时不展示  visible重新赋值1
          // 如果等于3且未登录展示
          if(data.visible>1){
718
            log.info(data,wx.getStorageSync('sessionid'),'------491')
李嘉林 committed
719 720 721
          }
          if (data.visible && data.visible > 1 && data.visibleCopy == undefined) {
              data.visibleCopy = data.visible;
722
              log.info(data.visibleCopy,'--data.visibleCopy')
李嘉林 committed
723 724 725 726 727
          }
          if ((data.visibleCopy == 2 && wx.getStorageSync('sessionid')) ||
              (data.visibleCopy == 3 && !wx.getStorageSync('sessionid'))
          ) {
              data.visible = 1;
728
          } else if ((data.visibleCopy == 2 && !wx.getStorageSync('sessionid')) ||
李嘉林 committed
729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753
              (data.visibleCopy == 3 && wx.getStorageSync('sessionid'))
          ) {
              data.visible = 0;
          } else {
            if (data.condition != "" && data.condition != undefined) {
              data.visible = ids.some((item) => {
                return item == data.condition;
              })
                ? 1
                : 0;
            }
          }
          for (const key in data) {
            if (data.hasOwnProperty(key)) {
              const element = data[key];
              if (
                Object.prototype.toString.call(element) === "[object Object]"
              ) {
                if (element.visible && element.visible > 1 && element.visibleCopy == undefined) {
                  element.visibleCopy = element.visible;
                }
                if ((element.visibleCopy == 2 && wx.getStorageSync('sessionid')) ||
                    (element.visibleCopy == 3 && !wx.getStorageSync('sessionid'))
                ) {
                    element.visible = 1;
754
                } else if ((element.visibleCopy == 2 && !wx.getStorageSync('sessionid')) ||
李嘉林 committed
755 756 757 758 759
                    (element.visibleCopy == 3 && wx.getStorageSync('sessionid'))
                ) {
                    element.visible = 0;
                } else {
                  if (element.condition != "" && element.condition != undefined) {
760
                    log.info("979797", element.condition);
李嘉林 committed
761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783
                    element.visible = ids.some((item) => {
                      return item == element.condition;
                    })
                      ? 1
                      : 0;
                  }
                }
                pollCondition(element);
              } else if (
                Object.prototype.toString.call(element) === "[object Array]" &&
                element.length > 0
              ) {
                element.forEach((item) => {
                  pollCondition(item);
                });
              }
            }
          }
        }
      }

      return JSON.stringify(pageData);
    },
程默 committed
784
    init(pageList) {
李嘉林 committed
785
      console.log("home-init");
786
      this.getCartNum();
程默 committed
787
      this.active=checkTabbarPage('/');
李嘉林 committed
788
      this.setVisible(pageList,(res)=>{
李嘉林 committed
789
        this.pageInfo = res;
李嘉林 committed
790 791 792 793 794 795
        if(this.pageInfo.pageSettingData && JSON.parse(this.pageInfo.pageSettingData).topNavStyleType) {
          this.customBgOpacity = true;
        } else {
          this.customBgOpacity = false;
        }
        console.log(this.customBgOpacity,'-this.customBgOpacity')
李嘉林 committed
796 797
        this.contentList = JSON.parse(this.pageInfo.pageData);
        this.pageData.push(this.contentList[0]);
李嘉林 committed
798
        console.log(this.pageInfo,'--this.pageInfo')
李嘉林 committed
799 800
        let i = 1;
        this.loadComponents(i);
李嘉林 committed
801
      });
802 803 804
      setTimeout(() => {
        this.showbottomCont = true;
      }, 100);
805
      log.info("36----------------------559", this.pageData,this.pageInfo.pageSettingData);
李嘉林 committed
806
      this.setPageLoading();
807
      log.info(app.globalData.shopInfo,'app')
程智春 committed
808
      wx.setNavigationBarTitle({title : app.globalData.shopInfo.shopName})
张卓 committed
809
      if(wx.getStorageSync("sessionid")) {
810 811
        //清空门店id
        wx.setStorageSync(this.$store.state.mixid+'storeId','')
张卓 committed
812
        wx.setStorageSync(this.$store.state.mixid+'sellerId','')
813
        log.info(111222,app.fenxiaoModel)
张卓 committed
814
        app.fenxiaoModel.query_isEntry().then((data)=>{
张卓 committed
815
          //分销弹框信息
816
          log.info(data,3333444)
张卓 committed
817 818 819 820 821
          if (
            data.applyRemind == "true" &&
            data.displayEntry == "true"
          ) {
            this.applySucessEntry = true;
822

张卓 committed
823 824 825 826 827
          }else if (
            data.applyRemindByDistributor == "true" &&
            data.displayEntryByDistributor == "true"
          ) {
            this.applySucessEntry = true
828
          }
张卓 committed
829 830 831 832 833 834 835 836 837 838 839 840 841 842 843
          let footerVal = {...app.globalData.footerVal};
          footerVal.componentData.list.forEach(res=>{
            if(res.link.name=="分销员中心"&&data.displayEntry == 'true') {
              res.show = true
            }else if(res.link.name=="分销员中心"&&data.displayEntry == 'false') {
              res.show = false
            }else if(res.link.name=="分销商中心"&&data.displayEntryByDistributor == 'true') {
              res.show = true
            }else if(res.link.name=="分销商中心"&&data.displayEntryByDistributor == 'false') {
              res.show = false
            }
          })
          app.globalData.footerVal = footerVal;
          this.$mp.page.selectComponent(".custom-tab-bar").init();
          // that.applySucessEntry = res;
844
        })
张卓 committed
845 846
      }else {
        let footerVal = {...app.globalData.footerVal};
847
        log.info('"分销员中心"',footerVal)
张卓 committed
848 849 850 851 852 853 854 855 856
        if (footerVal.componentData) {
          footerVal.componentData.list.forEach(res=>{
            if(res.link.name=="分销员中心"||res.link.name=="分销商中心") {
              res.show = false
            }
          })
          app.globalData.footerVal = footerVal;
          this.$mp.page.selectComponent(".custom-tab-bar").init();
        }
张卓 committed
857
      }
程默 committed
858
    },
李嘉林 committed
859 860 861 862 863 864 865 866 867 868 869
    loadComponents(index) {
      this.pageData.push(this.contentList[index]);
      index++;
      if (index > this.contentList.length - 1) {
        console.log("-页面渲染结束-");
        return;
      }
      setTimeout(() => {
        this.loadComponents(index);
      }, 30);
   },
张卓 committed
870
    getSpokesmanInit(extConfig) {
李嘉林 committed
871
      log.info(extConfig,'getSpokesmanInit-extConfig');
张卓 committed
872
      //绑定上下级关系
张卓 committed
873
      app.fenxiaoModel.becomeRelation(extConfig).then(res=>{
李嘉林 committed
874
        log.info('getSpokesmanInit调用becomeRelation')
李嘉林 committed
875
        log.info(res,'getSpokesmanInit-becomeRelation');
876
        if(res) {
张卓 committed
877 878 879 880
          wx.removeStorage({
            key: "becomeInfo"
          });
        }
张卓 committed
881 882
        //获取分销基本信息
        this.getSpokesmanInfo(extConfig)
李嘉林 committed
883 884
      }).catch(res=>{
        log.info(res,'becomeRelation-catch-636')
张卓 committed
885
      })
张卓 committed
886 887
    },
    getSpokesmanInfo(extConfig) {
张卓 committed
888
      let linkVal = '/personalCenter/spokesmanCenter/mine/spokesmanHomePage?from=_goodsInfo';
张卓 committed
889
      app.fenxiaoModel.getSpokesmanInfo(true).then(res=>{
李嘉林 committed
890
        log.info(res,'home-getSpokesmanInfo');
张卓 committed
891 892 893 894 895 896 897
        if(
          res&&
          res!='-1'&&
          res.distributorHomepage&&
          res.distributorHomepage != 'null'&&
          res.parentPartitionHomepageFlag == '1'
        ) {
张卓 committed
898
          this.toHomePage = true;
张卓 committed
899 900 901 902 903 904
          // let linkVal = '/personalCenter/spokesmanCenter/mine/spokesmanHomePage?from=_goodsInfo'
          app.$themeToLink({
            type: 1,
            link:linkVal,
          });
        }
905 906 907 908
        if(res &&
          res.id
        ){
          app.fenxiaoModel.getDistributorHomepage(res).then(ele=>{
李嘉林 committed
909
            log.info(ele,'getDistributorHomepage-661')
910 911 912 913 914 915 916
            if(ele.id) {
              this.getDistributorHomepageName = '我的小店';
            }else {
              this.getDistributorHomepageName = '一键开店';
            }
          });
        }
张卓 committed
917
        if(
张卓 committed
918
          res&&
919
          res.parentSpokesmanDistributionModel == '1'&&
张卓 committed
920
          res.distributorHomepage.id) {
张卓 committed
921 922 923 924
            this.showSpokesManHome = true;
        }else {
          this.showSpokesManHome = false;
        }
925
        log.info(res,555666)
张卓 committed
926
        if(res&&res.distributionModel == '1') {
张卓 committed
927 928 929 930 931 932
          this.showHomepage = true;
        }else{
          this.showHomepage = false;
        }
      })
    },
李嘉林 committed
933
    scrolls(el){
程默 committed
934
      // this.setFooterShow(el);
程默 committed
935 936 937 938 939 940 941
      if (this.pageData) {
        for (let i = 0; i < this.pageData.length; i++) {
          const element = this.pageData[i]
          if(element.componentCode=="time-limited-discount"){
            let com=this.$mp.page.selectComponent(".time-limited-discount"+i) ;
            com && com.getScroll(el);
          }
程智春 committed
942 943
          if(element.componentCode=="goods-list"){
            let com=this.$mp.page.selectComponent(".goodsListItem"+i) ;
程智春 committed
944 945
            com && com.getScroll(el);
          }
程智春 committed
946 947
          if(element.componentCode=="merchants-list"){
            let com=this.$mp.page.selectComponent(".merchants-list"+i) ;
程智春 committed
948 949
            com && com.getScroll(el);
          }
李嘉林 committed
950 951 952 953 954 955
          if(element.componentCode=="video-player"){
            console.log("视频组件滚动")
            let com=this.$mp.page.selectComponent(".VideoPlayer"+i);
            console.log(com,i,'--com')
            com && com.getScroll(el);
          }
程智春 committed
956

程默 committed
957
        }
958
      }
程默 committed
959

960 961 962
      if(this.$mp.page && this.$mp.page.selectComponent(".getIndexHomePage")){
        this.$mp.page.selectComponent(".getIndexHomePage").getScroll(el);
      }
李嘉林 committed
963
      if(this.$mp.page && this.$mp.page.selectComponent(".goodsListItem")){
李嘉林 committed
964
        this.$mp.page.selectComponent(".goodsListItem").getScroll(el);
程默 committed
965
      }
966 967 968 969 970
      if(this.$mp.page && this.$mp.page.selectAllComponents(".transverse-label-goodsListItem")){
        this.$mp.page.selectAllComponents(".transverse-label-goodsListItem").forEach(item=>{
          item.getScroll(el)
        })
      }
程默 committed
971
    },
李嘉林 committed
972
    setFooterShow(el){
程默 committed
973
      // return
李嘉林 committed
974 975
      let afterScrollTop = el.scrollTop;
      let delta = afterScrollTop - this.beforeScrollTop;
程默 committed
976
      let {showFlag} = this.$mp.page.selectComponent(".custom-tab-bar").data;
李嘉林 committed
977
      if(
程智春 committed
978
        Math.abs(delta) < 10 ||
李嘉林 committed
979
        afterScrollTop < 0 ||
980
        this.beforeScrollTop < 0 ||
李嘉林 committed
981 982 983
        (delta>0 && showFlag=='down') ||
        (delta<0 && showFlag=='up')
        ){
李嘉林 committed
984
        this.beforeScrollTop = afterScrollTop;
李嘉林 committed
985 986
         return;
      }
程默 committed
987
      this.$mp.page.selectComponent(".custom-tab-bar").setData({'showFlag':delta>0?'down':'up'})
988
      log.info('---------383')
李嘉林 committed
989
    },
李嘉林 committed
990
    scrolltolower(){
991
      log.info("scrolltolower")
992 993 994 995
    },
    getCartNum() {
      app.cartApi.my_cart_count().then(res => {
        if (res.data.code == 200) {
程默 committed
996
          this.$mp.page.selectComponent(".custom-tab-bar").setData({"cartNum": Number(res.data.data)});
997 998
        }
      });
李嘉林 committed
999 1000 1001 1002
    },
    newUserFun(){
      promote.query_org_new_customer_gift().then(res=>{
        if (res.data.code == 200 && res.data.data) {
1003
          log.info(res.data.data,'----------------------------res.data')
李嘉林 committed
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025
          this.newGiftList = [];
          res.data.data.coupons.forEach((item) => {
            if (item.couponQty >= 1) {
              for (var i = 0; i < item.couponQty; i++) {
                item.preferentialMoney = parseFloat(item.preferentialMoney);
                item.preferentialDiscount = parseFloat(item.preferentialDiscount);
                item.meetMoneyUse = parseFloat(item.meetMoneyUse);
                this.newGiftList.push(item);
              }
            }
          });
          this.newCustomerGiftActivityId = res.data.data.id;
          // 如果有活动
          if (res.data.data != null) {
            setTimeout(() => {
              if (!wx.getStorageSync("sessionid")) {
                this.showNewUser = true;
              } else {
                this.showNewUser = false; //入口隐藏
                live.getUserInfo().then((res) => {
                  if (res.data.code == 200) {
                    // 已经领取过的话,就判断是否展示弹框
李嘉林 committed
1026
                    // 判断是否是新客
李嘉林 committed
1027 1028
                    let isNewUser = false;
                    res.data.data.tagNames.forEach(function (item) {
1029
                      log.info(item.tagName + "999999");
李嘉林 committed
1030
                      if (item.tagName == "新客") {
李嘉林 committed
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043
                        isNewUser = true;
                      }
                    });
                    if (res.data.data.obtainNewCustomerGiftFlag == "true") {
                      //如果领取过
                      this.showNewUser = false;
                      // 判断是否需要展示弹框
                      // 如果需要弹,并且是新用户的话
                      if (
                        res.data.data.showDialogNewCustomerGiftFlag == "true" &&
                        isNewUser == true
                      ) {
                        this.showgiftBag = true; //弹框展示
1044
                        log.info(this.showgiftBag,'showgiftBag-----------1')
李嘉林 committed
1045 1046 1047 1048 1049 1050
                        this.showNewUser = false; //入口隐藏
                        this.getUserreceiveGift(); //定时查我领取的新客礼包
                      } else {
                        // 不是新用户,
                        this.showNewUser = false; //入口关闭
                        this.showgiftBag = false; //弹框不显示
1051
                        log.info(this.showgiftBag,'showgiftBag-----------2')
李嘉林 committed
1052 1053 1054 1055 1056 1057
                      }
                    } else {
                      // 未领取过的,判断是不是新用户
                      if (isNewUser == true) {
                        // 是新用户的,弹弹框提示,
                        this.showgiftBag = true;
1058
                        log.info(this.showgiftBag,'showgiftBag-----------3')
李嘉林 committed
1059 1060 1061 1062 1063
                        this.getUserreceiveGift();
                      } else {
                        // 不是新用户,
                        this.showNewUser = false; //入口关闭
                        this.showgiftBag = false; //弹框不显示
1064
                        log.info(this.showgiftBag,'showgiftBag-----------4')
李嘉林 committed
1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079
                      }
                    }
                  }
                });
              }
            }, 1000);
          } else {
            // 没活动
            this.showNewUser = false;
          }
        } else {
          // Toast(res.msg);
        }
      })
    },
侯体倬 committed
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092
    debugShopFun() {
      shop.get_shop_configuration().then(res=>{
        if (res.data.code == 200) {
          if (res.data.data.newStoreCommissioningStatus == 1) {
            wx.showModal({
              title: '重要提醒!',
              showCancel: false,
              content: `当前店铺处于筹备调试中,顾客们请勿下单。给您带来的不便,敬请谅解~`
            }) 
          }
        }
      })
    },
李嘉林 committed
1093 1094 1095 1096
    getUserreceiveGift() {
      this.timer = setInterval(() => {
        //  查询我领取的新客礼品
        promote.query_my_new_customer_gift().then((res) => {
李嘉林 committed
1097
          if (res.data.code == 200) {
李嘉林 committed
1098
            // data为null就是没有查询到我领取的优惠券,就再调一次领取优惠券接口手动领取下
李嘉林 committed
1099
            if (res.data.data == null) {
1100
              log.info("没领到");
李嘉林 committed
1101 1102 1103 1104
            } else {
              clearInterval(this.timer);
            }
          } else {
李嘉林 committed
1105
            Toast(res.data.msg);
李嘉林 committed
1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123
            clearInterval(this.timer);
          }
        });
      }, 5000);
    },
    togiftbag() {
      // 弹框展开之后,点击立即领取,然后去判断是否登录
      // 如果没有登录,就到登录页面去完成注册,登录,如果是已经登录过的,点击立即领取之后就直接显示知道了
      if (this.newGiftList.toString().length <= 0) {
        this.showgiftBag = false;
      } else {
        this.showgiftBag = true;
      }
    },
    closeHandle() {
      // 关闭弹框之后调取消接口就隐藏,不展示
      if (wx.getStorageSync("sessionid")) {
        index.cancelNewCustome(this.newCustomerGiftActivityId).then((res) => {
1124
          // log.info(res,'ooooooooo123');
李嘉林 committed
1125
          if (res.data.code == 200) {
李嘉林 committed
1126 1127 1128
            // 接口调成功之后,就关闭弹框
            this.showgiftBag = false;
          } else {
李嘉林 committed
1129
            Toast(res.data.msg);
李嘉林 committed
1130 1131 1132 1133 1134 1135 1136
            this.showgiftBag = false;
          }
        });
      } else {
        this.showgiftBag = false;
      }
    },
1137 1138 1139
    getBirthGift(that) {
      birth.getQueryGift().then(res => {
        let result = res.data
李嘉林 committed
1140 1141 1142 1143 1144 1145 1146
        if(result.code == -1 || result.msg == '没有查询到用户信息'){
          wx.removeStorage({
            key: "sessionid"
          });
          wx.removeStorage({
            key: "openid"
          });
李嘉林 committed
1147 1148 1149
          wx.removeStorage({
            key: "enterpriseAccount"
          });
李嘉林 committed
1150
        }
1151
        log.info(JSON.stringify(result), that, 'tztztz初始化')
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172
        if (result.data.gifts !== null && result.data.gifts.length > 0) {
          // 判断礼物是否领取完成
          let showPopup = false;
          let arr = [];
          for (let i = 0; i < result.data.gifts.length; i++) {
              // 未领取的礼物添加到数组中
            if (result.data.gifts[i].executeStatus !== "1") {
              showPopup = true;
              arr.push(result.data.gifts[i]);
            }
          }
          if (showPopup) {
            // 替换原有数组
            result.data.gifts = arr;
            that.toggleData(result.data)
          }
        }
      });
    },
    toggleData(res) {
      this.isShowBirth = true;
1173
      log.info(this.isShowBirth, JSON.stringify(res) + 'tzToggleData')
1174
      this.birthGifts = res;
李嘉林 committed
1175 1176
    },
    async getThemeList() {
1177
      console.log("getThemeList")
李嘉林 committed
1178
      this.pageLoading = true;
李嘉林 committed
1179 1180 1181 1182 1183
      try {
        await app.getThemePage(this.$store.state.extConfig);
      } catch (error) {
        
      }
李嘉林 committed
1184
    },
李嘉林 committed
1185
    async refreshInit() {
李嘉林 committed
1186
      console.log("refreshInit");
李嘉林 committed
1187
      this.pageLoading = true;
李嘉林 committed
1188 1189 1190 1191 1192 1193 1194 1195 1196
      this.pageData = [];
      log.info('onPullDownRefresh',this.$store.state.extConfig)
      app.getShopInfo(this.$store.state.extConfig);
      try {
        await this.getThemeList();
      } catch (error) {
        
      }
      wx.stopPullDownRefresh();
李嘉林 committed
1197 1198 1199 1200 1201 1202 1203 1204 1205 1206
    },
    ShopCodeDistributionOrg() {
      let setGuideEmployeeId = wx.getStorageSync(this.$store.state.mixid + 'setGuideEmployeeId');
      if (setGuideEmployeeId) {
        shop.ShopCodeDistributionOrg({
          isCover: false,
          employeeId: setGuideEmployeeId
        });
      }
    },
程默 committed
1207
  },
张卓 committed
1208
  async onShareAppMessage(res){
1209
    log.info(res)
张卓 committed
1210 1211
    let newHref = '/pages/home/main';
    let title = app.globalData.shopInfo.shopName;
张卓 committed
1212
    let hasInvitationStatus = 0;
1213
    if(wx.getStorageSync("sessionid")) {
1214
      await app.fenxiaoModel.getSpokesmanidByShare().then(data=>{
李嘉林 committed
1215 1216
        log.info(data,'onShareAppMessage-getSpokesmanidByShare')
        log.info('onShareAppMessage-getSpokesmanidByShare-917')
1217
        hasInvitationStatus = data.hasInvitationStatus;
李嘉林 committed
1218 1219
      }).catch(res=>{
        log.info(res,'getSpokesmanidByShare-catch-920')
1220
      })
李嘉林 committed
1221
      log.info(hasInvitationStatus,'onShareAppMessage-hasInvitationStatus')
1222
      await app.fenxiaoModel.getSpokesmanInfo().then(data=>{
李嘉林 committed
1223
        log.info('onShareAppMessage调用getSpokesmanInfo')
1224
        let newData = {}
李嘉林 committed
1225
        log.info(data,'getSpokesmanInfo.data')
李嘉林 committed
1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237
        if(data != null ) {
          if (hasInvitationStatus == 1) {
            newData = {
              spokesmanGroupId: data.groupId,
              spokesmanShopId: data.shopId,
              spokesmanRelId: data.id,
              userId: data.userId
            }
          }else {
            newData = {
              userId: data.userId
            }
1238
          }
1239
        }
1240
        newHref = concatUrl(newHref,newData)
李嘉林 committed
1241 1242
      }).catch(res=>{
        log.info(res,'getSpokesmanInfo-catch-943')
1243 1244 1245 1246 1247 1248 1249 1250 1251 1252
      })
    }
    let imageUrl = '';
    //多主题自定义分享标题和图片
    if(this.pageInfo.pageSettingData&&JSON.parse(this.pageInfo.pageSettingData).shareTitle) {
      title = JSON.parse(this.pageInfo.pageSettingData).shareTitle
    }
    if(this.pageInfo.pageSettingData&&JSON.parse(this.pageInfo.pageSettingData).shareImg) {
      imageUrl = JSON.parse(this.pageInfo.pageSettingData).shareImg
    }
1253
    log.info(newHref,3333555666,title,res)
张卓 committed
1254 1255 1256
    return {
      title: title, // 默认是小程序的名称
      path: newHref, // 默认是当前页面
1257
      imageUrl: imageUrl,
张卓 committed
1258 1259 1260
      success: function(res) {
        // 转发成功之后的回调
        if (res.errMsg == "shareAppMessage:ok") {
1261
          log.info(res, "分享成功");
张卓 committed
1262 1263 1264 1265 1266 1267
        }
      },
      fail: function() {
        // 转发失败之后的回调
        if (res.errMsg == "shareAppMessage:fail cancel") {
          // 用户取消转发
1268
          log.info(res, "分享失败");
张卓 committed
1269 1270 1271 1272 1273 1274 1275 1276
        } else if (res.errMsg == "shareAppMessage:fail") {
          // 转发失败,其中 detail message 为详细失败信息
        }
      },
      complete: function() {
        // 转发结束之后的回调(转发成不成功都会执行)
      }
    };
张卓 committed
1277
  },
1278
  onShareTimeline(res) {
1279
    log.info(res,'-----onShareTimeline')
1280
  },
1281
  onPullDownRefresh() {
李嘉林 committed
1282
    let that = this;
1283
    console.log("onPullDownRefresh");
李嘉林 committed
1284
    console.log("refreshInit--------4")
李嘉林 committed
1285
    this.refreshInit();
李嘉林 committed
1286 1287 1288 1289
    this.mpApp.pageCallBack = function (params) {
      console.log("获取页面数据-3",params)
      that.init(params);
    };
程智春 committed
1290
  }
程默 committed
1291
};
f  
程默 committed
1292 1293 1294 1295
</script>

<style>
.domain {
程默 committed
1296
  /* text-align: center; */
程默 committed
1297
  /* padding-top: 50%; */
f  
程默 committed
1298
}
liujinsa committed
1299
</style>