Authored by 郭成尧

分享优化

600 Bytes | W: | H:

2.66 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
@@ -8,12 +8,12 @@ @@ -8,12 +8,12 @@
8 * 8 *
9 * 希望能与 微信 JS-SDK 一样方便 9 * 希望能与 微信 JS-SDK 一样方便
10 */ 10 */
11 -const $ = require('yoho-jquery'); 11 +
12 const tip = require('common/tip'); 12 const tip = require('common/tip');
13 const native = window.yohoInterface; 13 const native = window.yohoInterface;
14 14
15 window.yohoWapInterface = { 15 window.yohoWapInterface = {
16 - headerRightTopBtn: $.loop() 16 + headerRightTopBtn: function() {}
17 }; 17 };
18 18
19 const yoho = { 19 const yoho = {
@@ -35,7 +35,7 @@ const yoho = { @@ -35,7 +35,7 @@ const yoho = {
35 */ 35 */
36 goTap(args, success, fail) { 36 goTap(args, success, fail) {
37 if (this.isApp) { 37 if (this.isApp) {
38 - native.triggerEvent(success || $.loop(), fail || $.loop(), { 38 + native.triggerEvent(success || function() {}, fail || function() {}, {
39 method: 'go.tab', 39 method: 'go.tab',
40 arguments: args 40 arguments: args
41 }); 41 });
@@ -52,7 +52,7 @@ const yoho = { @@ -52,7 +52,7 @@ const yoho = {
52 */ 52 */
53 goLogin(args, success, fail) { 53 goLogin(args, success, fail) {
54 if (this.isApp) { 54 if (this.isApp) {
55 - native.triggerEvent(success || $.loop(), fail || $.loop(), { 55 + native.triggerEvent(success || function() {}, fail || function() {}, {
56 method: 'go.login', 56 method: 'go.login',
57 arguments: args 57 arguments: args
58 }); 58 });
@@ -69,7 +69,7 @@ const yoho = { @@ -69,7 +69,7 @@ const yoho = {
69 */ 69 */
70 goShopingCart(args, success, fail) { 70 goShopingCart(args, success, fail) {
71 if (this.isApp) { 71 if (this.isApp) {
72 - native.triggerEvent(success || $.loop(), fail || $.loop(), { 72 + native.triggerEvent(success || function() {}, fail || function() {}, {
73 method: 'go.shopingCart', 73 method: 'go.shopingCart',
74 arguments: args 74 arguments: args
75 }); 75 });
@@ -86,7 +86,7 @@ const yoho = { @@ -86,7 +86,7 @@ const yoho = {
86 */ 86 */
87 goAddress(args, success, fail) { 87 goAddress(args, success, fail) {
88 if (this.isApp) { 88 if (this.isApp) {
89 - native.triggerEvent(success || $.loop(), fail || $.loop(), { 89 + native.triggerEvent(success || function() {}, fail || function() {}, {
90 method: 'go.address', 90 method: 'go.address',
91 arguments: args 91 arguments: args
92 }); 92 });
@@ -103,7 +103,7 @@ const yoho = { @@ -103,7 +103,7 @@ const yoho = {
103 */ 103 */
104 goImageBrowser(args, success, fail) { 104 goImageBrowser(args, success, fail) {
105 if (this.isApp) { 105 if (this.isApp) {
106 - native.triggerEvent(success || $.loop(), fail || $.loop(), { 106 + native.triggerEvent(success || function() {}, fail || function() {}, {
107 method: 'go.imageBrowser', 107 method: 'go.imageBrowser',
108 arguments: args 108 arguments: args
109 }); 109 });
@@ -120,7 +120,7 @@ const yoho = { @@ -120,7 +120,7 @@ const yoho = {
120 */ 120 */
121 goNewPage(args, success, fail) { 121 goNewPage(args, success, fail) {
122 if (this.isApp) { 122 if (this.isApp) {
123 - native.triggerEvent(success || $.loop(), fail || $.loop(), { 123 + native.triggerEvent(success || function() {}, fail || function() {}, {
124 method: 'go.newPage', 124 method: 'go.newPage',
125 arguments: args 125 arguments: args
126 }); 126 });
@@ -137,7 +137,7 @@ const yoho = { @@ -137,7 +137,7 @@ const yoho = {
137 */ 137 */
138 goPay(args, success, fail) { 138 goPay(args, success, fail) {
139 if (this.isApp) { 139 if (this.isApp) {
140 - native.triggerEvent(success || $.loop(), fail || $.loop(), { 140 + native.triggerEvent(success || function() {}, fail || function() {}, {
141 method: 'go.pay', 141 method: 'go.pay',
142 arguments: args 142 arguments: args
143 }); 143 });
@@ -147,6 +147,40 @@ const yoho = { @@ -147,6 +147,40 @@ const yoho = {
147 }, 147 },
148 148
149 /** 149 /**
  150 + * 回到上一个原生界面
  151 + * @param args
  152 + * @param success
  153 + * @param fail
  154 + */
  155 + goBack(args, success, fail) {
  156 + if (this.isApp) {
  157 + native.triggerEvent(success || function() {}, fail || function() {}, {
  158 + method: 'go.back',
  159 + arguments: args
  160 + });
  161 + } else {
  162 + tip('暂不支持,请在BLK应用中打开');
  163 + }
  164 + },
  165 +
  166 + /**
  167 + * 分享
  168 + * @param args
  169 + * @param success
  170 + * @param fail
  171 + */
  172 + goShare(args, success, fail) {
  173 + if (this.isApp) {
  174 + native.triggerEvent(success || function() {}, fail || function() {}, {
  175 + method: 'go.share',
  176 + arguments: args
  177 + });
  178 + } else {
  179 + tip('暂不支持,请在BLK应用中打开');
  180 + }
  181 + },
  182 +
  183 + /**
150 * 原生调用 JS 方法 184 * 原生调用 JS 方法
151 * @param name 方法名 185 * @param name 方法名
152 * @param callback 回调 186 * @param callback 回调
1 <template> 1 <template>
2 - <brand-top-cmpnt v-bind:share-Link="shareLink"></brand-top-cmpnt> 2 + <brand-top-cmpnt v-bind:share-data="shareData"></brand-top-cmpnt>
3 <brand-shop-top-cmpnt v-bind:domain="'nike'"></brand-shop-top-cmpnt> 3 <brand-shop-top-cmpnt v-bind:domain="'nike'"></brand-shop-top-cmpnt>
4 <!--<goods-list v-bind:data="productList"></goods-list>--> 4 <!--<goods-list v-bind:data="productList"></goods-list>-->
5 </template> 5 </template>
@@ -11,13 +11,14 @@ @@ -11,13 +11,14 @@
11 const brandShopTopCmpnt = require('channel/brand-shop-top.vue'); 11 const brandShopTopCmpnt = require('channel/brand-shop-top.vue');
12 const goodsList = require('product/list.vue'); 12 const goodsList = require('product/list.vue');
13 13
14 - // TODO 确定分享页面后需要添加拼接分享链接的公共方法  
15 - let shareLink = 'http://www.yohobuy.com';  
16 -  
17 module.exports = { 14 module.exports = {
18 data() { 15 data() {
19 return { 16 return {
20 - shareLink: shareLink, 17 + shareData: {
  18 + title: 'BLK',
  19 + link: 'm.blk.com',
  20 + img: 'https://img11.static.yhbimg.com/brandLogo/2016/04/13/15/010eb8606c1072fd2e769c62567d3bbe93.png?imageView2/2/w/140/h/140'
  21 + },
21 productList: [] 22 productList: []
22 }; 23 };
23 }, 24 },
1 <template> 1 <template>
2 <div class="top-box clearfix"> 2 <div class="top-box clearfix">
3 - <i class="back"></i> 3 + <i class="back" @click="goBack()"></i>
4 <div class="right"> 4 <div class="right">
5 <i class="favorite"></i> 5 <i class="favorite"></i>
6 - <a class="share" href="{{ shareLink }}"></a> 6 + <i class="share" @click="goShare()"></i>
7 <i class="filter"></i> 7 <i class="filter"></i>
8 </div> 8 </div>
9 </div> 9 </div>
@@ -41,10 +41,6 @@ @@ -41,10 +41,6 @@
41 } 41 }
42 42
43 .share { 43 .share {
44 - width: 60px;  
45 - height: 60px;  
46 - margin: 0 5px;  
47 - display: inline-block;  
48 background: url("/channel/share.png") no-repeat; 44 background: url("/channel/share.png") no-repeat;
49 } 45 }
50 46
@@ -56,15 +52,26 @@ @@ -56,15 +52,26 @@
56 </style> 52 </style>
57 53
58 <script> 54 <script>
  55 + const yoho = require('yoho');
  56 +
59 module.exports = { 57 module.exports = {
60 props: { 58 props: {
61 - shareLink: {  
62 - type: String 59 + shareData: {
  60 + type: Object
63 } 61 }
64 }, 62 },
65 methods: { 63 methods: {
66 - getShareLink() {  
67 - return '1234'; 64 + goShare() {
  65 +
  66 + // TODO 这边应该需要一个分享后的页面链接,需要与 APP 确定分享要传的参数
  67 + let link = this.shareData.title +
  68 + this.shareData.link +
  69 + this.shareData.img;
  70 +
  71 + yoho.goShare({link: link}, function() {}, function() {});
  72 + },
  73 + goBack() {
  74 + yoho.goBack({}, function() {}, function() {});
68 } 75 }
69 } 76 }
70 }; 77 };