H5 商城 UI 业务包

更新时间:2024-04-01 06:23:29下载pdf

介绍

涂鸦 H5 商城 UI 业务包提供承载 App 商城 的 Android 容器,让您的 IoT App 具备丰富的商城能力,让移动端流量通过商城变现。App 商城 是嵌入在 App 的全球电商平台,详情请访问 App 商城

集成业务包

创建工程

在 Android Studio 中建立您的工程,接入智能生活 SDK,并完成业务包 框架接入

build.gradle 配置


dependencies {
    api enforcedPlatform("com.thingclips.smart:thingsmart-BizBundlesBom:${biz_bom_version}")
    api 'com.thingclips.smart:thingsmart-bizbundle-mall'
    api "com.thingclips.smart:thingsmart:${sdk_version}}"
}

混淆配置

# 应配置 build.gradle 里所有三方依赖混淆

#fastJson
-keep class com.alibaba.fastjson.**{*;}
-dontwarn com.alibaba.fastjson.**

-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**

-keep class okio.** { *; }
-dontwarn okio.**

-keep class com.thingclips.**{*;}
-dontwarn com.thingclips.**

功能调用

注意事项

  1. 使用任何接口之前,务必确认用户已登录
  2. 获取商城页面之前,需要首先确认当前用户所注册的服务区是否开通商城服务
  3. 登录用户发生变化时,务必重新判断商城可用状态并重新获取商城页面

查询商城信息

查询商城业务相关的信息,此接口为异步接口。

requestMallEntrance(@Nullable IRequestMallEntranceCallback callback);

示例代码

ThingMallService service = MicroContext.getServiceManager().findServiceByInterface(ThingMallService.class.getName());
        service.requestMallEntrance(new IRequestMallEntranceCallback() {
            @Override
            public void onSuccess(boolean success) {
                // It only means that the interface call is successful
            }

            @Override
            public void onError(String code, String error) {

            }
        });

查询商城首页链接

必须首先调用查询商城信息接口并接口返回成功,之后可获取用户所在区商城首页 URL,此接口为同步接口。

接口说明

getMallHomeUrl()

示例代码

ThingMallService service = MicroContext.getServiceManager().findServiceByInterface(ThingMallService.class.getName());
String mallUrl = service.getMallHomeUrl();

查询商城订单链接

若商城可用时,可查询用户所在区商城订单 URL。此接口为同步接口。

接口说明

getMallUserCenterUrl()

示例代码

ThingMallService service = MicroContext.getServiceManager().findServiceByInterface(ThingMallService.class.getName());
String mallUrl = service.getMallUserCenterUrl();

打开商城页面

商城展示页面支持 Activity 和 Fragment。

示例代码

Activity

Intent intent = new Intent(context, WebViewActivity.class);
intent.putExtra("Uri", url);
context.startActivity(intent);

Fragment

WebViewFragment fragment = new WebViewFragment();
Bundle args = new Bundle();
args.putString("Uri", url);
args.putBoolean("enableLeftArea", true);
fragment.setArguments(args);
getSupportFragmentManager().beginTransaction()
        .add(R.id.web_content, fragment, WebViewFragment.class.getSimpleName())
        .commit();