hookehuyr

✨ feat(组件): 新增警告提示框组件及应用

1 +<template>
2 + <van-overlay :show="showNotice" z-index="1000">
3 + <div class="wrapper" @click.stop>
4 + <div class="block">
5 + <div style="position: absolute; top: -2rem; right: 1rem; font-size: 1.5rem;">
6 + <van-icon name="close" color="#FFFFFF" @click="handleClose" />
7 + </div>
8 + <div>
9 + <van-image width="100" height="100" :src="icon_notice" />
10 + <p style="margin: 1rem; font-size: 1.15rem; font-weight: bold; color: #222222;">温馨提示</p>
11 + </div>
12 + <slot></slot>
13 + <div style="margin: 3rem 0;">
14 + <my-button @on-click="handleSubmit" type="primary">{{ text }}</my-button>
15 + </div>
16 + </div>
17 + </div>
18 + </van-overlay>
19 +</template>
20 +
21 +<script setup>
22 +import MyButton from '@/components/MyButton/index.vue'
23 +import icon_notice from '@images/que-tishi@2x.png'
24 +
25 +import { ref, reactive, onMounted } from 'vue'
26 +const props = defineProps({
27 + showNotice: Boolean,
28 + text: String
29 +})
30 +const emit = defineEmits(['on-close', 'on-submit']);
31 +
32 +let show = props.showNotice;
33 +
34 +const handleClose = () => { // 关闭提示框回调
35 + show = false
36 + emit('on-close', false)
37 +}
38 +// 底部按钮
39 +const handleSubmit = () => {
40 + emit('on-submit', false)
41 +}
42 +
43 +onMounted(() => {
44 +
45 +})
46 +</script>
47 +
48 +<script>
49 +export default {
50 + data() {
51 + return {
52 +
53 + }
54 + },
55 + mounted() {
56 +
57 + },
58 + methods: {
59 +
60 + }
61 +}
62 +</script>
63 +
64 +<style lang="less" scoped>
65 +.wrapper {
66 + display: flex;
67 + align-items: center;
68 + justify-content: center;
69 + height: 100%;
70 + width: auto;
71 + text-align: center;
72 +}
73 +
74 +.block {
75 + width: 80%;
76 + // height: 25rem;
77 + background-color: #fff;
78 + border-radius: 10px;
79 + padding: 1rem;
80 + position: relative;
81 + margin-top: 1rem;
82 + margin-bottom: 5rem;
83 +}
84 +</style>
...\ No newline at end of file ...\ No newline at end of file
...@@ -84,30 +84,13 @@ ...@@ -84,30 +84,13 @@
84 <shortcut-fixed type="C" :item="['home', 'me']"></shortcut-fixed> 84 <shortcut-fixed type="C" :item="['home', 'me']"></shortcut-fixed>
85 </div> 85 </div>
86 86
87 - <!-- 上传作品时,如果没有实名认证提示弹框 --> 87 + <!-- 写评论时,如果没有实名认证提示弹框 -->
88 - <van-overlay :show="showNotice" z-index="1000"> 88 + <notice-overlay :show="showNotice" text="前往认证" @on-submit="onSubmit" @on-close="onClose">
89 - <div class="wrapper" @click.stop> 89 + <div style="color: #333333;">
90 - <div class="block"> 90 + <p>您还没有实名认证</p>
91 - <div style="position: absolute; top: -2rem; right: 1rem; font-size: 1.5rem;"> 91 + <p>请前往个人中心进行实名认证</p>
92 - <van-icon name="close" color="#FFFFFF" @click="closeNotice" />
93 - </div>
94 - <div>
95 - <van-image width="100" height="100" :src="icon_notice" />
96 - <p style="margin: 1rem; font-size: 1.15rem; font-weight: bold; color: #222222;">温馨提示</p>
97 - </div>
98 - <div style="color: #333333;">
99 - <p>您还没有实名认证</p>
100 - <p>请点击
101 - <van-icon :name="icon_me" /> 进行实名认证
102 - </p>
103 - <p>实名认证之后再上传</p>
104 - </div>
105 - <div style="margin: 3rem 0;">
106 - <my-button @on-click="closeNotice" type="primary">返回</my-button>
107 - </div>
108 - </div>
109 </div> 92 </div>
110 - </van-overlay> 93 + </notice-overlay>
111 </template> 94 </template>
112 95
113 <script setup> 96 <script setup>
...@@ -115,14 +98,13 @@ import { useVideoList } from '@/composables/useVideoList.js' ...@@ -115,14 +98,13 @@ import { useVideoList } from '@/composables/useVideoList.js'
115 98
116 import MyButton from '@/components/MyButton/index.vue' 99 import MyButton from '@/components/MyButton/index.vue'
117 import VideoCard from '@/components/VideoCard/index.vue' 100 import VideoCard from '@/components/VideoCard/index.vue'
101 +import NoticeOverlay from '@/components/NoticeOverlay/index.vue'
118 102
119 import icon_video from '@images/video.png' 103 import icon_video from '@images/video.png'
120 import icon_up from '@images/icon-guanbi@2x.png' 104 import icon_up from '@images/icon-guanbi@2x.png'
121 import icon_down from '@images/icon-zhankai@2x.png' 105 import icon_down from '@images/icon-zhankai@2x.png'
122 import icon_subscribed from '@images/icon-dingyue01@2x.png' 106 import icon_subscribed from '@images/icon-dingyue01@2x.png'
123 import icon_unsubscribe from '@images/icon-dingyue02@2x.png' 107 import icon_unsubscribe from '@images/icon-dingyue02@2x.png'
124 -import icon_me from '@images/icon-my@2x.png'
125 -import icon_notice from '@images/que-tishi@2x.png'
126 108
127 import ShortcutFixed from '@/components/ShortcutFixed/index.vue' 109 import ShortcutFixed from '@/components/ShortcutFixed/index.vue'
128 import tools from '@/common/tool' 110 import tools from '@/common/tool'
...@@ -190,11 +172,18 @@ const payFor = () => { ...@@ -190,11 +172,18 @@ const payFor = () => {
190 console.warn('弹出框'); 172 console.warn('弹出框');
191 } 173 }
192 174
193 -// 上传作品 175 +// 未实名认证提示
194 const showNotice = ref(false) 176 const showNotice = ref(false)
195 -const closeNotice = () => { 177 +const onClose = () => { // 关闭提示框回调
196 showNotice.value = false; 178 showNotice.value = false;
197 } 179 }
180 +// 跳转个人中心
181 +const onSubmit = () => {
182 + $router.push({
183 + path: '/me/index'
184 + });
185 +}
186 +
198 /** 187 /**
199 * 上传作品回调 188 * 上传作品回调
200 */ 189 */
......
...@@ -43,27 +43,13 @@ ...@@ -43,27 +43,13 @@
43 <comment-list :showPopup="showCommentListPopup" :data="commentData" @on-close="closeCommentList"></comment-list> 43 <comment-list :showPopup="showCommentListPopup" :data="commentData" @on-close="closeCommentList"></comment-list>
44 <comment-box :showPopup="showCommentBoxPopup" :type="commentType" :replayUser="replayUser" @on-submit="submitCommentBox" @on-close="closeCommentBox"></comment-box> 44 <comment-box :showPopup="showCommentBoxPopup" :type="commentType" :replayUser="replayUser" @on-submit="submitCommentBox" @on-close="closeCommentBox"></comment-box>
45 45
46 - <!-- 写评论时,如果没有上传作品提示弹框 --> 46 + <!-- 写评论时,如果没有实名认证提示弹框 -->
47 - <van-overlay :show="showNotice" z-index="1000"> 47 + <notice-overlay :show="showNotice" text="前往认证" @on-submit="onSubmit" @on-close="onClose">
48 - <div class="wrapper" @click.stop> 48 + <div style="color: #333333;">
49 - <div class="block"> 49 + <p>您还没有实名认证</p>
50 - <div> 50 + <p>请前往个人中心进行实名认证</p>
51 - <van-image width="100" height="100" :src="icon_notice" />
52 - <p style="margin: 1rem; font-size: 1.15rem; font-weight: bold; color: #222222;">温馨提示</p>
53 - </div>
54 - <div style="color: #333333;">
55 - <!-- <p>您还没有上传作品</p>
56 - <p>请返回书籍详情页,点击 <span style="font-weight: bold; color: #713610;">上传作品</span> 按钮</p>
57 - <p>上传之后再留言</p> -->
58 - <p>您还没有实名认证</p>
59 - <p>请前往个人中心进行实名认证</p>
60 - </div>
61 - <div style="margin: 3rem 0;">
62 - <my-button @on-click="closeNotice" type="primary">前往认证</my-button>
63 - </div>
64 - </div>
65 </div> 51 </div>
66 - </van-overlay> 52 + </notice-overlay>
67 </template> 53 </template>
68 54
69 <script setup> 55 <script setup>
...@@ -71,9 +57,7 @@ import { mainStore } from '@/store' ...@@ -71,9 +57,7 @@ import { mainStore } from '@/store'
71 57
72 import CommentList from '@/components/CommentList/index.vue' 58 import CommentList from '@/components/CommentList/index.vue'
73 import CommentBox from '@/components/CommentBox/index.vue' 59 import CommentBox from '@/components/CommentBox/index.vue'
74 -import MyButton from '@/components/MyButton/index.vue' 60 +import NoticeOverlay from '@/components/NoticeOverlay/index.vue'
75 -
76 -import icon_notice from '@images/que-tishi@2x.png'
77 61
78 import { ref, reactive, onMounted } from 'vue' 62 import { ref, reactive, onMounted } from 'vue'
79 import { useRoute, useRouter } from 'vue-router' 63 import { useRoute, useRouter } from 'vue-router'
...@@ -160,8 +144,11 @@ const onReload = () => { ...@@ -160,8 +144,11 @@ const onReload = () => {
160 /******** 留言框列表相关操作 END *******/ 144 /******** 留言框列表相关操作 END *******/
161 145
162 const showNotice = ref(false) 146 const showNotice = ref(false)
163 -const closeNotice = () => { // 关闭提示框回调 147 +const onClose = () => { // 关闭提示框回调
164 showNotice.value = false; 148 showNotice.value = false;
149 +}
150 +// 跳转个人中心
151 +const onSubmit = () => {
165 $router.push({ 152 $router.push({
166 path: '/me/index' 153 path: '/me/index'
167 }); 154 });
...@@ -180,9 +167,8 @@ const commentType = ref('comment'); // 类型 comment 为评论/类型 reply 为 ...@@ -180,9 +167,8 @@ const commentType = ref('comment'); // 类型 comment 为评论/类型 reply 为
180 */ 167 */
181 const commentId = ref('') 168 const commentId = ref('')
182 const replayUser = ref('') 169 const replayUser = ref('')
183 -// TODO: 本人的评论还是应该把回复按钮屏蔽掉,后台要给个字段判断一下,comment_list/reply_list两个接口都要调整 170 +const setComment = (v, type) => {
184 -const setComment = (v, type) => { // 171 + if (validIdCard.can_use.value) {
185 - if (validIdCard.can_use) {
186 showCommentBoxPopup.value = true; 172 showCommentBoxPopup.value = true;
187 commentType.value = type; 173 commentType.value = type;
188 replayUser.value = v.name; 174 replayUser.value = v.name;
...@@ -223,25 +209,11 @@ const submitCommentBox = (note) => { ...@@ -223,25 +209,11 @@ const submitCommentBox = (note) => {
223 // 留言可以刷新列表 209 // 留言可以刷新列表
224 onReload(); 210 onReload();
225 } else { 211 } else {
226 - // TODO: 初始化列表数据,会使得列表滚到最上面 212 + // 初始化列表数据,会使得列表滚到最上面
227 // 处理方法只能是插入相应的一条数据,这样就需要后台新增完成后,返回完整数据 213 // 处理方法只能是插入相应的一条数据,这样就需要后台新增完成后,返回完整数据
228 - // 后端需要返回一个完整结构,我临时写进去
229 - let temp = {
230 - "id": 314178,
231 - "prod_id": 314058,
232 - "pid": 314171,
233 - "reply_to": "王申羽",
234 - "name": "王申羽",
235 - "avatar": "https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPngf033a3cc00e4bb414ad696adbaf90a05f496c00e7210e889cd4ff3e4ea10ef24",
236 - "kg_name": "杨浦科技幼儿园",
237 - "note": "这是一条回复",
238 - "created_by": 314051,
239 - "comment_time": "5-4 07:03"
240 - }
241 -
242 _.each(commentList.value, comment => { 214 _.each(commentList.value, comment => {
243 if (comment.id === commentId.value) { 215 if (comment.id === commentId.value) {
244 - comment.reply_list.push(temp) 216 + comment.reply_list.push(res.data.data)
245 comment.total = comment.total + 1 217 comment.total = comment.total + 1
246 } 218 }
247 }) 219 })
...@@ -340,21 +312,4 @@ export default { ...@@ -340,21 +312,4 @@ export default {
340 box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.06); 312 box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.06);
341 } 313 }
342 } 314 }
343 -
344 -.wrapper {
345 - display: flex;
346 - align-items: center;
347 - justify-content: center;
348 - height: 100%;
349 - width: auto;
350 - text-align: center;
351 -}
352 -
353 -.block {
354 - width: 80%;
355 - // height: 25rem;
356 - background-color: #fff;
357 - border-radius: 10px;
358 - padding: 1rem;
359 -}
360 </style> 315 </style>
...\ No newline at end of file ...\ No newline at end of file
......