| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386 |
- <template>
- <view class="setting-wrap">
- <div class="header">
- <div class="name">智能实验终端</div>
- <div class="activation-btn" @click="confirmInfo" style="border-right: 1px solid;">修改信息</div>
- <div class="activation-btn" @click="confirm">激活终端</div>
- </div>
- <view class="lab-input-wrap">
- <view class="input-col">
- <view class="title">服务器IP:</view>
- <view class="input-box">
- <input class="lab-input" v-model="ip" type="text" placeholder="请输入服务器IP" />
- </view>
- </view>
- <view class="input-col">
- <view class="title required">终端编号:</view>
- <view class="input-box">
- <input class="lab-input" v-model="no" type="text" placeholder="请输入终端编号" />
- </view>
- </view>
- <view class="input-col">
- <view class="title">终端租户码:</view>
- <view class="input-box">
- <input class="lab-input" v-model="tenant" type="text" placeholder="请输入终端租户码" />
- </view>
- </view>
- <view class="input-col">
- <view class="title">秘钥:</view>
- <view class="input-box">
- <input class="lab-input" v-model="token" type="text" placeholder="请输入秘钥" />
- </view>
- </view>
- <view class="input-col">
- <view class="title">微服务:</view>
- <view class="input-box">
- <input class="lab-input" v-model="service_path" type="text" placeholder="请输入微服务路径" />
- </view>
- </view>
- <view class="input-col">
- <view class="title">sdk:</view>
- <view class="input-box flex">
- <input class="lab-input" v-model="sdkKey" type="text" placeholder="请输入sdk"
- style="flex: 1;padding-right: 20px;" />
- <u-button type="primary" style="width: 120px;" @click="getSdk">获取SDK</u-button>
- </view>
- </view>
- <view class="input-col">
- <view class="title">logo:</view>
- <view class="input-box">
- <input class="lab-input" v-model="headerImg" type="text" placeholder="请输入sdk" />
- </view>
- </view>
- <view class="input-col">
- <view class="title">文件路径:</view>
- <view class="input-box">
- <input class="lab-input" v-model="filePath" type="text" placeholder="请输入文件路径" />
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import instApi from "../../api/inst";
- import to from "await-to-js";
- const module = uni.requireNativePlugin("leven-arcFace-ArcFaceModule");
- export default {
- data() {
- return {
- ip: "",
- no: "",
- tenant: "",
- token: "",
- service_path: "",
- sdkKey: "91RPJZf6Xz158bBuHHDmX2BoEHWCKYyL2gnMvbuCADKD",
- headerImg: "static/images/header.png",
- filePath: "",
- };
- },
- onMounted() {
- this.ip =
- uni.getStorageSync("labsop_ip") ||
- process.uniEnv.VUE_APP_MicroSrvProxy_API;
- this.no = uni.getStorageSync("labsop_no") || "";
- this.tenant =
- uni.getStorageSync("labsop_tenant") || process.uniEnv.VUE_APP_TENANT;
- this.token =
- uni.getStorageSync("labsop_android_token") ||
- process.uniEnv.VUE_APP_TOKEN;
- this.service_path = uni.getStorageSync("labsop_service_path") || "";
- this.sdkKey =
- uni.getStorageSync("labsop_sdkKey") ||
- "91RPJZf6Xz158bBuHHDmX2BoEHWCKYyL2gnMvbuCADKD";
- this.headerImg =
- uni.getStorageSync("labsop_headerImg") || "static/images/header.png";
- this.filePath = uni.getStorageSync("labsop_filePath") || "";
- },
- onShow() {
- this.ip =
- uni.getStorageSync("labsop_ip") ||
- process.uniEnv.VUE_APP_MicroSrvProxy_API;
- this.no = uni.getStorageSync("labsop_no") || "";
- this.tenant =
- uni.getStorageSync("labsop_tenant") || process.uniEnv.VUE_APP_TENANT;
- this.token =
- uni.getStorageSync("labsop_android_token") ||
- process.uniEnv.VUE_APP_TOKEN;
- this.service_path = uni.getStorageSync("labsop_service_path") || "";
- this.sdkKey =
- uni.getStorageSync("labsop_sdkKey") ||
- "91RPJZf6Xz158bBuHHDmX2BoEHWCKYyL2gnMvbuCADKD";
- this.headerImg =
- uni.getStorageSync("labsop_headerImg") || "static/images/header.png";
- this.filePath = uni.getStorageSync("labsop_filePath") || "";
- },
- onLoad() { },
- methods: {
- // 重新获取系统Sdk
- async getSdk() {
- const [err, res] = await to(instApi.getEntityByKey({ configKey: 'hongruanSdk' }))
- if (err) {
- uni.showToast({
- title: "获取SDK失败",
- icon: "none",
- duration: 1000,
- });
- return;
- }
- this.sdkKey = res.data.configValue || ''
- },
- testSave() {
- // 测试用的方法
- uni.setStorageSync("labsop_ip", this.ip || "");
- uni.setStorageSync("labsop_no", "66400376");
- uni.setStorageSync("labsop_tenant", this.tenant || "");
- uni.setStorageSync("labsop_android_token", this.token || "");
- uni.setStorageSync("labsop_service_path", this.service_path || "");
- uni.setStorageSync(
- "labsop_sdkKey",
- this.sdkKey || "91RPJZf6Xz158bBuHHDmX2BoEHWCKYyL2gnMvbuCADKD"
- );
- uni.setStorageSync(
- "labsop_headerImg",
- "weed1/5,124d5a8af276"
- );
- uni.setStorageSync("labsop_filePath", this.filePath || "");
- },
- // 激活引擎
- confirm() {
- // this.testSave();
- // return;
- if (!this.no) {
- uni.showToast({
- title: "终端编号不能为空",
- icon: "none",
- duration: 1000,
- });
- return;
- }
- module.activeEngine(
- {
- appId: "9hEJzpvjHowhWTwrcAd47fSg42YRjx3RhvmpuHFAVLyy",
- sdkKey: this.sdkKey,
- },
- (res) => {
- console.log(res);
- if (res.code == 0 || res.code == 90114) {
- uni.showModal({
- title: "提示",
- content: "确认设置" + this.no + "为当前系统的终端编号?",
- success: (res) => {
- if (res.confirm) {
- this.clearFace();
- uni.setStorageSync("labsop_ip", this.ip || "");
- uni.setStorageSync("labsop_no", this.no || "");
- uni.setStorageSync("labsop_tenant", this.tenant || "");
- uni.setStorageSync(
- "labsop_android_token",
- this.token || ""
- );
- uni.setStorageSync(
- "labsop_service_path",
- this.service_path || ""
- );
- uni.setStorageSync(
- "labsop_sdkKey",
- this.sdkKey ||
- "91RPJZf6Xz158bBuHHDmX2BoEHWCKYyL2gnMvbuCADKD"
- );
- uni.setStorageSync(
- "labsop_headerImg",
- this.headerImg || "static/images/header.png"
- );
- uni.setStorageSync("labsop_filePath", this.filePath || "");
- uni.showToast({
- title: "保存成功",
- duration: 1000,
- });
- setTimeout(() => {
- plus.runtime.restart();
- }, 1000);
- }
- },
- });
- } else {
- uni.showToast({
- title: "激活失败,错误编号:" + res.code,
- icon: "none",
- duration: 1000,
- });
- }
- }
- );
- },
- // 只注册信息
- confirmInfo() {
- if (!this.no) {
- uni.showToast({
- title: "终端编号不能为空",
- icon: "none",
- duration: 1000,
- });
- return;
- }
- uni.showModal({
- title: "提示",
- content: "确认设置" + this.no + "为当前系统的终端编号?",
- success: (res) => {
- if (res.confirm) {
- uni.setStorageSync("labsop_ip", this.ip || "");
- uni.setStorageSync("labsop_no", this.no || "");
- uni.setStorageSync("labsop_tenant", this.tenant || "");
- uni.setStorageSync(
- "labsop_android_token",
- this.token || ""
- );
- uni.setStorageSync(
- "labsop_service_path",
- this.service_path || ""
- );
- uni.setStorageSync(
- "labsop_headerImg",
- this.headerImg || "static/images/header.png"
- );
- uni.setStorageSync("labsop_filePath", this.filePath || "");
- uni.showToast({
- title: "保存成功",
- duration: 1000,
- });
- setTimeout(() => {
- plus.runtime.restart();
- }, 1000);
- }
- },
- });
- },
- // 清空人脸库
- clearFace() {
- module.clearFace((res) => {
- console.log("清空人脸库结果", res);
- });
- },
- backHome() {
- uni.redirectTo({
- url: "/pages/home/index",
- });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .setting-wrap {
- width: 100%;
- height: 100vh;
- background: #fff;
- .header {
- background: skyblue;
- width: 100%;
- height: 12.6vh;
- box-sizing: border-box;
- display: flex;
- .name {
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 1.6vw;
- color: #fff;
- }
- .activation-btn {
- font-size: 1.6vw;
- letter-spacing: 2px;
- color: #fff;
- width: 15vw;
- height: 100%;
- background: #395294;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- }
- .lab-input-wrap {
- padding: 8vh 6vw 0 6vw;
- display: flex;
- flex-wrap: wrap;
- .input-col {
- width: 50%;
- display: flex;
- margin-bottom: 40px;
- padding-right: 40px;
- .title {
- width: 9vw;
- font-size: 1.4vw;
- margin-right: 20px;
- text-align: right;
- }
- .input-box {
- flex: 1;
- border-bottom: 1px solid #ccc;
- .lab-input {
- padding-left: 4px;
- padding-bottom: 10px;
- }
- }
- }
- }
- .flex {
- display: flex;
- }
- .required::before {
- margin-right: 4px;
- color: red;
- content: "*";
- font-size: 20px;
- }
- }
- </style>
|