小程序品牌开发、首页商品自动模式不需要推荐

This commit is contained in:
Devil
2021-01-12 21:51:39 +08:00
parent b11b6518f3
commit ebc295cc1e
51 changed files with 2648 additions and 352 deletions

View File

@ -54,7 +54,8 @@
"pages/plugins/signin/user-qrcode-detail/user-qrcode-detail",
"pages/plugins/signin/user-qrcode-saveinfo/user-qrcode-saveinfo",
"pages/plugins/signin/user-coming-list/user-coming-list",
"pages/plugins/points/index/index"
"pages/plugins/points/index/index",
"pages/plugins/brand/index/index"
],
"window": {
"navigationBarTitleText": "{{application_title}}",

View File

@ -145,6 +145,7 @@ textarea {
min-height: 104rpx;
line-height: 52rpx;
font-size: 32rpx;
white-space: initial;
}

View File

@ -4,6 +4,7 @@ Page({
data_list_loding_status: 1,
data_bottom_line_status: false,
data_list: [],
data_total: 0,
data_page_total: 0,
data_page: 1,
params: null,
@ -20,6 +21,21 @@ Page({
// 基础配置
currency_symbol: app.data.currency_symbol,
// 搜素条件
search_map_info: [],
brand_list: [],
category_list: [],
screening_price_list: [],
goods_params_list: [],
goods_spec_list: [],
map_fields_list: {
"brand_list": {"height":"100rpx", "default":"100rpx", "form_key":"brand_ids"},
"category_list": {"height":"82rpx", "default":"82rpx", "form_key":"category_ids"},
"screening_price_list": {"height":"82rpx", "default":"82rpx", "form_key":"screening_price_values"},
"goods_params_list": {"height":"82rpx", "default":"82rpx", "form_key":"goods_params_values"},
"goods_spec_list": {"height":"82rpx", "default":"82rpx", "form_key":"goods_spec_values"}
},
},
onLoad(params) {
@ -82,16 +98,9 @@ Page({
// 加载loding
qq.showLoading({title: "加载中..." });
this.setData({
data_list_loding_status: 1
});
// 参数
var params = this.data.params;
var post_data = this.data.post_data;
post_data['page'] = this.data.data_page;
post_data['category_id'] = params['category_id'] || 0;
post_data['brand_id'] = params['brand_id'] || 0;
var post_data = this.request_map_handle();
// 获取数据
qq.request({
@ -104,20 +113,36 @@ Page({
qq.hideLoading();
qq.stopPullDownRefresh();
if (res.data.code == 0) {
if (res.data.data.data.length > 0) {
var data = res.data.data;
// 仅首次请求赋值条件数据
if(this.data.data_list_loding_status == 1)
{
this.setData({
search_map_info: data.search_map_info || [],
brand_list: data.brand_list || [],
category_list: data.category_list || [],
screening_price_list: data.screening_price_list || [],
goods_params_list: data.goods_params_list || [],
goods_spec_list: data.goods_spec_list || [],
});
}
// 列表数据处理
if (data.data.length > 0) {
if (this.data.data_page <= 1) {
var temp_data_list = res.data.data.data;
var temp_data_list = data.data;
} else {
var temp_data_list = this.data.data_list;
var temp_data = res.data.data.data;
var temp_data = data.data;
for (var i in temp_data) {
temp_data_list.push(temp_data[i]);
}
}
this.setData({
data_list: temp_data_list,
data_total: res.data.data.total,
data_page_total: res.data.data.page_total,
data_total: data.total,
data_page_total: data.page_total,
data_list_loding_status: 3,
data_page: this.data.data_page + 1
});
@ -144,7 +169,6 @@ Page({
this.setData({
data_list_loding_status: 0
});
app.showToast(res.data.msg);
}
},
@ -160,6 +184,55 @@ Page({
});
},
// 搜索条件处理
request_map_handle() {
var params = this.data.params;
var post_data = this.data.post_data;
post_data['page'] = this.data.data_page;
// 指定分类、品牌
post_data['category_id'] = params['category_id'] || 0;
post_data['brand_id'] = params['brand_id'] || 0;
// 搜索条件
var data = this.data;
for(var i in data.map_fields_list)
{
if((data[i] != null) != null && data[i].length > 0)
{
var temp = {};
var index = 0;
for(var k in data[i])
{
if((data[i][k]['active'] || 0) == 1)
{
switch(i)
{
// 价格
case 'screening_price_list' :
temp[index] = data[i][k]['min_price']+'-'+data[i][k]['max_price'];
break;
// 属性、规格
case 'goods_params_list' :
case 'goods_spec_list' :
temp[index] = data[i][k]['value'];
break;
// 默认取值id
default :
temp[index] = data[i][k]['id'];
}
index++;
}
}
post_data[data.map_fields_list[i]['form_key']] = (app.get_length(temp) > 0) ? JSON.stringify(temp) : '';
}
}
return post_data;
},
// 下拉刷新
onPullDownRefresh() {
this.setData({
@ -190,7 +263,7 @@ Page({
this.setData({ is_show_popup_form: true });
},
// 筛选
// 排序事件
nav_sort_event(e) {
var index = e.currentTarget.dataset.index || 0;
var temp_post_data = this.data.post_data;
@ -221,15 +294,66 @@ Page({
this.get_data_list(1);
},
// 条件-更多数据展示事件
more_event(e) {
var value = e.currentTarget.dataset.value || null;
var temp_more = this.data.map_fields_list;
if(value != null && (temp_more[value] || null) != null)
{
temp_more[value]['height'] = (temp_more[value]['height'] == 'auto') ? temp_more[value]['default'] : 'auto';
this.setData({map_fields_list: temp_more});
}
},
// 条件-选择事件
map_item_event(e) {
var index = e.currentTarget.dataset.index;
var field = e.currentTarget.dataset.field;
var data = this.data;
if((data[field] || null) != null && (data[field][index] || null) != null)
{
data[field][index]['active'] = ((data[field][index]['active'] || 0) == 0) ? 1 : 0;
this.setData(data);
}
},
// 条件-清空
map_remove_event(e) {
var data = this.data;
// 关键字
data['post_data']['wd'] = '';
// 品牌、分类、价格、属性、规格
for(var i in data.map_fields_list)
{
if((data[i] != null) != null && data[i].length > 0)
{
for(var k in data[i])
{
data[i][k]['active'] = 0;
}
}
}
// 关闭条件弹层
data['is_show_popup_form'] = false;
// 分页恢复1页、重新获取数据
data['data_page'] = 1;
this.setData(data);
this.get_data_list(1);
},
// 自定义分享
onShareAppMessage() {
var user_id = app.get_user_cache_info('id', 0) || 0;
var category_id = this.data.params['category_id'] || 0;
var brand_id = this.data.params['brand_id'] || 0;
var keywords = this.data.params['keywords'] || '';
return {
title: app.data.application_title,
desc: app.data.application_describe,
path: '/pages/goods-search/goods-search?referrer=' + user_id+'&category_id='+category_id+'&keywords='+keywords
path: '/pages/goods-search/goods-search?referrer=' + user_id+'&category_id='+category_id+'&brand_id='+brand_id+'&keywords='+keywords
};
},
});

View File

@ -37,21 +37,97 @@
</scroll-view>
<!-- popup -->
<component-popup prop-show="{{is_show_popup_form}}" prop-position="right" bindonclose="popup_form_event_close">
<component-popup prop-show="{{is_show_popup_form}}" prop-position="left" bindonclose="popup_form_event_close">
<form bindsubmit="form_submit_event" class="popup-form oh bg-white">
<view class="item oh screening-price">
<view class="title cr-666">()</view>
<view class="tc oh">
<input type="digit" placeholder="最低价" name="min_price" class="br fl" />
<text class="cr-888 separator">~</text>
<input type="digit" placeholder="最高价" name="max_price" class="br fr" />
<view class="search-map">
<view class="map-item map-base">
<text></text>
<text class="cr-main"> {{data_total}} </text>
<text></text>
<text class="map-remove-submit fr" bindtap="map_remove_event"></text>
</view>
<!-- -->
<input type="text" placeholder="其实搜索很简单^_^ !" name="wd" value="{{(post_data.wd || '')}}" class="map-keywords wh-auto" placeholder-class="cr-ccc" />
<!-- -->
<view qq:if="{{((brand_list || null) != null && brand_list.length > 0) || ((search_map_info.brand || null) != null)}}" class="map-item">
<view class="map-nav tc">
<text></text>
<text class="arrow-bottom" qq:if="{{brand_list.length > 3}}" bindtap="more_event" data-value="brand_list"></text>
</view>
<view qq:if="{{(search_map_info.brand || null) != null}}" class="map-content brand-info oh bg-white">
<image qq:if="{{(search_map_info.brand.logo || null) != null}}" src="{{search_map_info.brand.logo}}" mode="aspectFit" class="fl" />
<view qq:else class="info-logo-empty tc fl">{{search_map_info.brand.name}}</view>
<view class="info-right fr">
<view qq:if="{{(search_map_info.brand.logo || null) != null}}" class="info-name">{{search_map_info.brand.name}}</view>
<view qq:if="{{(search_map_info.brand.describe || null) != null}}"class="info-desc multi-text">{{search_map_info.brand.describe}}</view>
</view>
</view>
<view qq:else class="map-content map-images-text-items map-brand-container oh bg-white" style="height:{{map_fields_list.brand_list.height}};">
<block qq:for="{{brand_list}}" qq:key="key">
<view class="fl tc single-text {{item.active == 1 ? 'active' : ''}}" bindtap="map_item_event" data-index="{{index}}" data-field="brand_list">
<image qq:if="{{(item.logo || null) != null}}" src="{{item.logo}}" mode="aspectFit" />
<text qq:else>{{item.name}}</text>
</view>
</block>
</view>
</view>
<!-- -->
<view qq:if="{{(category_list || null) != null && category_list.length > 0}}" class="map-item">
<view class="map-nav tc">
<text></text>
<text class="arrow-bottom" qq:if="{{category_list.length > 3}}" bindtap="more_event" data-value="category_list"></text>
</view>
<view class="map-content map-text-items map-category-container oh bg-white" style="height:{{map_fields_list.category_list.height}};">
<block qq:for="{{category_list}}" qq:key="key">
<view class="fl {{item.active == 1 ? 'active' : ''}}" bindtap="map_item_event" data-index="{{index}}" data-field="category_list">{{item.name}}</view>
</block>
</view>
</view>
<!-- -->
<view qq:if="{{(screening_price_list || null) != null && screening_price_list.length > 0}}" class="map-item">
<view class="map-nav tc">
<text></text>
<text class="arrow-bottom" qq:if="{{screening_price_list.length > 3}}" bindtap="more_event" data-value="screening_price_list"></text>
</view>
<view class="map-content map-text-items screening-price-container oh bg-white" style="height:{{map_fields_list.screening_price_list.height}};">
<block qq:for="{{screening_price_list}}" qq:key="key">
<view class="fl {{item.active == 1 ? 'active' : ''}}" bindtap="map_item_event" data-index="{{index}}" data-field="screening_price_list">{{item.name}}</view>
</block>
</view>
</view>
<!-- -->
<view qq:if="{{(goods_params_list || null) != null && goods_params_list.length > 0}}" class="map-item">
<view class="map-nav tc">
<text></text>
<text class="arrow-bottom" qq:if="{{goods_params_list.length > 3}}" bindtap="more_event" data-value="goods_params_list"></text>
</view>
<view class="map-content map-text-items goods-params-container oh bg-white" style="height:{{map_fields_list.goods_params_list.height}};">
<block qq:for="{{goods_params_list}}" qq:key="key">
<view class="fl {{item.active == 1 ? 'active' : ''}}" bindtap="map_item_event" data-index="{{index}}" data-field="goods_params_list">{{item.value}}</view>
</block>
</view>
</view>
<!-- -->
<view qq:if="{{(goods_spec_list || null) != null && goods_spec_list.length > 0}}" class="map-item">
<view class="map-nav tc">
<text></text>
<text class="arrow-bottom" qq:if="{{goods_spec_list.length > 3}}" bindtap="more_event" data-value="goods_spec_list"></text>
</view>
<view class="map-content map-text-items goods-spec-container oh bg-white" style="height:{{map_fields_list.goods_spec_list.height}};">
<block qq:for="{{goods_spec_list}}" qq:key="key">
<view class="fl {{item.active == 1 ? 'active' : ''}}" bindtap="map_item_event" data-index="{{index}}" data-field="goods_spec_list">{{item.value}}</view>
</block>
</view>
</view>
<button formType="submit" class="bg-main search-submit wh-auto" disabled="{{popup_form_loading_status}}" hover-class="none"></button>
</view>
<view class="item keywords">
<view class="title cr-666"></view>
<input type="text" placeholder="关键字" name="wd" value="{{(params.keywords || '')}}" class="br" />
</view>
<button formType="submit" class="bg-main form-submit wh-auto" disabled="{{popup_form_loading_status}}" hover-class="none"></button>
</form>
</component-popup>

View File

@ -61,40 +61,102 @@
/**
* 条件
*/
.popup-form {
height: 100vh;
.search-map {
height: calc(100vh - 80rpx);
width: 680rpx;
overflow-y: scroll;
overflow-x: hidden;
}
.popup-form input {
.map-keywords {
border-radius: 0 !important;
padding: 0 10rpx;
line-height: 66rpx;
height: 66rpx;
font-size: 26rpx;
height: 60rpx;
box-sizing: border-box;
}
.map-nav {
position: relative;
}
.map-nav .arrow-bottom {
position: absolute;
top: 0;
right: 10rpx;
padding-right: 46rpx;
color: #999;
}
.map-item {
background: #f0f0f0;
line-height: 76rpx;
}
.map-base,
.map-nav {
padding: 0 10rpx;
}
.map-content {
padding: 15rpx;
line-height: 60rpx;
background: #fbfbfb;
border-radius: 6rpx;
padding: 0 6rpx;
}
.screening-price input {
width: calc(50% - 20px);
.map-text-items view,
.map-images-text-items view {
padding: 0 15rpx;
border-radius: 2px;
margin: 15rpx;
border: 1px solid transparent;
}
.screening-price .separator {
line-height: 50rpx;
.map-images-text-items view {
vertical-align: middle;
border: 1px solid #eee;
width: 150rpx;
height: 72rpx;
line-height: 72rpx;
}
.popup-form .item {
width: 480rpx;
padding: 0 20rpx;
margin-top: 20rpx;
.map-images-text-items view image {
width: 150rpx;
height: calc(100% - 8rpx);
display: block;
margin: 0 auto;
margin-top: 4rpx;
}
.popup-form .item:not(:last-child) {
margin-bottom: 30rpx;
.map-text-items view.active,
.map-images-text-items view.active {
border: 1px solid #e23f36;
color: #e23f36;
font-weight: bold;
}
.popup-form .item .title {
margin-bottom: 10rpx;
font-size: 28rpx;
}
.popup-form .form-submit {
.search-map .search-submit {
height: 80rpx;
line-height: 80rpx;
position: absolute;
left: 0;
bottom: 0;
border-radius: 0;
}
.map-remove-submit {
color: #e23f36;
}
/**
* 品牌基础信息
*/
.brand-info {
padding: 35rpx 15rpx;
}
.brand-info image,
.brand-info .info-logo-empty {
width: 300rpx;
height: 130rpx;
border: 1px solid #eee;
}
.brand-info .info-logo-empty {
line-height: 130rpx;
}
.brand-info .info-right {
width: calc(100% - 330rpx);
}
.brand-info .info-desc {
color: #999;
font-size: 28rpx;
line-height: 40rpx;
min-height: 80rpx;
}

View File

@ -157,7 +157,7 @@
}
.limitedtimediscount .goods-list .item {
width: 460rpx;
height: 605rpx;
height: 670rpx;
border: 1px solid #f5f5f5;
background: white;
display: inline-block;

View File

@ -0,0 +1,129 @@
const app = getApp();
Page({
data: {
data_bottom_line_status: false,
data_list_loding_status: 1,
data_list_loding_msg: '',
params: null,
data_base: null,
brand_list: [],
brand_category_list: [],
nav_active_value: 0,
},
onLoad(params) {
this.setData({
params: params,
});
},
onShow() {
this.get_data();
// 显示分享菜单
app.show_share_menu();
},
// 获取数据
get_data() {
var self = this;
qq.request({
url: app.get_request_url("index", "index", "brand"),
method: "POST",
data: {},
dataType: "json",
success: res => {
qq.stopPullDownRefresh();
if (res.data.code == 0) {
var data = res.data.data;
self.setData({
data_base: data.base || null,
brand_list: data.brand_list || [],
brand_category_list: data.brand_category_list || [],
data_list_loding_msg: '',
data_list_loding_status: ((data.brand_list || []).length > 0) ? 3 : 0,
data_bottom_line_status: ((data.brand_list || []).length > 0),
});
// 选中处理
self.nav_active_handle();
} else {
self.setData({
data_bottom_line_status: false,
data_list_loding_status: 2,
data_list_loding_msg: res.data.msg,
});
}
},
fail: () => {
qq.stopPullDownRefresh();
self.setData({
data_bottom_line_status: false,
data_list_loding_status: 2,
data_list_loding_msg: '服务器请求出错',
});
app.showToast("服务器请求出错");
}
});
},
// 下拉刷新
onPullDownRefresh() {
this.get_data();
},
// 导航事件
nav_event(e) {
this.setData({
nav_active_value: e.currentTarget.dataset.value || 0,
});
this.nav_active_handle();
},
// 导航选中处理
nav_active_handle() {
var value = this.data.nav_active_value;
var temp_brand_list = this.data.brand_list;
var count = 0;
for(var i in temp_brand_list)
{
if(value == 0)
{
temp_brand_list[i]['is_not_show'] = 0;
count++;
} else {
var is_not_show = (temp_brand_list[i]['brand_category_ids'].indexOf(value) == -1) ? 1 : 0;
temp_brand_list[i]['is_not_show'] = is_not_show;
if(is_not_show == 0)
{
count++;
}
}
}
this.setData({
brand_list: temp_brand_list,
data_list_loding_status: (count > 0) ? 3 : 0,
data_bottom_line_status: (count > 0),
});
},
// 自定义分享
onShareAppMessage() {
var user_id = app.get_user_cache_info('id', 0) || 0;
return {
title: this.data.data_base.seo_title || '品牌 - '+app.data.application_title,
desc: this.data.data_base.seo_desc || app.data.application_describe,
path: '/pages/plugins/brand/index/index?referrer=' + user_id
};
},
// 分享朋友圈
onShareTimeline() {
var user_id = app.get_user_cache_info('id', 0) || 0;
return {
title: this.data.data_base.seo_title || '品牌 - '+app.data.application_title,
query: 'referrer=' + user_id,
imageUrl: this.data.data_base.right_images || ''
};
},
});

View File

@ -0,0 +1,4 @@
{
"enablePullDownRefresh": true,
"navigationBarTitleText": "品牌"
}

View File

@ -0,0 +1,32 @@
<view qq:if="{{(data_base || null) != null}}">
<!-- -->
<scroll-view qq:if="{{(brand_category_list || null) != null && brand_category_list.length > 0}}" class="nav-list bg-white tc oh" scroll-x="true">
<view class="item cr-888 {{nav_active_value == 0 ? 'active' : ''}}" bindtap="nav_event" data-value="0"></view>
<block qq:for="{{brand_category_list}}" qq:key="key">
<view class="item cr-888 {{nav_active_value == item.id ? 'active' : ''}}" bindtap="nav_event" data-value="{{item.id}}">{{item.name}}</view>
</block>
</scroll-view>
<!-- -->
<view qq:if="{{(brand_list || null) != null && brand_list.length > 0}}" class="data-list oh spacing-mt">
<block qq:for="{{brand_list}}" qq:key="key">
<view qq:if="{{(item.is_not_show || 0) == 0}}" class="items bg-white">
<navigator url="/pages/goods-search/goods-search?brand_id={{item.id}}" hover-class="none">
<image src="{{item.logo}}" mode="aspectFit" />
<view class="base br-t-dashed">
<view class="single-text name tc">{{item.name}}</view>
<view class="multi-text desc">{{item.describe}}</view>
</view>
</navigator>
</view>
</block>
</view>
<!-- -->
<import src="/pages/common/bottom_line.qml" />
<template is="bottom_line" data="{{status: data_bottom_line_status}}"></template>
</view>
<view qq:if="{{data_list_loding_status != 3}}">
<import src="/pages/common/nodata.qml" />
<template is="nodata" data="{{status: data_list_loding_status, msg: data_list_loding_msg}}"></template>
</view>

View File

@ -0,0 +1,48 @@
/**
* 分类导航
*/
.nav-list {
width: 100%;
height: 80rpx;
white-space: nowrap;
box-sizing: border-box;
}
.nav-list .item {
padding: 20rpx 30rpx;
border-bottom: 3px solid #f0f0f0;
display: inline-block;
position: relative;
}
.nav-list .active {
border-bottom: 3px solid #d2364c;
color: #d2364c;
}
/**
* 数据列表
*/
.data-list .items {
width: calc(50% - 5rpx);
margin-bottom: 10rpx;
}
.data-list .items:nth-child(2n) {
float: right;
}
.data-list .items:nth-child(2n+1) {
float: left;
}
.data-list .items image {
width: 100%;
height: 160rpx !important;
}
.data-list .items .base {
padding-top: 20rpx;
margin: 20rpx;
}
.data-list .items .desc {
color: #999;
margin-top: 10rpx;
font-size: 28rpx;
line-height: 40rpx;
min-height: 80rpx;
}