index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <view class="setting-wrap">
  3. <div class="header">
  4. <div class="name">智能实验终端</div>
  5. <div class="activation-btn" @click="confirmInfo" style="border-right: 1px solid;">修改信息</div>
  6. <div class="activation-btn" @click="confirm">激活终端</div>
  7. </div>
  8. <view class="lab-input-wrap">
  9. <view class="input-col">
  10. <view class="title">服务器IP:</view>
  11. <view class="input-box">
  12. <input class="lab-input" v-model="ip" type="text" placeholder="请输入服务器IP" />
  13. </view>
  14. </view>
  15. <view class="input-col">
  16. <view class="title required">终端编号:</view>
  17. <view class="input-box">
  18. <input class="lab-input" v-model="no" type="text" placeholder="请输入终端编号" />
  19. </view>
  20. </view>
  21. <view class="input-col">
  22. <view class="title">终端租户码:</view>
  23. <view class="input-box">
  24. <input class="lab-input" v-model="tenant" type="text" placeholder="请输入终端租户码" />
  25. </view>
  26. </view>
  27. <view class="input-col">
  28. <view class="title">秘钥:</view>
  29. <view class="input-box">
  30. <input class="lab-input" v-model="token" type="text" placeholder="请输入秘钥" />
  31. </view>
  32. </view>
  33. <view class="input-col">
  34. <view class="title">微服务:</view>
  35. <view class="input-box">
  36. <input class="lab-input" v-model="service_path" type="text" placeholder="请输入微服务路径" />
  37. </view>
  38. </view>
  39. <view class="input-col">
  40. <view class="title">sdk:</view>
  41. <view class="input-box flex">
  42. <input class="lab-input" v-model="sdkKey" type="text" placeholder="请输入sdk"
  43. style="flex: 1;padding-right: 20px;" />
  44. <u-button type="primary" style="width: 120px;" @click="getSdk">获取SDK</u-button>
  45. </view>
  46. </view>
  47. <view class="input-col">
  48. <view class="title">logo:</view>
  49. <view class="input-box">
  50. <input class="lab-input" v-model="headerImg" type="text" placeholder="请输入sdk" />
  51. </view>
  52. </view>
  53. <view class="input-col">
  54. <view class="title">文件路径:</view>
  55. <view class="input-box">
  56. <input class="lab-input" v-model="filePath" type="text" placeholder="请输入文件路径" />
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import instApi from "../../api/inst";
  64. import to from "await-to-js";
  65. const module = uni.requireNativePlugin("leven-arcFace-ArcFaceModule");
  66. export default {
  67. data() {
  68. return {
  69. ip: "",
  70. no: "",
  71. tenant: "",
  72. token: "",
  73. service_path: "",
  74. sdkKey: "91RPJZf6Xz158bBuHHDmX2BoEHWCKYyL2gnMvbuCADKD",
  75. headerImg: "static/images/header.png",
  76. filePath: "",
  77. };
  78. },
  79. onMounted() {
  80. this.ip =
  81. uni.getStorageSync("labsop_ip") ||
  82. process.uniEnv.VUE_APP_MicroSrvProxy_API;
  83. this.no = uni.getStorageSync("labsop_no") || "";
  84. this.tenant =
  85. uni.getStorageSync("labsop_tenant") || process.uniEnv.VUE_APP_TENANT;
  86. this.token =
  87. uni.getStorageSync("labsop_android_token") ||
  88. process.uniEnv.VUE_APP_TOKEN;
  89. this.service_path = uni.getStorageSync("labsop_service_path") || "";
  90. this.sdkKey =
  91. uni.getStorageSync("labsop_sdkKey") ||
  92. "91RPJZf6Xz158bBuHHDmX2BoEHWCKYyL2gnMvbuCADKD";
  93. this.headerImg =
  94. uni.getStorageSync("labsop_headerImg") || "static/images/header.png";
  95. this.filePath = uni.getStorageSync("labsop_filePath") || "";
  96. },
  97. onShow() {
  98. this.ip =
  99. uni.getStorageSync("labsop_ip") ||
  100. process.uniEnv.VUE_APP_MicroSrvProxy_API;
  101. this.no = uni.getStorageSync("labsop_no") || "";
  102. this.tenant =
  103. uni.getStorageSync("labsop_tenant") || process.uniEnv.VUE_APP_TENANT;
  104. this.token =
  105. uni.getStorageSync("labsop_android_token") ||
  106. process.uniEnv.VUE_APP_TOKEN;
  107. this.service_path = uni.getStorageSync("labsop_service_path") || "";
  108. this.sdkKey =
  109. uni.getStorageSync("labsop_sdkKey") ||
  110. "91RPJZf6Xz158bBuHHDmX2BoEHWCKYyL2gnMvbuCADKD";
  111. this.headerImg =
  112. uni.getStorageSync("labsop_headerImg") || "static/images/header.png";
  113. this.filePath = uni.getStorageSync("labsop_filePath") || "";
  114. },
  115. onLoad() { },
  116. methods: {
  117. // 重新获取系统Sdk
  118. async getSdk() {
  119. const [err, res] = await to(instApi.getEntityByKey({ configKey: 'hongruanSdk' }))
  120. if (err) {
  121. uni.showToast({
  122. title: "获取SDK失败",
  123. icon: "none",
  124. duration: 1000,
  125. });
  126. return;
  127. }
  128. this.sdkKey = res.data.configValue || ''
  129. },
  130. testSave() {
  131. // 测试用的方法
  132. uni.setStorageSync("labsop_ip", this.ip || "");
  133. uni.setStorageSync("labsop_no", "66400376");
  134. uni.setStorageSync("labsop_tenant", this.tenant || "");
  135. uni.setStorageSync("labsop_android_token", this.token || "");
  136. uni.setStorageSync("labsop_service_path", this.service_path || "");
  137. uni.setStorageSync(
  138. "labsop_sdkKey",
  139. this.sdkKey || "91RPJZf6Xz158bBuHHDmX2BoEHWCKYyL2gnMvbuCADKD"
  140. );
  141. uni.setStorageSync(
  142. "labsop_headerImg",
  143. "weed1/5,124d5a8af276"
  144. );
  145. uni.setStorageSync("labsop_filePath", this.filePath || "");
  146. },
  147. // 激活引擎
  148. confirm() {
  149. // this.testSave();
  150. // return;
  151. if (!this.no) {
  152. uni.showToast({
  153. title: "终端编号不能为空",
  154. icon: "none",
  155. duration: 1000,
  156. });
  157. return;
  158. }
  159. module.activeEngine(
  160. {
  161. appId: "9hEJzpvjHowhWTwrcAd47fSg42YRjx3RhvmpuHFAVLyy",
  162. sdkKey: this.sdkKey,
  163. },
  164. (res) => {
  165. console.log(res);
  166. if (res.code == 0 || res.code == 90114) {
  167. uni.showModal({
  168. title: "提示",
  169. content: "确认设置" + this.no + "为当前系统的终端编号?",
  170. success: (res) => {
  171. if (res.confirm) {
  172. this.clearFace();
  173. uni.setStorageSync("labsop_ip", this.ip || "");
  174. uni.setStorageSync("labsop_no", this.no || "");
  175. uni.setStorageSync("labsop_tenant", this.tenant || "");
  176. uni.setStorageSync(
  177. "labsop_android_token",
  178. this.token || ""
  179. );
  180. uni.setStorageSync(
  181. "labsop_service_path",
  182. this.service_path || ""
  183. );
  184. uni.setStorageSync(
  185. "labsop_sdkKey",
  186. this.sdkKey ||
  187. "91RPJZf6Xz158bBuHHDmX2BoEHWCKYyL2gnMvbuCADKD"
  188. );
  189. uni.setStorageSync(
  190. "labsop_headerImg",
  191. this.headerImg || "static/images/header.png"
  192. );
  193. uni.setStorageSync("labsop_filePath", this.filePath || "");
  194. uni.showToast({
  195. title: "保存成功",
  196. duration: 1000,
  197. });
  198. setTimeout(() => {
  199. plus.runtime.restart();
  200. }, 1000);
  201. }
  202. },
  203. });
  204. } else {
  205. uni.showToast({
  206. title: "激活失败,错误编号:" + res.code,
  207. icon: "none",
  208. duration: 1000,
  209. });
  210. }
  211. }
  212. );
  213. },
  214. // 只注册信息
  215. confirmInfo() {
  216. if (!this.no) {
  217. uni.showToast({
  218. title: "终端编号不能为空",
  219. icon: "none",
  220. duration: 1000,
  221. });
  222. return;
  223. }
  224. uni.showModal({
  225. title: "提示",
  226. content: "确认设置" + this.no + "为当前系统的终端编号?",
  227. success: (res) => {
  228. if (res.confirm) {
  229. uni.setStorageSync("labsop_ip", this.ip || "");
  230. uni.setStorageSync("labsop_no", this.no || "");
  231. uni.setStorageSync("labsop_tenant", this.tenant || "");
  232. uni.setStorageSync(
  233. "labsop_android_token",
  234. this.token || ""
  235. );
  236. uni.setStorageSync(
  237. "labsop_service_path",
  238. this.service_path || ""
  239. );
  240. uni.setStorageSync(
  241. "labsop_headerImg",
  242. this.headerImg || "static/images/header.png"
  243. );
  244. uni.setStorageSync("labsop_filePath", this.filePath || "");
  245. uni.showToast({
  246. title: "保存成功",
  247. duration: 1000,
  248. });
  249. setTimeout(() => {
  250. plus.runtime.restart();
  251. }, 1000);
  252. }
  253. },
  254. });
  255. },
  256. // 清空人脸库
  257. clearFace() {
  258. module.clearFace((res) => {
  259. console.log("清空人脸库结果", res);
  260. });
  261. },
  262. backHome() {
  263. uni.redirectTo({
  264. url: "/pages/home/index",
  265. });
  266. },
  267. },
  268. };
  269. </script>
  270. <style lang="scss" scoped>
  271. .setting-wrap {
  272. width: 100%;
  273. height: 100vh;
  274. background: #fff;
  275. .header {
  276. background: skyblue;
  277. width: 100%;
  278. height: 12.6vh;
  279. box-sizing: border-box;
  280. display: flex;
  281. .name {
  282. flex: 1;
  283. display: flex;
  284. align-items: center;
  285. justify-content: center;
  286. font-size: 1.6vw;
  287. color: #fff;
  288. }
  289. .activation-btn {
  290. font-size: 1.6vw;
  291. letter-spacing: 2px;
  292. color: #fff;
  293. width: 15vw;
  294. height: 100%;
  295. background: #395294;
  296. display: flex;
  297. align-items: center;
  298. justify-content: center;
  299. }
  300. }
  301. .lab-input-wrap {
  302. padding: 8vh 6vw 0 6vw;
  303. display: flex;
  304. flex-wrap: wrap;
  305. .input-col {
  306. width: 50%;
  307. display: flex;
  308. margin-bottom: 40px;
  309. padding-right: 40px;
  310. .title {
  311. width: 9vw;
  312. font-size: 1.4vw;
  313. margin-right: 20px;
  314. text-align: right;
  315. }
  316. .input-box {
  317. flex: 1;
  318. border-bottom: 1px solid #ccc;
  319. .lab-input {
  320. padding-left: 4px;
  321. padding-bottom: 10px;
  322. }
  323. }
  324. }
  325. }
  326. .flex {
  327. display: flex;
  328. }
  329. .required::before {
  330. margin-right: 4px;
  331. color: red;
  332. content: "*";
  333. font-size: 20px;
  334. }
  335. }
  336. </style>