This commit is contained in:
zmr900709
2020-06-19 19:20:33 +08:00
parent 84d15f6b29
commit d384e6d4e7
6 changed files with 441 additions and 133 deletions

View File

@@ -0,0 +1,74 @@
/*
graceUI rich-text 鍔犲己宸ュ叿
link : graceui.hcoder.net
author : 5213606@qq.com 娣辨捣
*/
// 姝e垯鍙橀噺
var graceRichTextReg;
// 鎵归噺鏇挎崲鐨勬牱寮<E789B1> [ 鏍规嵁椤圭洰闇€姹傝嚜琛岃缃<EE8695> ]
var GRT = [
// div 鏍峰紡
['div', "line-height:2em;"],
// h1 鏍峰紡
['h1', "font-size:3em; line-height:1.5em;"],
// h2 鏍峰紡
['h2', "font-size:2em; line-height:1.8em;"],
// h3 鏍峰紡
['h3', "font-size:1.6em; line-height:2em;"],
// h4 鏍峰紡
['h4', "font-size:1.2em; line-height:2em;"],
// h5 鏍峰紡
['h5', "font-size:1em; line-height:2em;"],
// h6 鏍峰紡
['h6', "font-size:0.9em; line-height:2em;"],
// p 鏍峰紡
['p', "font-size:1em; line-height:2em;"],
// b 鏍峰紡
['b', "font-size:1em; line-height:2em;"],
// strong 鏍峰紡
['strong', "font-size:1em; line-height:2em;"],
// code 鏍峰紡
['code', "font-size:1em; line-height:1.2em; background:#F6F7F8; padding:8px 2%; width:96%;"],
// img 鏍峰紡
['img', "width:100%; margin:8px 0;"],
// blockquote
['blockquote', "font-size:1em; border-left:3px solid #D1D1D1; line-height:2em; border-radius:5px; background:#F6F7F8; padding:8px 2%;"],
// li 鏍峰紡
['ul', "padding:5px 0; list-style:none; padding:0; margin:0;"],
['li', "line-height:1.5em; padding:5px 0; list-style:none; padding:0; margin:0; margin-top:10px;"],
// table
['table', "width:100%; border-left:1px solid #F2F3F4; border-top:1px solid #F2F3F4;"],
['th', "border-right:1px solid #F2F3F4; border-bottom:1px solid #F2F3F4;"],
['td', "border-right:1px solid #F2F3F4; border-bottom:1px solid #F2F3F4; padding-left:5px;"]
];
module.exports = {
format : function(html){
html = html.replace(/<pre.*pre>?/gis, function(word){
word = word.replace(/[\n]/gi,'<br />');
word = word.replace(/ /gi,'<span style="padding-left:2em;"></span>');
return word.replace(/[\t]/gi, '<span style="padding-left:2em;"></span>');
});
html = html.replace(/<pre/gi, '<p style="font-size:1em; margin:12px 0; line-height:1.2em; background:#F6F7F8; border-radius:5px; padding:8px 4%; width:92%;"');
html = html.replace(/<\/pre/gi,"</p");
for(let i = 0; i < GRT.length; i++){
graceRichTextReg = new RegExp('<'+GRT[i][0]+'>|<'+GRT[i][0]+' (.*?)>', 'gi');
html = html.replace(graceRichTextReg , function(word){
// 鍒嗘瀽 dom 涓婃槸鍚﹀甫鏈<E794AB> style=""
if(word.indexOf('style=') != -1){
var regIn = new RegExp('<' + GRT[i][0] + '(.*?)style="(.*?)"(.*?)(/?)>', 'gi');
return word.replace(regIn, '<'+ GRT[i][0] +'$1style="$2 ' + GRT[i][1] +'"$3$4>');
}else{
var regIn = new RegExp('<' + GRT[i][0] + '(.*?)(/?)>', 'gi');
return word.replace(regIn, '<'+ GRT[i][0] +'$1 style="' + GRT[i][1] +'$2">');
}
});
}
return html;
}
}

View File

@@ -1,19 +1,32 @@
<template>
<view>
<image v-if="type" class="welcome_images" src="../../static/pageA/welcome_img.jpg" mode="aspectFill"></image>
<view v-if="type" class="welcome_jumpes" @click="leap_over" >跳过{{remaining}}</view>
<view v-if="banner" class="welcome_jumpes" @click="leap_overto" >跳过</view>
<!-- <image v-if="type" class="welcome_images" src="../../static/pageA/welcome_img.jpg" mode="aspectFill"></image> -->
<view v-if="type" id="video_mp4">
<view class="page-body">
<view class="page-section">
<video id="myVideo" :src=" 'https://' + vide0_url" :controls="controls" :autoplay="autoplayes" :loop="loop" @error="videoErrorCallback" enable-danmu danmu-btn></video>
</view>
</view>
</view>
<view v-if="type" class="welcome_jumpes" @click="leap_over">跳过{{remaining}}</view>
<view v-if="banner" class="welcome_jumpes" @click="leap_overto">跳过</view>
<!-- 轮播图 -->
<view class="uni-padding-wrap" v-if="banner" >
<view class="page-section swiper">
<view class="page-section-spacing">
<swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
<swiper-item v-for="(item,index) in imgurl" :key="index">
<view class="swiper-item uni-bg-red">
<image :src="item" mode="aspectFill"></image>
</view>
</swiper-item>
</swiper>
<view class="uni-padding-wrap" v-if="banner">
<view class="uni-padding-wrap">
<view class="page-section swiper">
<view class="page-section-spacing">
<swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
<swiper-item>
<view class="swiper-item uni-bg-red">A</view>
</swiper-item>
<swiper-item>
<view class="swiper-item uni-bg-green">B</view>
</swiper-item>
<swiper-item>
<view class="swiper-item uni-bg-blue">C</view>
</swiper-item>
</swiper>
</view>
</view>
</view>
</view>
@@ -35,82 +48,144 @@
export default {
data() {
return {
remaining : 3,
type:true,
banner : false,
protocol : false,
heightes:'',
imgurl: ['../../static/pageA/welcome_banner.jpg', '../../static/pageA/welcome_img2.jpg', '../../static/pageA/welcome_img3.jpg'],
remaining: 10,
type: true,
banner: false,
protocol: false,
heightes: '',
imgurl: [],
indicatorDots: true,
autoplay: true,
loop : 'true',
interval: 3000,
duration: 500,
vide0_url : '',
agreement: { // 用户协议内容
document_title: "",
document_content: ""
}
},
title: 'video',
src: '',
inputValue: '',
controls : false,
autoplayes : true,
danmuList: [{
text: '第 1s 出现的弹幕',
color: '#ff0000',
time: 1
},
{
text: '第 3s 出现的弹幕',
color: '#ff00ff',
time: 3
}
]
};
},
onLoad() {
},
onReady: function(res) {
this.videoContext = uni.createVideoContext('myVideo')
},
methods: {
unescapeHTML (temp){
unescapeHTML(temp) {
temp = "" + temp;
return temp.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&apos;/g, "'");
},
apiwelcome(){
apiwelcome() {
this.$u.api.documentInfo({
document_code:'agreement'
}).then((res)=>{
document_code: 'agreement'
}).then((res) => {
if (res.errCode == 0) {
let agreement = res.data;
// console.log(agreement.document_content)
agreement.document_content = this.unescapeHTML(agreement.document_content);
// console.log(agreement);
this.agreement = agreement;
}
})
// 启动页
this.$u.api.pageList({}).then((res)=>{
console.log('协议',res)
this.$u.api.pageList({}).then((res) => {
console.log('协议', res)
let data_image = res.data.welcome_page
let vide0_url = res.data.start_page[0].launch_path
this.list = data_image;
this.vide0_url = vide0_url;
console.log(this.list)
})
},
// 3秒倒计时
remaining_time(){
this.timer=setInterval(() => {
remaining_time() {
this.timer = setInterval(() => {
this.remaining--;
if(this.remaining <= 0){
if (this.remaining <= 0) {
clearInterval(this.timer);
// console.log("完了")
console.log("完了")
this.type = !this.type
this.banner = !this.banner;
}
},1000);
}, 1000);
},
leap_over(){
leap_over() {
this.type = !this.type
this.banner = !this.banner;
},
leap_overto(){
leap_overto() {
this.protocol = true
},
getSystemInfo(){
getSystemInfo() {
// 获取屏幕高度
uni.getSystemInfo({
success: function (res) {
this.heightes = res.windowHeight;
console.log( this.heightes)
}
success: function(res) {
this.heightes = res.windowHeight;
console.log(this.heightes)
}
});
},
// 我同意
to_agree(){
to_agree() {
uni.navigateTo({
url: '/pageA/login/login'
url: '/pageA/login/login'
});
},
// 视频引入
bindInputBlur: function(e) {
this.inputValue = e.target.value
},
bindButtonTap: function() {
var that = this
uni.chooseVideo({
sourceType: ['album', 'camera'],
maxDuration: 60,
camera: ['front', 'back'],
success: function(res) {
this.src = res.tempFilePath
}
})
},
bindSendDanmu: function() {
this.videoContext.sendDanmu({
text: this.inputValue,
color: this.getRandomColor()
})
},
videoErrorCallback: function(e) {
console.log('视频错误信息:')
console.log(e.target.errMsg)
},
getRandomColor: function() {
const rgb = []
for (let i = 0; i < 3; ++i) {
let color = Math.floor(Math.random() * 256).toString(16)
color = color.length == 1 ? '0' + color : color
rgb.push(color)
}
return '#' + rgb.join('')
}
},
mounted(){
mounted() {
// 3秒倒计时调用
this.remaining_time()
// 获取屏幕高度
@@ -121,71 +196,96 @@
</script>
<style lang="scss" scoped>
.welcome_jumpes{
.welcome_jumpes {
width: 90rpx;
height: 35rpx;
opacity:0.5;
border-radius:18rpx;
opacity: 0.5;
border-radius: 18rpx;
position: absolute;
right: 37rpx;
top: 34rpx;
font-size:20rpx;
font-size: 20rpx;
text-align: center;
line-height: 35rpx;
color: #fff;
background: #C4CAC6;
z-index: 10;
}
#myVideo{
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin: auto;
}
uni-video{
width: 100%;
height: auto;
}
.uni-video-container{
background-color: none!important;
}
.welcome_images {
width: 100%;
position: fixed;
height: 100%
}
uni-swiper,uni-view,uni-image{
uni-swiper,
uni-view,
uni-image {
width: 100%;
// position: fixed;
height: 100%
}
uni-image{
uni-image {
width: 100%;
}
// 轮播图分页器颜色
uni-swiper .uni-swiper-dot-active{
background-color: #fff!important;
uni-swiper .uni-swiper-dot-active {
background-color: #fff !important;
}
.welcome_backes{
.welcome_backes {
width: 100%;
position: fixed;
height: 100%;
background:#999999;
.content{
width:558rpx;
height:730rpx;
background:rgba(255,255,255,1);
background: #999999;
.content {
width: 558rpx;
height: 730rpx;
background: rgba(255, 255, 255, 1);
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin: auto;
.title{
width:558rpx;
.title {
width: 558rpx;
text-align: center;
height:29rpx;
font-size:30rpx;
font-weight:bold;
color:rgba(51,51,51,1);
line-height:29rpx;
height: 29rpx;
font-size: 30rpx;
font-weight: bold;
color: rgba(51, 51, 51, 1);
line-height: 29rpx;
margin: 30rpx 0 24rpx 0;
}
.scroll {
height: 560rpx;
.protocol_content{
width:494rpx;
height:528rpx;
font-size:24rpx;
font-weight:400;
color:rgba(51,51,51,1);
.protocol_content {
width: 494rpx;
height: 528rpx;
font-size: 24rpx;
font-weight: 400;
color: rgba(51, 51, 51, 1);
display: block;
text-align: left;
margin: 80rpx auto 33rpx;
@@ -195,15 +295,16 @@
}
}
.to_agree{
width:558rpx;
font-size:30rpx;
font-weight:bold;
color:rgba(255,121,16,1);
.to_agree {
width: 558rpx;
font-size: 30rpx;
font-weight: bold;
color: rgba(255, 121, 16, 1);
text-align: center;
padding-top: 27rpx;
border-top: #D8D8D8 solid 1px;
}
}
}
</style>
</style>