Authored by TaoHuang

share miniapp

... ... @@ -2,7 +2,7 @@ export default {
name: 'AuthComponent',
props: {
tag: String,
auth: {
requiredAuth: {
type: Boolean,
default: true
}
... ... @@ -15,17 +15,17 @@ export default {
this._lastTime = e.timeStamp;
if (!this.auth) {
return this.$emit('click');
}
if (this.requiredAuth) {
const user = await this.$sdk.getUser();
const user = await this.$sdk.getUser();
if (user && user.uid) {
this.$emit('click', {uid: user.uid});
if (user && user.uid) {
this.$emit('click', {uid: user.uid});
} else {
this.$emit('cancel');
this.$sdk.goLogin();
}
} else {
this.$emit('cancel');
this.$sdk.goLogin();
return this.$emit('click');
}
}
},
... ...
<template>
<AuthComponent class="btn-follow hover-opacity" :class="followClass" :auth="isAuth" @click="onFollow">
<AuthComponent class="btn-follow hover-opacity" :class="followClass" :requiredAuth="isAuth" @click="onFollow">
<span>{{followText}}</span>
</AuthComponent>
</template>
... ...
<template>
<div class="icon-btn" :class="{'btn-selected': viewOption.selected}" :style="btnStyle">
<AuthComponent :auth="isAuth" class="click-wrap" @click="onClick"></AuthComponent>
<AuthComponent :requiredAuth="isAuth" class="click-wrap" @click="onClick"></AuthComponent>
<i class="iconfont" :class="iconClass" :style="iconStyle">
<div v-if="type === 'fav'" class="praise-lottie">
<WidgetLottie ref="lottie" class="praise-lottie-wrap" :options="lottieOptions"></WidgetLottie>
... ... @@ -241,10 +241,11 @@ export default {
return Promise.resolve({code: 404});
}
},
onClick(evt) {
async onClick(evt) {
if (this.share) {
return this.$links.toDownloadApp();
}
if (this.syncing) {
return;
}
... ...
const serverDownloadMixin = {
methods: {
isDownloadBarHide() {
async isDownloadBarHide() {
return true;
}
}
... ... @@ -8,8 +8,39 @@ const serverDownloadMixin = {
const clientDownloadMixin = {
methods: {
isDownloadBarHide() {
async isDownloadBarHide() {
let isMiniapp = await this.isMiniapp();
if (isMiniapp) {
return true;
}
return document.getElementById('no-download');
},
isMiniapp() {
// 因为不在微信环境里面,这个接口回调不返回,因此做了一个 race,强制返回值
return Promise.race([new Promise((resolve) => {
if (/micromessenger/i.test(navigator.userAgent)) {
/* eslint-disable-next-line */
wx.miniProgram.getEnv((res) => {
console.log(res);
if (res.miniprogram) {
resolve(true);
} else {
resolve(false);
}
});
} else {
resolve(false);
}
}), this.sleep(3000).then(() => false)]);
},
sleep(ns) {
return new Promise(resolve => {
setTimeout(resolve, ns);
});
}
}
};
... ...
... ... @@ -45,7 +45,7 @@
:index="data.index"
:data="data.data"
:width="colWidthForTwo"
:share="false"
:share="share"
:article-id="data.data.articleId"
:pos-id="posId">
<template v-if="data.data.dataType == 2">
... ...
... ... @@ -137,10 +137,6 @@ export default {
this.reportClickAvatar();
},
toArticlePage() {
if (this.share) {
return this.$links.toDownloadApp();
}
this.$router.push({
name: 'article',
params: {
... ...
... ... @@ -15,8 +15,10 @@ export default {
visible: true
};
},
mounted() {
if (this.isDownloadBarHide()) {
async mounted() {
let isHide = await this.isDownloadBarHide();
if (isHide) {
this.visible = false;
}
},
... ...
... ... @@ -11,8 +11,10 @@ export default {
visible: true
};
},
mounted() {
if (this.isDownloadBarHide()) {
async mounted() {
const isHide = await this.isDownloadBarHide();
if (isHide) {
this.visible = false;
return;
}
... ...
... ... @@ -22,7 +22,7 @@
:index="data.index"
:data="data.data"
:width="colWidthForTwo"
:share="false"
:share="share"
:article-id="data.data.articleId"
:pos-id="posId">
<template v-if="data.data.dataType == 2">
... ... @@ -113,7 +113,6 @@ export default {
}
},
mounted() {
this.share = !this.$yoho.isApp;
this.scrollEvent = throttle(this.onDounceScroll.bind(this), throttleTime);
... ...
... ... @@ -14,6 +14,7 @@
<script type="text/javascript">
(function(d,c){var e=d.documentElement,a="orientationchange" in window?"orientationchange":"resize",b=function(){var f=e.clientWidth;if(!f){return}if(f>=750){e.style.fontSize="40px"}else{e.style.fontSize=40*(f/750)+"px"}};if(!d.addEventListener){return}b();c.addEventListener(a,b,false);d.addEventListener("DOMContentLoaded",b,false)})(document,window);
</script>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
<link rel="dns-prefetch" href="//cdn.yoho.cn">
<link rel="dns-prefetch" href="imgsocial.yohobuy.com">
<link rel="dns-prefetch" href="flv01.static.yhbimg.com">
... ...