diff --git a/components/upload/upload.vue b/components/upload/upload.vue index 7999d1eb..a41e5702 100644 --- a/components/upload/upload.vue +++ b/components/upload/upload.vue @@ -26,7 +26,9 @@ const app = getApp(); var common_static_url = app.globalData.get_static_url('common'); export default { + //#ifdef APP-NVUE i18n, + //#endif props: { // 是否使用卡槽 propSlot: { diff --git a/pages/plugins/video/detail/detail.nvue b/pages/plugins/video/detail/detail.nvue index 36546bcc..bd3b9ad5 100644 --- a/pages/plugins/video/detail/detail.nvue +++ b/pages/plugins/video/detail/detail.nvue @@ -3,13 +3,13 @@ - - + + - + @@ -25,7 +25,7 @@ {{ video_item.give_thumbs_count }} - + {{ video_item.comments_count }} @@ -34,13 +34,13 @@ - - - - + + + + - - {{ video_item.goods.title }} + + {{ video_item.goods.title }} ¥{{ video_item.goods.price }} @@ -48,17 +48,17 @@ - + - {{$t('common.buy')}} {{$t('common.goods')}} - - + {{$t('common.buy')}} {{$t('common.goods')}} + + - + {{ format_time(current_video_progress) }} / {{ format_time(current_video_duration) }} @@ -68,7 +68,7 @@ - + @@ -77,7 +77,7 @@ - + @@ -293,7 +293,7 @@ comment_start_y: 0, // 评论开始拖拽位置 comment_current_y: 0, // 评论当前拖拽位置 move_distance: 0, // 评论拖拽距离 - current_video_id: '', // 当前播放视频的ID + current_video_id: 5, // 当前播放视频的ID is_slide_start: false, swiper_key: get_math(), comment_scroll_top: 0, // 评论滚动距离顶部的距离 @@ -612,15 +612,15 @@ }); // 更新所有视频信息 // this.video_data_list = this.video_data_list; + this.$set(this, 'video_data_list', this.video_data_list) this.current_index = is_last == 1 && is_next == 1 ? (new_index == this.video_data_list.length - 1 ? 2 : (new_index == this.video_data_list.length - 2 ? 1 : 0)) : this.current_index; if (is_last == 1 && is_next == 1) { - // 更新显示数据数据信息 - this.update_display_data(); - - console.log(this.display_video_list, '1125'); - setTimeout(() => { + // 更新显示数据数据信息 + this.update_display_data(true); + console.log(this.display_video_list, '1125'); + if (this.display_video_list && this.display_video_list.length > 0) { // 更新分享信息 this.update_share_info(this.display_video_list[this.current_index]); @@ -722,9 +722,8 @@ this.is_slide_start = false; this.current_index = 0; this.swiper_key = get_math(); - this.$nextTick(() => { - this.display_video_list.splice(0, this.display_video_list.length, ...list); - }); + // 刷新数据 + this.update_display_video_list(list); } else if (this.current_video_index == this.video_data_list.length - 1) { const list = [ this.get_video_by_index(this.current_video_index - 2), @@ -733,9 +732,8 @@ ]; this.current_index = 2; this.swiper_key = get_math(); - this.$nextTick(() => { - this.display_video_list.splice(0, this.display_video_list.length, ...list); - }); + // 刷新数据 + this.update_display_video_list(list); } else { this.is_slide_start = true; this.swiper_key = get_math(); @@ -808,6 +806,27 @@ console.error('toggle_play_pause error:', error); } }, + // 播放数组更新 + update_display_video_list(list) { + try { + // 不理解为什么这里时undefined的 + // 根据 weex 的通用做法,需要同时改变“引用”和“长度”两个维度才能被识别数组更新。 + // 1. 先清空原数组(触发长度变化) + if (this.display_video_list && this.display_video_list.length > 0) { + this.display_video_list.splice(0, this.display_video_list.length) + } else { + this.display_video_list = []; + } + // this.$nextTick(() => { + // setTimeout(() => { + // 2. 再把新数据 push 进去(触发内容变化) + list.forEach(item => this.display_video_list.push(item)) + // }, 0); + // }); + } catch (e) { + console.log('update_display_video_list', e); + } + }, // 更新分享信息 update_share_info(data) { @@ -889,7 +908,7 @@ /* * 更新显示的视频数据 */ - update_display_data() { + update_display_data(flag = false) { try { let list = []; // 如果当前索引为0,只显示当前元素和下一个元素 @@ -912,15 +931,15 @@ this.get_video_by_index(this.current_video_index), ]; } - console.log(list); - // this.$nextTick(() => { - if (this.display_video_list && this.display_video_list.length > 0) { - this.display_video_list.splice(0, this.display_video_list.length, ...list); - } else { - this.display_video_list = list; + console.log(this.display_video_list); + // this.$set(this, 'display_video_list', list) + // 刷新数据 + this.update_display_video_list(list); + // 第一次需要强制刷新 + if (flag) { + // 页面数据不更新,执行强制刷新 + this.$forceUpdate(); } - this.$forceUpdate(); - // }); } catch (error) { console.error('update_display_data error:', error); } @@ -1214,7 +1233,8 @@ item.comments_count++; } }) - this.video_data_list = this.video_data_list; + // this.video_data_list = this.video_data_list; + this.$set(this, 'video_data_list', this.video_data_list) this.comment_scroll_top = 0 + Math.random(); // 添加主评论时滚动到最顶部 } else { this.active_comments.forEach(item => { @@ -1408,7 +1428,8 @@ } } - this.video_data_list = this.video_data_list; + // this.video_data_list = this.video_data_list; + this.$set(this, 'video_data_list', this.video_data_list) } else { if (app.globalData.is_login_check(res.data)) { app.globalData.showToast(res.data.msg); @@ -1534,7 +1555,8 @@ } }); - this.video_data_list = this.video_data_list; + // this.video_data_list = this.video_data_list; + this.$set(this, 'video_data_list', this.video_data_list) } catch (error) { console.error('product_close_event error:', error); } @@ -1565,7 +1587,8 @@ } }); - this.video_data_list = this.video_data_list; + // this.video_data_list = this.video_data_list; + this.$set(this, 'video_data_list', this.video_data_list) } catch (error) { console.error('handle_product_button error:', error); } @@ -1695,7 +1718,8 @@ }) // 更新数据 this.active_comments = filteredComments; - this.video_data_list = this.video_data_list; + // this.video_data_list = this.video_data_list; + this.$set(this, 'video_data_list', this.video_data_list) } } catch (error) { console.error('delete_comment_handle error:', error); @@ -1854,21 +1878,8 @@ };