Browse Source

问卷填写返回增加提示

htc 19 hours ago
parent
commit
f37d60e1b6
2 changed files with 38 additions and 21 deletions
  1. 37 20
      components/CusHeader/index.vue
  2. 1 1
      pages/questionnaireFill.vue

+ 37 - 20
components/CusHeader/index.vue

@@ -39,7 +39,11 @@
 					fontWeight: "bold",
 					color: '#111111'
 				}
-			},
+			},
+			backAlert:{
+				typeof:Boolean,
+				default:false
+			}
 		},
 		data() {
 			return {
@@ -53,25 +57,38 @@
 			}
 		},
 		methods: {
-			toBack(url) {
-				if (!url) {
-					if (uni.getStorageSync('options')) {
-						uni.redirectTo(JSON.parse(decodeURIComponent(uni.getStorageSync('options'))));
-						return uni.removeStorageSync('options');
-					}
-					let canNavBack = getCurrentPages();
-					if (canNavBack && canNavBack.length > 1) uni.navigateBack();
-					else uni.reLaunch({
-						url: '/pages/index/index'
-					})
-				} else {
-					if (this.tabUrls.find(u => u == url)) uni.reLaunch({
-						url
-					});
-					else uni.redirectTo({
-						url
-					});
-				}
+			toBack(url) {
+				if(this.backAlert){
+					uni.showModal({
+						title:'温馨提示',
+						content:'您当前正在填写问卷,返回会清空作答进度,是否确认返回?',
+						success: (res) => {
+							if(res.confirm){
+								this.dealBack(url)
+							}
+						}
+					})
+				}else this.dealBack(url)
+			},
+			dealBack(url){
+				if (!url) {
+					if (uni.getStorageSync('options')) {
+						uni.redirectTo(JSON.parse(decodeURIComponent(uni.getStorageSync('options'))));
+						return uni.removeStorageSync('options');
+					}
+					let canNavBack = getCurrentPages();
+					if (canNavBack && canNavBack.length > 1) uni.navigateBack();
+					else uni.reLaunch({
+						url: '/pages/index/index'
+					})
+				} else {
+					if (this.tabUrls.find(u => u == url)) uni.reLaunch({
+						url
+					});
+					else uni.redirectTo({
+						url
+					});
+				}
 			},
 			toHome() {
 				uni.reLaunch({

+ 1 - 1
pages/questionnaireFill.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
-		<cus-header title='问卷填写'></cus-header>
+		<cus-header title='问卷填写' :backAlert="true"></cus-header>
 		<div class="top adffcacjc">
 			<p>{{title}}</p>
 			<p class="tip">共 <span>{{list.length}}</span> 题,请耐心选择!</p>