Showing
6 changed files
with
77 additions
and
78 deletions
@@ -25,8 +25,8 @@ module.exports = { | @@ -25,8 +25,8 @@ module.exports = { | ||
25 | }); | 25 | }); |
26 | }, | 26 | }, |
27 | 27 | ||
28 | - /* 获取品牌介绍 */ | ||
29 | - getBrandIntro: (req, res) => { | 28 | + /* 获取品牌店铺介绍 */ |
29 | + getShopInfo: (req, res) => { | ||
30 | brandModel.getBrandData({ | 30 | brandModel.getBrandData({ |
31 | domain: req.query.domain, | 31 | domain: req.query.domain, |
32 | uid: req.user.uid | 32 | uid: req.user.uid |
@@ -86,8 +86,8 @@ module.exports = { | @@ -86,8 +86,8 @@ module.exports = { | ||
86 | /* 收藏店铺 */ | 86 | /* 收藏店铺 */ |
87 | collectShop: (req, res) => { | 87 | collectShop: (req, res) => { |
88 | brandModel.collectShopData({ | 88 | brandModel.collectShopData({ |
89 | - shopId: req.query.shopId, | ||
90 | - favId: req.query.favId, | 89 | + shopId: req.body.shopId, |
90 | + favId: req.body.favId, | ||
91 | uid: req.user.uid, | 91 | uid: req.user.uid, |
92 | type: 'shop' | 92 | type: 'shop' |
93 | }).then(result => { | 93 | }).then(result => { |
@@ -84,8 +84,7 @@ const getBrandData = params => { | @@ -84,8 +84,7 @@ const getBrandData = params => { | ||
84 | showBrandLogo: false, | 84 | showBrandLogo: false, |
85 | brandLogo: subResult[0].data.shop_logo, | 85 | brandLogo: subResult[0].data.shop_logo, |
86 | brandName: subResult[0].data.shop_name, | 86 | brandName: subResult[0].data.shop_name, |
87 | - brandIntro: subResult[0].data.shop_intro, | ||
88 | - showMore: false | 87 | + brandIntro: subResult[0].data.shop_intro |
89 | }); | 88 | }); |
90 | return finalResult; | 89 | return finalResult; |
91 | } else { | 90 | } else { |
@@ -114,7 +113,11 @@ const getBrandShopGoodsData = params => { | @@ -114,7 +113,11 @@ const getBrandShopGoodsData = params => { | ||
114 | 113 | ||
115 | /* TODO 获取店铺商品暂时没有接口 */ | 114 | /* TODO 获取店铺商品暂时没有接口 */ |
116 | return api.all([brandApi.getBrandShopGoodsOriginData(params)]).then(result => { | 115 | return api.all([brandApi.getBrandShopGoodsOriginData(params)]).then(result => { |
117 | - | 116 | + if (result[0].code === 200) { |
117 | + return finalResult; | ||
118 | + } else { | ||
119 | + logger.error('getBrandShopGoodsOriginData api code no 200'); | ||
120 | + } | ||
118 | }); | 121 | }); |
119 | }; | 122 | }; |
120 | 123 | ||
@@ -124,15 +127,10 @@ const getBrandShopGoodsData = params => { | @@ -124,15 +127,10 @@ const getBrandShopGoodsData = params => { | ||
124 | * @returns {*|Promise.<TResult>} | 127 | * @returns {*|Promise.<TResult>} |
125 | */ | 128 | */ |
126 | const collectShopData = params => { | 129 | const collectShopData = params => { |
127 | - let finalResult = {}; | ||
128 | 130 | ||
129 | - /* TODO 收藏店铺接口返回状态处理*/ | 131 | + /* TODO 收藏店铺接口返回状态处理 */ |
130 | return api.all([brandApi.collectShopOriginData(params)]).then(result => { | 132 | return api.all([brandApi.collectShopOriginData(params)]).then(result => { |
131 | - if (result[0].code === 200) { | ||
132 | - | ||
133 | - } else { | ||
134 | - logger.error('collectShopOriginData api code no 200'); | ||
135 | - } | 133 | + return result[0]; |
136 | }); | 134 | }); |
137 | }; | 135 | }; |
138 | 136 | ||
@@ -248,5 +246,6 @@ module.exports = { | @@ -248,5 +246,6 @@ module.exports = { | ||
248 | getBrandShopGoodsData, | 246 | getBrandShopGoodsData, |
249 | getBrandListData, | 247 | getBrandListData, |
250 | getCateListData, | 248 | getCateListData, |
251 | - getCateResource | 249 | + getCateResource, |
250 | + collectShopData | ||
252 | }; | 251 | }; |
@@ -16,14 +16,14 @@ const router = expressRouter(); | @@ -16,14 +16,14 @@ const router = expressRouter(); | ||
16 | router.get('/', channel.index); // 首页 | 16 | router.get('/', channel.index); // 首页 |
17 | router.get('/resources', channel.resources); // 资源位接口 | 17 | router.get('/resources', channel.resources); // 资源位接口 |
18 | router.get('/brand', brand.index); // 店铺首页 | 18 | router.get('/brand', brand.index); // 店铺首页 |
19 | -router.get('/get-brand-intro', brand.getBrandIntro); // 店铺介绍 | 19 | +router.get('/get-shop-info', brand.getShopInfo); // 店铺介绍 |
20 | router.post('/get-brand-shop-goods', brand.getBrandShopGoods); // 店铺介绍 | 20 | router.post('/get-brand-shop-goods', brand.getBrandShopGoods); // 店铺介绍 |
21 | router.get('/brand-list', brand.brandList); // 品牌列表页 | 21 | router.get('/brand-list', brand.brandList); // 品牌列表页 |
22 | router.get('/get-brand-list', brand.getBrandList); // 获取品牌列表数据 | 22 | router.get('/get-brand-list', brand.getBrandList); // 获取品牌列表数据 |
23 | router.get('/brand-share', brand.brandShare); // 获取品牌列表数据 | 23 | router.get('/brand-share', brand.brandShare); // 获取品牌列表数据 |
24 | 24 | ||
25 | router.get('/cate-resource', brand.cateResource); // 品类资源位页面 | 25 | router.get('/cate-resource', brand.cateResource); // 品类资源位页面 |
26 | -router.get('/collect-shop', brand.collectShop); // 收藏品牌店铺 | 26 | +router.post('/collect-shop', brand.collectShop); // 收藏品牌店铺 |
27 | router.get('/cate', brand.cate); // 全部分类 | 27 | router.get('/cate', brand.cate); // 全部分类 |
28 | router.get('/get-cate-list', brand.getCateList); // 全部分类数据列表 | 28 | router.get('/get-cate-list', brand.getCateList); // 全部分类数据列表 |
29 | 29 |
1 | <template> | 1 | <template> |
2 | - <brand-top v-bind:share-data="shareData"></brand-top> | ||
3 | - <brand-shop-top></brand-shop-top> | 2 | + <brand-top-bar v-bind:share-data="shareData"></brand-top-bar> |
3 | + <brand-shop-top v-bind:shop-info="shopInfo"></brand-shop-top> | ||
4 | <goods-list v-bind:data="productList"></goods-list> | 4 | <goods-list v-bind:data="productList"></goods-list> |
5 | <drawer v-ref:drawer> | 5 | <drawer v-ref:drawer> |
6 | <filter :config.once="filterConfig"></filter> | 6 | <filter :config.once="filterConfig"></filter> |
@@ -9,10 +9,11 @@ | @@ -9,10 +9,11 @@ | ||
9 | 9 | ||
10 | <script> | 10 | <script> |
11 | const $ = require('yoho-jquery'); | 11 | const $ = require('yoho-jquery'); |
12 | + const qs = require('yoho-qs'); | ||
12 | const bus = require('common/vue-bus'); | 13 | const bus = require('common/vue-bus'); |
13 | const tip = require('common/tip'); | 14 | const tip = require('common/tip'); |
14 | - const brandTop = require('channel/brand-top.vue'); | ||
15 | - const brandShopTop = require('channel/brand-shop-top.vue'); | 15 | + const brandTopBar = require('channel/brand-top-bar.vue'); // 顶部栏,包括返回、收藏店铺、分享,打开筛选页面 |
16 | + const brandShopTop = require('channel/brand-shop-top.vue'); // 店铺头部信息 | ||
16 | const goodsList = require('product/list.vue'); | 17 | const goodsList = require('product/list.vue'); |
17 | const drawer = require('product/drawer.vue'); | 18 | const drawer = require('product/drawer.vue'); |
18 | const filter = require('product/filter.vue'); | 19 | const filter = require('product/filter.vue'); |
@@ -22,11 +23,10 @@ | @@ -22,11 +23,10 @@ | ||
22 | module.exports = { | 23 | module.exports = { |
23 | data() { | 24 | data() { |
24 | return { | 25 | return { |
25 | - shareData: { | ||
26 | - title: 'BLK', | ||
27 | - link: 'm.blk.com', | ||
28 | - img: 'https://img11.static.yhbimg.com/brandLogo/2016/04/13/15/010eb8606c1072fd2e769c62567d3bbe93.png?imageView2/2/w/140/h/140' | ||
29 | - }, | 26 | + domain: qs.domain, |
27 | + shareData: {}, // 分享相关数据 | ||
28 | + shopInfo: {}, // 店铺介绍相关数据 | ||
29 | + | ||
30 | sortConfig: global.sortConfig, | 30 | sortConfig: global.sortConfig, |
31 | filterConfig: global.filterConfig, | 31 | filterConfig: global.filterConfig, |
32 | 32 | ||
@@ -45,6 +45,10 @@ | @@ -45,6 +45,10 @@ | ||
45 | }; | 45 | }; |
46 | }, | 46 | }, |
47 | watch: { | 47 | watch: { |
48 | + domain: function() { | ||
49 | + this.getShopInfo(); | ||
50 | + }, | ||
51 | + | ||
48 | /* sort 和 filter 改变 都会触发 重新搜索 (想象成清空所有分页) */ | 52 | /* sort 和 filter 改变 都会触发 重新搜索 (想象成清空所有分页) */ |
49 | sort: function() { | 53 | sort: function() { |
50 | this.research(); | 54 | this.research(); |
@@ -54,6 +58,28 @@ | @@ -54,6 +58,28 @@ | ||
54 | } | 58 | } |
55 | }, | 59 | }, |
56 | methods: { | 60 | methods: { |
61 | + | ||
62 | + /* 获取店铺简介相关数据 */ | ||
63 | + getShopInfo() { | ||
64 | + $.get({ | ||
65 | + url: '/get-shop-info', | ||
66 | + data: { domain: this.domain } | ||
67 | + }).done(result => { | ||
68 | + if (result) { | ||
69 | + this.shopInfo = result; | ||
70 | + this.shopInfo.showBrandInfo = true; | ||
71 | + this.shareData = { | ||
72 | + title: result.brandName, | ||
73 | + link: '/brand-share?domain=' + this.domain, | ||
74 | + img: result.brandBg | ||
75 | + }; | ||
76 | + } else { | ||
77 | + this.shopInfo.showBrandInfo = false; | ||
78 | + } | ||
79 | + }).fail(() => { | ||
80 | + tip('网络错误'); | ||
81 | + }); | ||
82 | + }, | ||
57 | getProductList() { | 83 | getProductList() { |
58 | let data = {}; | 84 | let data = {}; |
59 | 85 | ||
@@ -106,14 +132,16 @@ | @@ -106,14 +132,16 @@ | ||
106 | } | 132 | } |
107 | }, | 133 | }, |
108 | components: { | 134 | components: { |
109 | - brandTop, | 135 | + brandTopBar, |
110 | brandShopTop, | 136 | brandShopTop, |
111 | goodsList, | 137 | goodsList, |
112 | drawer, | 138 | drawer, |
113 | filter | 139 | filter |
114 | }, | 140 | }, |
115 | created() { | 141 | created() { |
116 | - this.search(); | 142 | + this.getShopInfo(); |
143 | + | ||
144 | +// this.search(); | ||
117 | bus.$on('list.paging', function() { | 145 | bus.$on('list.paging', function() { |
118 | this.search(); | 146 | this.search(); |
119 | }); | 147 | }); |
1 | <template> | 1 | <template> |
2 | - <div v-if="showBrandInfo" class="brand-top-box" v-bind:style="{ 'background-image': `url(${brandIntro.brandBg})` }"> | 2 | + <div v-if="shopInfo.showBrandInfo" class="brand-top-box" v-bind:style="{ 'background-image': `url(${shopInfo.brandBg})` }"> |
3 | <div class="brand-bottom"> | 3 | <div class="brand-bottom"> |
4 | - <img v-if="brandIntro.showBrandLogo" v-lazy="brandIntro.brandLogo" alt="{{ brandIntro.brandName }}"> | ||
5 | - <div v-else class="brand-title">{{ brandIntro.brandName }}</div> | 4 | + <img v-if="shopInfo.showBrandLogo" v-lazy="brandIntro.brandLogo" alt="{{ shopInfo.brandName }}"> |
5 | + <div v-else class="brand-title">{{ shopInfo.brandName }}</div> | ||
6 | <hr> | 6 | <hr> |
7 | - <div v-show="showMore" transition="brand-intro" v-bind:class="{ 'brand-short': !showMore }">{{ brandIntro.brandIntro }}</div> | 7 | + <div v-show="showMore" transition="brand-intro" v-bind:class="{ 'brand-short': !showMore }">{{ shopInfo.brandIntro }}</div> |
8 | </div> | 8 | </div> |
9 | <div v-if="!showMore" class="showmore expand" @click="introTrans()"><span class="icon"></span></div> | 9 | <div v-if="!showMore" class="showmore expand" @click="introTrans()"><span class="icon"></span></div> |
10 | <div v-else class="showmore collapse" @click="introTrans()"><span class="icon"></span></div> | 10 | <div v-else class="showmore collapse" @click="introTrans()"><span class="icon"></span></div> |
@@ -42,7 +42,7 @@ | @@ -42,7 +42,7 @@ | ||
42 | transition: all 0.3s ease; | 42 | transition: all 0.3s ease; |
43 | font-size: 16px; | 43 | font-size: 16px; |
44 | line-height: 32px; | 44 | line-height: 32px; |
45 | - width: 82%; | 45 | + width: 90%; |
46 | height: 220px; | 46 | height: 220px; |
47 | overflow-y: auto; | 47 | overflow-y: auto; |
48 | } | 48 | } |
@@ -57,7 +57,7 @@ | @@ -57,7 +57,7 @@ | ||
57 | display: -webkit-box !important; | 57 | display: -webkit-box !important; |
58 | font-size: 16px; | 58 | font-size: 16px; |
59 | line-height: 32px; | 59 | line-height: 32px; |
60 | - width: 82%; | 60 | + width: 90%; |
61 | text-overflow: ellipsis; | 61 | text-overflow: ellipsis; |
62 | overflow-y: hidden; | 62 | overflow-y: hidden; |
63 | display: -webkit-box; | 63 | display: -webkit-box; |
@@ -77,47 +77,21 @@ | @@ -77,47 +77,21 @@ | ||
77 | } | 77 | } |
78 | </style> | 78 | </style> |
79 | <script> | 79 | <script> |
80 | - const $ = require('yoho-jquery'); | ||
81 | - const tip = require('common/tip'); | ||
82 | - const qs = require('yoho-qs'); | ||
83 | - | ||
84 | module.exports = { | 80 | module.exports = { |
81 | + props: { | ||
82 | + shopInfo: { | ||
83 | + type: Object | ||
84 | + } | ||
85 | + }, | ||
85 | data() { | 86 | data() { |
86 | return { | 87 | return { |
87 | - brandIntro: {}, | ||
88 | - showMore: false, | ||
89 | - showBrandInfo: false | 88 | + showMore: false |
90 | }; | 89 | }; |
91 | }, | 90 | }, |
92 | - watch: { | ||
93 | - domain() { | ||
94 | - this.getShopIntro(); | ||
95 | - } | ||
96 | - }, | ||
97 | methods: { | 91 | methods: { |
98 | - getShopIntro() { | ||
99 | - let data = { | ||
100 | - domain: qs.domain | ||
101 | - }; | ||
102 | - | ||
103 | - $.ajax({ | ||
104 | - url: '/get-brand-intro', | ||
105 | - data: data | ||
106 | - }).then(result => { | ||
107 | - if (result) { | ||
108 | - this.showBrandInfo = true; | ||
109 | - this.brandIntro = result; | ||
110 | - } | ||
111 | - }).fail(() => { | ||
112 | - tip('网络错误'); | ||
113 | - }); | ||
114 | - }, | ||
115 | introTrans() { | 92 | introTrans() { |
116 | this.showMore = this.showMore !== true; | 93 | this.showMore = this.showMore !== true; |
117 | } | 94 | } |
118 | - }, | ||
119 | - created() { | ||
120 | - this.getShopIntro(); | ||
121 | } | 95 | } |
122 | }; | 96 | }; |
123 | </script> | 97 | </script> |
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | <div class="top-box clearfix"> | 2 | <div class="top-box clearfix"> |
3 | <span class="icon back" @click="goBack()"></span> | 3 | <span class="icon back" @click="goBack()"></span> |
4 | <div class="right"> | 4 | <div class="right"> |
5 | - <span class="icon" v-bind:class="{'favorite': isFav}" @click="collectShop()"></span> | 5 | + <span class="icon" v-bind:class="{'favorite': shareData.isFav}" @click="collectShop()"></span> |
6 | <span class="icon share" @click="goShare()"></span> | 6 | <span class="icon share" @click="goShare()"></span> |
7 | <span class="icon filter" @click="showFilter()"></span> | 7 | <span class="icon filter" @click="showFilter()"></span> |
8 | </div> | 8 | </div> |
@@ -59,32 +59,30 @@ | @@ -59,32 +59,30 @@ | ||
59 | }, | 59 | }, |
60 | methods: { | 60 | methods: { |
61 | goShare() { | 61 | goShare() { |
62 | - | ||
63 | - // TODO 这边应该需要一个分享后的页面链接,需要与 APP 确定分享要传的参数 | ||
64 | - let link = this.shareData.title + | ||
65 | - this.shareData.link + | ||
66 | - this.shareData.img; | ||
67 | - | ||
68 | - yoho.goShare({link: link}, function() {}, function() {}); | 62 | + yoho.goShare(this.shareData, function() {}, function() {}); |
69 | }, | 63 | }, |
70 | goBack() { | 64 | goBack() { |
71 | yoho.goBack({}, function() {}, function() {}); | 65 | yoho.goBack({}, function() {}, function() {}); |
72 | }, | 66 | }, |
67 | + | ||
68 | + /* 收藏或者取消收藏店铺 */ | ||
73 | collectShop() { | 69 | collectShop() { |
74 | 70 | ||
75 | /* TODO 获取数据策略待确定 */ | 71 | /* TODO 获取数据策略待确定 */ |
76 | let data = { | 72 | let data = { |
77 | shopId: this.shareData.shopId, | 73 | shopId: this.shareData.shopId, |
78 | - favId: this.shareData.shopId, | ||
79 | isFav: this.shareData.isFav | 74 | isFav: this.shareData.isFav |
80 | }; | 75 | }; |
81 | 76 | ||
82 | - $.ajax({ | 77 | + $.post({ |
83 | url: '/collect-shop', | 78 | url: '/collect-shop', |
84 | data: data | 79 | data: data |
85 | }).done(result => { | 80 | }).done(result => { |
86 | - | ||
87 | - /* TODO 处理收藏状态 */ | 81 | + if (result.code === 200) { |
82 | + this.shareData.isFav = this.shareData.isFav !== true; | ||
83 | + } else { | ||
84 | + tip('网络错误'); | ||
85 | + } | ||
88 | }).fail(() => { | 86 | }).fail(() => { |
89 | tip('网络错误'); | 87 | tip('网络错误'); |
90 | }); | 88 | }); |
-
Please register or login to post a comment