index.js 1.17 KB
Newer Older
zhanghaozhe committed
1 2
import React, { Component } from "react"
import CallApp from "callapp-lib"
zhanghaozhe committed
3 4

const options = {
zhanghaozhe committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
  scheme: {
    protocol: "julyedu",
    host: "",
    port: "",
  },
  intent: {
    package: "com.julyapp.julyonline",
    scheme: "julyedu",
    action: "julyapp.julyedu",
    category: "category_julyedu",
  },
  universal: {
    host: "api.julyedu.com/action",
    pathKey: "page",
  },
  appstore: "https://itunes.apple.com/cn/app/id1102275343?mt=8",
  yingyongbao:
    "http://android.myapp.com/myapp/detail.htm?apkName=com.julyapp.julyonline",
  fallback:
    "http://android.myapp.com/myapp/detail.htm?apkName=com.julyapp.julyonline",
zhanghaozhe committed
25 26 27
}

class OpenApp extends Component {
zhanghaozhe committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
  callApp = new CallApp(options)
  // callApp = null

  static defaultProps = {
    text: "在APP打开",
  }

  handleClick = () => {
    this.callApp.open({
      path: "",
      param: {},
      callback: () => {
        window.location.href =
          "http://android.myapp.com/myapp/detail.htm?apkName=com.julyapp.julyonline"
      },
    })
  }

  render() {
    return (
      <div className={this.props.className} onClick={this.handleClick}>
        {this.props.text}
      </div>
    )
  }
zhanghaozhe committed
53 54
}

zhanghaozhe committed
55
export default OpenApp