<template>
  <div class="app-content">
    <div class="tab-wrap">
      <div class="logo-img">
        <img :src="`${constant.imgUrl}/retail/official/logo.png`" alt />
      </div>
      <div class="phone-img" @click="contactFn">
        <img :src="`${constant.imgUrl}/retail/official/phone.png`" alt />
      </div>
    </div>
    <app-swiper :height="{type: 'number',val: 750}" :list="swiper" />
    <div class="module-com" v-for="(item, index) in contentData" :key="index">
      <div class="module-tit">
        <div class="tit-main" v-html="item.title"></div>
        <div class="tit-sub">{{ item.subTitle }}</div>
      </div>
      <div class="module-det">
        <app-img class="module-img" :src="item.img" :lazy-load="true" mode="widthFix" />
      </div>
    </div>
    <!-- ad -->
    <div class="cooperation-wrap" :style="{backgroundImage:'url(' + backgroundImg + ')'}">
      <div class="ad-title">
        <span>他们都在用</span>
      </div>
      <div class="ad-list-wrap">
        <div class="ad-list" v-for="(item, index) in adData" :key="index">
          <app-img
            :src="`${constant.imgUrl}/retail/official/list-${index + 1}.png`"
            mode="widthFix"
            alt="他们都在用"
          />
        </div>
      </div>
      <div class="official-wrap">
        <div class="off-title">技术让花店经营更简单</div>
        <div class="off-sub-tit" @click="contactFn">
          <app-img
            :src="`${constant.imgUrl}/retail/official/phone-small.png`"
            alt="电话"
            mode="widthFix"
          />
          <span>咨询热线：0592 - 3272000</span>
        </div>
      </div>
    </div>
    <!-- trademark -->
    <div class="bottom-trademark">
      <img :src="`${constant.imgUrl}/retail/common/trademark.png`" alt />
    </div>
    <!-- buttom -->
    <div class="app-footer" @click="pageTo({url: '/pagesClient/official/pay',type: 2,query:{...option}})" v-if="getLoginInfo.openShop == 1">申请试用</div>
    <div class="app-footer" v-if="getLoginInfo.openShop == 2">审核中</div>
    <div class="app-footer" v-if="getLoginInfo.openShop == 3" @click="pageTo({url: '/pagesClient/official/renewal',type: 2})">续期</div>
  </div>
</template>

<script>
import store from '@/store'
import AppSwiper from "@/components/app-swiper";
import AppImg from "@/components/app-img";
import { applyStatus } from "@/api/official";
import { share } from "@/mixins";
import {mapActions, mapGetters} from 'vuex';
import util from "../../utils/util";
import { postWxCode,getDictionaries } from '@/api/mini'
import { getUser } from '@/utils/auth'
export default {
  name: "index",
  components: {
    AppSwiper,
    AppImg
  },
  mixins: [share],
  data() {
    return {
      constant: this.$constant,
      swiper: [
        {
          img: `${this.$constant.imgUrl}/retail/official/banner-1.png`
        },
        {
          img: `${this.$constant.imgUrl}/retail/official/banner-2.png`
        },
        {
          img: `${this.$constant.imgUrl}/retail/official/banner-3.png`
        },
        {
          img: `${this.$constant.imgUrl}/retail/official/banner-4.png`
        }
      ],
      backgroundImg: `${this.$constant.imgUrl}/retail/official/bg.png`,
      contentData: [
        {
          title: `<span class="app-color-1">一键开通商城</span>`,
          subTitle: `线上线下二个门店，店铺管理一个系统，经营管理更方便`,
          img: `${this.$constant.imgUrl}/retail/official/content-1.png`
        },
        {
          title: `<span class="app-color-1">客户分销</span>`,
          subTitle: `招募粉丝，不断裂变，通过佣金激励粉丝将商品分享给朋友，实现社群传播，产生订单`,
          img: `${this.$constant.imgUrl}/retail/official/content-4.png`
        },
        {
          title: `<span class="app-color-1">一键操作 快速涨粉</span>`,
          subTitle: `一键操作，快速注册会员，到店客户粉丝转化率提升80%`,
          img: `${this.$constant.imgUrl}/retail/official/content-5.png`
        },
        {
          title: `<span class="app-color-1">精准管理客户</span>`,
          subTitle: `实现订单和客户分门别类，把握每个客户的个性和特征，精准营销，快速提高客户复购`,
          img: `${this.$constant.imgUrl}/retail/official/content-6.png`
        },
        {
          title: `<span class="app-color-1">流程化订单管理</span>`,
          subTitle: `流程化管理订单，下单、制单、发货、配送、送到通知客户，享尊贵开店体验`,
          img: `${this.$constant.imgUrl}/retail/official/content-2.png`
        },
        {
          title: `<span class="app-color-1">丰富多样的营销工具</span>`,
          subTitle: `契合花店的营销工具，拉新、转化、复购、裂变，面面俱到`,
          img: `${this.$constant.imgUrl}/retail/official/content-3.png`
        },
        {
          title: `<span class="app-color-1">经营数据分析</span>`,
          subTitle: `大数据分析客户行为，精准定位高利润项目，投入产出更高效`,
          img: `${this.$constant.imgUrl}/retail/official/content-7.png`
        }
      ],
      adData: [1, 2, 3, 4, 5, 6, 7, 8]
    };
  },
  computed: {
    ...mapGetters(["getLoginInfo"])
  },
  onShareAppMessage(res) {
    
    console.log('option',this.options)
    console.log('option1',this.option)
    console.log('option2',res)

    //查看分享的路径，不要删除 shish 20210517
    console.log("pagesClient/official/index?ghsShopAdminId="+this.option.ghsShopAdminId+"&hdShopAdminId="+this.getLoginInfo.shopAdminId)

    return {
      title: "更懂您的花卉宝",
      desc: "",
      imgUrl: "",
      path: "pagesClient/official/index?ghsShopAdminId="+this.option.ghsShopAdminId+"&hdShopAdminId="+this.getLoginInfo.shopAdminId,
    }
	},
  mounted() {
    // 隐藏返回首页按钮。
    // uni.hideHomeButton()
  },
  methods: {
			...mapActions(['setUserShopAll']),
      contactFn() {
        uni.makePhoneCall({
          phoneNumber: "05923272000"
        });
      },
			experienceFun(){
				/**姜枫 2021.04.30  小程序审核体验账号**/
				postWxCode().then(subRes => {
					if (util.isEmpty(subRes)) {
						return false
					}
					uni.setStorageSync('token', subRes.data.token)
					uni.setStorageSync('shopId', subRes.data.admin.currentShopId)
					getDictionaries({ token: subRes.data.token }).then(res => {
						if (util.isEmpty(res)) {
							return false
						}
						store.commit('setDictionariesInfo', {
							...res.data.dict,
							...res.data
						})
						store.commit('setMyShopInfo', {
							...res.data.shop,
							...res.data
						})
					})
					store.commit('setLoginInfo', {
						...subRes.data.admin,
						...subRes.data
					})

					//启动更新逻辑 shish 2020.5.18
					if (subRes.data.update == 1) {
						const updateManager = wx.getUpdateManager()
						updateManager.onCheckForUpdate(function (res) {
							// 请求完新版本信息的回调
							console.log(res.hasUpdate)
						})
						updateManager.onUpdateReady(function () {
							wx.showModal({
								title: '更新提示',
								content: '新版本已经准备好，是否重启应用？',
								success(res) {
									if (res.confirm) {
										// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
										updateManager.applyUpdate()
									}
								}
							})
						})
						updateManager.onUpdateFailed(function () {})// 新版本下载失败
						return true;
					}
					getUser(true)
					//获取门店信息
					this.setUserShopAll();
					uni.switchTab({url:'/admin/home/workbench'})
				})
			},
  }
};
</script>

<style lang="scss" scoped>
.experience{
	display: flex;
	align-items: center;
	justify-content: flex-end;
	height: 60rpx;
	padding: 0 30rpx;
	color: #3385FF;
}
.app-content {
  background-color: #fff;
  padding-bottom: 130px;
}
.tab-wrap {
  @include disFlex(center, space-between);
  padding: 0 30px;
  .logo-img {
    width: 160px;
  }
  .phone-img {
    width: 50px;
  }
}
// module
.module-com {
  margin-top: 80px;
  .module-tit {
    text-align: center;
    .tit-main {
      font-size: 36px;
      font-weight: 600;
      margin-bottom: 14px;
    }
    .tit-sub {
      width: 90%;
      margin: 0 auto;
      color: $fontColor3;
      line-height: 34px;
      font-size:27rpx;
    }
  }
  .module-det {
    .module-img {
      min-height: 470px;
    }
  }
}
// cooperation
.cooperation-wrap {
  width: 100%;
  height: 552px;
  padding-top: 60px;
  .ad-title {
    color: #fff;
    font-size: 36px;
    font-weight: 600;
    margin-bottom: 50px;
    text-align: center;
  }
  .ad-list-wrap {
    @include disFlex(center, center);
    flex-wrap: wrap;
    margin-bottom: 30px;
    .ad-list {
      width: 166px;
      margin-right: 10px;
      margin-bottom: 10px;
    }
  }
  .official-wrap {
    color: #fff;
    background-color: rgba(#000000, 0.6);
    width: 90%;
    margin: 0 auto;
    padding: 20px 0;
    .off-title {
      font-size: 36px;
      font-weight: 600;
      margin-bottom: 10px;
      text-align: center;
    }
    .off-sub-tit {
      @include disFlex(center, center);
      img {
        width: 28px;
        height: 28px;
        margin-right: 10px;
      }
    }
  }
}
// trademark
.bottom-trademark {
  @include disFlex(center, center);
  background-color: #242627;
  img {
    width: 140px;
  }
}
// footer
.app-footer {
  color: #fff;
  font-size: 36px;
  font-weight: 600;
  background: linear-gradient(90deg, #3ab7ff, #3385ff);
  &.under-review {
    background: #fff !important;
    color: #333 !important;
  }
}
</style>
