package com.yyrh.core.network;

import android.webkit.JavascriptInterface;

import com.yyrh.core.internal.IJsFeature;

/**
 * @author #Suyghur.
 * Created on 2021/10/22
 */
public class SdkJsImpl {

    private IJsFeature callback = null;

    public SdkJsImpl(IJsFeature callback) {
        this.callback = callback;
    }

    @JavascriptInterface
    public void zfColse() {
        callback.onJsInvoke(SdkJsFeature.FEATURE_CLOSE, "");
    }

    @JavascriptInterface
    public void usrRn(String data) {
        callback.onJsInvoke(SdkJsFeature.FEATURE_REAL_NAME, data);
    }

    @JavascriptInterface
    public void showJsMsg(String data) {
        callback.onJsInvoke(SdkJsFeature.FEATURE_SHOW_MSG, data);
    }

    @JavascriptInterface
    public void modifyPwd(String data) {
        callback.onJsInvoke(SdkJsFeature.FEATURE_MODIFY_PWD, data);
    }


    @JavascriptInterface
    public void zfOrder(String data) {
        callback.onJsInvoke(SdkJsFeature.FEATURE_ZF_ORDER, data);
    }

    @JavascriptInterface
    public void openq0q0(String url) {
        callback.onJsInvoke(SdkJsFeature.FEATURE_OPEN_0Q0, url);
    }

    @JavascriptInterface
    public String webExt() {
        return callback.onJsCallback(SdkJsFeature.FEATURE_WEB_EXT, "");
    }

    @JavascriptInterface
    public void switchAccount() {
        callback.onJsInvoke(SdkJsFeature.FEATURE_SWITCH_ACCOUNT, "");
    }


    public @interface SdkJsFeature {
        int FEATURE_CLOSE = 1000;
        int FEATURE_REAL_NAME = 1001;
        int FEATURE_SHOW_MSG = 1002;
        int FEATURE_MODIFY_PWD = 1003;
        int FEATURE_ZF_ORDER = 1004;
        int FEATURE_OPEN_0Q0 = 1005;
        int FEATURE_WEB_EXT = 1006;
        int FEATURE_SWITCH_ACCOUNT = 1007;
    }
}
