share.js 486 Bytes
Newer Older
zhanghaozhe committed
1
/* global wx */
zhanghaozhe committed
2
import { getWXObject, getSignature } from "./base"
3

zhanghaozhe committed
4 5 6 7 8 9
const shareApiList = [
  "updateAppMessageShareData",
  "updateTimelineShareData",
  "onMenuShareAppMessage",
  "onMenuShareTimeline",
]
10

zhanghaozhe committed
11 12 13 14 15 16
export default async function (
  data = { title: "", desc: "", link: "", imgUrl: "" },
  config = {}
) {
  await getWXObject()
  await getSignature(config)
17

zhanghaozhe committed
18 19 20 21
  wx.ready(function () {
    console.log("ready")
    shareApiList.forEach((item) => {
      wx[item](data)
22
    })
zhanghaozhe committed
23 24
  })
}