微信小程序多商户优化
parent
a1c3a09845
commit
d7a989275a
|
|
@ -482,6 +482,7 @@ class BaseLayout
|
||||||
|
|
||||||
// 多商户
|
// 多商户
|
||||||
'plugins-shop-home' => PluginsHomeUrl('shop', 'index', 'index'),
|
'plugins-shop-home' => PluginsHomeUrl('shop', 'index', 'index'),
|
||||||
|
'plugins-shop-favor' => PluginsHomeUrl('shop', 'shopfavor', 'index'),
|
||||||
|
|
||||||
// 品牌
|
// 品牌
|
||||||
'plugins-brand-home' => PluginsHomeUrl('brand', 'index', 'index'),
|
'plugins-brand-home' => PluginsHomeUrl('brand', 'index', 'index'),
|
||||||
|
|
@ -530,6 +531,7 @@ class BaseLayout
|
||||||
|
|
||||||
// 多商户
|
// 多商户
|
||||||
'plugins-shop-home' => '/pages/plugins/shop/index/index',
|
'plugins-shop-home' => '/pages/plugins/shop/index/index',
|
||||||
|
'plugins-shop-faovr' => '/pages/plugins/shop/favor/favor',
|
||||||
|
|
||||||
// 品牌
|
// 品牌
|
||||||
'plugins-brand-home' => '/pages/plugins/brand/index/index',
|
'plugins-brand-home' => '/pages/plugins/brand/index/index',
|
||||||
|
|
@ -940,7 +942,11 @@ class BaseLayout
|
||||||
'data' => [
|
'data' => [
|
||||||
[
|
[
|
||||||
'value' => 'home',
|
'value' => 'home',
|
||||||
'name' => '首页',
|
'name' => '所有店铺',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'value' => 'favor',
|
||||||
|
'name' => '店铺收藏',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
@ -950,7 +956,7 @@ class BaseLayout
|
||||||
'data' => [
|
'data' => [
|
||||||
[
|
[
|
||||||
'value' => 'home',
|
'value' => 'home',
|
||||||
'name' => '首页',
|
'name' => '所有品牌',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
@ -960,7 +966,7 @@ class BaseLayout
|
||||||
'data' => [
|
'data' => [
|
||||||
[
|
[
|
||||||
'value' => 'home',
|
'value' => 'home',
|
||||||
'name' => '首页',
|
'name' => '领券中心',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'value' => 'user',
|
'value' => 'user',
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"pages": [
|
"pages": [
|
||||||
"pages/index/index",
|
"pages/index/index",
|
||||||
"pages/goods-category/goods-category",
|
"pages/goods-category/goods-category",
|
||||||
"pages/cart/cart",
|
"pages/cart/cart",
|
||||||
|
|
@ -82,10 +82,11 @@
|
||||||
"pages/plugins/signin/user-coming-list/user-coming-list",
|
"pages/plugins/signin/user-coming-list/user-coming-list",
|
||||||
"pages/plugins/points/index/index",
|
"pages/plugins/points/index/index",
|
||||||
"pages/plugins/brand/index/index",
|
"pages/plugins/brand/index/index",
|
||||||
"pages/plugins/shop/search/search",
|
"pages/plugins/shop/index/index",
|
||||||
"pages/plugins/shop/detail/detail",
|
"pages/plugins/shop/detail/detail",
|
||||||
"pages/plugins/shop/faovr/faovr",
|
"pages/plugins/shop/search/search",
|
||||||
"pages/plugins/shop/design/design"
|
"pages/plugins/shop/design/design",
|
||||||
|
"pages/plugins/shop/faovr/faovr"
|
||||||
],
|
],
|
||||||
"permission": {
|
"permission": {
|
||||||
"scope.userLocation": {
|
"scope.userLocation": {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,203 @@
|
||||||
|
const app = getApp();
|
||||||
|
Page({
|
||||||
|
data: {
|
||||||
|
data_list_loding_status: 1,
|
||||||
|
data_list_loding_msg: '',
|
||||||
|
data_bottom_line_status: false,
|
||||||
|
data_list: [],
|
||||||
|
data_total: 0,
|
||||||
|
data_page_total: 0,
|
||||||
|
data_page: 1,
|
||||||
|
params: null,
|
||||||
|
data_base: null,
|
||||||
|
shop_category: [],
|
||||||
|
nav_active_value: 0,
|
||||||
|
},
|
||||||
|
|
||||||
|
onLoad(params) {
|
||||||
|
// 显示分享菜单
|
||||||
|
app.show_share_menu();
|
||||||
|
},
|
||||||
|
|
||||||
|
onShow() {
|
||||||
|
// 数据加载
|
||||||
|
this.get_data();
|
||||||
|
},
|
||||||
|
|
||||||
|
// 初始化
|
||||||
|
get_data() {
|
||||||
|
wx.showLoading({title: "加载中..." });
|
||||||
|
var data = {
|
||||||
|
"category_id": this.data.nav_tab_value || 0
|
||||||
|
};
|
||||||
|
wx.request({
|
||||||
|
url: app.get_request_url("index", "index", "shop"),
|
||||||
|
method: "POST",
|
||||||
|
data: data,
|
||||||
|
dataType: "json",
|
||||||
|
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||||
|
success: res => {
|
||||||
|
wx.hideLoading();
|
||||||
|
wx.stopPullDownRefresh();
|
||||||
|
if (res.data.code == 0) {
|
||||||
|
var data = res.data.data;
|
||||||
|
this.setData({
|
||||||
|
data_base: data.base || null,
|
||||||
|
shop_category: data.shop_category || [],
|
||||||
|
});
|
||||||
|
|
||||||
|
// 标题名称
|
||||||
|
if((this.data.data_base || null) != null && (this.data.data_base.application_name || null) != null)
|
||||||
|
{
|
||||||
|
wx.setNavigationBarTitle({title: this.data.data_base.application_name});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取列表数据
|
||||||
|
this.get_data_list(1);
|
||||||
|
} else {
|
||||||
|
this.setData({
|
||||||
|
data_list_loding_status: 0,
|
||||||
|
data_list_loding_msg: res.data.msg
|
||||||
|
});
|
||||||
|
app.showToast(res.data.msg);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
wx.hideLoading();
|
||||||
|
wx.stopPullDownRefresh();
|
||||||
|
this.setData({
|
||||||
|
data_list_loding_status: 2
|
||||||
|
});
|
||||||
|
app.showToast("服务器请求出错");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取数据列表
|
||||||
|
get_data_list(is_mandatory) {
|
||||||
|
// 分页是否还有数据
|
||||||
|
if ((is_mandatory || 0) == 0) {
|
||||||
|
if (this.data.data_bottom_line_status == true) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载loding
|
||||||
|
wx.showLoading({title: "加载中..." });
|
||||||
|
|
||||||
|
// 参数
|
||||||
|
var data = {
|
||||||
|
"category_id": this.data.nav_active_value || 0
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取数据
|
||||||
|
wx.request({
|
||||||
|
url: app.get_request_url("shoplist", "index", "shop"),
|
||||||
|
method: "POST",
|
||||||
|
data: data,
|
||||||
|
dataType: "json",
|
||||||
|
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||||
|
success: res => {
|
||||||
|
wx.hideLoading();
|
||||||
|
wx.stopPullDownRefresh();
|
||||||
|
if (res.data.code == 0) {
|
||||||
|
var data = res.data.data;
|
||||||
|
// 列表数据处理
|
||||||
|
if (data.data.length > 0) {
|
||||||
|
if (this.data.data_page <= 1) {
|
||||||
|
var temp_data_list = data.data;
|
||||||
|
} else {
|
||||||
|
var temp_data_list = this.data.data_list;
|
||||||
|
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: data.total,
|
||||||
|
data_page_total: data.page_total,
|
||||||
|
data_list_loding_status: 3,
|
||||||
|
data_page: this.data.data_page + 1
|
||||||
|
});
|
||||||
|
|
||||||
|
// 是否还有数据
|
||||||
|
if (this.data.data_page > 1 && this.data.data_page > this.data.data_page_total)
|
||||||
|
{
|
||||||
|
this.setData({ data_bottom_line_status: true });
|
||||||
|
} else {
|
||||||
|
this.setData({data_bottom_line_status: false});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.setData({
|
||||||
|
data_list_loding_status: 0,
|
||||||
|
});
|
||||||
|
if (this.data.data_page <= 1) {
|
||||||
|
this.setData({
|
||||||
|
data_list: [],
|
||||||
|
data_bottom_line_status: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.setData({
|
||||||
|
data_list_loding_status: 0,
|
||||||
|
data_list_loding_msg: res.data.msg
|
||||||
|
});
|
||||||
|
app.showToast(res.data.msg);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
wx.hideLoading();
|
||||||
|
wx.stopPullDownRefresh();
|
||||||
|
this.setData({
|
||||||
|
data_list_loding_status: 2
|
||||||
|
});
|
||||||
|
app.showToast("服务器请求出错");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// 下拉刷新
|
||||||
|
onPullDownRefresh() {
|
||||||
|
this.setData({
|
||||||
|
data_page: 1
|
||||||
|
});
|
||||||
|
this.get_data();
|
||||||
|
},
|
||||||
|
|
||||||
|
// 滚动加载
|
||||||
|
scroll_lower(e) {
|
||||||
|
this.get_data_list();
|
||||||
|
},
|
||||||
|
|
||||||
|
// 导航事件
|
||||||
|
nav_event(e) {
|
||||||
|
this.setData({
|
||||||
|
nav_active_value: e.currentTarget.dataset.value || 0,
|
||||||
|
data_page: 1
|
||||||
|
});
|
||||||
|
|
||||||
|
// 获取列表数据
|
||||||
|
this.get_data_list(1);
|
||||||
|
},
|
||||||
|
|
||||||
|
// 自定义分享
|
||||||
|
onShareAppMessage() {
|
||||||
|
var user_id = app.get_user_cache_info('id', 0) || 0;
|
||||||
|
return {
|
||||||
|
title: this.data.data_base.seo_title || this.data.data_base.application_name || app.data.application_title,
|
||||||
|
desc: this.data.data_base.seo_desc || app.data.application_describe,
|
||||||
|
path: '/pages/plugins/shop/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 || this.data.data_base.application_name || app.data.application_title,
|
||||||
|
query: 'referrer=' + user_id
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"enablePullDownRefresh": true,
|
||||||
|
"navigationBarTitleText": "所有店铺",
|
||||||
|
"usingComponents": {
|
||||||
|
"component-quick-nav": "/components/quick-nav/quick-nav",
|
||||||
|
"component-popup": "/components/popup/popup"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
<view wx:if="{{(data_base || null) != null}}">
|
||||||
|
<!-- 分类 -->
|
||||||
|
<scroll-view wx:if="{{(shop_category || null) != null && shop_category.length > 0}}" class="nav-list bg-white oh" scroll-x="true">
|
||||||
|
<view class="item cr-888 {{nav_active_value == 0 ? 'active' : ''}}" bindtap="nav_event" data-value="0">全部</view>
|
||||||
|
<block wx:for="{{shop_category}}" wx: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>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<scroll-view scroll-y="{{true}}" class="scroll-box" bindscrolltolower="scroll_lower" lower-threshold="30">
|
||||||
|
<view wx:if="{{(data_list || null) != null && data_list.length > 0}}" class="data-list oh spacing-mt">
|
||||||
|
<block wx:for="{{data_list}}" wx:key="key">
|
||||||
|
<view class="item bg-white">
|
||||||
|
<navigator url="/pages/plugins/shop/detail/detail?id={{item.id}}" hover-class="none">
|
||||||
|
<image src="{{item.logo_long}}" 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 class="oh margin-top-sm single-text base-bottom">
|
||||||
|
<view class="bitem fl cr-888 single-text">商品 {{item.goods_count}}</view>
|
||||||
|
<view class="bitem fr cr-888 single-text tr">销量 {{item.goods_sales_count}}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</navigator>
|
||||||
|
</view>
|
||||||
|
</block>
|
||||||
|
</view>
|
||||||
|
<view wx:else>
|
||||||
|
<import src="/pages/common/nodata.wxml" />
|
||||||
|
<template is="nodata" data="{{status: data_list_loding_status, msg: data_list_loding_msg}}"></template>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 结尾 -->
|
||||||
|
<import src="/pages/common/bottom_line.wxml" />
|
||||||
|
<template is="bottom_line" data="{{status: data_bottom_line_status}}"></template>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
<view wx:else>
|
||||||
|
<import src="/pages/common/nodata.wxml" />
|
||||||
|
<template is="nodata" data="{{status: data_list_loding_status, msg: data_list_loding_msg}}"></template>
|
||||||
|
</view>
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
/**
|
||||||
|
* 分类导航
|
||||||
|
*/
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据列表
|
||||||
|
*/
|
||||||
|
.scroll-box {
|
||||||
|
height: calc(100vh - 80rpx);
|
||||||
|
}
|
||||||
|
.data-list .item {
|
||||||
|
width: calc(50% - 5rpx);
|
||||||
|
margin-bottom: 10rpx;
|
||||||
|
}
|
||||||
|
.data-list .item:nth-child(2n) {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
.data-list .item:nth-child(2n+1) {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
.data-list .item image {
|
||||||
|
width: 100%;
|
||||||
|
height: 160rpx !important;
|
||||||
|
}
|
||||||
|
.data-list .item .base {
|
||||||
|
padding-top: 20rpx;
|
||||||
|
margin: 20rpx;
|
||||||
|
}
|
||||||
|
.data-list .item .desc {
|
||||||
|
color: #999;
|
||||||
|
margin-top: 10rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
line-height: 40rpx;
|
||||||
|
min-height: 80rpx;
|
||||||
|
}
|
||||||
|
.data-list .item .base-bottom .bitem {
|
||||||
|
width: 45%;
|
||||||
|
font-size: 24rpx;
|
||||||
|
}
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
</block>
|
</block>
|
||||||
</block>
|
</block>
|
||||||
<block wx:else>
|
<block wx:else>
|
||||||
<view class="padding-top-xxl padding-bottom-xxl cr-888">暂无数据</view>
|
<view class="padding-top-xxl padding-bottom-xxl cr-ccc">暂无数据</view>
|
||||||
</block>
|
</block>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* 排序导航
|
* 排序导航
|
||||||
*/
|
*/
|
||||||
.nav-sort {
|
.nav-sort {
|
||||||
background: #eee;
|
background: #eee;
|
||||||
}
|
}
|
||||||
.nav-sort-content .item {
|
.nav-sort-content .item {
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
/**
|
/**
|
||||||
* 商品列表
|
* 商品列表
|
||||||
*/
|
*/
|
||||||
.scroll-box {
|
.scroll-box {
|
||||||
height: calc(100vh - 80rpx);
|
height: calc(100vh - 80rpx);
|
||||||
}
|
}
|
||||||
.data-list {
|
.data-list {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue