Authored by 李奇

商品列表添加

... ... @@ -16,6 +16,8 @@
"pages/product/search/search",
"pages/goodsDetail/goodsDetail",
"pages/goodsList/productPool",
"pages/goodsList/goodsList",
"pages/goodsList/brandStore",
"pages/shop/category/category",
"pages/shop/list/list",
"pages/webview/webview"
... ...
... ... @@ -16,7 +16,7 @@ export default {
},
/**
* 商品商品池商品列表
* 商品池商品列表
* @param params
* @returns {*}
*/
... ... @@ -30,6 +30,20 @@ export default {
},
/**
* 品类商品列表
* @param params
* @returns {*}
*/
categoryProductList(params) {
return api.get({
url: '',
data: Object.assign({
method: 'app.search.category'
}, params)
});
},
/**
* 品牌信息
* @param brandId
* @returns {*}
... ...
import wx from '../../utils/wx';
import Yas from '../../common/yas';
import config from '../../config';
import listModel from '../../models/product/list';
import shopModel from '../../models/product/shop';
import { Actionsheet } from '../../vendors/zanui/index';
let app = getApp();
let { windowHeight } = app.getSystemInfo();
let yas;
Page(Object.assign({
data: {
query: '',
order: '',
gender: '',
shopId: 0,
shopName: '',
searched: false,
productList: [],
snapshootShareData: {},
floor: {},
actionsheet: {
componentId: 'shareActionSheet',
show: false,
closeOnClickOverlay: true,
cancelText: '取消',
actions: [{
name: '分享给朋友',
className: 'action-class',
loading: false,
openType: 'share'
}]
},
shopInfoHeight: 0,
scrollTop: 0,
fixedFilter: false,
windowHeight,
currentPage: 1,
totalPage: 0,
showLoading: false,
showNoMore: false,
isLoading: false,
noResult: false
},
onLoad: function(options) {
Object.keys(options).map(key => {
options[key] = decodeURIComponent(options[key] || '');
});
let shopId = options.shop_id || options.shopId;
this.data.shopId = shopId;
this.setData({
shopId
});
this.shopInfo();
this.shopDecFloor();
this.productList({page: 1, limit: 20, shop_id: shopId});
yas = new Yas(app);
yas.pageOpenReport();
},
onReady: function() {
wx.createSelectorQuery().select('.shop-info').boundingClientRect(rect => {
this.setData({
shopInfoHeight: rect.height
});
}).exec();
},
onShareAppMessage: function(res) {
let params = {
FROM: res.from,
SHARE_RESUIL: 0,
TITLE: this.data.shopName,
DESC: '我在有货发现了一个不错的店铺,赶快来看看吧!',
PATH: `/pages/product/list/shop?shop_id=${this.data.shopId}`,
};
return {
title: params.TITLE, // 分享标题
desc: params.DESC, // 分享描述
path: params.PATH, // 分享路径
success: function() {
params.SHARE_RESUIL = 1;
yas.report('YB_SHARE_RESULT_L', params);
},
fail: function() {
params.SHARE_RESUIL = 2;
yas.report('YB_SHARE_RESULT_L', params);
}
};
},
productList: function(params) {
if (this.data.isLoading) {
return;
}
this.data.isLoading = true;
wx.showLoading({title: '加载中'});
params.order = this.data.order;
params.gender = this.data.gender;
params.shop_id = this.data.shopId;
listModel.productList(params).then(res => {
if (res.code === 200) {
const keyAdapter = {
skn: 'product_skn',
salesPrice: 'sales_price',
marketPrice: 'market_price',
productName: 'product_name',
defaultImages: 'default_images'
};
let list = [];
(res.data.product_list || []).forEach(product => {
let item = {};
Object.keys(keyAdapter).forEach(key => {
item[key] = product[keyAdapter[key]];
});
list.push(item);
});
this.data.isLoading = false;
wx.hideLoading();
this.setData({
showLoading: false,
productList: this.data.productList.concat(list),
currentPage: params.page,
totalPage: res.data.page_total,
noResult: !this.data.productList.concat(list).length
});
if (this.data.fixedFilter && params.resetScroll) {
wx.pageScrollTo({
scrollTop: this.data.shopInfoHeight,
duration: 10
});
}
}
}).catch(() => {
this.data.isLoading = false;
});
},
shareShop: function() {
this.setData({
'actionsheet.show': true
});
},
handleZanActionsheetCancel() {
this.setData({
'actionsheet.show': false
});
},
handleZanActionsheetClick() {
this.setData({
'actionsheet.show': false
});
},
sortChange: function(e) {
let params;
let {curSort, gender} = e.detail;
this.data.gender = gender || '';
this.data.order = curSort;
params = {
gender,
order: curSort,
page: 1,
limit: 20
};
this.data.productList = [];
params.resetScroll = true;
this.productList(params);
},
// 店铺信息
shopInfo: function() {
let params = {
shop_id: this.data.shopId,
fromePage: 'iFP_RedPersonBrand'
};
this.setData({
info: {
isLoading: true,
}
});
shopModel.shopInfo(params)
.then(data => {
if (!data || !data.code || data.code !== 200) {
this.setData({
info: {
isLoading: false,
error: { code: data.code, message: data.message },
}
});
return;
}
if (data.data.shop_name) {
let shopName = data.data.shop_name;
wx.setNavigationBarTitle({
title: shopName,
});
}
let shopInfo = data.data;
let logoUrl = shopInfo.shop_logo.replace(/{width}/g, 100).replace(/{height}/g, 100).replace('{mode}', 2); // eslint-disable-line
shopInfo.shop_logo = logoUrl;
let shareData = this.data.snapshootShareData;
shareData.shop_logo = logoUrl;
shareData.shop_intro_simple = shopInfo.shop_intro_simple;
shareData.shop_id = shopInfo.shops_id;
shareData.shop_name = shopInfo.shop_name;
shareData.shop_qrCode = config.domains.api + '/wechat/miniapp/img-check.jpg?miniQrType=3&param=' + shopInfo.shops_id; // eslint-disable-line
this.setData({
info: {
isLoading: false,
data: shopInfo,
},
shopName: shopInfo.shop_name,
snapshootShareData: shareData
});
});
},
shopDecFloor: function() {
let params = {
shop_id: this.data.shopId,
fromePage: 'iFP_RedPersonBrand'
};
shopModel.shopDecorator(params)
.then(res => {
let floor = res.data.modules;
if (floor && floor.length > 0) {
let shopBanner = floor[0];
if (shopBanner && shopBanner.module_type === 'ShopBanner') {
let module_data = JSON.parse(shopBanner.module_data);
let data = module_data.data;
if (data && data.length > 0) {
let resource = data[0];
let shareData = this.data.snapshootShareData;
shareData.bannerUrl = resource.pic;
this.setData({
bannerUrl: resource.pic,
snapshootShareData: shareData
});
}
}
}
this.setData({
floor: {
isLoading: false,
data: res.data
},
});
})
.catch(error =>{
this.setData({
floor: {
isLoading: false,
error,
}
});
});
},
onPageScroll: function({scrollTop}) {
const floatSign = scrollTop >= this.data.shopInfoHeight;
if (floatSign !== this.data.fixedFilter) {
this.setData({
fixedFilter: floatSign
});
}
const backSign = scrollTop > windowHeight * 2;
if (backSign !== this.data.showBackTop) {
this.setData({
showBackTop: backSign
});
}
},
backTop: function() {
wx.pageScrollTo({
scrollTop: 0
});
},
onReachBottom: function() {
if (this.data.currentPage < this.data.totalPage) {
this.setData({
showLoading: true
});
this.productList({page: this.data.currentPage + 1, limit: 20, order: this.data.order});
} else {
this.setData({
showNoMore: true
});
}
}
}, Actionsheet));
... ...
{
"navigationBarTitleText": "",
"usingComponents": {
"copyright": "/components/layout/copyright/copyright",
"quick-navigation": "/components/layout/quick-navigation/quick-navigation",
"product-list": "/components/product/list",
"product-list-filter": "/components/product/list-filter"
}
}
\ No newline at end of file
... ...
<wxs src="../../wxs/helper.wxs" module="helper"></wxs>
<import src="../../vendors/zanui/actionsheet/index.wxml"/>
<view class="shop-container" scroll-y bindscroll="scroll" scroll-top="{{scrollTop}}" bindscrolltolower="loadMore"
style="height:{{windowHeight}}px;">
<view class="shop-info">
<image class="shop-info-bg" src="{{bannerUrl}}"></image>
<view class="shop-logo-mask" style="height: {{bannerHeight}}px; margin-top: {{-bannerHeight}}px"></view>
<view class="shop-info-content">
<view class="shop-info-left">
<image class="shop-logo" mode="aspectFit" src="{{info.data.shop_logo}}" bindtap="jumpToShopIntro"></image>
<text class="shop-title">{{info.data.shop_name}}</text>
</view>
<image class="shop-share" mode="aspectFit" src="../../../static/images/share-ic@2x.png" bindtap="shareShop"></image>
</view>
</view>
<view class="filter-view {{fixedFilter ? 'fixed' : ''}}">
<product-list-filter bind:sortchange="sortChange"></product-list-filter>
</view>
<view class="filter-view-float-holder" wx:if="{{fixedFilter}}"></view>
<view class="list-view">
<view class="no-res" wx:if="{{noResult}}">
<image class="no-res-img" src="https://cdn.yoho.cn/yoho-brand-shop/assets/img/product/no-search-icon.png"></image>
<view class="no-res-txt">未搜索到任何相关商品</view>
</view>
<view wx:if="{{productList.length}}">
<product-list list="{{productList}}" show-loading="{{showLoading}}"
show-no-more="{{showNoMore}}"></product-list>
</view>
</view>
<copyright wx:if="{{!noResult}}"></copyright>
<quick-navigation show-menu="{{true}}" show-back-top="{{showBackTop}}" bindbacktop="backTop"></quick-navigation>
</view>
<template is="zan-actionsheet" data="{{...actionsheet}}" />
\ No newline at end of file
... ...
.shop-container .filter-view {
border-top: 1rpx solid #eee;
border-bottom: 1rpx solid #eee;
z-index: 10001;
background-color: #fff;
}
.shop-container .filter-view.fixed {
position: fixed;
top: 0;
left: 0;
right: 0;
}
.filter-view-float-holder {
height: 92rpx;
}
.shop-container .list-view {
padding-bottom: 65rpx;
}
.shop-info {
height: 235rpx;
display: flex;
width: 100%;
flex-direction: column;
justify-content: flex-start;
}
.shop-info-bg {
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: black;
}
.shop-logo-mask {
width: 100%;
background-color: rgba(0, 0, 0, 0.5);
}
.shop-info-content {
display: flex;
flex-direction: row;
align-items: flex-end;
width: 100%;
height: 120rpx;
margin-top: -140rpx;
}
.shop-info-content .shop-info-left {
height: 100%;
width: 689rpx;
display: flex;
flex-direction: row;
align-items: flex-end;
}
.shop-info-content .shop-info-left .shop-logo {
margin-left: 30rpx;
width: 120rpx;
height: 120rpx;
}
.shop-info-content .shop-info-left .shop-title {
color: white;
margin-left: 20rpx;
font-weight: bold;
font-size: 32rpx;
text-align: left;
width: 509rpx;
height: 34rpx;
line-height: 34rpx;
white-space: nowrap;
text-overflow: ellipsis;
display: block;
overflow: hidden;
margin-bottom: 20rpx;
}
.shop-info-content .shop-share {
width: 41rpx;
height: 42rpx;
margin-bottom: 10rpx;
}
.no-res {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
padding-top: 360rpx;
text-align: center;
background-color: #fff;
z-index: -1;
}
.no-res .no-res-img {
width: 204rpx;
height: 204rpx;
margin-top: 110rpx;
}
.no-res .no-res-txt {
font-size: 24rpx;
text-align: center;
margin-top: 21rpx;
color: #444;
}
... ...
import wx from '../../utils/wx';
import Yas from '../../common/yas';
import listModel from '../../models/product/list';
let yas;
const app = getApp();
const {windowHeight} = getApp().getSystemInfo();
Page({
data: {
order: '',
gender: '',
// 原始参数
orgOps: {},
page: 1,
limit: 20,
totalPage: 1,
allLoaded: false,
showNoMore: false,
productList: [],
noResult: false,
windowHeight
},
onLoad: function(options) {
Object.keys(options).map(key => {
options[key] = decodeURIComponent(options[key] || '');
});
wx.setNavigationBarTitle({
title: options.title || ''
});
delete options.title;
this.data.orgOps = options;
this._productList();
yas = new Yas();
yas.pageOpenReport();
},
onPageScroll: function({scrollTop}) {
if (scrollTop > windowHeight * 2 !== this.data.showBackTop) {
this.setData({
showBackTop: scrollTop > windowHeight * 2
});
}
},
backTop: function() {
wx.pageScrollTo({
scrollTop: 0
});
},
onReachBottom: function() {
this._productList(this.data.urlParams);
},
// 筛选变更
filterChange: function(e) {
let {curSort, gender} = e.detail;
this.data.order = curSort;
this.data.gender = gender;
this.data.addFilter = true;
this._resetPage();
this.data.productList = [];
this._productList();
},
_resetPage: function() {
this.data.page = 1;
this.data.totalPage = 1;
this.data.allLoaded = false;
},
// 商品列表
_productList: function(params = {}) {
if (this.data.allLoaded) {
return;
}
this.setData({
showLoading: true
});
Object.assign(params, this.data.orgOps, {
page: this.data.page,
limit: this.data.limit
});
if (this.data.addFilter) {
params.order = this.data.order;
params.gender = this.data.gender;
}
params.shop_id = app.getShopId();
listModel.categoryProductList(params).then(res => {
if (res.code === 200) {
const keyAdapter = {
skn: 'product_skn',
salesPrice: 'sales_price',
marketPrice: 'market_price',
productName: 'product_name',
defaultImages: 'default_images'
};
let list = [];
(res.data.product_list || []).forEach(product => {
let item = {};
Object.keys(keyAdapter).forEach(key => {
item[key] = product[keyAdapter[key]];
});
list.push(item);
});
this.data.page += 1;
this.data.totalPage = res.data && res.data.page_total || 1;
this.setData({
showLoading: false,
noResult: this.data.totalPage,
allLoaded: this.data.page > this.data.totalPage,
productList: this.data.productList.concat(list)
});
}
}).catch(() => {});
}
});
... ...
{
"navigationBarTitleText": "",
"usingComponents": {
"copyright": "/components/layout/copyright/copyright",
"product-list": "/components/product/list",
"product-list-filter": "/components/product/list-filter",
"quick-navigation": "/components/layout/quick-navigation/quick-navigation"
}
}
\ No newline at end of file
... ...
<view class="list-container" style="min-height:{{windowHeight}}px;">
<view class="filter-view">
<product-list-filter bind:sortchange="filterChange" cur-gender="{{gender}}"></product-list-filter>
</view>
<view class="list-view">
<view class="no-res" wx:if="{{noResult}}">
<image class="no-res-img" src="https://cdn.yoho.cn/yoho-brand-shop/assets/img/product/no-search-icon.png"></image>
<view class="no-res-txt">未搜索到任何相关商品</view>
</view>
<view wx:if="{{productList.length}}">
<product-list list="{{productList}}"
show-loading="{{showLoading}}"
show-no-more="{{showNoMore}}"></product-list>
</view>
</view>
<copyright class="copy-right"></copyright>
<quick-navigation show-menu="{{true}}" show-back-top="{{showBackTop}}" bindbacktop="backTop"></quick-navigation>
</view>
... ...
.list-container {
position: relative;
padding-bottom: 180rpx;
box-sizing: border-box;
}
.list-container .filter-view {
position: fixed;
top: 0;
left: 0;
right: 0;
border-top: 1rpx solid #eee;
border-bottom: 1rpx solid #eee;
z-index: 10001;
background-color: #fff;
}
.list-container .list-view {
padding-top: 88rpx;
padding-bottom: 65rpx;
}
.copy-right {
position: absolute;
bottom: 0;
right: 0;
left: 0;
}
.no-res {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
padding-top: 220rpx;
text-align: center;
background-color: #fff;
z-index: -1;
}
.no-res .no-res-img {
width: 204rpx;
height: 204rpx;
margin-top: 110rpx;
}
.no-res .no-res-txt {
font-size: 24rpx;
text-align: center;
margin-top: 21rpx;
color: #444;
}
... ...
{
"description": "项目配置文件。",
"setting": {
"urlCheck": false,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true
},
"compileType": "miniprogram",
"libVersion": "1.9.1",
"appid": "wxe8bfc9b404772199",
"projectname": "有货官方-VANS",
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"plugin": {
"current": -1,
"list": []
},
"game": {
"current": -1,
"list": []
},
"miniprogram": {
"current": -1,
"list": [
{
"id": 1,
"name": "useCoupon",
"pathName": "pages/useCoupon/useCoupon",
"query": ""
},
{
"id": -1,
"name": "paymentSuccessed",
"pathName": "pages/paymentSuccessed/paymentSuccessed",
"query": ""
},
{
"id": -1,
"name": "statements",
"pathName": "pages/statements/statements",
"query": ""
},
{
"id": 4,
"name": "详情",
"pathName": "pages/goodsDetail/goodsDetail",
"query": "productSkn=51193193"
},
{
"id": 5,
"name": "orderDetail",
"pathName": "pages/orders/orderDetail/orderDetail",
"query": "order_code= 35387004245"
},
{
"id": 6,
"name": "envelopesActivity",
"pathName": "pages/envelopesActivity/envelopesActivity",
"query": ""
},
{
"id": 6,
"name": "品类页",
"pathName": "pages/product/category/category",
"query": ""
},
{
"id": 8,
"name": "商品池",
"pathName": "pages/goodsList/productPool",
"query": "productPool=20564&title=GG"
},
{
"id": -1,
"name": "商品详情",
"pathName": "pages/goodsDetail/goodsDetail",
"query": "productSkn=294967295"
},
{
"id": -1,
"name": "品类列表",
"pathName": "pages/product/list/list",
"query": "title=T恤"
},
{
"id": -1,
"name": "店铺商品列表",
"pathName": "pages/product/list/shop",
"query": "title=VANS&shop_id=792"
},
{
"id": -1,
"name": "我的订单",
"pathName": "pages/home/order/order",
"query": ""
},
{
"id": 12,
"name": "订单结算页",
"pathName": "pages/cart/ensure/ensure",
"query": "productSku=2030768"
},
{
"id": -1,
"name": "商品详情页",
"pathName": "pages/goodsDetail/goodsDetail",
"query": "fromPage=home&fromParam=&productSkn=51829280"
},
{
"id": -1,
"name": "webview",
"pathName": "pages/webview/webview",
"query": "url=https://www.baidu.com&title=百度"
}
]
}
}
"description": "项目配置文件。",
"setting": {
"urlCheck": false,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true
},
"compileType": "miniprogram",
"libVersion": "1.9.1",
"appid": "wxe8bfc9b404772199",
"projectname": "有货官方-VANS",
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"plugin": {
"current": -1,
"list": []
},
"game": {
"current": -1,
"list": []
},
"miniprogram": {
"current": 1,
"list": [
{
"id": -1,
"name": "webview",
"pathName": "pages/webview/webview",
"query": "url=https://www.baidu.com&title=百度"
},
{
"id": -1,
"name": "goodsList",
"pathName": "pages/goodsList/goodsList",
"query": "gender=1,3&promotion=104&title=VIP价全开启"
}
]
}
}
}
\ No newline at end of file
... ...