效果:
頁面目錄:
index.html:
<!DOCTYPE html >
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta http-equiv="x-dns-prefetch-control" content="on">
<title>投訴</title>
<link rel="stylesheet" href="css/weui.css">
<link rel="stylesheet" href="css/wxappeal.css">
<script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
<script src="https://cdn.staticfile.org/vue-router/2.7.0/vue-router.min.js"></script>
<script src="js/tools/jquery.js"></script>
<script src="js/tools/methods.js"></script>
<!--組件js引入要注意順序,否則會報錯-->
<script src="js/components/TopNav.js"></script>
<script src="js/components/BottomNav.js"></script>
<script src="js/components/AppealNav.js"></script>
<script src="js/pages/AppealDetail.js"></script>
<script src="js/pages/AppealSuccess.js"></script>
<script src="js/pages/ChooseAppeal.js"></script>
<script src="js/pages/ChooseType.js"></script>
<script src="js/pages/NetError.js"></script>
<script src="js/main.js"></script>
</head>
<body>
<div id="app">
<keep-alive>
<router-view class="child-view" v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
<router-view class="child-view" v-if="!$route.meta.keepAlive"></router-view>
</div>
<!-- 選擇投訴類型 start-->
<script type="text/x-template" id="chooseTypeCom">
<div class='all'>
<TopNav :toptxt="toptxt"></TopNav>
<router-link tag='li' v-for="item in types" :to="{name:'ChooseAppeal',query:{id:item.id}}" class="weui-cell weui-cell_access js_item" data-id="button">
<div class="weui-cell__bd">
<p class="bold">{{item.title}}</p>
</div>
<div class="weui-cell__ft"></div>
</router-link>
<BottomNav :bottomtxt="bottomtxt" :link_url="link_url"></BottomNav>
<AppealNav></AppealNav>
</div>
</script>
<!-- 選擇投訴類型 end-->
<!-- 提交給微信團隊 start-->
<script type="text/x-template" id="chooseAppealCom">
<div class="all">
<TopNav :toptxt="toptxt"></TopNav>
<li class="weui-cell weui-cell_access js_item" data-id="button" @click="submitAppeal">
<div class="weui-cell__bd">
<p class="bold">{{title}}</p>
</div>
<div class="weui-cell__ft"></div>
</li>
<BottomNav :bottomtxt="bottomtxt" :link_url="link_url"></BottomNav>
<AppealNav></AppealNav>
</div>
</script>
<!-- 提交給微信團隊 end-->
<!-- 投訴須知 start-->
<script type="text/x-template" id="appealDetailCom">
<div class="backWhite">
<p class="appealTitle center">投訴須知</p>
<div class="content">
<span class="small">你應保證你的投訴行為基于善意褐缠,并代表你本人真實意思政鼠。
騰訊作為中立的平臺服務者,收到你投訴后队魏,會盡快按照相關法律法規(guī)的規(guī)定獨立判斷并進行處理公般。
騰訊將會采取合理的措施保護你的個人信息;除法律法規(guī)規(guī)定的情形外,未經(jīng)用戶許可騰訊不會向第三方公開官帘、
透露你的個人信息瞬雹。</span>
</div>
</div>
</script>
<!-- 投訴須知 end-->
<!-- 提交成功 start-->
<script type="text/x-template" id="appealSuccessCom">
<div class="weui-msg">
<div class="weui-msg__icon-area">
<i class="weui-icon-success weui-icon_msg"></i>
</div>
<div class="weui-msg__text-area">
<h2 class="weui-msg__title">投訴已提交</h2>
<p class="weui-msg__desc left">微信團隊將會盡快核實,并通過"微信團隊"通知你審核結果遏佣。感謝你的支持挖炬。</p>
</div>
<div class="weui-msg__opr-area">
<p class="weui-btn-area">
<a href="javascript:;" class="weui-btn weui-btn_primary" @click="$close">關閉</a>
</p>
</div>
</div>
</script>
<!-- 提交成功 end-->
<!-- 提交失敗 start-->
<script type="text/x-template" id="netErrorCom">
<div class="weui-msg">
<div class="weui-msg__icon-area">
<i class="weui-icon-warn weui-icon_msg"></i>
</div>
<div class="weui-msg__text-area">
<h2 class="weui-msg__title">錯誤</h2>
<p class="weui-msg__desc">網(wǎng)絡異常,請稍后嘗試</p>
</div>
<div class="weui-msg__opr-area">
<p class="weui-btn-area">
<a href="javascript:;" class="weui-btn weui-btn_primary" @click="$close">關閉</a>
</p>
</div>
</div>
</script>
<!-- 提交失敗 end-->
</body>
</html>
weui.css: 采用的是WeUI v2.0.1 (https://github.com/weui/weui)
wxappeal.css:
body {
width: 100%;
height: 100%;
}
.all {
width: 100%;
height: 100%;
/* background-color: #ededed; */
}
div {
margin: 0;
padding: 0;
font-size: 17px;
}
.content {
width: 90%;
margin: auto;
}
.center {
text-align: center;
}
.left {
text-align: left;
}
.gray {
color: rgba(0, 0, 0, 0.5);
}
.deepBlue {
color: #576B95;
}
.small {
font-size: 14px;
}
.bold {
/* font-weight: 600; */
}
.top-nav {
padding: 12px 16px 5px 16px;
}
.bottom-nav {
padding: 5px 16px 0 16px;
}
.weui-cell {
background-color: #ffffff;
}
.appeal-nav {
width: 100%;
display: flex;
justify-content: center;
position: absolute;
bottom: 7%;
}
.backWhite {
width: 100%;
height: 100%;
background-color: #ffffff;
}
.appealTitle {
margin: 20px 0;
}
methods.js:
Vue.prototype.$close = function() { //關閉微信瀏覽器状婶,只在微信端有效意敛,其他會報錯
document.addEventListener('WeixinJSBridgeReady', function() {
WeixinJSBridge.call('closeWindow');
}, false);
WeixinJSBridge.call('closeWindow');
}
TopNav.js:
// 頂部組件 start
var TopNav = Vue.extend({
template: "<p class='top-nav gray small'>{{toptxt}}</p>",
data() {
return {
toptxt: ''
}
},
props: ['toptxt'],
watch: {
toptxt: function(newVal, oldVal) {
this.toptxt = newVal;
}
}
})
Vue.component(TopNav)
// 頂部組件 end
BottomNav.js:
// 底部組件 start
var BottomNav = Vue.extend({
template: "<p class='small bottom-nav'><a class='deepBlue'" +
":href='link_url'>{{bottomtxt}}</a></p>",
data() {
return {
bottomtxt: '',
link_url: ''
}
},
props: ['bottomtxt', 'link_url'],
watch: {
bottomtxt: function(newVal, oldVal) {
this.bottomtxt = newVal;
},
link_url: function(newVal, oldVal) {
this.link_url = newVal;
}
}
})
Vue.component(BottomNav)
// 底部組件 end
AppealNav.js:
// 底部投訴組件 start
var AppealNav = Vue.extend({
template: "<p class='appeal-nav small'><router-link class='deepBlue'" +
"to='/appealDetail'>投訴須知</router-link></p>",
})
Vue.component(AppealNav)
// 底部投訴組件 end
AppealDetail.js:
// 投訴須知組件 start
var AppealDetail = Vue.extend({
template: "#appealDetailCom",
})
Vue.component(AppealDetail)
// 投訴須知組件 end
AppealSuccess.js:
// 投訴成功組件 start
var AppealSuccess = Vue.extend({
template: "#appealSuccessCom",
})
Vue.component(AppealSuccess)
// 投訴成功組件 end
ChooseAppeal.js:
//提交投訴 start
var ChooseAppeal = Vue.extend({
template: "#chooseAppealCom",
components: {
TopNav,
BottomNav,
AppealNav
},
data() {
return {
toptxt: '你可以:',
bottomtxt: '',
link_url: 'javascript:;',
title: '提交給微信團隊審核',
i: ''
}
},
mounted() {
let _this = this;
_this.setUrl();
},
methods: {
submitAppeal() {
let _this = this;
_this.$router.push({
name: "AppealSuccess"
})
},
setUrl() {
let _this = this,
i = _this.$route.query.id;
_this.i = i;
if (i == 6) {
_this.bottomtxt = '了解什么是誘導分享類內容';
_this.link_url = 'www.baidu.com';
} else if (i == 7) {
_this.bottomtxt = '了解微信對謠言的治理';
_this.link_url = '';
}
}
}
})
Vue.component(ChooseAppeal)
//提交投訴 end
ChooseType.js:
// 選擇投訴類型 start
var ChooseType = Vue.extend({
template: "#chooseTypeCom",
components: {
TopNav,
BottomNav,
AppealNav
},
data() {
return {
toptxt: '請選擇投訴該網(wǎng)頁的原因:',
bottomtxt: '遇到網(wǎng)頁流量被劫持怎么辦',
link_url: 'javascript:;',
types: [{
"id": 1,
"title": "網(wǎng)頁包含欺詐信息(如: 假紅包)"
},
{
"id": 2,
"title": "網(wǎng)頁包含色情信息"
},
{
"id": 3,
"title": "網(wǎng)頁包含暴力恐怖信息"
},
{
"id": 4,
"title": "網(wǎng)頁包含政治敏感信息"
},
{
"id": 5,
"title": "網(wǎng)頁在收集個人隱私信息(如: 釣魚鏈接)"
},
{
"id": 6,
"title": "網(wǎng)頁包含誘導分享/關注性質的內容"
},
{
"id": 7,
"title": "網(wǎng)頁可能包含謠言信息"
},
{
"id": 8,
"title": "網(wǎng)頁包含賭博信息"
},
]
}
}
})
Vue.component(ChooseType)
//選擇投訴類型 end
NetError.js:
// 投訴失敗組件 start
var NetError = Vue.extend({
template: "#netErrorCom",
})
Vue.component(NetError)
// 投訴失敗組件 end
main.js:
'use strict';
$(document).ready(function() {
Vue.use(VueRouter);
var router = new VueRouter({
routes: [{
path: '/',
name: 'ChooseType',
meta: {
index: 0,
keepAlive: true,
title: '投訴'
},
component: ChooseType
},
{
path: '/chooseAppeal',
name: 'ChooseAppeal',
meta: {
index: 1,
keepAlive: false,
title: '投訴'
},
component: ChooseAppeal
},
{
path: '/appealDetail',
name: 'AppealDetail',
meta: {
index: 3,
keepAlive: false,
title: '投訴須知'
},
component: AppealDetail
},
{
path: '/appealSuccess',
name: 'AppealSuccess',
meta: {
index: 4,
keepAlive: false,
title: '投訴'
},
component: AppealSuccess
},
{
path: '/netError',
name: 'NetError',
meta: {
index: 5,
keepAlive: false,
title: '投訴'
},
component: NetError
},
]
})
router.beforeEach((to, from, next) => {
var toDepth = to.meta.index;
var fromDepth = from.meta.index;
if (to.meta.title) {
document.title = to.meta.title;
if (toDepth == 'undefined' || toDepth == undefined) {
next({
path: "/netError"
})
} else if (toDepth < fromDepth) { //類似緩存效果
from.meta.keepAlive = false;
to.meta.keepAlive = true;
next()
} else {
next()
}
} else {
next()
}
})
var app = new Vue({
el: '#app',
router
}).$mount('#app')
})