Authored by ccbikai

Merge branch 'feature/brand' into develop

@@ -39,7 +39,6 @@ module.exports = { @@ -39,7 +39,6 @@ module.exports = {
39 getCateListData(params) { 39 getCateListData(params) {
40 return api.get('', Object.assign(params, { 40 return api.get('', Object.assign(params, {
41 method: 'app.sort.get' 41 method: 'app.sort.get'
42 - })  
43 - ); 42 + }));
44 } 43 }
45 }; 44 };
@@ -51,7 +51,7 @@ module.exports = { @@ -51,7 +51,7 @@ module.exports = {
51 }, 51 },
52 52
53 /** 53 /**
54 - * TODO 从接口获得店铺装修资源 54 + * 从接口获得店铺装修资源
55 * @param params 55 * @param params
56 * @returns {*} 56 * @returns {*}
57 */ 57 */
@@ -11,6 +11,7 @@ const shopApi = require('./shop-api'); @@ -11,6 +11,7 @@ const shopApi = require('./shop-api');
11 const path = require('path'); 11 const path = require('path');
12 const processProductList = require(path.join(global.utils, '/beautify/product')).processProductList; 12 const processProductList = require(path.join(global.utils, '/beautify/product')).processProductList;
13 const camelCase = global.yoho.camelCase; 13 const camelCase = global.yoho.camelCase;
  14 +const _ = require('lodash');
14 15
15 /** 16 /**
16 * 获取品牌店铺数据 17 * 获取品牌店铺数据
@@ -26,8 +27,14 @@ const getShopData = params => { @@ -26,8 +27,14 @@ const getShopData = params => {
26 27
27 if (result[0].code === 200) { 28 if (result[0].code === 200) {
28 29
29 - /* 品牌有店铺 */ 30 + /* 品牌是否有店铺 */
30 if (result[0].data.shop_id) { 31 if (result[0].data.shop_id) {
  32 +
  33 + /* 是 BLK 的店铺 */
  34 + Object.assign(finalResult, {
  35 + isBlkShop: true
  36 + });
  37 +
31 return api.all([ 38 return api.all([
32 shopApi.getShopInfoData({ 39 shopApi.getShopInfoData({
33 shopId: result[0].data.shop_id, 40 shopId: result[0].data.shop_id,
@@ -36,33 +43,61 @@ const getShopData = params => { @@ -36,33 +43,61 @@ const getShopData = params => {
36 ]).then(subResult => { 43 ]).then(subResult => {
37 if (subResult[0].code === 200) { 44 if (subResult[0].code === 200) {
38 45
39 - /* TODO 判断是否是使用 BLK 模板,不使用 BLK 模板的就直接返回 */  
40 - if (subResult[0].data.shop_template_type === '2') {  
41 - Object.assign(finalResult, { 46 + /* 取店铺的基本信息 */
  47 + Object.assign(finalResult, {
  48 + brandLogo: subResult[0].data.shop_logo,
  49 + brandName: subResult[0].data.shop_name,
  50 + brandIntro: subResult[0].data.shop_intro
  51 + });
  52 +
  53 + /* TODO shop_template_type 待接口确认 */
  54 + if (subResult[0].data.shop_template_type === '3') {
  55 +
  56 + /* 取资源位店铺背景图 */
  57 + return api.all([
  58 + shopApi.getShopsDecoratorList({shopId: result[0].data.shop_id})
  59 + ]).then(thResult => {
  60 + if (thResult.code === 200) {
  61 + _.forEach(thResult[0].data.list, value => {
  62 +
  63 + /* TODO resource_name 待接口确认 */
  64 + if (value.resource_name === 'shopTopBanner_BLK') {
  65 + Object.assign(finalResult, {
  66 + brandBg: value.resource_data.shopSrc
  67 + });
  68 + }
  69 + });
42 70
43 - /* TODO 背景图取资源位,接口未开发 */  
44 - brandBg: 'http://7xwj52.com1.z0.glb.clouddn.com/brandbg.jpg', 71 + } else {
  72 + logger.info('getShopsDecoratorList api code no 200');
  73 + }
45 74
46 - /* TODO 是否显示店铺 LOGO,接口未开发 */  
47 - showBrandLogo: false,  
48 - brandLogo: subResult[0].data.shop_logo,  
49 - brandName: subResult[0].data.shop_name,  
50 - brandIntro: subResult[0].data.shop_intro 75 + return finalResult;
51 }); 76 });
52 - return finalResult; 77 +
53 } else { 78 } else {
54 - logger.info('no BLK template'); 79 + logger.info('no BLK template resource');
55 } 80 }
56 } else { 81 } else {
57 logger.error('getShopInfoData api code no 200'); 82 logger.error('getShopInfoData api code no 200');
58 } 83 }
  84 +
  85 + return finalResult;
59 }); 86 });
60 } else { 87 } else {
  88 +
  89 + /* 不是 BLK 的店铺 */
  90 + Object.assign(finalResult, {
  91 + isBlkShop: false
  92 + });
  93 +
61 logger.info('brand has no shop'); 94 logger.info('brand has no shop');
62 } 95 }
63 } else { 96 } else {
64 logger.error('getBrandOriginData api code no 200'); 97 logger.error('getBrandOriginData api code no 200');
65 } 98 }
  99 +
  100 + return finalResult;
66 }); 101 });
67 }; 102 };
68 103
@@ -249,7 +249,9 @@ const yoho = { @@ -249,7 +249,9 @@ const yoho = {
249 * @param callback 回调 249 * @param callback 回调
250 */ 250 */
251 addNativeMethod(name, callback) { 251 addNativeMethod(name, callback) {
252 - window.yohoInterface[name] = callback; 252 + if (window.yohoInterface) {
  253 + window.yohoInterface[name] = callback;
  254 + }
253 } 255 }
254 }; 256 };
255 257
@@ -31,6 +31,14 @@ @@ -31,6 +31,14 @@
31 return { 31 return {
32 yoho 32 yoho
33 }; 33 };
  34 + },
  35 + created() {
  36 + yoho.addNativeMethod('headerRightTopBtn', function(data) {
  37 + alert('app 调用 H5 成功!');
  38 + if (data) {
  39 + alert('传递的信息是:' + data);
  40 + }
  41 + });
34 } 42 }
35 }; 43 };
36 </script> 44 </script>
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 <div class="brand-title">{{ brandName }}</div> 4 <div class="brand-title">{{ brandName }}</div>
5 <div class="brand-intro">{{ brandIntro }}</div> 5 <div class="brand-intro">{{ brandIntro }}</div>
6 <div class="tip">进入 BLK 选购潮品</div> 6 <div class="tip">进入 BLK 选购潮品</div>
7 - <div class="arrow">i</div> 7 + <div class="icon arrow">&#xe602;</div>
8 <img v-lazy="brandBg | resize 752 365"> 8 <img v-lazy="brandBg | resize 752 365">
9 </div> 9 </div>
10 <share-bottom></share-bottom> 10 <share-bottom></share-bottom>
1 <template> 1 <template>
2 - <div v-if="shopInfo.showBrandInfo" class="brand-top-box" v-bind:style="{ 'background-image': `url(${shopInfo.brandBg})` }"> 2 + <div v-if="shopInfo.isBlkShop" 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="shopInfo.showBrandLogo" v-lazy="brandIntro.brandLogo" alt="{{ shopInfo.brandName }}"> 4 <img v-if="shopInfo.showBrandLogo" v-lazy="brandIntro.brandLogo" alt="{{ shopInfo.brandName }}">
5 <div v-else class="brand-title">{{ shopInfo.brandName }}</div> 5 <div v-else class="brand-title">{{ shopInfo.brandName }}</div>