asdfa

28 阅读7分钟

<!--pages/index/index.wxml-->
<import src="../../wxParse/wxParse.wxml" />
<view class="index-container" style="background: #fff;">
  <view wx:if="{{platform}}" class="top-back" style="height:{{navBarHeight}}px;padding-top:{{menuTop}}px;padding-right: {{callRight + 5}}px; box-sizing: border-box;padding-left:10px;position: fixed;z-index: 999;background: #fff;width:100vw;">
    <image src="../../images/index/logo.png" class="logo" style="height:{{logoHeight}}px"></image>
    <view class="top-phone" style="height:{{callheight}}px;margin-right: 20px;" bindtap="showCustomerServiceModal"><image src="../../images/index/call2.png" /><text>客服</text></view>
  </view>
  <view wx:else class="top-back" style="height:{{navBarHeight}}px;position: fixed;z-index: 999;background: #fff;width:100vw;display: flex;align-items: center;padding-left:10px;">
    <image src="../../images/index/logo.png" class="logo" style="height:{{logoHeight-5}}px"></image>
    <view class="top-phone-windows" style="height:{{callheight}}px; margin-right: {{callRight + 25}}px;" bindtap="showCustomerServiceModal"><image src="../../images/index/call2.png" /> <text>客服</text></view>
  </view>
  <cover-view class="navigation" style="height:{{navBarHeight}}px;" wx:if="{{showNavigation}}">
  乐存
  </cover-view>
  <!-- 顶部banner -->
  <view class="banner" style="height:200px;position: absolute;top:{{navBarHeight}}px;">
    <swiper  autoplay="{{autoplay}}" circular="{{circular}}" interval="{{interval}}" vertical="{{vertical}}" duration="{{duration}}" previous-margin="{{previousMargin}}px" next-margin="{{nextMargin}}px"
    style="height:200px">
      <swiper-item wx:for="{{data2}}" wx:for-item="item" wx:key="index" data-url="{{item.url}}" bindtap="bannerJump">
        <image style="height:200px" src="{{item.mediaUrl}}" class="banner-item"/>
      </swiper-item>
    </swiper>
    <!-- <view class="discount "  bindtap="tomoredisc">
      <image class="dis-font" src="https://proxyapi.letstorage.com/group1/M00/00/7B/CgEBBGN2DXyAB8aYAAB6_Ih6WYc404.png&#34;   />
    </view> -->
  </view>

  <!-- 列表list -->
  <view class="list" style="position: absolute;top:{{navBarHeight+200}}px;">
    <view id="search" class="list-search" style="top: {{navBarHeight}}px;">
      <view class="list-search-input">
        <view class="list-search-address" bindtap="toAddressPage">{{locaCity.shortName}}</view>
         <van-field style="width: 100%;" input-class="fieldInput" right-icon="search" input-align="center" value="{{ address }}" placeholder="请输入地址搜索附近门店" clearable bind:input="inputChange" input-class="van-input"/>
      </view>
    </view>
    <view  class="mapList" wx:if="{{showMap}}">
      <view class="mapItem" wx:for="{{mapList}}" wx:key="{{inex}}" bind:tap="chooseThisMap" data-addressLat="{{item.lat}}" data-addressLng="{{item.lng}}" data-address="{{item.originTitle}}">
        <view>
          <template is="wxParse" data="{{wxParseData:article[index].nodes}}" />
        </view>
        <view class="flexView">
          <view class="flexItem">{{item.address}}</view>
          <view>{{item.distance}}km</view>
        </view>
      </view>
      
    </view >

    <view  class="list-body"  wx:if="{{!showMap&&storeList.length>0}}">
        <view class="list-item" wx:for="{{storeList}}" wx:key="{{inex}}"
        bindtap="navigateToDetail" data-id="{{item.storeId}}">
          <view class="list-item-image">
            <image src="{{item.thumbnailUrl}}"></image>
            <span class="tag" wx:if="{{item.status==4}}">预售</span>
            <span class="tag" wx:if="{{item.isNotNewStore}}">新店</span>
          </view>
          <view class="list-item-info">
            <view class="info-top">
              <view class="info-top-name">
                {{item.storeName}}
                <view wx:if="{{item.firstMonthPrice!=null}}"  class="firstMonthPrice" space="nbsp">
                  <text space="nbsp">首月</text>¥{{item.firstMonthPrice||0}}<text space="nbsp"></text>
                  <!-- ¥{{item.firstMonthPrice||0}}<text class="firstMonthPrice-text" space="nbsp">起/首月</text> -->
                </view>
                <view wx:else class="firstMonthPrice" >
                  <text space="nbsp">每月</text>¥{{item.everyMonthPrice||0}}<text space="nbsp"></text>
                  <!-- ¥{{item.everyMonthPrice||0}}<text class="firstMonthPrice-text" space="nbsp">起/月</text> -->
                </view> 
              </view>
            </view>
            <view class="info-tag">
              <view class="info-tag-item" wx:for-items="{{item.homeTags}}" wx:key="tagIndex">
                <image wx:if="{{item.hotTag == 2}}" src="../../images/index/hot_label.png" ></image>
                <text style="vertical-align: middle">{{item.attrValue}}</text>
              </view>
            </view>
            <view class="info-ads">
            <text class="info-ads-text">{{item.address}}</text>
   
             <block wx:if="{{item.distance == 0 || item.distance}}">
              <text class="info-ads-dis" wx:if="{{item.unit==1}}">{{item.distance}}m</text>
              <text class="info-ads-dis" wx:if="{{item.unit==2}}">{{item.distance}}km</text>
            </block>
            </view>
          </view>
        </view>
        <view class="list-item-loading" wx:if="{{showListLoading}}"></view>
        <view class="list-item-bottom" wx:if="{{storeList.length === showPages}}">—— 已经到底啦 ——</view>
    </view>
  </view>
  <view class="fixed-certificate" wx:if="{{!show&&!show2&&!show3}}" bindtap="tomoredisc">领券</view>

</view>


<!-- 一条奖励弹框 -->
<van-popup show="{{ show }}" overlay="{{ true }}" bind:close="onClose" class="onlineCall" custom-style="background-color: transparent;" catchtouchmove="fingerTouchMove">
  <view class="popupFrame">
    <view class="reward">
      <view class="rewardList" bindtap="gotoCurrentPage">
        <view wx:if="{{credits>0}}">
          <view class="itemTop">
            <view class="itemTopLeft textCenter themeTextColor">
              <view>
                {{credits}}
                <text></text>
              </view>
            </view>
            <view class="itemTopRight">
              <view class="firstLine">
                <view class="couponType">积分券</view>
                <text class="couponMoney">{{credits}}积分券</text>
              </view>
              <view class="secondLine">无时效限制</view>
            </view>
          </view>
        </view>
        <view wx:for-items="{{couponTemplateList}}" wx:key="index" index="{{index}}">
          <view class="itemTop">
            <view class="itemTopLeft textCenter themeTextColor">
              <view wx:if="{{item.couponType != 2}}">
                <text></text>{{item.couponAmount}}</view>
              <view wx:else>{{item.couponAmount}}
                <text></text>
              </view>
            </view>
            <view class="itemTopRight">
              <view class="firstLine">
                <view wx:if="{{item.couponType==1}}" class="couponType">满减券</view>
                <view wx:if="{{item.couponType==2}}" class="couponType">折扣券</view>
                <view wx:if="{{item.couponType==3}}" class="couponType">现金券</view>
                <view wx:if="{{item.couponType==4}}" class="couponType">时长券</view>
                <text class="couponMoney">{{item.couponName}}</text>
              </view>
              <view class="secondLine">{{item.effectTimeStr}}至{{item.effectEndTimeStr}}</view>
            </view>
          </view>
        </view>
      </view>
    </view>
    <view class="icon2">
      <image class="icon3" bindtap="onClose" src="/images/index/close.png" />
    </view>
  </view>
</van-popup>
<!-- 两条奖励弹框 -->
<van-popup show="{{ show2 }}" overlay="{{ true }}" bind:close="onClose" class="onlineCall2" custom-style="background-color: transparent;" catchtouchmove="fingerTouchMove">
  <view class="popupFrame2">
    <view class="reward2">
      <view class="rewardList" bindtap="gotoCurrentPage">
        <view wx:if="{{credits>0}}">
          <view class="itemTop">
            <view class="itemTopLeft textCenter themeTextColor">
              <view>
                {{credits}}
                <text></text>
              </view>
            </view>
            <view class="itemTopRight">
              <view class="firstLine">
                <view class="couponType">积分券</view>
                <text class="couponMoney">{{credits}}积分券</text>
              </view>
              <view class="secondLine">无时效限制</view>
            </view>
          </view>
        </view>
        <view wx:for-items="{{couponTemplateList}}" wx:key="index" index="{{index}}">
          <view class="itemTop">
            <view class="itemTopLeft textCenter themeTextColor">
              <view wx:if="{{item.couponType != 2}}">
                <text></text>{{item.couponAmount}}</view>
              <view wx:else>{{item.couponAmount}}
                <text></text>
              </view>
            </view>
            <view class="itemTopRight">
              <view class="firstLine">
                <view wx:if="{{item.couponType==1}}" class="couponType">满减券</view>
                <view wx:if="{{item.couponType==2}}" class="couponType">折扣券</view>
                <view wx:if="{{item.couponType==3}}" class="couponType">现金券</view>
                <text class="couponMoney">{{item.couponName}}</text>
              </view>
              <view class="secondLine">{{item.effectTimeStr}}至{{item.effectEndTimeStr}}</view>
            </view>
          </view>
        </view>
      </view>
    </view>
    <view class="icon2">
      <image class="icon3" bindtap="onClose" src="/images/index/close.png" />
    </view>
  </view>
</van-popup>

<!-- 三条奖励弹框 -->
<van-popup show="{{ show3 }}" overlay="{{ true }}" bind:close="onClose" class="onlineCall3" custom-style="background-color: transparent;" catchtouchmove="fingerTouchMove">
  <view class="popupFrame3">
    <view class="reward3">
      <view class="rewardList" bindtap="gotoCurrentPage">
        <view wx:if="{{credits>0}}">
          <view class="itemTop">
            <view class="itemTopLeft textCenter themeTextColor">
              <view>
                {{credits}}
                <text></text>
              </view>
            </view>
            <view class="itemTopRight">
              <view class="firstLine">
                <view class="couponType">积分券</view>
                <text class="couponMoney">{{credits}}积分券</text>
              </view>
              <view class="secondLine">无时效限制</view>
            </view>
          </view>
        </view>
        <view wx:for-items="{{couponTemplateList}}" wx:key="index" index="{{index}}">
          <view class="itemTop">
            <view class="itemTopLeft textCenter themeTextColor">
              <view wx:if="{{item.couponType != 2}}">
                <text></text>{{item.couponAmount}}</view>
              <view wx:else>{{item.couponAmount}}
                <text></text>
              </view>
            </view>
            <view class="itemTopRight">
              <view class="firstLine">
                <view wx:if="{{item.couponType==1}}" class="couponType">满减券</view>
                <view wx:if="{{item.couponType==2}}" class="couponType">折扣券</view>
                <view wx:if="{{item.couponType==3}}" class="couponType">现金券</view>
                <text class="couponMoney">{{item.couponName}}</text>
              </view>
              <view class="secondLine">{{item.effectTimeStr}}至{{item.effectEndTimeStr}}</view>
            </view>
          </view>
        </view>
      </view>
    </view>
    <view class="icon2">
      <image class="icon3" bindtap="onClose" src="/images/index/close.png" />
    </view>
  </view>
</van-popup>

<van-popup round close-on-click-overlay="{{closeOnClickOverlay}}" show="{{ showApproach }}" custom-style="border-radius: 20rpx" bind:close="onCloseApproach">
  <view class="approach-content {{channelsSelect ?  'approach-content-isShow' : ''}}">
    <view class="approach-content-top">
      <view class="approach-content-top-skip" bind:tap="onCloseApproach">跳过</view>
    </view>
    <view class="approach-content-question">您是如何了解到乐存的?</view>
    <view class="approach-content-rewards">奖励200积分</view>
    <!-- <view class="approach-content-selects">
        <view class="approach-content-selects-item" wx:for="{{channels}}" wx:for-item="item">{{item}}</view>
    </view> -->
    <view class="approach-content-selects">
        <view class="approach-content-selects-item {{selectApproachText == '大众/美团' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="大众/美团">大众/美团</view>
        <view class="approach-content-selects-item {{selectApproachText == '小红书' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="小红书" >小红书</view>
        <view class="approach-content-selects-item {{selectApproachText == '微信' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="微信">微信</view>
    </view>
    <view class="approach-content-selects">
        <view class="approach-content-selects-item {{selectApproachText == '抖音' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="抖音">抖音</view>
        <view class="approach-content-selects-item {{selectApproachText == '百度' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="百度">百度</view>
        <view class="approach-content-selects-item {{selectApproachText == '地图' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="地图">地图</view>
    </view>
    <view class="approach-content-selects">
        <view class="approach-content-selects-item {{selectApproachText == '朋友推荐' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="朋友推荐">朋友推荐</view>
        <view class="approach-content-selects-item {{selectApproachText == '自己用过' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="自己用过">自己用过</view>
        <view class="approach-content-selects-item {{selectApproachText == '58同城' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="58同城">58同城</view>
    </view>
    <view class="approach-content-selects">
        <view class="approach-content-selects-item {{selectApproachText == '闲鱼' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="闲鱼">闲鱼</view>
        <view class="approach-content-selects-item {{selectApproachText == '电梯道闸护栏' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="电梯道闸护栏">电梯道闸护栏</view>
        <view class="approach-content-selects-item {{selectApproachText == '中介公司' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="中介公司">中介公司</view>
    </view>
    <view class="approach-content-selects">
        <view class="approach-content-selects-item {{selectApproachText == '装修公司' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="装修公司">装修公司</view>
        <view class="approach-content-selects-item {{selectApproachText == '展会' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="展会">展会</view>
        <view class="approach-content-selects-item {{selectApproachText == '地推' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="地推">地推</view>
    </view>
    <view class="approach-content-selects" wx:if="{{channelsSelect}}">
        <view class="approach-content-selects-item {{selectApproachText == '高效/招聘' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="高效/招聘">高效/招聘</view>
        <view class="approach-content-selects-item {{selectApproachText == '车身广告' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="车身广告">车身广告</view>
        <view class="approach-content-selects-item {{selectApproachText == '报纸等传统传媒' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="报纸等传统传媒">报纸等传统传媒</view>
    </view>
    <view class="approach-content-selects" wx:if="{{channelsSelect}}">
        <view class="approach-content-selects-item {{selectApproachText == '乐存官网' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="乐存官网">乐存官网</view>
        <view class="approach-content-selects-item {{selectApproachText == '今日头条' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="今日头条">今日头条</view>
        <view class="approach-content-selects-item {{selectApproachText == '市民卡' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="市民卡">市民卡</view>
    </view>
    <view class="approach-content-selects" wx:if="{{channelsSelect}}">
        <view class="approach-content-selects-item {{selectApproachText == '其他网络搜索' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="其他网络搜索">其他网络搜索</view>
        <view class="approach-content-selects-item {{selectApproachText == '其他' ? 'approach-content-selects-item-active' : ''}}" bind:tap="onclickSelectChannel" data-value="其他">其他</view>
        <view ></view>
    </view>
    <view class="approach-content-more" wx:if="{{!channelsSelect}}">
      <van-icon bind:tap="showMoreSelect" name="arrow-down"/>
      <view style="font-size: 22rpx;" class="approach-content-more-text" bind:tap="showMoreSelect">展开更多</view>
    </view>
  </view>
</van-popup>

<!-- <feedback wx:if="{{!show&&!show2&&!show3}}" /> -->如何做到点击客服时在下方弹出一个宽度为机子宽度,然后高度为机身高度的60%的框// pages/index/index.js
const util = require('../../utils/util.js')
var api = require('../../utils/api.js');
var my = require('../../api/my.js');
var store = require('../../api/store.js');
var WxParse = require('../../wxParse/wxParse.js');
var indeApi = require('../../api/index.js');
const wxDiscode = require('../../wxParse/wxDiscode.js');
const app = getApp() // 获取应用实例
const customerServiceQRCode = 'https://example.com/path/to/qr-code.jpg&#39;;  
// 获取系统信息
const systemInfo = wx.getSystemInfoSync();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    data: [],
    address: '',
    indicatorDots: false,
    storeList: [],
    vertical: false,
    autoplay: true,
    circular: true,
    interval: 3000,
    duration: 500,
    previousMargin: 0,
    nextMargin: 0,
    phone: '4000857799',
    rejectGetPhone: false,
    show: false,
    show2: false,
    show3: false,
    overlay: true,
    keyword: '',
    page: 1,
    size: 10,
    showMap: false,
    defaultData: {
      address: "武林广场",
      addressLat: 30.271001349,
      addressLng: 120.163280674,
      lat: "",
      lng: "",
      page: 1,
      size: 10,
    },
    isLoading: true,
    locaCity: '',
    regionRandom: false,
    menuTop: wx.getMenuButtonBoundingClientRect().top-3,
    navBarHeight: wx.getSystemInfoSync().statusBarHeight+44,
    barWidth: wx.getMenuButtonBoundingClientRect().width,
    callRight: 0,
    callheight: 0,
    logoHeight: wx.getMenuButtonBoundingClientRect().height+10,
    platform: true,
    showPages: 0,
    showListLoading: false,
    showApproach: false, // 展示了解途径弹框,
    selectApproachText: '',
    channels: ['大众/美团', '小红书', '微信', '抖音', '百度', '地图', '朋友推荐', '自己用过', '58同城', '咸鱼', '电梯道闸护栏', 
    '中介公司', '装修公司', '展会', '地推', '高效/招聘', '车身广告', '报纸等传统传媒', '乐存官网', '今日头条', '市民卡', '其他网络搜索', '其他'],
    channelsSelect: false,
    closeOnClickOverlay: false
  },
  locationCity() {
    let param = {
      lat: app.globalData.locationInfo.latitude,
      lng: app.globalData.locationInfo.longitude,
    }
    store.cityByLoaction(param).then(res => {
      this.setData({
        locaCity: {
          shortName: res.data,
          code: '',
          lat: app.globalData.locationInfo.latitude,
          lng: app.globalData.locationInfo.longitude,
        }
      })
      app.globalData.locaCity={
        shortName: res.data,
        code: '',
        lat: app.globalData.locationInfo.latitude,
        lng: app.globalData.locationInfo.longitude,
      }
    })
    
  },
  onClose() {
    this.setData({ show: false, show2: false, show3: false });
  },
  toAddressPage() {
    this.setData({
      regionRandom: true
    })
    wx.navigateTo({
      url: '/pages/storeAddress/storeAddress',
    })
  },
  inputChange(e) {//输入关键字
    let { locaCity, regionRandom } = this.data
    this.setData({
      address: e.detail,
      searchStatus: false,
      showMap: true
    })
    let mapData = {
      // keyword: e.detail+locaCity.shortName,
      keyword: e.detail,
      lat:  regionRandom ? locaCity.lat :app.globalData.locationInfo.latitude,
      lng:  regionRandom ? locaCity.lng :app.globalData.locationInfo.longitude,
      region: locaCity.shortName
    }
    if (e.detail !== '') {
      store.getMapAdress(mapData).then(res => {
        let arr = res.data
        let newArr = res.data
        let sKey = "<span style='color: #0354A1'>" + e.detail + "</span>"
        arr.map((item, index) => {
          newArr[index].originTitle = item.title
          var reg = new RegExp(e.detail, "gi")
          var ress = '';
          let content = item.title
          ress = content.replace(reg, sKey)
          newArr[index].title = ress
          WxParse.wxParse('article.' + index, 'html', ress, this, 5)
        })
        this.setData({
          mapList: newArr
        })
      }).finally(() => {
        if (this.data.address === '') {
          this.setData({
            mapList: []
          })
        }
      })
    } else {
      this.setData({
        showMap: false,
        mapList: [],
        addressLat: null,
        addressLng: null,
      })
      // this.searchStore()

    }
  },
  chooseThisMap: function (e) {
    this.setData({
      address: e.currentTarget.dataset.address,
      page: 1,
      lat: null,
      lng: null,
      addressLat: e.currentTarget.dataset.addresslat,
      addressLng: e.currentTarget.dataset.addresslng,
      loading: true,
      showMap: false,
    }, () => {
      this.searchStore()
    })
  },
  getStore: function (e) {
    this.setData({
      status: true,
      address: e.currentTarget.dataset.address,
      showMap: false,
      mapList: []
    })
    let data = {
      page: this.data.page,
      size: this.data.size,
      lat: null,
      lng: null,
      addressLat: e.currentTarget.dataset.addresslat,
      addressLng: e.currentTarget.dataset.addresslng
    }
    if (!this.data.timeout) {
      this.setData({
        timeout: true
      })
      store.getStore(data).then(res => {
        this.setData({
          total: res.data.pagination.total,
          totalPage: res.data.pagination.totalPage,
          showPages: res.data.pagination.total,
          status: true
        })
        if (res.data.result.length > 0) {
          if (res.data.result && this.data.page > 1) {
            this.setData({
              storeList: this.data.result.concat(res.data.result)
            })
          } else {
            this.setData({
              storeList: res.data.result,
            })
          }
          if (this.data.page === res.data.pagination.totalPage) {
            this.setData({
              hidden: false
            })
          }
        } else {
          this.setData({
            storeList: []
          })
        }
        this.setData({
          totalPage: res.data.pagination.totalPage,
          showPages: res.data.pagination.total,
        })
        this.setData({
          loading: false
        })
      }).catch(() => {
        this.setData({
          storeList: []
        })
      }).finally(() => {
        this.setData({
          timeout: false,
          loading: false
        })
      })
    }
  },
  searchStore(type) {
    let { address, page, size, storeList, addressLat, addressLng, locaCity, regionRandom } = this.data
    if (type != 1) {
      page = 1
      storeList = []
      this.setData({
        page: 1
      })
    }
    if(page !== 1){
      this.setData({
        showListLoading: true
      })
    }
    let searchparams = {
      address: address,
      page: page,
      size: size,
      lat: regionRandom ? locaCity.lat : app.globalData.locationInfo.latitude,
      lng: regionRandom ? locaCity.lng : app.globalData.locationInfo.longitude,
      addressLat: addressLat,
      addressLng
    }
    if (this.data.rejectGetPhone) {
      this.data.defaultData.page = searchparams.page;
      searchparams = this.data.defaultData
    }
    store.searchStore(searchparams).then(res => {
      if (res.data.pagination.total > 0) {
        storeList.push(...res.data.result)
        this.setData({
          isLoading: false,
          totalPage: res.data.pagination.totalPage,
          showPages: res.data.pagination.total,
          storeList: storeList,
          showMap: false,
        })
      } else {
        searchparams = this.data.defaultData
        store.searchStore(searchparams).then(res2 => {
          storeList.push(...res2.data.result)
          this.setData({
            isLoading: false,
            totalPage: res2.data.pagination.totalPage,
            showPages: res2.data.pagination.total,
            storeList: storeList,
            showMap: false,
          })
        })
      }
      this.setData({
        showListLoading: false
      })
    })
  },
  onPageScroll(e) {
    wx.createSelectorQuery().select('#search').boundingClientRect(data => {
      // console.log(e.scrollTop)
      if (data.top < 0) {
        this.setData({
          topSearch: true
        })
      }
      if (data.top == 0 && e.scrollTop <= 200) {
        this.setData({
          topSearch: false
        })
      }
      //  console.log(this.data.topSearch)
    }).exec()
    //  if (e.scrollTop === 0){
    //    this.setData({
    //      showNavigation:false
    //    })
    //  }else{
    //    this.setData({
    //      showNavigation: true
    //    })
    //  }
  },
  changePage(e) {
    if (this.data.page < this.data.totalPage) {

      this.setData({
        page: this.data.page + 1
      })
      this.searchStore(1)
    } else {
      this.setData({
        showLast: true
      })
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (options.refereeId) { // 邀请有礼
      app.globalData.refereeId = options.refereeId

    }
    wx.getSystemInfo({
        success: (res) => {
            // windows | mac为pc端
            // android | ios为手机端
            if(res.platform == 'android' || res.platform == 'ios') {
                this.setData({
                    platform: true
                })
            }
            else {
                this.setData({
                    platform: false
                })
            }
        }
      });
    app.globalData.sharedLoginPage = false
    this.setData({
      screenHeight: app.globalData.screenHeight,
      navBarHeight: app.globalData.navBarHeight,
      region: options.region === '' ? '杭州市' : options.region
    })
    if (!this.data.regionRandom) {
      this.getLocat()
    } else {
      this.searchStore()
    }
  },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    console.log('wx.getMenuButtonBoundingClientRect()---', wx.getMenuButtonBoundingClientRect());
    let menuButton = wx.getMenuButtonBoundingClientRect();
    wx.getSystemInfo({
      success: (res) => {
        console.log('res--', res);
        this.setData({
          callRight: res.windowWidth - menuButton.right + + menuButton.width,
          callheight: menuButton.height
        });
      }
    })
    if (typeof this.getTabBar === 'function' &&
      this.getTabBar()) {
      this.getTabBar().setData({
        selected: 0
      })
    }
    this.setData({
      btnDisable: false
    })
    this.getBanner();
    this.registerReword()
    
    if(wx.getStorageSync('isShowShowApproach') == true){
      this.setData({
        showApproach: true
      })
    }

  },
  tomoredisc() {
    if (!this.data.btnDisable) {
      this.setData({
        btnDisable: true
      })
      my.judgeUserStatus(false).then(res => {
        if (res.code === 200) { // 已登录状态下
          wx.navigateTo({
            url: '/pages/mydiscount/mydiscount?type=resc',
            success: (res) => {
              setTimeout(() => {
                this.setData({
                  btnDisable: false
                })
              }, 1000)
            },
          })

        } else { // 未登录
          wx.navigateTo({
            url: '/pages/login/login',
            success: (res) => {
              setTimeout(() => {
                this.setData({
                  btnDisable: false
                })
              }, 1000)
            },
          })
        }
      })

    }
  },
  // 跳转至迷你仓
  navigateToDetail(e) {
    wx.navigateTo({ url: '/pages/miniWarehouseDetails/miniWarehouseDetails?id=' + e.currentTarget.dataset.id })
  },

  
  call() {
    // util.callPhone(this.data.phone)

  },
  
  



  fingerTouchMove: function () {
  },

  //获取当前地理位置
  getLocat: util.throttle(function () {
    let that = this
    if (this.data.rejectGetPhone) {
      wx.showModal({
        title: '是否允许授权当前位置',
        content: '"乐存自助仓"需要获取您的地理位置',
        confirmText: '允许',
        cancelText: '不允许',
        confirmColor: "#1E2E53",
        cancelColor: "#999999",
        success(res) {
          if (res.confirm) { // 确定
            wx.openSetting({
              success(res) {
                if (res.authSetting['scope.userLocation']) {
                  that.setData({ rejectGetPhone: false })
                }
                that.searchStore()
              }
            })
          } else if (res.cancel) { // 取消

          }
        }
      })
    } else {
      // 授权,通过 wx.getSetting 先查询一下用户是否授权了 "scope.record" 这个 scope
      wx.getSetting({
        success: res => {
          if (!res.authSetting['scope.userLocation']) {
            console.log('没有授权过获取地理位置')
            wx.authorize({
              scope: 'scope.userLocation',
              success() {
                wx.getLocation({
                  type: 'gcj02',
                  success(res) {
                    app.globalData.locationInfo = res
                    that.searchStore()
                    that.locationCity()
                  },
                })
              },
              fail: (res) => { // 询问弹窗中点了拒绝
                console.log('拒绝:', res)
                this.setData({ rejectGetPhone: true })
                that.searchStore()
              }
            })
          } else { // 授权过了
            console.log('授权过了,更新地理位置')
            wx.getLocation({
              type: 'gcj02',
              success(res) {
                app.globalData.locationInfo = res
                that.locationCity()
              },
              complete(res) {
                that.searchStore()
              }
            })
          }
        }
      })
    }
  }, 3000),



  // 跳转页面
  navigateToPage: function (pageUrl) {
    wx.navigateTo({
      url: pageUrl
    })
  },

  // 跳转到增值服务页
  toValueAddList: function () {
    this.navigateToPage('/pages/valueAddList/valueAddList')
  },

  //获取banner图
  getBanner: function () {
    my.getBanner().then(res => {
      this.setData({
        data2: res.data,
        indicatorDots: res.data && res.data.length > 1 ? true : false
      })
    }).catch(() => {
    })
  },

  // 点击banner跳转到后台配置的页面
  bannerJump: function (e) {
    // this.navigateToPage('/'+ e.currentTarget.dataset.url)
    if (e.currentTarget.dataset.url === '/pages/my/my') {
      wx.switchTab({
        url: '/pages/my/my'
      })
    } else {
      this.navigateToPage(e.currentTarget.dataset.url)
    }
  },
  //获取注册奖励
  registerReword: function () {
    my.registerReword().then(res => {
      this.setData({
        // data: res.data,
        count: res.data.count,
        credits: res.data.credits,
        isNotFirstCall: res.data.isNotFirstCall,
        showPopup: (!res.data.isNotLogin) && res.data.isNotFirstCall,
        couponTemplateList: res.data.couponTemplateList
      })
      if (this.data.count == 1 && this.data.showPopup == true) {
        this.setData({
          show: true
        })
      } else if (this.data.count == 2 && this.data.showPopup == true) {
        this.setData({
          show2: true
        })

      } else if (this.data.count == 3 && this.data.showPopup == true) {
        this.setData({
          show3: true
        })
      } else {
        this.setData({
          show: false,
          show2: false,
          show3: false
        })
      }
    }).catch(() => {
    }).finally(() => {
      setTimeout(() => { wx.hideLoading() }, 500)
    })
  },
  gotoCurrentPage: function () {
    wx.navigateTo({
      url: '/pages/login/login',
    })
  },
  onShareAppMessage: function () {

  },

  onReachBottom: function () {
    if (this.data.page < this.data.totalPage) {

      this.setData({
        page: this.data.page + 1
      })
      this.searchStore(1)
    } else {
      this.setData({
        showLast: true
      })
    }
  },
  onCloseApproach: function(){
    this.setData({
      showApproach: false
    });
    wx.setStorageSync('isShowShowApproach', null);
  },
  showMoreSelect: function(){
    this.setData({
      channelsSelect: true
    })
  },
  onclickSelectChannel: util.throttle(function(e){
    let channel = e.currentTarget.dataset.value;
    this.setData({
      selectApproachText: channel
    });
    indeApi.setSupplementChannel(channel).then(res => {
      if(res.code == 200){
         console.log('res', res);
         wx.setStorageSync('isShowShowApproach', null);
         wx.showToast({
          title: '恭喜获得200积分!',
          icon: 'none'
        })
         setTimeout(() => {
          this.setData({
            showApproach:false
           })
         }, 1500);
         
      }
    })
  })
})