123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- <template>
- <div class="page">
- <div class="page-top" @click="toActivity">
- <img class="logo" :src="logoImage" alt="" />
- </div>
- <div class="page-content">
- <keep-alive>
- <div class="list">
- <div
- class="section flex flex-col justify-center items-center rounded-md"
- v-for="item in list"
- :key="item.id"
- >
- <icon-image class="icon" :name="item.image"></icon-image>
- <div
- class="name mt-4"
- v-text="item.name"
- @click="toDetail(item)"
- ></div>
- </div>
- </div>
- </keep-alive>
- </div>
- <div class="page-footer flex flex-col justify-center">
- <div class="name mb-1">需要帮助吗?</div>
- <div class="contact">联系我们官方客服</div>
- </div>
- </div>
- </template>
- <script>
- import { toAuthorization } from '~/utils'
- import { isWeChat } from '~/utils/validator'
- import { mapGetters } from 'vuex'
- export default {
- layout: 'app-ldm',
- data() {
- return {
- logoImage: '',
- list: [],
- banner: {},
- screenWidth: ""
- }
- },
- asyncData({ store }) {
- const logoImage = store.getters.static + '/ldm-logo-rect-white.png'
- return {
- logoImage,
- list: [
- {
- id: 0,
- name: '正品授权',
- image: 'ldm-icon-approve.png',
- path: '/approve',
- },
- {
- id: 1,
- name: '云资料库',
- image: 'ldm-icon-database.png',
- path: '/docs/0',
- },
- ],
- }
- },
- watch: {
- screenWidth: {
- handler(val) {
- const changeBanner = document.getElementsByClassName('page-top')[0]
- if (changeBanner) {
- if (val > 768) {
- if(this.banner.headPcBanner) {
- changeBanner.style.backgroundImage = 'url('+ this.banner.headPcBanner+ ')'
- }
- }else {
- if(this.banner.headAppBanner) {
- changeBanner.style.backgroundImage = 'url('+ this.banner.headAppBanner+ ')'
- }
- }
- }
- },
- immediate: true,
- deep: true
- }
- },
- computed: {
- ...mapGetters(['authUserId', 'appId', 'routePrefix', 'accountType']),
- },
- mounted() {
- this.initAppMessageShareData() // 公众号分享授权页面
- window.addEventListener('scroll', () => {
- this.scrollTop = document.documentElement.scrollTop
- })
- this.getBanner() // 获取轮播图
- // 监听页面尺寸变化
- this.screenWidth = document.body.clientWidth
- window.onresize = () => {
- return (() => {
- this.screenWidth = document.body.clientWidth
- })()
- }
- },
- beforeDestroy() {
- this.$removeStorage(this.routePrefix, 'login_redicret')
- },
- created() {
- document.title = '官方正品授权查询'
- },
- methods: {
- // 抖音挑战赛
- toActivity() {
- if(this.screenWidth > 768) {
- this.banner.jumpLink && window.open(this.banner.jumpLink)
- this.banner.jumpPcPicture && window.open(this.banner.jumpPcPicture)
- } else {
- this.banner.jumpLink && window.open(this.banner.jumpLink)
- this.banner.jumpAppPicture && window.open(this.banner.jumpAppPicture)
- }
- },
- toDetail(item) {
- // 保存登录重定向路由
- this.$setStorage(
- this.routePrefix,
- 'login_redicret',
- this.routePrefix + item.path
- )
- const hasLogin = this.$store.getters.accessToken
- if (item.id > 1 && !hasLogin) {
- // 在微信浏览器中使用微信授权登录
- if (isWeChat() && this.appId && this.accountType === 2) {
- const payload = {
- authUserId: this.authUserId,
- routePrefix: this.routePrefix,
- }
- return toAuthorization(this.appId, payload)
- }
- this.$toast({ message: '请先登录', duration: 1000 })
- this.$store.commit('app/SHOW_LOGIN')
- return
- }
- const url = this.routePrefix + item.path
- this.$router.push(url)
- },
- // banner
- async getBanner() {
- const { data } = await this.$http.api.bannerImg(this.authUserId)
- this.banner = data
- const changeBanner = document.getElementsByClassName('page-top')[0]
- if (this.screenWidth > 768) {
- this.banner.headPcBanner && (changeBanner.style.backgroundImage = 'url('+ this.banner.headPcBanner+ ')')
- }else {
- this.banner.headAppBanner && (changeBanner.style.backgroundImage = 'url('+ this.banner.headAppBanner+ ')')
- }
- },
- // 分享当前页面
- initAppMessageShareData() {
- console.log(window.location.href, window.location.origin)
- // 重试次数
- let retryCount = 1
- this.$wxReady((wx) => {
- //需在用户可能点击分享按钮前就先调用
- wx.updateAppMessageShareData({
- title: '官方正品授权查询', // 分享标题
- desc: '官方正品授权', // 分享描述
- link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
- imgUrl: this.banner.headAppBanner, // 分享图标
- fail: () => {
- if (retryCount === 0) return
- this.initAppMessageShareData()
- retryCount--
- },
- })
- })
- },
- },
- }
- </script>
- <style scoped lang="scss">
- @media screen and (min-width: 768px) {
- .page-top {
- height: 596px;
- background: url(https://static.caimei365.com/www/authentic/pc/ldm-bg-home.png)
- no-repeat center;
- background-size: auto 596px;
- .logo {
- display: none;
- }
- }
- .page-content {
- width: 700px;
- margin: 0 auto;
- min-height: calc(100vh - 596px - 100px);
- overflow: hidden;
- .list {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-top: 124px;
- margin-bottom: 314px;
- .section {
- .icon {
- width: 120px;
- height: 120px;
- }
- .name {
- width: 241px;
- height: 73px;
- background: #000;
- text-align: center;
- line-height: 73px;
- color: #fff;
- font-size: 22px;
- cursor: pointer;
- }
- }
- }
- }
- .page-footer {
- position: relative;
- height: 100px;
- padding-left: 194px;
- background: linear-gradient(to bottom, #f1f1f1, #fdfdfd, #f1f1f1);
- .name {
- font-size: 24px;
- color: #9d9d9d;
- }
- .contact {
- font-size: 19px;
- color: #9d9d9d;
- }
- &::before {
- position: absolute;
- left: 120px;
- top: 50%;
- transform: translateY(-50%);
- content: '';
- display: block;
- width: 56px;
- height: 56px;
- background: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-contact1.png)
- no-repeat center;
- background-size: 56px auto;
- }
- }
- }
- @media screen and (max-width: 768px) {
- .page-top {
- position: relative;
- height: 59.6vw;
- background: url(https://static.caimei365.com/www/authentic/h5/ldm-bg-home.gif);
- background-size: auto 59.6vw;
- .logo {
- position: absolute;
- left: 50%;
- top: 13.7vw;
- width: 37.8vw;
- transform: translateX(-50%);
- }
- }
- .page-content {
- min-height: calc(100vh - 59.6vw - 15.4vw);
- overflow: hidden;
- .list {
- display: flex;
- flex-direction: column;
- align-items: center;
- margin-top: 10.9vw;
- .section {
- width: 80vw;
- height: 48vw;
- background: #f8f8f8;
- border: 0.1vw solid #bfbfbf;
- margin-bottom: 5.8vw;
- .icon {
- width: 18.9vw;
- height: 18.9vw;
- }
- .name {
- width: 37.8vw;
- height: 11.4vw;
- background: #000;
- text-align: center;
- line-height: 11.4vw;
- color: #fff;
- }
- }
- }
- }
- .page-footer {
- position: relative;
- height: 15.4vw;
- padding-left: 12.5vw;
- background: linear-gradient(to bottom, #f1f1f1, #fdfdfd, #f1f1f1);
- .name {
- font-size: 3.2vw;
- color: #9d9d9d;
- }
- .contact {
- font-size: 2.6vw;
- color: #9d9d9d;
- }
- &::before {
- position: absolute;
- left: 2.4vw;
- top: 50%;
- transform: translateY(-50%);
- content: '';
- display: block;
- width: 7.5vw;
- height: 7.5vw;
- background: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-contact1.png)
- no-repeat center;
- background-size: 7.4vw auto;
- }
- }
- }
- </style>
|