Merge branch 'dev-yxl' of gitee.com:zongzhige/shopxo-uniapp into dev

master
gongfuxiang 2026-02-26 16:56:28 +08:00
commit 9fa4d44067
3 changed files with 55 additions and 52 deletions

View File

@ -50,6 +50,7 @@
</view>
<view v-if="!isEmpty(video_item.goods) && base_config_data && base_config_data.is_video_detail_show_goods && base_config_data.is_video_detail_show_goods == 1" class="product-card">
<view class="flex-col gap-10">
<text>{{ video_item.show_goods }}</text>
<view v-if="video_item.show_goods" class="flex-row align-c gap-10 product-card-item" :data-id="video_item.id" @tap.stop="handle_product_card_item">
<view class="product-image">
<image :src="video_item.goods.images" mode="aspectFill" class="product-image"></image>
@ -320,6 +321,7 @@
listener_height: 0,
comments_data: {},
editor_path_type: 'video',
is_manual_pause: false, //
};
},
computed: {
@ -350,6 +352,11 @@
params: app.globalData.launch_params_handle(params),
});
},
onShow() {
if (!this.is_manual_pause && this.video_contexts != null) {
this.video_play_event(this.video_contexts[this.current_index], true);
}
},
onHide() {
//
if (this.video_switch_debounce_timer) {
@ -479,11 +486,10 @@
if (data.code == 0) {
const new_data = data.data;
//
let data_list = JSON.parse(JSON.stringify(this.video_data_list));
// let data_list = JSON.parse(JSON.stringify(this.video_data_list));
// ID
const existing_ids = new Map();
data_list.forEach(item => {
this.video_data_list.forEach(item => {
existing_ids.set(item.id, true);
});
@ -492,7 +498,7 @@
if (new_data.last.length > 0) {
const unique_last = new_data.last.filter(item => !existing_ids.has(item.id));
if (unique_last.length > 0) {
data_list.unshift(...unique_last);
this.video_data_list.unshift(...unique_last);
// ID
unique_last.forEach(item => existing_ids.set(item.id, true));
}
@ -501,23 +507,24 @@
if (new_data.next.length > 0) {
const unique_next = new_data.next.filter(item => !existing_ids.has(item.id));
if (unique_next.length > 0) {
data_list.push(...unique_next);
this.video_data_list.push(...unique_next);
}
}
} else if (is_last == 1 && new_data.last.length > 0) { // -
const unique_last = new_data.last.filter(item => !existing_ids.has(item.id));
if (unique_last.length > 0) {
data_list.unshift(...unique_last);
this.video_data_list.unshift(...unique_last);
}
} else if (is_next == 1 && new_data.next.length > 0) { // -
const unique_next = new_data.next.filter(item => !existing_ids.has(item.id));
if (unique_next.length > 0) {
data_list.push(...unique_next);
this.video_data_list.push(...unique_next);
}
}
//
const new_index = data_list.findIndex(item => item.id == this.params.id);
data_list.forEach((item) => {
const new_index = this.video_data_list.findIndex(item => item.id == this.params.id);
//
this.video_data_list.forEach((item) => {
if (isEmpty(item.show_goods)) {
if (this.base_config_data && this.base_config_data.is_video_detail_show_goods_modal && this.base_config_data.is_video_detail_show_goods_modal == 1) {
item.show_goods = true;
@ -527,8 +534,8 @@
}
});
this.setData({
video_data_list: data_list,
current_index: is_last == 1 && is_next == 1 ? (new_index == data_list.length - 1 ? 2 : (new_index == data_list.length - 2 ? 1 : 0)) : this.current_index,
video_data_list: this.video_data_list,
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) {
@ -549,18 +556,16 @@
});
setTimeout(() => {
if (!this.paused) {
//#ifdef H5
if (this.video_contexts[this.current_index]) { // 0
this.video_play_event(this.video_contexts[this.current_index], true);
}
//#endif
//#ifndef H5
if (this.create_video_contexts[this.current_index]) { // 0
this.video_play_event(this.create_video_contexts[this.current_index], true);
}
//#endif
//#ifdef H5
if (this.video_contexts[this.current_index]) { // 0
this.video_play_event(this.video_contexts[this.current_index], true);
}
//#endif
//#ifndef H5
if (this.create_video_contexts[this.current_index]) { // 0
this.video_play_event(this.create_video_contexts[this.current_index], true);
}
//#endif
}, 200);
}, 0);
}
@ -603,6 +608,7 @@
this.setData({
current_index: current,
paused: false,
is_manual_pause: false,
current_video_progress: 0,
current_video_duration: 1,
is_seeking: false,
@ -675,6 +681,9 @@
if (index !== exceptIndex && context) {
try {
context.pause();
this.setData({
is_manual_pause: false,
});
} catch (error) {
console.warn(`暂停视频 ${index} 失败:`, error);
}
@ -694,7 +703,6 @@
//
toggle_play_pause() {
const currentIndex = this.current_index;
//
const videoContext = this.create_video_contexts[currentIndex] || this.video_contexts[currentIndex];
if (!videoContext) {
@ -703,7 +711,8 @@
}
this.setData({
paused: !this.paused
paused: !this.paused,
is_manual_pause: !this.paused,
});
if (this.paused) {
@ -736,7 +745,7 @@
//
video_play_event(videoContext, is_first_play = false) {
if (!videoContext) {
this.setData({ paused: true });
this.setData({ paused: true, is_manual_pause: false });
return;
}
@ -744,7 +753,7 @@
if (is_first_play) {
//#ifdef H5
videoContext.play().catch((error) => {
this.setData({ paused: true });
this.setData({ paused: true, is_manual_pause: false });
});
//#endif
//#ifndef H5
@ -755,7 +764,7 @@
}
} catch (error) {
console.error('视频播放异常:', error);
this.setData({ paused: true });
this.setData({ paused: true, is_manual_pause: false });
}
},
//
@ -839,11 +848,11 @@
},
on_transition(e) {
const dy = e.detail.dy;
let status = 'direction'
let status = 'direction';
if (dy > 0) {
status = 'next'
status = 'next';
} else if (dy < 0) {
status = 'prev'
status = 'prev';
}
//
if (this.direction != status) {
@ -852,22 +861,8 @@
})
}
},
//
toggle_play_pause() {
if (this.create_video_contexts[this.current_index] == null) return; // 1
this.setData({
paused: !this.paused
});
//
if (this.paused) {
this.create_video_contexts[this.current_index].pause(); //
} else {
this.video_play_event(this.create_video_contexts[this.current_index], false); //
}
},
handle_play() {
this.setData({ paused: false });
this.setData({ paused: false, is_manual_pause: false });
},
//
handle_like(e) {
@ -1327,8 +1322,8 @@
//
this.pause_all_videos_except(-1);
//
this.create_video_contexts = [];
this.video_contexts = [];
// this.create_video_contexts = [];
// this.video_contexts = [];
console.log('视频资源清理完成');
} catch (error) {
console.error('清理视频资源时出错:', error);

View File

@ -147,7 +147,7 @@ export default {
menu_button_info: menu_button_info
});
//
this.search_history = uni.getStorageSync('search_history_key') || [];
this.search_history = uni.getStorageSync('cache_plugins_video_search_history_key') || [];
if (this.search_history.length > 0) {
this.show_search_history = this.search_history.filter((item, index) => index < 5);
} else {
@ -193,7 +193,7 @@ export default {
//
if (!isEmpty(e) && !this.search_history.includes(e)) {
this.search_history.push(e);
uni.setStorageSync('search_history_key', this.search_history);
uni.setStorageSync('cache_plugins_video_search_history_key', this.search_history);
}
this.search_query = e;
//
@ -212,7 +212,7 @@ export default {
this.search_history.splice(newIndex, 1);
}
this.show_search_history.splice(index, 1);
uni.setStorageSync('search_history_key', this.search_history);
uni.setStorageSync('cache_plugins_video_search_history_key', this.search_history);
},
perform_url(e) {
const url = e?.currentTarget?.dataset?.url || '';
@ -235,7 +235,7 @@ export default {
});
},
clear_history() {
uni.setStorageSync('search_history_key', []);
uni.setStorageSync('cache_plugins_video_search_history_key', []);
this.setData({
search_history: [],
show_search_history: [],
@ -248,6 +248,7 @@ export default {
<style lang="scss" scoped>
.search-record-container {
background: #fff;
height: 100vh;
}
.header-top {

View File

@ -154,7 +154,8 @@ export default {
data_tabs_loding_status: 1,
data_tabs_loding_msg: '',
data_list_loding_status: 1,
data_list_loding_msg: ''
data_list_loding_msg: '',
search_history: [],
};
},
onLoad(params) {
@ -207,6 +208,8 @@ export default {
})
.exec(); //
}, 500);
this.search_history = uni.getStorageSync('cache_plugins_video_search_history_key') || [];
//
this.init_data();
},
@ -263,6 +266,10 @@ export default {
data_list_loding_status: 1,
recommend_videos: []
})
if (!isEmpty(e) && !this.search_history.includes(e)) {
this.search_history.push(e);
uni.setStorageSync('cache_plugins_video_search_history_key', this.search_history);
}
//
this.load_recommend_videos();
},