Authored by 郭成尧

分享优化

600 Bytes | W: | H:

2.66 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
... ... @@ -8,12 +8,12 @@
*
* 希望能与 微信 JS-SDK 一样方便
*/
const $ = require('yoho-jquery');
const tip = require('common/tip');
const native = window.yohoInterface;
window.yohoWapInterface = {
headerRightTopBtn: $.loop()
headerRightTopBtn: function() {}
};
const yoho = {
... ... @@ -35,7 +35,7 @@ const yoho = {
*/
goTap(args, success, fail) {
if (this.isApp) {
native.triggerEvent(success || $.loop(), fail || $.loop(), {
native.triggerEvent(success || function() {}, fail || function() {}, {
method: 'go.tab',
arguments: args
});
... ... @@ -52,7 +52,7 @@ const yoho = {
*/
goLogin(args, success, fail) {
if (this.isApp) {
native.triggerEvent(success || $.loop(), fail || $.loop(), {
native.triggerEvent(success || function() {}, fail || function() {}, {
method: 'go.login',
arguments: args
});
... ... @@ -69,7 +69,7 @@ const yoho = {
*/
goShopingCart(args, success, fail) {
if (this.isApp) {
native.triggerEvent(success || $.loop(), fail || $.loop(), {
native.triggerEvent(success || function() {}, fail || function() {}, {
method: 'go.shopingCart',
arguments: args
});
... ... @@ -86,7 +86,7 @@ const yoho = {
*/
goAddress(args, success, fail) {
if (this.isApp) {
native.triggerEvent(success || $.loop(), fail || $.loop(), {
native.triggerEvent(success || function() {}, fail || function() {}, {
method: 'go.address',
arguments: args
});
... ... @@ -103,7 +103,7 @@ const yoho = {
*/
goImageBrowser(args, success, fail) {
if (this.isApp) {
native.triggerEvent(success || $.loop(), fail || $.loop(), {
native.triggerEvent(success || function() {}, fail || function() {}, {
method: 'go.imageBrowser',
arguments: args
});
... ... @@ -120,7 +120,7 @@ const yoho = {
*/
goNewPage(args, success, fail) {
if (this.isApp) {
native.triggerEvent(success || $.loop(), fail || $.loop(), {
native.triggerEvent(success || function() {}, fail || function() {}, {
method: 'go.newPage',
arguments: args
});
... ... @@ -137,7 +137,7 @@ const yoho = {
*/
goPay(args, success, fail) {
if (this.isApp) {
native.triggerEvent(success || $.loop(), fail || $.loop(), {
native.triggerEvent(success || function() {}, fail || function() {}, {
method: 'go.pay',
arguments: args
});
... ... @@ -147,6 +147,40 @@ const yoho = {
},
/**
* 回到上一个原生界面
* @param args
* @param success
* @param fail
*/
goBack(args, success, fail) {
if (this.isApp) {
native.triggerEvent(success || function() {}, fail || function() {}, {
method: 'go.back',
arguments: args
});
} else {
tip('暂不支持,请在BLK应用中打开');
}
},
/**
* 分享
* @param args
* @param success
* @param fail
*/
goShare(args, success, fail) {
if (this.isApp) {
native.triggerEvent(success || function() {}, fail || function() {}, {
method: 'go.share',
arguments: args
});
} else {
tip('暂不支持,请在BLK应用中打开');
}
},
/**
* 原生调用 JS 方法
* @param name 方法名
* @param callback 回调
... ...
<template>
<brand-top-cmpnt v-bind:share-Link="shareLink"></brand-top-cmpnt>
<brand-top-cmpnt v-bind:share-data="shareData"></brand-top-cmpnt>
<brand-shop-top-cmpnt v-bind:domain="'nike'"></brand-shop-top-cmpnt>
<!--<goods-list v-bind:data="productList"></goods-list>-->
</template>
... ... @@ -11,13 +11,14 @@
const brandShopTopCmpnt = require('channel/brand-shop-top.vue');
const goodsList = require('product/list.vue');
// TODO 确定分享页面后需要添加拼接分享链接的公共方法
let shareLink = 'http://www.yohobuy.com';
module.exports = {
data() {
return {
shareLink: shareLink,
shareData: {
title: 'BLK',
link: 'm.blk.com',
img: 'https://img11.static.yhbimg.com/brandLogo/2016/04/13/15/010eb8606c1072fd2e769c62567d3bbe93.png?imageView2/2/w/140/h/140'
},
productList: []
};
},
... ...
<template>
<div class="top-box clearfix">
<i class="back"></i>
<i class="back" @click="goBack()"></i>
<div class="right">
<i class="favorite"></i>
<a class="share" href="{{ shareLink }}"></a>
<i class="share" @click="goShare()"></i>
<i class="filter"></i>
</div>
</div>
... ... @@ -41,10 +41,6 @@
}
.share {
width: 60px;
height: 60px;
margin: 0 5px;
display: inline-block;
background: url("/channel/share.png") no-repeat;
}
... ... @@ -56,15 +52,26 @@
</style>
<script>
const yoho = require('yoho');
module.exports = {
props: {
shareLink: {
type: String
shareData: {
type: Object
}
},
methods: {
getShareLink() {
return '1234';
goShare() {
// TODO 这边应该需要一个分享后的页面链接,需要与 APP 确定分享要传的参数
let link = this.shareData.title +
this.shareData.link +
this.shareData.img;
yoho.goShare({link: link}, function() {}, function() {});
},
goBack() {
yoho.goBack({}, function() {}, function() {});
}
}
};
... ...