更新记录

1.0.1(2023-05-04)

功能(Features)

  • 交付版本

平台兼容性

Android Android CPU类型 iOS
适用版本区间:5.0 - 12.0 armeabi-v7a:支持,arm64-v8a:未测试,x86:未测试 ×

原生插件通用使用流程:

  1. 购买插件,选择该插件绑定的项目。
  2. 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
  3. 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
  4. 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
  5. 开发完毕后正式云打包

付费原生插件目前不支持离线打包。
Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android
iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios

注意事项:使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择


食方 AI 秤 - super-module-sf

⚠️ 警告

查看在线文档:https://doc.yoouu.cn/front-end/uni-app/nativeplugins/super-module-sf

简介

食方 AI 秤

https://www.mt.com/cn/zh/home/products/retail-weighing-scales/AI-Scales.html

插件地址:https://ext.dcloud.net.cn/plugin?id=11963

平台兼容性

Android iOS
5.0 - 13.0 x

使用示例

const superModuleSF = uni.requireNativePlugin('super-module-sf')

/**
 * Toast 提示
 */
const toast = (title, val) => {
  try {
    if (typeof val === 'object') {
      val = JSON.stringify(val)
    } else {
      val = String(val)
    }
  } catch (e) {
    val = e.message
  } finally {
    uni.showToast({
      icon: 'none',
      title: `${title}: ${val}`,
      duration: 3000,
    })
  }
}

/**
 * 安全运行
 */
const safeRunning = (name, fun) => {
  try {
    fun()
  } catch (e) {
    toast(name, e.message)
  }
}

SFSurfaceView

<SFSurfaceView ref="sfSurfaceView" class="wd-w-640r wd-h-480r wd-rounded-12" />

测试 uni-app .vue 文件

只用来做个示例

super-module-sf

<template>
  <view class="content">
    <!-- getVersion -->
    <button class="margin" type="primary" @tap="getVersion">getVersion</button>
    <!-- checkPermissions -->
    <button class="margin" type="primary" @tap="checkPermissions">checkPermissions</button>
    <!-- release -->
    <button class="margin" type="primary" @tap="release">release</button>
    <!-- setAppAuth -->
    <view class="input"> <input v-model="appAuth" type="text" placeholder="请输入 appAuth" /> </view>
    <button type="primary" @click="setAppAuth">setAppAuth</button>

    <!-- login -->
    <view class="input"> <input v-model="mLicenseNo" type="text" placeholder="请输入 mLicenseNo" /> </view>
    <view class="input"> <input v-model="mStoreNo" type="text" placeholder="请输入 mStoreNo" /> </view>
    <button type="primary" @click="login">login</button>
    <button type="primary" @click="onToSFSurfaceView">onToSFSurfaceView</button>
  </view>
</template>
<script>
  import { toast, safeRunning } from '@/utils'

  // #ifdef APP-PLUS
  const superModuleSF = uni.requireNativePlugin('super-module-sf')
  // #endif
  export default {
    name: 'SuperSF',
    data() {
      return {
        appAuth: '',
        mLicenseNo: '',
        mStoreNo: '',
      }
    },
    methods: {
      getVersion() {
        safeRunning('getVersion', () => {
          const res = superModuleSF.getVersion()
          console.log('getVersion>>>', res)
          toast('getVersion', res)
        })
      },
      setAppAuth() {
        safeRunning('setAppAuth', () => {
          const res = superModuleSF.setAppAuth({
            appAuth: this.appAuth,
          })
          console.log('setAppAuth>>>', res)
          toast('setAppAuth', res)
        })
      },
      login() {
        safeRunning('login', () => {
          superModuleSF.login(
            {
              mLicenseNo: this.mLicenseNo,
              mStoreNo: this.mStoreNo,
            },
            (res) => {
              console.log('login>>>', res)
              toast('login', res)
            }
          )
        })
      },
      checkPermissions() {
        safeRunning('checkPermissions', () => {
          superModuleSF.checkPermissions((res) => {
            console.log('checkPermissions>>>', res)
            toast('checkPermissions', res)
          })
        })
      },
      release() {
        safeRunning('release', () => {
          const res = superModuleSF.release()
          console.log('release>>>', res)
          toast('release', res)
        })
      },
      onToSFSurfaceView() {
        uni.navigateTo({
          url: '/pages/android/ext-super-sf-surface-view',
        })
      },
    },
  }
</script>
<style lang="scss" scoped>
  .content {
    padding: 12px 24rpx;
  }
  .margin {
    margin: 12px 16px;
  }

  .gap {
    margin-top: 18px;
  }

  .input {
    margin-top: 12px;
    padding: 12rpx 24rpx;
    border: 1px solid #eee;
    color: #333;
  }
</style>

SFSurfaceView

<template>
  <view class="wd-p-12">
    <view class="wd-flex-center">
      <!-- #ifdef APP-NVUE -->
      <SFSurfaceView ref="sfSurfaceView" class="wd-w-640r wd-h-480r wd-rounded-12" />
      <!-- #endif -->
      <!-- #ifndef APP-NVUE -->
      <view class="wd-w-640r wd-h-480r wd-rounded-12" style="background-color: darkorchid;"></view>
      <!-- #endif -->
    </view>

    <view class="wd-mt-12">
      <!-- 识别 -->
      <button type="primary" @click="recognize">recognize</button>
      <view class="wd-mt-6">
        <!-- 同步方法测试 -->
        <button type="primary" @click="syncFunTest">同步方法测试 - syncFunTest</button>
      </view>

      <view class="wd-mt-6">
        <!-- 异步方法测试 -->
        <button class="wd-mt-6" type="primary" @click="asyncFunTest">异步方法测试 - asyncFunTest</button>
      </view>
    </view>

    <view class="wd-mt-12">
      <view
        style="background-color: darkcyan;"
        class="wd-px-12 wd-py-6 wd-mb-12 wd-rounded-12"
        v-for="item of products"
        :key="item.id"
        @click="feedback(item)"
      >
        <view>
          <text class="wd-text-12 wd-text-fff"
            >{{ `name: ${item.name} - code: ${item.code} - isSale: ${item.isSale}` }}</text
          >
        </view>
        <view>
          <text class="wd-text-12 wd-text-fff"
            >{{ `pluNo: ${item.pluNo} - priceFen: ${item.priceFen} - priceUnit: ${item.priceUnit} - price:
            ${item.price}` }}</text
          >
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  import { toast, safeRunning } from '@/utils'

  // #ifdef APP-PLUS
  // const superModuleSF = uni.requireNativePlugin('super-module-sf')
  // #endif

  export default {
    name: 'SuperSFSurfaceView',
    data() {
      return {
        products: [
          {
            code: '6615',
            id: 2020,
            isSale: true,
            name: '商品1',
            pluNo: 6615,
            priceFen: 1200,
            priceUnit: 'kg',
            price: 12.0,
          },
          {
            code: '5981',
            id: 2021,
            isSale: true,
            name: '商品2',
            pluNo: 5981,
            priceFen: 3500,
            priceUnit: 'kg',
            price: 35.0,
          },
          {
            code: '4020',
            id: 2022,
            isSale: true,
            name: '商品3',
            pluNo: 4020,
            priceFen: 4000,
            priceUnit: 'kg',
            price: 40.0,
          },
          {
            code: '9673',
            id: 2023,
            isSale: true,
            name: '商品4',
            pluNo: 9673,
            priceFen: 9800,
            priceUnit: 'kg',
            price: 98.0,
          },
          {
            code: '9694',
            id: 2024,
            isSale: true,
            name: '商品5',
            pluNo: 9694,
            priceFen: 17600,
            priceUnit: 'kg',
            price: 176.0,
          },
          {
            code: '2542',
            id: 2025,
            isSale: true,
            name: '商品6',
            pluNo: 2542,
            priceFen: 4800,
            priceUnit: 'kg',
            price: 48.0,
          },
          {
            code: '3940',
            id: 2026,
            isSale: true,
            name: '商品7',
            pluNo: 3940,
            priceFen: 1100,
            priceUnit: 'kg',
            price: 11.0,
          },
          {
            code: '10406',
            id: 2028,
            isSale: true,
            name: '商品8',
            pluNo: 10406,
            priceFen: 3980,
            priceUnit: 'kg',
            price: 39.8,
          },
          {
            code: '9727',
            id: 2029,
            isSale: true,
            name: '商品9',
            pluNo: 9727,
            priceFen: 1300,
            priceUnit: 'kg',
            price: 13.0,
          },
          {
            code: '2697',
            id: 2030,
            isSale: true,
            name: '商品10',
            pluNo: 2697,
            priceFen: 3600,
            priceUnit: 'kg',
            price: 36.0,
          },
          {
            code: '10409',
            id: 2031,
            isSale: true,
            name: '商品11',
            pluNo: 10409,
            priceFen: 600,
            priceUnit: 'kg',
            price: 6.0,
          },
          {
            code: '9956',
            id: 2032,
            isSale: true,
            name: '商品12',
            pluNo: 9956,
            priceFen: 1500,
            priceUnit: 'kg',
            price: 15.0,
          },
          {
            code: '3934',
            id: 2033,
            isSale: true,
            name: '商品13',
            pluNo: 3934,
            priceFen: 500,
            priceUnit: 'kg',
            price: 5.0,
          },
          {
            code: '90304',
            id: 2036,
            isSale: true,
            name: '商品14',
            pluNo: 90304,
            priceFen: 5500,
            priceUnit: 'kg',
            price: 55.0,
          },
          {
            code: '9957',
            id: 2037,
            isSale: true,
            name: '商品15',
            pluNo: 9957,
            priceFen: 11100,
            priceUnit: 'kg',
            price: 111.0,
          },
          {
            code: '9341',
            id: 2038,
            isSale: true,
            name: '商品16',
            pluNo: 9341,
            priceFen: 1100,
            priceUnit: 'kg',
            price: 11.0,
          },
        ],
      }
    },
    methods: {
      recognize() {
        safeRunning('recognize', () => {
          this.$refs.sfSurfaceView.recognize((res) => {
            console.log('recognize>>>', res)
            toast('recognize', res)
          })
        })
      },
      feedback(item) {
        safeRunning('feedback', () => {
          this.$refs.sfSurfaceView.feedback(item, (res) => {
            console.log('feedback>>>', res)
            toast('feedback', res)
          })
        })
      },
      syncFunTest() {
        safeRunning('syncFunTest', () => {
          const res = this.$refs.sfSurfaceView.syncFunTest()
          console.log('syncFunTest>>>', res)
          toast('syncFunTest', res)
        })
      },
      asyncFunTest() {
        safeRunning('asyncFunTest', () => {
          this.$refs.sfSurfaceView.asyncFunTest((res) => {
            console.log('asyncFunTest>>>', res)
            toast('asyncFunTest', res)
          })
        })
      },
    },
  }
</script>

<style lang="scss" scoped></style>

模块方法

getVersion() : result

获取 sdk 版本

  • result <Object> 执行返回信息
    • success <Boolean> 操作是否成功
    • code <Number> 状态码
    • 200 操作成功
    • msg <String> 请求信息
    • data <String> 请求成功返回数据

checkPermissions(callback) : void

检查所需权限

  • callback <Function> 结果回调

    回调结果 <Object>

    • success <Boolean> 操作是否成功
    • code <Number> 状态码
    • 200 操作成功
    • msg <String> 请求信息
    • data <Object> 提示数据
    • permissions <Array<String>>
    • paramArrayOfInt <Array<Int>>

setAppAuth(options) : result

  • result <Object>执行返回信息
    • success <Boolean> 操作是否成功
    • code <Number> 状态码
    • 200 操作成功
    • 400 用户操作导致失败
    • msg <String> 请求信息
    • data <Object> 权限描述
    • permissions 操作成功

login(options, callback) : void

  • options <Object>

    • mLicenseNo <String> mLicenseNo
    • mStoreNo <String> mStoreNo
  • callback <Function> 结果回调

    回调结果 <Object>

    • success <Boolean> 操作是否成功
    • code <Number> 状态码
    • 200 操作成功
    • msg <String> 请求信息
    • err <String> | <Object> 错误信息,不能直接提示给用户,可以用于 debug

release(): void

释放资源

  • result <Object>执行返回信息
    • success <Boolean> 操作是否成功
    • code <Number> 状态码
    • 200 操作成功
    • 500 操作失败
    • msg <String> 请求信息
    • data <Object> 结果码
    • error <String> 错误消息

全局组件

SFSurfaceView 模块方法

recognize(callback) : void

识别

  • callback <Function> 结果回调

    回调结果 <Object>

    • success <Boolean> 操作是否成功
    • code <Number> 状态码
    • 200 操作成功
    • 400 调用相关错误
    • msg <String> 请求信息

feedback(callback) : void

  • callback <Function> 结果回调

    回调结果 <Object>

    • success <Boolean> 操作是否成功
    • code <Number> 状态码
    • 200 操作成功
    • 400 调用相关错误
    • msg <String> 请求信息

权限列表

ios

Android

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

演示截图

IOS Android
x x

更新日志

1.0.0

功能(Features)

  • 交付版本

问题反馈

虽然插件已经经过开发者测试和使用,但不排除某些场景下产生问题的可能性,如遇到 Bug 可以

  • 在评论区留言,收到通知邮件我会第一次时间查看
  • 或添加 微信: sunseekerx 进行反馈
  • 或添加 QQ: 1647800606 进行反馈

更多插件

如有插件定制需求,也可以联系我哦。

隐私、权限声明

1. 本插件需要申请的系统权限列表:

<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

暂无用户评论。

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问