Commit 4a93b0ee authored by chenqikuai's avatar chenqikuai

fix

parent e167dd72
......@@ -22,48 +22,54 @@
<script lang="ts">
import { defineComponent } from "vue";
import Icon from "../common/Icon.vue";
import Bridge from "@/utils/jsBridge2"
import Bridge from "@/utils/jsBridge2";
import { Toast } from "vant";
import { enableLive } from "@/service/StaffService";
import { getCurrentUserAvatarUrl } from "@/utils/userMsg";
export default defineComponent({
components: { Icon },
props: {
title: String,
},
mounted() {
},
mounted() {},
methods: {
goto() {
const USER_MSG = window.localStorage.getItem('USER_MSG')
const avatarUrl = getCurrentUserAvatarUrl();
const finalAvatarUrl =
window.location.protocol + "//" + window.location.host + avatarUrl;
const USER_MSG = window.localStorage.getItem("USER_MSG");
if (!USER_MSG) {
Toast('请先登录')
return
Toast("请先登录");
return;
}
let allow = false
let time_section = ''
enableLive().then(res => {
if (res.code === 200) {
allow = res.data.allow
time_section = res.data.time_section
}
new Bridge().bridge_gotoLiveRoom({
phone: JSON.parse(window.localStorage.getItem('USER_MSG') as string)?.userInfo.phone,
avatar: window.location.host + require('@/assets/icons/avatar.png'),
allow,
time_section
})
}).catch(() => {
new Bridge().bridge_gotoLiveRoom({
phone: JSON.parse(window.localStorage.getItem('USER_MSG') as string)?.userInfo.phone,
avatar: window.location.host + require('@/assets/icons/avatar.png'),
allow,
time_section
let allow = false;
let time_section = "";
enableLive()
.then((res) => {
if (res.code === 200) {
allow = res.data.allow;
time_section = res.data.time_section;
}
new Bridge().bridge_gotoLiveRoom({
phone: JSON.parse(window.localStorage.getItem("USER_MSG") as string)
?.userInfo.phone,
avatar: finalAvatarUrl,
allow,
time_section,
});
})
})
.catch(() => {
new Bridge().bridge_gotoLiveRoom({
phone: JSON.parse(window.localStorage.getItem("USER_MSG") as string)
?.userInfo.phone,
avatar: finalAvatarUrl,
allow,
time_section,
});
});
},
}
},
});
</script>
<style scoped>
......@@ -101,14 +107,13 @@ export default defineComponent({
.outer3 {
overflow: hidden;
background: url(../../assets/img/live-outer3.png)
100% no-repeat;
background: url(../../assets/img/live-outer3.png) 100% no-repeat;
background-size: cover;
}
.block2 {
background: url(../../assets/img/live-block2.png)
/* background: url(https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPngb5e34933d0e615000378ebf1491cce32e934e21b7f3de7cddbddd3f05e03ed7a) */
/* background: url(https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPngb5e34933d0e615000378ebf1491cce32e934e21b7f3de7cddbddd3f05e03ed7a) */
100% no-repeat;
background-size: cover;
}
......@@ -139,4 +144,4 @@ export default defineComponent({
line-height: 17px;
text-align: left;
}
</style>
\ No newline at end of file
</style>
import Bridge from '@/utils/jsBridge2'
import { Toast } from 'vant'
import { enableLive } from '@/service/StaffService/index'
import { getCurrentUserAvatarUrl } from './userMsg'
export const sendLive = () => {
const avatarUrl = getCurrentUserAvatarUrl()
const finalAvatarUrl =
window.location.protocol + '//' + window.location.host + avatarUrl
const USER_MSG = window.localStorage.getItem('USER_MSG')
if (!USER_MSG) {
Toast('请先登录')
......@@ -25,11 +30,7 @@ export const sendLive = () => {
new Bridge().bridge_live({
phone: JSON.parse(window.localStorage.getItem('USER_MSG') as string)
?.userInfo.phone,
avatar:
window.location.protocol +
'//' +
window.location.host +
require('../assets/icons/avatar.png'),
avatar: finalAvatarUrl,
allow,
time_section,
})
......@@ -37,11 +38,7 @@ export const sendLive = () => {
{
phone: JSON.parse(window.localStorage.getItem('USER_MSG') as string)
?.userInfo.phone,
avatar:
window.location.protocol +
'//' +
window.location.host +
require('../assets/icons/avatar.png'),
avatar: finalAvatarUrl,
allow,
time_section,
},
......@@ -52,11 +49,7 @@ export const sendLive = () => {
new Bridge().bridge_live({
phone: JSON.parse(window.localStorage.getItem('USER_MSG') as string)
?.userInfo.phone,
avatar:
window.location.protocol +
'//' +
window.location.host +
require('../assets/icons/avatar.png'),
avatar: finalAvatarUrl,
allow,
time_section,
})
......@@ -64,11 +57,7 @@ export const sendLive = () => {
{
phone: JSON.parse(window.localStorage.getItem('USER_MSG') as string)
?.userInfo.phone,
avatar:
window.location.protocol +
'//' +
window.location.host +
require('../assets/icons/avatar.png'),
avatar: finalAvatarUrl,
allow,
time_section,
},
......
......@@ -28,7 +28,12 @@
"
/>
</Skeleton>
<group-title class="mt-7" title="精彩直播" v-if="LiveRoomTitle" @seeMore="handleSeeMoreLive" />
<group-title
class="mt-7"
title="精彩直播"
v-if="LiveRoomTitle"
@seeMore="handleSeeMoreLive"
/>
<LiveCard class="mt-4" :title="LiveRoomTitle" v-if="LiveRoomTitle" />
<group-title
class="mt-7"
......@@ -51,7 +56,12 @@
/>
</div>
</Skeleton>
<group-title class="mt-7" v-if="hotNews" title="热门资讯" @click="$router.push('News')" />
<group-title
class="mt-7"
v-if="hotNews"
title="热门资讯"
@click="$router.push('News')"
/>
<HotNews v-for="n in hotNews" :key="n.uuid" :info="n" />
</div>
</div>
......@@ -60,7 +70,7 @@
<script lang="ts">
import { defineComponent, onMounted, onUnmounted, watch } from "vue";
import Banner from "./Banner/Banner.vue";
import Navbar from "@/components/NavBar/index.vue"
import Navbar from "@/components/NavBar/index.vue";
import AppList from "./AppList/index.vue";
import appList from "./appList";
import Icon from "@/components/common/Icon.vue";
......@@ -75,7 +85,7 @@ import { queryBannerList } from "@/service/BannerService";
import { getImageSrcFromFileHash } from "@/service/FileService";
import { queryNotifyList } from "@/service/NotifyService";
import { queryActivityList } from "@/service/ActivityService";
import Bridge from "@/utils/jsBridge2"
import Bridge from "@/utils/jsBridge2";
import {
queryLoanProductList,
queryLoanProductInfo,
......@@ -83,16 +93,23 @@ import {
import { number } from "bitcoinjs-lib/types/script";
import { Skeleton } from "vant";
import { eProductStatus } from "@/service/LoanProductService/type";
import { getUserMsg } from "@/utils/userMsg"
import { getCurrentUserAvatarUrl, getUserMsg } from "@/utils/userMsg";
import { sendLive } from "@/utils/live";
import { isReviewMode } from "@/utils/vueAppEnv";
import { chatLoginActionMark, eLoginType } from "@/store/chatStore";
var hiddenProperty = 'hidden' in document ? 'hidden' :
'webkitHidden' in document ? 'webkitHidden' :
'mozHidden' in document ? 'mozHidden' :
null;
var visibilityChangeEvent = (hiddenProperty as string).replace(/hidden/i, 'visibilitychange');
var hiddenProperty =
"hidden" in document
? "hidden"
: "webkitHidden" in document
? "webkitHidden"
: "mozHidden" in document
? "mozHidden"
: null;
var visibilityChangeEvent = (hiddenProperty as string).replace(
/hidden/i,
"visibilitychange"
);
export default defineComponent({
components: {
......@@ -109,16 +126,16 @@ export default defineComponent({
Skeleton,
},
data() {
const theAppList = appList.filter(i => {
const theAppList = appList.filter((i) => {
if (isReviewMode()) {
return !i.hideInReviewMode
return !i.hideInReviewMode;
} else {
return true;
}
})
});
return {
LiveRoomTitle: '',
LiveRoomTitle: "",
appList: theAppList,
skeLoading: false,
bannerList: [] as string[],
......@@ -156,8 +173,11 @@ export default defineComponent({
};
},
beforeUnmount() {
clearInterval(this.intervalId)
document.removeEventListener(visibilityChangeEvent, this.onVisibilityChange)
clearInterval(this.intervalId);
document.removeEventListener(
visibilityChangeEvent,
this.onVisibilityChange
);
},
mounted() {
this.getHotNews();
......@@ -170,38 +190,48 @@ export default defineComponent({
},
methods: {
startGettingLiveRoom() {
console.log('start getting live room');
console.log("start getting live room");
(window as any).bridge_initLiveRoomCard = this.initLiveRoomCard;
this.initLiveRoomCard();
this.intervalId = window.setInterval(this.initLiveRoomCard, 2000)
this.intervalId = window.setInterval(this.initLiveRoomCard, 2000);
},
onVisibilityChange() {
if (hiddenProperty && !(document as any)[(<string>hiddenProperty)]) {
console.log('进入页面');
if (hiddenProperty && !(document as any)[<string>hiddenProperty]) {
console.log("进入页面");
this.startGettingLiveRoom();
} else {
console.log('离开页面');
clearInterval(this.intervalId)
console.log("离开页面");
clearInterval(this.intervalId);
}
},
handleSeeMoreLive() {
sendLive()
sendLive();
},
initLiveRoomCard() {
const avatarUrl = getCurrentUserAvatarUrl();
if (getUserMsg()) {
console.log('in initLiveRoomCard: login, requesting');
new Bridge().bridge_getliveInfo(getUserMsg()?.userInfo.phone, (msg: string) => {
console.log('in initLiveRoomCard: get msg', msg);
if (msg) {
this.LiveRoomTitle = msg;
}else{
this.LiveRoomTitle = '';
console.log("in initLiveRoomCard: login, requesting");
new Bridge().bridge_getliveInfo(
{
phone: getUserMsg()?.userInfo.phone,
avatar:
window.location.protocol +
"//" +
window.location.host +
avatarUrl,
},
(msg: string) => {
console.log("in initLiveRoomCard: get msg", msg);
if (msg) {
this.LiveRoomTitle = msg;
} else {
this.LiveRoomTitle = "";
}
}
})
);
} else {
console.log('in initLiveRoomCard: not login');
this.LiveRoomTitle = '';
console.log("in initLiveRoomCard: not login");
this.LiveRoomTitle = "";
}
},
getHotNews() {
......@@ -225,7 +255,7 @@ export default defineComponent({
const ret = await queryNotifyList({ notify_type: "1" });
if (ret.code === 200) {
const list = ret.data.items;
list.sort((a, b) => b.update_at - a.update_at)
list.sort((a, b) => b.update_at - a.update_at);
this.notifyList = list;
}
},
......@@ -249,7 +279,7 @@ export default defineComponent({
limit: 1,
offset: 0,
loan_type: 2,
product_status: eProductStatus.hot
product_status: eProductStatus.hot,
});
if (ret.code === 200) {
this.skeLoading = false;
......@@ -271,9 +301,9 @@ export default defineComponent({
},
computed: {
isReviewMode() {
return isReviewMode()
}
}
return isReviewMode();
},
},
});
</script>
<style scoped>
......@@ -753,4 +783,4 @@ export default defineComponent({
align-self: center;
margin-top: 8px;
}
</style>
\ No newline at end of file
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment