onLaunch: function () {
console.log('App Launch')
var firstOpen = uni.getStorageSync('firstOpen');
// var firstOpen = 0;
if (firstOpen != null && firstOpen == 1) {
uni.switchTab({
url: '/pages/home/home'
});
} else {
uni.reLaunch({
url: '/pages/guidePage/guidePage'
})
}
// uni.reLaunch({
// url: '/pages/guidePage/guidePage'
// })
},
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1">
<!-- #endif -->
<swiper class="swiper" :indicator-dots="false" :style="{'height':windowHeight}"
@animationfinish="animationfinish">
<swiper-item>
<view class="swiper-item" :style="{'height':windowHeight}">
<image src="../../static/image/home1.jpg" :style="{'height':windowHeight}" class="filtrate_img_1">
</image>
</view>
</swiper-item>
<swiper-item>
<view class="swiper-item" :style="{'height':windowHeight}">
<image src="../../static/image/home2.jpg" :style="{'height':windowHeight}" class="filtrate_img_1">
</image>
</view>
</swiper-item>
<swiper-item>
<view class="swiper-item" :style="{'height':windowHeight}">
<image src="../../static/image/home3.jpg" :style="{'height':windowHeight}" class="filtrate_img_1">
</image>
</view>
</swiper-item>
<swiper-item>
<view class="swiper-item" :style="{'height':windowHeight}" @tap="goHome()">
<image src="../../static/image/home4.jpg" :style="{'height':windowHeight}" class="filtrate_img_1">
</image>
<!-- <text class="swiper-text">进入首页</text> -->
</view>
</swiper-item>
</swiper>
<!-- #ifdef APP -->
</scroll-view>
<view v-if="show4" class="dialog-container">
<view class="dialog-content" :style="{'top':dialogTop}">
<text style="text-align: center;padding-top: 20px;font-size: 20px;color: black;background-color: #fff;">
{{title}}</text>
<scroll-view
style="flex: 1;align-content: center;padding-top: 10px;padding-left: 25px;padding-right: 25px;background-color: #fff;"
show-scrollbar="false">
<rich-text style="font-size: 10px;color: red;" :nodes="htmlString" @itemclick="itemClick"></rich-text>
</scroll-view>
<button class="button" style="background-color: #fff;" @click="reject"
hover-class="button-hover1">{{rejectTxt}}</button>
<button class="button" style="background-color: royalblue;" hover-class="button-hover2"
open-type="agreePrivacyAuthorization" @click="agree">{{agreeTxt}}</button>
</view>
</view>
<!-- #endif -->
</template>
<script>
import { openSchema } from '@/uni_modules/uts-openSchema'
export default {
data() {
return {
title: '服务协议和隐私政策',
windowHeight: '603px',
show4: false,
maskClose: false,
opacity: 0.5,
privacyState: false,
rejectTxt: '不同意',
agreeTxt: '同意并接受',
dialogTop: '20%',
htmlString: '<span style="color:grey">请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了更好的向你提供服务,我们需要收集你的设备标识等信息用于分析、优化应用性能。你可阅读<br><a href="">《用户协议》</a></strong>和<a href="">《隐私政策》</a></strong>了解详细信息。如果你同意,请点击下面按钮开始接受我们的服务。</span>'
}
},
onLoad() {
this.windowHeight = uni.getSystemInfoSync().screenHeight + 'px'
const that = this
// #ifdef APP-ANDROID
uni.getPrivacySetting({
success: (res) => {
console.log("res:" + JSON.stringify(res));
if (res.needAuthorization) {
that.openPrivacyDialog();
}
}
})
// #endif
},
methods: {
agree() {
console.log('agree');
this.show4 = false
},
reject() {
console.log('reject');
if (this.privacyState) {
uni.exit({
success: function (res) {
console.log(res)
},
fail: function (error) {
console.log(error)
}
})
} else {
this.privacyState = true
this.title = '温馨提示'
this.rejectTxt = '退出应用'
this.agreeTxt = '同意并继续'
this.dialogTop = '40%'
this.htmlString = '<span style="color:grey">进入应用前,你需先同意<br><a href="">《用户协议》</a></strong>和<a href="">《隐私政策》</a></strong>,否则将退出应用</span>'
}
},
itemClick(e : RichTextItemClickEvent) {
let ref = e.detail.href
console.log('ref:' + ref);
if (ref != null) {
openSchema(ref)
}
},
clickProtocol(i : number) {
var itemObj = {} as UTSJSONObject;
itemObj["id"] = 0;
if (i == 1) {
itemObj["h5Url"] = "/UserInfo/desingleUserProtocol";
itemObj["name"] = '用户协议';
} else if (i == 2) {
itemObj["h5Url"] = "/UserInfo/desinglePrivateProtocl";
itemObj["name"] = '隐私协议';
}
var params = {
"id": 0
} as UTSJSONObject;
uni.navigateTo({
url: '../generalPage/generalPage?h5Url=' + itemObj["h5Url"] + "&pageName=" + itemObj["name"] + "¶ms=" + JSON.stringify(params),
success: res => { },
fail: () => { },
complete: () => { }
});
},
openPrivacyDialog() {
this.show4 = true
},
goHome() {
uni.switchTab({
url: '/pages/home/home'
})
},
animationfinish(e : UniSwiperAnimationFinishEvent) {
console.log(JSON.stringify(e.detail));
//判断到最后一张后,自动转向进入首页
if (e.detail.current == 3) {
uni.setStorageSync("firstOpen", 1);
setTimeout(function () {
uni.switchTab({
url: '/pages/home/home'
});
}, 1000)
}
}
}
}
</script>
0 个回复