Authored by 李奇

店铺分类页修改

... ... @@ -3,7 +3,6 @@ import udid from './common/udid';
import event from './common/event';
import {verify} from './common/api';
import config from './common/config';
import commonModel from './models/common';
import Promise from './vendors/es6-promise';
import { MD5 } from './vendors/crypto';
import { wechatAuthLogin, verifySessionKey } from './common/login';
... ... @@ -75,9 +74,6 @@ App({
this.globalData.systemInfo = res;
});
// 获取关联店铺
this.getUnionShop();
// 设置渠道来源
if (options && options.query && options.query.union_type) {
this.globalData.union_type = options.query.union_type;
... ... @@ -118,21 +114,6 @@ App({
this.wechatAuthLogin();
}, 1000);
},
getUnionShop() {
return commonModel.getBindShop({ app_id: config.appid})
.then(res => {
if (res.code === 200) {
if (res.data && res.data.shopId) {
this.globalData.appShopId = res.data.shopId;
this.globalData.appUnionType = res.data.unionType;
this._setSync('app_bind_shop_id', res.data.shopId);
this._setSync('app_bind_union_type', res.data.unionType);
event.emit('app_shop_id_update');
}
}
})
.catch(() => {});
},
_getSync(key) {
try {
return wx.getStorageSync(key);
... ... @@ -280,7 +261,8 @@ App({
return config.unionType;
},
getShopId() {
return this.globalData.appShopId || this._getSync('app_bind_shop_id');
return this.globalData.unionShop && this.globalData.unionShop.shopId ||
this._getSync('unionShop').shopId;
},
getAppId() {
return config.appid;
... ...
... ... @@ -17,7 +17,7 @@
"pages/product/list/shop",
"pages/product/search/search",
"pages/product/detail/detail",
"pages/product/category/category"
"pages/shop/category/category"
],
"window": {
"navigationBarTextStyle": "white",
... ... @@ -38,7 +38,7 @@
"selectedIconPath": "static/images/home-dark.png"
},
{
"pagePath": "pages/product/category/category",
"pagePath": "pages/shop/category/category",
"text": "分类",
"iconPath": "static/images/category-light.png",
"selectedIconPath": "static/images/category-dark.png"
... ...
import api from '../../common/api';
export default {
categoryList(id) {
return api.get({
data: {
channel_id: id,
method: 'app.distribution.category'
}
});
},
subCategoryList({id, channelId}) {
return api.get({
data: {
categoryId: id,
channel_id: channelId,
method: 'app.distribution.subCategory'
}
});
}
};
import api from '../../common/api';
export default {
shopSort(params) {
return api.get({
data: Object.assign({
method: 'app.shop.getSortInfo'
}, params)
});
}
};
... ...
... ... @@ -28,6 +28,9 @@ Page({
if (res.code === 200 && res.data.shopId) {
const id = res.data.shopId;
app.globalData.unionShop = res.data;
app._setSync('unionShop', res.data);
this.getShopData(id);
this.getShopProducts(id);
} else {
... ...
Page({
data: {
show: false
},
onLoad: function() {
},
onShow: function() {
},
expandItem: function(e) {
if (e.target) {
this.setData({
show: !this.data.show
});
}
}
});
<wxs src="../../../wxs/helper.wxs" module="helper" />
<view class="container category">
<view class="gap"></view>
<view class="all">全部商品</view>
<view class="gap"></view>
<view class="items" >
<view class="item" bindtap="expandItem">上衣</view>
<view class="item">裤装</view>
<view class="item">鞋靴</view>
<view class="item">包类</view>
<view class="item">裙装</view>
<view class="item">服配</view>
<view class="item-expand {{show ? 'open' : ''}}">
</view>
</view>
</view>
import cateModel from '../../../models/shop/category';
const app = getApp();
Page({
data: {
expand: false,
expandIndex: 0,
cateList: [],
subCateList: []
},
onLoad: function() {
},
onShow: function() {
this.getSort();
},
getSort: function() {
cateModel.shopSort({shop_id: app.getShopId()}).then(res => {
this.setData({
cateList: res.data
});
});
},
expandItem: function(e) {
const {idx} = e.currentTarget.dataset;
const sub = this.data.cateList[idx].sub;
if (!this.data.expand) {
this.setData({
expand: true,
expandIndex: idx,
subCateList: sub
});
} else {
if (idx === this.data.expandIndex) {
this.setData({
expand: false,
subCateList: []
});
} else {
this.setData({
expand: true,
expandIndex: idx,
subCateList: sub
});
}
}
}
});
... ...
<wxs src="../../../wxs/helper.wxs" module="helper" />
<view class="container category">
<view class="gap"></view>
<view class="all">全部商品</view>
<view class="gap"></view>
<view class="items">
<view class="item" wx:for="{{cateList}}" data-idx="{{index}}" bindtap="expandItem">
{{item.category_name}}
</view>
<view class="item-expand {{expand ? 'open' : ''}}">
<view class="sub-item" wx:for="{{subCateList}}" wx:for-item="subItem" wx:key="index">
{{subItem.category_name}}
</view>
</view>
</view>
</view>
... ...
... ... @@ -41,6 +41,10 @@
transition: left 0.4s linear;
}
.category .item-expand .sub-item {
font-size: 24rpx;
}
.category .item-expand.open {
left: 40%;
left: 50%;
}
... ...
... ... @@ -10,7 +10,7 @@ export default {
productSearch: {path: '/pages/product/search/search'},
productShop: {path: '/pages/product/list/shop', report: {pageName: 'brandStore', paramKey: 'shopId'}},
productDetail: {path: '/pages/product/detail/detail', report: {paramKey: 'productSkn'}},
productCategory: {path: '/pages/product/category/category', type: jump.switchTab, report: {pageName: 'category'}},
shopCategory: {path: '/pages/shop/category/category', type: jump.switchTab, report: {pageName: 'category'}},
userCenter: {path: '/pages/home/home', type: jump.switchTab},
service: {path: '/pages/home/service/service'},
address: {path: '/pages/home/address/list', auth: true },
... ...