1.3.5 • Published 6 years ago

@freshservice/bridge v1.3.5

Weekly downloads
31
License
UNLICENSED
Repository
-
Last release
6 years ago

@freshservice/bridge

freshes bridge

安装

# install dependencies
yarn add @freshservice/bridge

引入

import {
    SignIn,
    Address,
    AddToCart,
    Cart,
    Coupon,
    FindPayPwd,
    HomePage,
    OnlineService,
    Order,
    Point,
    Product,
    Profile,
    Recharge,
    Refresh,
    Register,
    SetShareOptions,
    ShareMenu,
    UnlockPayPwd,
    UpdateAuth,
    SetCustomData,
    AccountCard,
    LimitInWx,
    Category
  } from '@freshservice/bridge'

 ...

 data () {
     return {
         from: 'app/wechat' // 从建议从url获取或者从UpdateAuth方法存储的localStorage中获取from
     }
 }

统一说明

为了开发更方便测试,故在版本1.2.7加入了测试选项(仅对跳转类方法),如下:

例如登录,跳转到测试环境:
SignIn.init({test: true}).execute()

跳转到正式:
SignIn.init().execute()

跳转登录

SignIn.init().execute()

获取登录信息

// 手机号码只有从微信商城登录才有,app无此字段
UpdateAuth.init().execute()
console.log(window.localStorage.getItem('TOC_TOKEN'))// 用户token, 例如 {"AccessToken":"xxxxxabcxx","CustomerGuid":"xxx-xxx","SourceType":"9","Phone":"181111xxxxxxx","from":"wechat","expires":"2019-01-08T02:13:30.713Z"}
console.log(window.localStorage.getItem('TOC_CITY'))// 城市信息, 例如 {"CityId":"3","CityFlag":"sh"}

注意:app里登录完成后仅仅只是将用户信息塞入到url,并不会刷新。 解决方案:

'$route.query' () {
  if (this.$route.query.token) {
    window.location.reload()
  }
}

加入购物车

const productId = 111 // 商品id
AddToCart
  .init()
  .execute(productId)
  .success(response => {
    // do something
  })

设置分享信息

const data = {
    title: '标题',
    desc: '描述',
    link: 'https://www.baidu.com',
    imgUrl: 'https://picpro-sz.34580.com/sz/ImageUrl/8367/400.jpeg',
    shareCode: 3 // 0.禁止分享 1.只允许微信 2.允许所有 3.分享大图
}
SetShareOptions.init().execute(data).success(() => {
 // 分享成功
})

地址管理(只能查看)

Address.init().execute()

跳转购物车

Cart.init().execute()

查看优惠券

Coupon.init().execute()

找回支付密码

FindPayPwd.init().execute()

解锁支付密码

UnlockPayPwd.init().execute()

app/商城首页

HomePage.init().execute()

在线客服

OnlineService.init().execute()

查看我的订单

Order.init().execute()

查看我的积分

Point.init().execute()

查看商品

const productId = 111 // 商品id
Product.init().execute(productId)

用户信息页

Profile.init().execute()

跳转充值

Recharge.init().execute()

刷新页面

Refresh.init().execute()

注册

// 一般此方法不使用,由公共登录页引导登录即可
const registerMethod = 1200 // ios 安卓有区别
Register.init().execute(registerMethod)

打开分享

ShareMenu.init().execute()

设置zhugeTitle(埋点用)

SetCustomData.init().execute({ zhugeTitle: '测试标题吼吼吼吼' })

跳转到绑定卡

AccountCard.init().execute()

获取微信code

LimitInWx.init().execute()

当前环境为微信返回true,并且code作为query string跟在url后,否则返回false.

优惠券根据品类跳转

type: 1 全场通用  2 品类  4 or 5 单品
// Category.init().execute({type: 4, id: 10493})
// Category.init().execute({type: 2, id: 300})
Category.init().execute({type: 1})
1.3.5

6 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.9

6 years ago

1.2.8

6 years ago

1.2.7

6 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago