index.vue 8.5 KB

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