init
This commit is contained in:
85
wx05cb767e6530b48f/pages/category/index.js
Normal file
85
wx05cb767e6530b48f/pages/category/index.js
Normal file
@@ -0,0 +1,85 @@
|
||||
var t = getApp();
|
||||
|
||||
Page({
|
||||
data: {
|
||||
searchColor: "rgba(0,0,0,0.4)",
|
||||
searchSize: "15",
|
||||
searchName: "搜索商品",
|
||||
scrollHeight: 0,
|
||||
curIndex: -1,
|
||||
curCateId: 0,
|
||||
categoryList: [],
|
||||
goodsList: [],
|
||||
noMore: !1,
|
||||
isLoading: !0,
|
||||
page: 1
|
||||
},
|
||||
onLoad: function() {
|
||||
this.setListHeight(), this.getCategoryList();
|
||||
},
|
||||
onShow: function() {},
|
||||
setListHeight: function() {
|
||||
var t = this;
|
||||
wx.getSystemInfo({
|
||||
success: function(a) {
|
||||
t.setData({
|
||||
scrollHeight: a.windowHeight - 47
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
getCategoryList: function() {
|
||||
var a = this;
|
||||
t._get("category/index", {}, function(t) {
|
||||
var o = t.data;
|
||||
a.setData({
|
||||
categoryList: o.categoryList,
|
||||
goodsList: o.goodsList
|
||||
});
|
||||
});
|
||||
},
|
||||
getGoodsList: function(a, o) {
|
||||
var s = this;
|
||||
t._get("goods/lists", {
|
||||
page: o || 1,
|
||||
category_id: s.data.curCateId
|
||||
}, function(t) {
|
||||
var o = t.data.list, e = s.data.goodsList;
|
||||
1 == a ? s.setData({
|
||||
"goodsList.data": e.data.concat(o.data),
|
||||
isLoading: !1
|
||||
}) : s.setData({
|
||||
goodsList: o,
|
||||
isLoading: !1
|
||||
});
|
||||
});
|
||||
},
|
||||
onTargetGoods: function(t) {
|
||||
wx.navigateTo({
|
||||
url: "../goods/index?goods_id=" + t.detail.target.dataset.id
|
||||
});
|
||||
},
|
||||
onSelectNav: function(t) {
|
||||
var a = t.currentTarget.dataset.index;
|
||||
this.setData({
|
||||
curIndex: a,
|
||||
curCateId: a > -1 ? this.data.categoryList[a].category_id : 0,
|
||||
goodsList: [],
|
||||
page: 1,
|
||||
noMore: !1,
|
||||
isLoading: !0
|
||||
}), this.getGoodsList();
|
||||
},
|
||||
onDownLoad: function() {
|
||||
if (this.data.page >= this.data.goodsList.last_page) return this.setData({
|
||||
noMore: !0
|
||||
}), !1;
|
||||
this.getGoodsList(!0, ++this.data.page);
|
||||
},
|
||||
onShareAppMessage: function() {
|
||||
return {
|
||||
title: "全部商品",
|
||||
path: "/pages/category/index"
|
||||
};
|
||||
}
|
||||
});
|
||||
4
wx05cb767e6530b48f/pages/category/index.json
Normal file
4
wx05cb767e6530b48f/pages/category/index.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "全部商品",
|
||||
"usingComponents": {}
|
||||
}
|
||||
53
wx05cb767e6530b48f/pages/category/index.wxml
Normal file
53
wx05cb767e6530b48f/pages/category/index.wxml
Normal file
@@ -0,0 +1,53 @@
|
||||
<view class="container">
|
||||
<view class="index-search-box">
|
||||
<navigator class="index-search" hoverClass="none" openType="navigate" url="../search/index">
|
||||
<view class="index-cont-search t-c">
|
||||
<icon class="text-center" color="{{searchColor}}" size="{{searchSize}}" type="search"></icon>
|
||||
<text>{{searchName}}</text>
|
||||
</view>
|
||||
</navigator>
|
||||
</view>
|
||||
<view class="cate-content dis-flex">
|
||||
<scroll-view class="cate-left f-28" scrollY="{{true}}" style="height: {{scrollHeight}}px; ">
|
||||
<text catchtap="onSelectNav" class="type-nav {{curIndex==-1?'selected':''}}" data-index="-1">全部</text>
|
||||
<text catchtap="onSelectNav" class="type-nav {{curIndex==index?'selected':''}} onelist-hidden" data-index="{{index}}" wx:for="{{categoryList}}" wx:key="cateLeft">{{item.name}}</text>
|
||||
</scroll-view>
|
||||
<scroll-view bindscrolltolower="onDownLoad" class="cate-right b-f" scrollTop="{{scrollTop}}" scrollY="true" style="height: {{scrollHeight}}px; ">
|
||||
<view class="goods-item" wx:for="{{goodsList.data}}" wx:key="this">
|
||||
<form bindsubmit="onTargetGoods" reportSubmit="true">
|
||||
<button class="btn-normal" data-id="{{item.goods_id}}" formType="submit">
|
||||
<view class="goods-item_detail dis-flex">
|
||||
<view class="goods-item_left">
|
||||
<image src="{{item.goods_image}}"></image>
|
||||
</view>
|
||||
<view class="goods-item_right">
|
||||
<view class="goods-item_title twolist-hidden">
|
||||
<text>{{item.goods_name}}</text>
|
||||
</view>
|
||||
<view class="goods-item_desc">
|
||||
<view class="desc-selling_point dis-flex">
|
||||
<text class="onelist-hidden">{{item.selling_point}}</text>
|
||||
</view>
|
||||
<view class="desc-goods_sales onelist-hidden dis-flex">
|
||||
<text>已售{{item.goods_sales}}件</text>
|
||||
</view>
|
||||
<view class="desc_footer">
|
||||
<text class="price_x">¥{{item.goods_sku.goods_price}}</text>
|
||||
<text class="price_y col-9">¥{{item.goods_sku.line_price}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</button>
|
||||
</form>
|
||||
</view>
|
||||
<view class="no-more f-30" wx:if="{{noMore}}">亲, 没有更多了</view>
|
||||
<view wx:if="{{!isLoading&&!goodsList.data.length}}">
|
||||
<view class="yoshop-notcont">
|
||||
<text class="iconfont icon-ziyuan"></text>
|
||||
<text class="cont">亲,此处暂无商品哦</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
132
wx05cb767e6530b48f/pages/category/index.wxss
Normal file
132
wx05cb767e6530b48f/pages/category/index.wxss
Normal file
@@ -0,0 +1,132 @@
|
||||
.index-search-box {
|
||||
background: #fff;
|
||||
padding: 13rpx 13rpx 18rpx;
|
||||
}
|
||||
|
||||
.index-search {
|
||||
border-bottom: 0;
|
||||
border-radius: 50rpx;
|
||||
box-sizing: border-box;
|
||||
color: #999;
|
||||
font-size: 28rpx;
|
||||
height: 64rpx;
|
||||
line-height: 64rpx;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.index-search,page {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.no-more {
|
||||
font-size: 28rpx;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.cate-content {
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.cate-left {
|
||||
background: #f8f8f8;
|
||||
color: #444;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
width: 22.2222%;
|
||||
}
|
||||
|
||||
.cate-left .type-nav {
|
||||
display: block;
|
||||
font-size: 26rpx;
|
||||
height: 90rpx;
|
||||
line-height: 90rpx;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.cate-left .type-nav.selected {
|
||||
background: #fff;
|
||||
border-right: none;
|
||||
color: #ff495e;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.cate-right {
|
||||
width: 77.7778%;
|
||||
}
|
||||
|
||||
.goods-item {
|
||||
background: #fff;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 10rpx;
|
||||
padding: 16rpx;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.goods-item text {
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.goods-item:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.goods-item_left {
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
display: flex;
|
||||
width: 36%;
|
||||
}
|
||||
|
||||
.goods-item_left image {
|
||||
display: block;
|
||||
height: 190rpx;
|
||||
width: 190rpx;
|
||||
}
|
||||
|
||||
.goods-item_right {
|
||||
padding-left: 20rpx;
|
||||
position: relative;
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.goods-item_right .goods-item_title {
|
||||
color: #333;
|
||||
font-size: 26rpx;
|
||||
height: 72rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.goods-item_right .goods-item_title text {
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.goods-item_desc {
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
|
||||
.desc-selling_point {
|
||||
color: #ff495e;
|
||||
font-size: 24rpx;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.desc-goods_sales {
|
||||
color: #999;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.desc_footer .price_x {
|
||||
color: #f03c3c;
|
||||
font-size: 27rpx;
|
||||
margin-right: 16rpx;
|
||||
}
|
||||
|
||||
.desc_footer .price_y {
|
||||
font-size: 24rpx;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
90
wx05cb767e6530b48f/pages/category/list.js
Normal file
90
wx05cb767e6530b48f/pages/category/list.js
Normal file
@@ -0,0 +1,90 @@
|
||||
var t = getApp();
|
||||
|
||||
Page({
|
||||
data: {
|
||||
searchColor: "rgba(0,0,0,0.4)",
|
||||
searchSize: "15",
|
||||
searchName: "搜索商品",
|
||||
scrollHeight: null,
|
||||
showView: !1,
|
||||
arrange: "",
|
||||
sortType: "all",
|
||||
sortPrice: !1,
|
||||
option: {},
|
||||
list: {},
|
||||
noList: !0,
|
||||
no_more: !1,
|
||||
page: 1
|
||||
},
|
||||
onLoad: function(t) {
|
||||
var a = this;
|
||||
a.setListHeight(), a.setData({
|
||||
option: t
|
||||
}, function() {
|
||||
a.getGoodsList(!0);
|
||||
});
|
||||
},
|
||||
getGoodsList: function(a, e) {
|
||||
var s = this;
|
||||
t._get("goods/lists", {
|
||||
page: e || 1,
|
||||
sortType: s.data.sortType,
|
||||
sortPrice: s.data.sortPrice ? 1 : 0,
|
||||
category_id: s.data.option.category_id || 0,
|
||||
search: s.data.option.search || ""
|
||||
}, function(t) {
|
||||
var e = t.data.list, i = s.data.list;
|
||||
!0 === a || void 0 === i.data ? s.setData({
|
||||
list: e,
|
||||
noList: !1
|
||||
}) : s.setData({
|
||||
"list.data": i.data.concat(e.data)
|
||||
});
|
||||
});
|
||||
},
|
||||
setListHeight: function() {
|
||||
var t = this;
|
||||
wx.getSystemInfo({
|
||||
success: function(a) {
|
||||
t.setData({
|
||||
scrollHeight: a.windowHeight - 90
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
switchSortType: function(t) {
|
||||
var a = this, e = t.currentTarget.dataset.type, s = "price" !== e || !a.data.sortPrice;
|
||||
a.setData({
|
||||
list: {},
|
||||
page: 1,
|
||||
sortType: e,
|
||||
sortPrice: s
|
||||
}, function() {
|
||||
a.getGoodsList(!0);
|
||||
});
|
||||
},
|
||||
toSynthesize: function(t) {
|
||||
wx.navigateTo({
|
||||
url: "../category/screen?objectId="
|
||||
});
|
||||
},
|
||||
onChangeShowState: function() {
|
||||
this.setData({
|
||||
showView: !this.data.showView,
|
||||
arrange: this.data.arrange ? "" : "arrange"
|
||||
});
|
||||
},
|
||||
bindDownLoad: function() {
|
||||
if (this.data.page >= this.data.list.last_page) return this.setData({
|
||||
no_more: !0
|
||||
}), !1;
|
||||
this.getGoodsList(!1, ++this.data.page);
|
||||
},
|
||||
onShareAppMessage: function() {
|
||||
return {
|
||||
title: "全部分类",
|
||||
desc: "",
|
||||
path: "/pages/category/index"
|
||||
};
|
||||
}
|
||||
});
|
||||
5
wx05cb767e6530b48f/pages/category/list.json
Normal file
5
wx05cb767e6530b48f/pages/category/list.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"navigationBarTitleText": "商品列表",
|
||||
"enablePullDownRefresh": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
56
wx05cb767e6530b48f/pages/category/list.wxml
Normal file
56
wx05cb767e6530b48f/pages/category/list.wxml
Normal file
@@ -0,0 +1,56 @@
|
||||
<view class="container">
|
||||
<view class="list-header">
|
||||
<view class="index-search-box dis-flex" style="position:static">
|
||||
<navigator class="index-search flex-box" hoverClass="none" openType="navigate" url="../search/index">
|
||||
<view class="index-cont-search">
|
||||
<icon class="text-center" color="rgba(0,0,0,0.4)" size="15" type="search"></icon>
|
||||
<text>搜索商品</text>
|
||||
</view>
|
||||
</navigator>
|
||||
<view bindtap="onChangeShowState" class="list-right f-28">
|
||||
<text class="iconfont icon-tubiao_kuaizhuangpailie" wx:if="{{showView}}"></text>
|
||||
<text class="iconfont icon-tubiao_liebiaopailie" wx:else></text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="store_nav_cont dis-flex b-f b-b">
|
||||
<view bindtap="switchSortType" class="flex-box t-c p-r" data-index="0 " data-type="all" id="list-{{sortType==='all'?true:0}}">
|
||||
<text>综合</text>
|
||||
</view>
|
||||
<view bindtap="switchSortType" class="flex-box t-c p-r" data-index="1" data-type="sales" id="list-{{sortType==='sales'?true:0}}">
|
||||
<text> 销量</text>
|
||||
</view>
|
||||
<view bindtap="switchSortType" class="flex-box t-c p-r" data-index="2" data-type="price" id="list-{{sortType==='price'?true:0}}">
|
||||
<text class="price"> 价格</text>
|
||||
<text class="iconfont icon-jiantou-copy tf-180 top_jiantou {{sortPrice?'':'active'}}"></text>
|
||||
<text class="iconfont icon-jiantou-copy bot_jiantou {{sortPrice?'active':''}}"></text>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view bindscrolltolower="bindDownLoad" class="weui-panel weui-panel_access" scrollY="true" style="height: {{scrollHeight}}px; width: 750rpx;" wx:if="{{list.data.length>0}}">
|
||||
<view class="new">
|
||||
<view class="category-list {{arrange}}">
|
||||
<navigator class="list b-f" hoverClass="none" url="../goods/index?goods_id={{item.goods_id}}" wx:for="{{list.data}}" wx:key="list">
|
||||
<view class="left">
|
||||
<view class="img">
|
||||
<image class="goodsImg" mode="scaleToFill" src="{{item.image[0].file_path}}"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="right">
|
||||
<view class="cont">
|
||||
<text class="f-28 title twolist-hidden m-top10">{{item.goods_name}}</text>
|
||||
<view class="price f-30 col-m"> ¥{{item.goods_min_price}} <text class="del f-22" wx:if="{{item.goods_sku.line_price>0}}">{{item.goods_sku.line_price}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
<view class="no-more f-30" hidden="{{!no_more}}">亲, 没有更多了</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<view class="yoshop-notcont" style="margin-top:130px;" wx:if="{{!noList&&!list.data.length}}">
|
||||
<view class="img">
|
||||
<image mode="aspectFit" src="../../images/no_content.png"></image>
|
||||
</view>
|
||||
<text class="cont">亲, 没有相关内容</text>
|
||||
</view>
|
||||
</view>
|
||||
159
wx05cb767e6530b48f/pages/category/list.wxss
Normal file
159
wx05cb767e6530b48f/pages/category/list.wxss
Normal file
@@ -0,0 +1,159 @@
|
||||
.store_nav_cont {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.store_nav_cont #list-true {
|
||||
color: #ff495e;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.store_nav_cont #list-0 {
|
||||
color: #333;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.store_nav_cont #list-0 .icon-fenlei {
|
||||
color: #777;
|
||||
font-size: 28rpx;
|
||||
padding-left: 8rpx;
|
||||
}
|
||||
|
||||
.store_nav_cont #list-true .icon-fenlei {
|
||||
color: #ff495e;
|
||||
font-size: 28rpx;
|
||||
padding-left: 8rpx;
|
||||
}
|
||||
|
||||
.store_nav_cont .price {
|
||||
padding-right: 30rpx;
|
||||
}
|
||||
|
||||
.store_nav_cont #list-0 .top_jiantou,.store_nav_cont #list-true .top_jiantou {
|
||||
color: #777;
|
||||
font-size: 18rpx;
|
||||
margin-top: -16rpx;
|
||||
position: absolute;
|
||||
right: 52rpx;
|
||||
top: 50%;
|
||||
}
|
||||
|
||||
.store_nav_cont #list-0 .bot_jiantou,.store_nav_cont #list-true .bot_jiantou {
|
||||
color: #777;
|
||||
font-size: 18rpx;
|
||||
margin-top: -2rpx;
|
||||
position: absolute;
|
||||
right: 52rpx;
|
||||
top: 50%;
|
||||
}
|
||||
|
||||
.store_nav_cont #list-true .bot_jiantou.active,.store_nav_cont #list-true .top_jiantou.active {
|
||||
color: #ff495e;
|
||||
}
|
||||
|
||||
.container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.cate-btn {
|
||||
background: #ff495e;
|
||||
bottom: 18rpx;
|
||||
color: #fff;
|
||||
font-size: 20rpx;
|
||||
padding: 4px 18rpx;
|
||||
right: 18rpx;
|
||||
}
|
||||
|
||||
.index-cont-search icon {
|
||||
left: 0;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.index-search-box {
|
||||
background: #fff;
|
||||
border-bottom: 1px solid #eee;
|
||||
left: 0rpx;
|
||||
padding: 18rpx 13rpx;
|
||||
position: fixed;
|
||||
right: 0rpx;
|
||||
top: 1rpx;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.index-search {
|
||||
background: #fff;
|
||||
border-bottom: 0;
|
||||
border-radius: 50rpx;
|
||||
box-sizing: border-box;
|
||||
color: #999;
|
||||
font-size: 32rpx;
|
||||
height: 64rpx;
|
||||
line-height: 64rpx;
|
||||
margin: 0 10rpx;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.list-right {
|
||||
width: 60rpx;
|
||||
}
|
||||
|
||||
.list-right text {
|
||||
font-size: 40rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
}
|
||||
|
||||
.list-header {
|
||||
left: 0;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
top: 1rpx;
|
||||
}
|
||||
|
||||
.no-more {
|
||||
color: #737373;
|
||||
margin: 10px 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.category-list {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.category-list .list {
|
||||
box-sizing: border-box;
|
||||
float: left;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.category-list .list:nth-child(2n) {
|
||||
border-bottom: 4px solid #f7f7f7;
|
||||
border-left: 2px solid #f7f7f7;
|
||||
}
|
||||
|
||||
.category-list .list:nth-child(2n-1) {
|
||||
border-bottom: 4px solid #f7f7f7;
|
||||
border-right: 2px solid #f7f7f7;
|
||||
}
|
||||
|
||||
.category-list.arrange .list {
|
||||
border-bottom: 1rpx solid #f7f7f7;
|
||||
overflow: hidden;
|
||||
padding: 15rpx;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.category-list.arrange .list .left {
|
||||
float: left;
|
||||
width: 35%;
|
||||
}
|
||||
|
||||
.category-list.arrange .list .right {
|
||||
float: left;
|
||||
width: 65%;
|
||||
}
|
||||
|
||||
.category-list.arrange .list .left .img image {
|
||||
height: 220rpx;
|
||||
width: 220rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user