Showing
1 changed file
with
59 additions
and
42 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-04-07 10:15:55 | 2 | * @Date: 2024-04-07 10:15:55 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-04-12 15:42:26 | 4 | + * @LastEditTime: 2024-04-12 21:58:01 |
| 5 | * @FilePath: /fxPark/src/views/fxPark/index.vue | 5 | * @FilePath: /fxPark/src/views/fxPark/index.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -12,8 +12,8 @@ | ... | @@ -12,8 +12,8 @@ |
| 12 | <div class="quick-entrance-item" @click="goToAudio"> | 12 | <div class="quick-entrance-item" @click="goToAudio"> |
| 13 | <van-icon name="chat-o" /> <span>植物之声</span> | 13 | <van-icon name="chat-o" /> <span>植物之声</span> |
| 14 | </div> | 14 | </div> |
| 15 | - <div class="quick-entrance-item" @click="onShare"> | 15 | + <div class="quick-entrance-item" @click="goToPoster"> |
| 16 | - <van-icon name="chat-o" /> <span>分享海报</span> | 16 | + <van-icon name="chat-o" /> <span>海报列表</span> |
| 17 | </div> | 17 | </div> |
| 18 | </div> | 18 | </div> |
| 19 | <div class="container" v-for="(item, index) in data_list" :key="index" @click="onChipClick()"> | 19 | <div class="container" v-for="(item, index) in data_list" :key="index" @click="onChipClick()"> |
| ... | @@ -24,8 +24,8 @@ | ... | @@ -24,8 +24,8 @@ |
| 24 | <!-- <div @click="commentsBtn" style="display: inline-flex; padding: 0.6rem 2rem; color: #fff; background-color: #F68015;align-items: center; border-radius: 1.5rem;">弹幕留言</div> --> | 24 | <!-- <div @click="commentsBtn" style="display: inline-flex; padding: 0.6rem 2rem; color: #fff; background-color: #F68015;align-items: center; border-radius: 1.5rem;">弹幕留言</div> --> |
| 25 | <!-- </div> --> | 25 | <!-- </div> --> |
| 26 | 26 | ||
| 27 | - <van-action-sheet v-model:show="show_danmu_message" title="留言" :round="false" :close-on-click-overlay="false" @cancel="onCancel"> | 27 | + <van-action-sheet v-model:show="show_danmu_message" title="留言" :round="false" :close-on-click-overlay="false" :closeable="false"> |
| 28 | - <div style="padding: 1rem 0; height: 10vh; display: flex; padding: 0.5rem;"> | 28 | + <div class="danmu-input-wrapper" :style="{ height: space_height }"> |
| 29 | <van-field | 29 | <van-field |
| 30 | ref="RefDanmu" | 30 | ref="RefDanmu" |
| 31 | v-model="danmu_message" | 31 | v-model="danmu_message" |
| ... | @@ -36,27 +36,14 @@ | ... | @@ -36,27 +36,14 @@ |
| 36 | @keydown.enter="handleEnterPress" | 36 | @keydown.enter="handleEnterPress" |
| 37 | enterkeyhint="send" | 37 | enterkeyhint="send" |
| 38 | /> | 38 | /> |
| 39 | - <!-- <van-field | ||
| 40 | - ref="RefDanmu" | ||
| 41 | - v-model="danmu_message" | ||
| 42 | - rows="3" | ||
| 43 | - autosize | ||
| 44 | - label="" | ||
| 45 | - type="textarea" | ||
| 46 | - placeholder="请输入留言" | ||
| 47 | - @blur="onBlur" | ||
| 48 | - @focus="onFocus" | ||
| 49 | - enterkeyhint="send" | ||
| 50 | - style="background-color: #F3F3F3; padding: 1rem; border-radius: 5px; flex: 1; margin-right: 1rem;" | ||
| 51 | - /> | ||
| 52 | - <div @click="sendMessage" style="display: flex; align-items: flex-end; justify-content: center; margin-right: 0.5rem;">发送</div> --> | ||
| 53 | </div> | 39 | </div> |
| 54 | - <div v-if="spaceDiv" style="height: 10vh;"></div> | 40 | + <div v-if="spaceDiv" :style="{ height: space_height }"></div> |
| 55 | </van-action-sheet> | 41 | </van-action-sheet> |
| 56 | 42 | ||
| 57 | <van-floating-bubble icon="chat" @click="onCloseDanmu" /> | 43 | <van-floating-bubble icon="chat" @click="onCloseDanmu" /> |
| 58 | - <div v-if="show_danmu" style="position: fixed; bottom: 0; left: 0; right: 0; background-color: white; z-index: 10; height: 5rem;"> | 44 | + |
| 59 | - <div @click="commentsBtn" style="background-color: #F3F3F3; margin: 1rem 0.85rem; border-radius: 10px; padding: 0.5rem 1rem; font-size: 0.9rem; color: #ABABAB;">发一条友好的弹幕吧</div> | 45 | + <div v-if="show_danmu" class="danmu-boxer"> |
| 46 | + <div class="danmu-boxer-btn" @click="commentsBtn">发一条友好的弹幕吧</div> | ||
| 60 | </div> | 47 | </div> |
| 61 | </div> | 48 | </div> |
| 62 | </template> | 49 | </template> |
| ... | @@ -72,6 +59,7 @@ import { parseQueryString } from '@/utils/tools.js' | ... | @@ -72,6 +59,7 @@ import { parseQueryString } from '@/utils/tools.js' |
| 72 | //import { } from '@/composables' | 59 | //import { } from '@/composables' |
| 73 | import danmaku from '@/components/danmaku.vue'; | 60 | import danmaku from '@/components/danmaku.vue'; |
| 74 | import { getTreeAPI, saveDanmuAPI } from '@/api/carbon.js'; | 61 | import { getTreeAPI, saveDanmuAPI } from '@/api/carbon.js'; |
| 62 | +import { showToast } from 'vant'; | ||
| 75 | 63 | ||
| 76 | // 初始化WX环境 | 64 | // 初始化WX环境 |
| 77 | import wx from 'weixin-js-sdk' | 65 | import wx from 'weixin-js-sdk' |
| ... | @@ -112,7 +100,14 @@ const TREE_CHIP = { // 碎片图结构 | ... | @@ -112,7 +100,14 @@ const TREE_CHIP = { // 碎片图结构 |
| 112 | const data_list = ref([]); | 100 | const data_list = ref([]); |
| 113 | const all_actived = ref(false); // 全部激活 | 101 | const all_actived = ref(false); // 全部激活 |
| 114 | 102 | ||
| 103 | +const space_height = ref('10vh'); // 第一次进入没有导航栏 | ||
| 104 | + | ||
| 115 | onMounted(async () => { | 105 | onMounted(async () => { |
| 106 | + // 根据历史记录显示高度不一样,高度调高一点 | ||
| 107 | + if (history.length > 1) { | ||
| 108 | + space_height.value = '15vh'; | ||
| 109 | + } | ||
| 110 | + // | ||
| 116 | const { code, data } = await getTreeAPI(); | 111 | const { code, data } = await getTreeAPI(); |
| 117 | if (code) { | 112 | if (code) { |
| 118 | let index = data.findIndex(item => item.is_tree === 0); // 全点亮标识 | 113 | let index = data.findIndex(item => item.is_tree === 0); // 全点亮标识 |
| ... | @@ -122,6 +117,9 @@ onMounted(async () => { | ... | @@ -122,6 +117,9 @@ onMounted(async () => { |
| 122 | }); | 117 | }); |
| 123 | } else { // 全点亮 | 118 | } else { // 全点亮 |
| 124 | all_actived.value = true; | 119 | all_actived.value = true; |
| 120 | + data.forEach(item => { | ||
| 121 | + item.chip_src = TREE_CHIP[item.revision]['active']; // 根据点亮状态,显示碎片地址 | ||
| 122 | + }); | ||
| 125 | } | 123 | } |
| 126 | // | 124 | // |
| 127 | data_list.value = data; | 125 | data_list.value = data; |
| ... | @@ -153,7 +151,9 @@ const onChipClick = () => { // 点击碎片回调 | ... | @@ -153,7 +151,9 @@ const onChipClick = () => { // 点击碎片回调 |
| 153 | }); | 151 | }); |
| 154 | } | 152 | } |
| 155 | 153 | ||
| 156 | -const commentsBtn = () => { | 154 | +const spaceDiv = ref(false); // 占位符 |
| 155 | + | ||
| 156 | +const commentsBtn = () => { // 点击留言输入框 | ||
| 157 | show_danmu_message.value = true; | 157 | show_danmu_message.value = true; |
| 158 | nextTick(() => { | 158 | nextTick(() => { |
| 159 | spaceDiv.value = true; | 159 | spaceDiv.value = true; |
| ... | @@ -161,12 +161,11 @@ const commentsBtn = () => { | ... | @@ -161,12 +161,11 @@ const commentsBtn = () => { |
| 161 | }); | 161 | }); |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | -const spaceDiv = ref(false); | 164 | +const saveMessage = async () => { // 提交留言 |
| 165 | - | ||
| 166 | -const sendMessage = async () => { | ||
| 167 | const { code, data } = await saveDanmuAPI({ note: danmu_message.value }); | 165 | const { code, data } = await saveDanmuAPI({ note: danmu_message.value }); |
| 168 | if (code) { | 166 | if (code) { |
| 169 | show_danmu_message.value = false; | 167 | show_danmu_message.value = false; |
| 168 | + // 实时更新到弹幕列表 | ||
| 170 | add_text.value = { | 169 | add_text.value = { |
| 171 | status: '2', | 170 | status: '2', |
| 172 | note: danmu_message.value | 171 | note: danmu_message.value |
| ... | @@ -176,29 +175,25 @@ const sendMessage = async () => { | ... | @@ -176,29 +175,25 @@ const sendMessage = async () => { |
| 176 | } | 175 | } |
| 177 | } | 176 | } |
| 178 | 177 | ||
| 179 | -const onDanmuBlur = (evt) => { | 178 | +const onDanmuBlur = (evt) => { // 弹幕输入框失去焦点 |
| 180 | show_danmu_message.value = false; | 179 | show_danmu_message.value = false; |
| 181 | spaceDiv.value = false; | 180 | spaceDiv.value = false; |
| 182 | document.body.scrollIntoView({behavior: 'smooth'}); | 181 | document.body.scrollIntoView({behavior: 'smooth'}); |
| 183 | } | 182 | } |
| 184 | 183 | ||
| 185 | -const handleEnterPress = (evt) => { | 184 | +const handleEnterPress = (evt) => { // 小键盘回车回调 |
| 186 | if (evt.keyCode === 13) { | 185 | if (evt.keyCode === 13) { |
| 187 | - sendMessage(); | 186 | + saveMessage(); |
| 188 | document.body.scrollIntoView({behavior: 'smooth'}); | 187 | document.body.scrollIntoView({behavior: 'smooth'}); |
| 189 | } | 188 | } |
| 190 | } | 189 | } |
| 191 | 190 | ||
| 192 | -const onFocus = () => { | 191 | +const goToPoster = () => { // 海报列表按钮 |
| 193 | - // spaceDiv.value = true; | 192 | + let index = data.findIndex(item => item.is_light === '1'); // 没有一个点亮 |
| 194 | -} | 193 | + if (index === -1) { |
| 195 | - | 194 | + showToast('没有点亮的植被,无法生成海报'); |
| 196 | -const onCancel = () => { | 195 | + return false; |
| 197 | - console.warn(0); | 196 | + } |
| 198 | -} | ||
| 199 | - | ||
| 200 | -const onShare = () => { // 分享海报按钮 | ||
| 201 | - // go('/finish') | ||
| 202 | let raw_data = data_list.value.filter(item => item.is_light === '1'); // 获取所有已点亮的植被 | 197 | let raw_data = data_list.value.filter(item => item.is_light === '1'); // 获取所有已点亮的植被 |
| 203 | // | 198 | // |
| 204 | $router.push({ | 199 | $router.push({ |
| ... | @@ -209,11 +204,11 @@ const onShare = () => { // 分享海报按钮 | ... | @@ -209,11 +204,11 @@ const onShare = () => { // 分享海报按钮 |
| 209 | }); | 204 | }); |
| 210 | } | 205 | } |
| 211 | 206 | ||
| 212 | -const goToAudio = () => { | 207 | +const goToAudio = () => { // 播放音频列表 |
| 213 | - go('/audio') | 208 | + go('/audio'); |
| 214 | } | 209 | } |
| 215 | 210 | ||
| 216 | -const onCloseDanmu = () => { | 211 | +const onCloseDanmu = () => { // 弹幕开关 |
| 217 | show_danmu.value = !show_danmu.value; | 212 | show_danmu.value = !show_danmu.value; |
| 218 | } | 213 | } |
| 219 | </script> | 214 | </script> |
| ... | @@ -254,4 +249,26 @@ const onCloseDanmu = () => { | ... | @@ -254,4 +249,26 @@ const onCloseDanmu = () => { |
| 254 | } | 249 | } |
| 255 | } | 250 | } |
| 256 | } | 251 | } |
| 252 | + | ||
| 253 | +.danmu-input-wrapper { | ||
| 254 | + padding: 1rem 0; display: flex; padding: 0.5rem; | ||
| 255 | +} | ||
| 256 | + | ||
| 257 | +.danmu-boxer { | ||
| 258 | + position: fixed; | ||
| 259 | + bottom: 0; | ||
| 260 | + left: 0; | ||
| 261 | + right: 0; | ||
| 262 | + background-color: white; | ||
| 263 | + z-index: 10; | ||
| 264 | + height: 5rem; | ||
| 265 | + .danmu-boxer-btn { | ||
| 266 | + background-color: #F3F3F3; | ||
| 267 | + margin: 1rem 0.85rem; | ||
| 268 | + border-radius: 10px; | ||
| 269 | + padding: 0.5rem 1rem; | ||
| 270 | + font-size: 0.9rem; | ||
| 271 | + color: #ABABAB; | ||
| 272 | + } | ||
| 273 | +} | ||
| 257 | </style> | 274 | </style> | ... | ... |
-
Please register or login to post a comment