index.js 1.28 KB
Newer Older
FE committed
1
import React, { Component } from 'react';
zhanghaozhe committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
import CallApp from 'callapp-lib'

const options = {
    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",
FE committed
22
    fallback: "http://android.myapp.com/myapp/detail.htm?apkName=com.julyapp.julyonline"
zhanghaozhe committed
23 24 25 26
}

class OpenApp extends Component {

FE committed
27 28
    callApp = new CallApp(options)
    // callApp = null
zhanghaozhe committed
29

30 31 32 33
    static defaultProps = {
        text: '在APP打开'
    }

zhanghaozhe committed
34
    handleClick = () => {
FE committed
35 36 37 38 39 40
        this.callApp.open({
            path: '',
            param: {

            },
            callback: () => {
FE committed
41
                window.location.href = "http://android.myapp.com/myapp/detail.htm?apkName=com.julyapp.julyonline";
FE committed
42 43
            }
        });
zhanghaozhe committed
44 45 46 47
    }

    render() {
        return (
48
            <div className={this.props.className} onClick={this.handleClick}>{this.props.text}</div>
zhanghaozhe committed
49 50 51 52 53
        );
    }
}

export default OpenApp;