From d7a989275ae4b29e49b2ead96969e6e55239d180 Mon Sep 17 00:00:00 2001 From: Devil Date: Mon, 5 Jul 2021 23:50:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E5=A4=9A=E5=95=86=E6=88=B7=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/layout/service/BaseLayout.php | 12 +- sourcecode/weixin/default/app.json | 9 +- .../default/pages/plugins/shop/index/index.js | 203 ++++++++++++++++++ .../pages/plugins/shop/index/index.json | 8 + .../pages/plugins/shop/index/index.wxml | 42 ++++ .../pages/plugins/shop/index/index.wxss | 55 +++++ .../pages/plugins/shop/public/header.wxml | 2 +- .../pages/plugins/shop/search/search.wxss | 4 +- 8 files changed, 325 insertions(+), 10 deletions(-) create mode 100755 sourcecode/weixin/default/pages/plugins/shop/index/index.js create mode 100755 sourcecode/weixin/default/pages/plugins/shop/index/index.json create mode 100755 sourcecode/weixin/default/pages/plugins/shop/index/index.wxml create mode 100755 sourcecode/weixin/default/pages/plugins/shop/index/index.wxss diff --git a/application/layout/service/BaseLayout.php b/application/layout/service/BaseLayout.php index bc5b6c8f2..d4bcb0253 100644 --- a/application/layout/service/BaseLayout.php +++ b/application/layout/service/BaseLayout.php @@ -482,6 +482,7 @@ class BaseLayout // 多商户 'plugins-shop-home' => PluginsHomeUrl('shop', 'index', 'index'), + 'plugins-shop-favor' => PluginsHomeUrl('shop', 'shopfavor', 'index'), // 品牌 'plugins-brand-home' => PluginsHomeUrl('brand', 'index', 'index'), @@ -530,6 +531,7 @@ class BaseLayout // 多商户 'plugins-shop-home' => '/pages/plugins/shop/index/index', + 'plugins-shop-faovr' => '/pages/plugins/shop/favor/favor', // 品牌 'plugins-brand-home' => '/pages/plugins/brand/index/index', @@ -940,7 +942,11 @@ class BaseLayout 'data' => [ [ 'value' => 'home', - 'name' => '首页', + 'name' => '所有店铺', + ], + [ + 'value' => 'favor', + 'name' => '店铺收藏', ], ], ], @@ -950,7 +956,7 @@ class BaseLayout 'data' => [ [ 'value' => 'home', - 'name' => '首页', + 'name' => '所有品牌', ], ], ], @@ -960,7 +966,7 @@ class BaseLayout 'data' => [ [ 'value' => 'home', - 'name' => '首页', + 'name' => '领券中心', ], [ 'value' => 'user', diff --git a/sourcecode/weixin/default/app.json b/sourcecode/weixin/default/app.json index d6da01c42..2d0809ab5 100755 --- a/sourcecode/weixin/default/app.json +++ b/sourcecode/weixin/default/app.json @@ -1,5 +1,5 @@ { - "pages": [ + "pages": [ "pages/index/index", "pages/goods-category/goods-category", "pages/cart/cart", @@ -82,10 +82,11 @@ "pages/plugins/signin/user-coming-list/user-coming-list", "pages/plugins/points/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/faovr/faovr", - "pages/plugins/shop/design/design" + "pages/plugins/shop/search/search", + "pages/plugins/shop/design/design", + "pages/plugins/shop/faovr/faovr" ], "permission": { "scope.userLocation": { diff --git a/sourcecode/weixin/default/pages/plugins/shop/index/index.js b/sourcecode/weixin/default/pages/plugins/shop/index/index.js new file mode 100755 index 000000000..1c69e2e70 --- /dev/null +++ b/sourcecode/weixin/default/pages/plugins/shop/index/index.js @@ -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 + }; + }, +}); diff --git a/sourcecode/weixin/default/pages/plugins/shop/index/index.json b/sourcecode/weixin/default/pages/plugins/shop/index/index.json new file mode 100755 index 000000000..19ce470a7 --- /dev/null +++ b/sourcecode/weixin/default/pages/plugins/shop/index/index.json @@ -0,0 +1,8 @@ +{ + "enablePullDownRefresh": true, + "navigationBarTitleText": "所有店铺", + "usingComponents": { + "component-quick-nav": "/components/quick-nav/quick-nav", + "component-popup": "/components/popup/popup" + } +} \ No newline at end of file diff --git a/sourcecode/weixin/default/pages/plugins/shop/index/index.wxml b/sourcecode/weixin/default/pages/plugins/shop/index/index.wxml new file mode 100755 index 000000000..322a5e7ac --- /dev/null +++ b/sourcecode/weixin/default/pages/plugins/shop/index/index.wxml @@ -0,0 +1,42 @@ + + + + 全部 + + {{item.name}} + + + + + + + + + + + + {{item.name}} + {{item.describe}} + + 商品 {{item.goods_count}} + 销量 {{item.goods_sales_count}} + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sourcecode/weixin/default/pages/plugins/shop/index/index.wxss b/sourcecode/weixin/default/pages/plugins/shop/index/index.wxss new file mode 100755 index 000000000..8bf7e055f --- /dev/null +++ b/sourcecode/weixin/default/pages/plugins/shop/index/index.wxss @@ -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; +} \ No newline at end of file diff --git a/sourcecode/weixin/default/pages/plugins/shop/public/header.wxml b/sourcecode/weixin/default/pages/plugins/shop/public/header.wxml index 2d36f6b69..b773b6f85 100644 --- a/sourcecode/weixin/default/pages/plugins/shop/public/header.wxml +++ b/sourcecode/weixin/default/pages/plugins/shop/public/header.wxml @@ -64,7 +64,7 @@ - 暂无数据 + 暂无数据 diff --git a/sourcecode/weixin/default/pages/plugins/shop/search/search.wxss b/sourcecode/weixin/default/pages/plugins/shop/search/search.wxss index 13b24464c..787ae74c0 100755 --- a/sourcecode/weixin/default/pages/plugins/shop/search/search.wxss +++ b/sourcecode/weixin/default/pages/plugins/shop/search/search.wxss @@ -1,7 +1,7 @@ /** * 排序导航 */ - .nav-sort { +.nav-sort { background: #eee; } .nav-sort-content .item { @@ -27,7 +27,7 @@ /** * 商品列表 */ - .scroll-box { +.scroll-box { height: calc(100vh - 80rpx); } .data-list { -- GitLab