搜索优化

master
gongfuxiang 2022-06-30 23:54:51 +08:00
parent cedc41c0a7
commit eb5e3f32dc
3 changed files with 89 additions and 38 deletions

View File

@ -173,6 +173,8 @@
popup_form_loading_status: false, popup_form_loading_status: false,
// //
share_info: {}, share_info: {},
//
search_nav_sort_index: 0,
search_nav_sort_list: [ search_nav_sort_list: [
{ name: "综合", field: "default", sort: "asc", "icon": null }, { name: "综合", field: "default", sort: "asc", "icon": null },
{ name: "销量", field: "sales_count", sort: "asc", "icon": "default" }, { name: "销量", field: "sales_count", sort: "asc", "icon": "default" },
@ -443,6 +445,13 @@
post_data[temp_field[i]['form_key']] = app.globalData.get_length(temp) > 0 ? JSON.stringify(temp) : ''; post_data[temp_field[i]['form_key']] = app.globalData.get_length(temp) > 0 ? JSON.stringify(temp) : '';
} }
} }
//
var temp_index = this.search_nav_sort_index;
var temp_search_nav_sort = this.search_nav_sort_list;
post_data['order_by_type'] = temp_search_nav_sort[temp_index]['sort'] == 'desc' ? 'asc' : 'desc';
post_data['order_by_field'] = temp_search_nav_sort[temp_index]['field'];
return post_data; return post_data;
}, },
@ -478,7 +487,6 @@
// //
nav_sort_event(e) { nav_sort_event(e) {
var index = e.currentTarget.dataset.index || 0; var index = e.currentTarget.dataset.index || 0;
var temp_post_data = this.post_data;
var temp_search_nav_sort = this.search_nav_sort_list; var temp_search_nav_sort = this.search_nav_sort_list;
var temp_sort = temp_search_nav_sort[index]['sort'] == 'desc' ? 'asc' : 'desc'; var temp_sort = temp_search_nav_sort[index]['sort'] == 'desc' ? 'asc' : 'desc';
for (var i in temp_search_nav_sort) { for (var i in temp_search_nav_sort) {
@ -493,10 +501,9 @@
if (temp_search_nav_sort[index]['icon'] != null) { if (temp_search_nav_sort[index]['icon'] != null) {
temp_search_nav_sort[index]['icon'] = temp_sort; temp_search_nav_sort[index]['icon'] = temp_sort;
} }
temp_post_data['order_by_field'] = temp_search_nav_sort[index]['field'];
temp_post_data['order_by_type'] = temp_sort;
this.setData({ this.setData({
post_data: temp_post_data, search_nav_sort_index: index,
search_nav_sort_list: temp_search_nav_sort, search_nav_sort_list: temp_search_nav_sort,
data_page: 1 data_page: 1
}); });
@ -545,11 +552,20 @@
} }
} }
//
var temp_search_nav_sort = this.search_nav_sort_list;
for (var i in temp_search_nav_sort) {
temp_search_nav_sort[i]['sort'] = 'asc';
temp_search_nav_sort[i]['icon'] = (temp_search_nav_sort[i]['field'] == 'default') ? null : 'default';
}
// 1 // 1
this.setData({ this.setData({
search_map_list: temp_list, search_map_list: temp_list,
post_data: temp_post, post_data: temp_post,
is_show_popup_form: false, is_show_popup_form: false,
search_nav_sort_list: temp_search_nav_sort,
search_nav_sort_index: 0,
data_page: 1 data_page: 1
}); });
this.get_data_list(1); this.get_data_list(1);

View File

@ -1017,9 +1017,19 @@
// //
var starting_price = parseFloat(this.info.starting_price) || 0; var starting_price = parseFloat(this.info.starting_price) || 0;
if(starting_price > 0 && this.cart.total_price < starting_price) { if(starting_price > 0 && this.cart.total_price < starting_price) {
app.globalData.showToast("起步价"+starting_price+"元"); //
var limit_type = this.info.starting_price_limit_type_list || [];
if(limit_type.length > 0) {
var buy_use_type = this.info.buy_use_type_list[this.buy_use_type_index];
if(limit_type.indexOf(buy_use_type['index']) != -1 || limit_type.indexOf(buy_use_type['index'].toString()) != -1) {
app.globalData.showToast(buy_use_type['name']+'起步价'+starting_price+'元');
return false; return false;
} }
} else {
app.globalData.showToast('起步价'+starting_price+'元');
return false;
}
}
// //
var data = this.request_params_merge({ var data = this.request_params_merge({
@ -1149,7 +1159,16 @@
if(index === null || index === '') { if(index === null || index === '') {
// //
if(this.info.default_buy_use_type != undefined && this.info.default_buy_use_type != -1) { if(this.info.default_buy_use_type != undefined && this.info.default_buy_use_type != -1) {
index = this.info.default_buy_use_type; // 0
var temp_index = null;
for(var i in this.info.buy_use_type_list) {
if(this.info.buy_use_type_list[i]['index'] == this.info.default_buy_use_type) {
temp_index = i;
}
}
if(temp_index !== null) {
index = temp_index;
}
} }
} }

View File

@ -96,6 +96,8 @@
shop: null, shop: null,
is_show_popup_form: false, is_show_popup_form: false,
popup_form_loading_status: false, popup_form_loading_status: false,
//
search_nav_sort_index: 0,
search_nav_sort_list: [ search_nav_sort_list: [
{ name: "综合", field: "default", sort: "asc", "icon": null }, { name: "综合", field: "default", sort: "asc", "icon": null },
{ name: "销量", field: "sales_count", sort: "asc", "icon": "default" }, { name: "销量", field: "sales_count", sort: "asc", "icon": "default" },
@ -349,6 +351,13 @@
post_data[temp_field[i]['form_key']] = app.globalData.get_length(temp) > 0 ? JSON.stringify(temp) : ''; post_data[temp_field[i]['form_key']] = app.globalData.get_length(temp) > 0 ? JSON.stringify(temp) : '';
} }
} }
//
var temp_index = this.search_nav_sort_index;
var temp_search_nav_sort = this.search_nav_sort_list;
post_data['order_by_type'] = temp_search_nav_sort[temp_index]['sort'] == 'desc' ? 'asc' : 'desc';
post_data['order_by_field'] = temp_search_nav_sort[temp_index]['field'];
return post_data; return post_data;
}, },
@ -384,7 +393,6 @@
// //
nav_sort_event(e) { nav_sort_event(e) {
var index = e.currentTarget.dataset.index || 0; var index = e.currentTarget.dataset.index || 0;
var temp_post_data = this.post_data;
var temp_search_nav_sort = this.search_nav_sort_list; var temp_search_nav_sort = this.search_nav_sort_list;
var temp_sort = temp_search_nav_sort[index]['sort'] == 'desc' ? 'asc' : 'desc'; var temp_sort = temp_search_nav_sort[index]['sort'] == 'desc' ? 'asc' : 'desc';
for (var i in temp_search_nav_sort) { for (var i in temp_search_nav_sort) {
@ -399,10 +407,9 @@
if (temp_search_nav_sort[index]['icon'] != null) { if (temp_search_nav_sort[index]['icon'] != null) {
temp_search_nav_sort[index]['icon'] = temp_sort; temp_search_nav_sort[index]['icon'] = temp_sort;
} }
temp_post_data['order_by_field'] = temp_search_nav_sort[index]['field'];
temp_post_data['order_by_type'] = temp_sort;
this.setData({ this.setData({
post_data: temp_post_data, search_nav_sort_index: index,
search_nav_sort_list: temp_search_nav_sort, search_nav_sort_list: temp_search_nav_sort,
data_page: 1 data_page: 1
}); });
@ -451,11 +458,20 @@
} }
} }
//
var temp_search_nav_sort = this.search_nav_sort_list;
for (var i in temp_search_nav_sort) {
temp_search_nav_sort[i]['sort'] = 'asc';
temp_search_nav_sort[i]['icon'] = (temp_search_nav_sort[i]['field'] == 'default') ? null : 'default';
}
// 1 // 1
this.setData({ this.setData({
search_map_list: temp_list, search_map_list: temp_list,
post_data: temp_post, post_data: temp_post,
is_show_popup_form: false, is_show_popup_form: false,
search_nav_sort_list: temp_search_nav_sort,
search_nav_sort_index: 0,
data_page: 1 data_page: 1
}); });
this.get_data_list(1); this.get_data_list(1);