index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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>
  53. </view>
  54. </template>
  55. <script>
  56. const module = uni.requireNativePlugin("leven-arcFace-ArcFaceModule");
  57. export default {
  58. data() {
  59. return {
  60. ip: "",
  61. no: "",
  62. tenant: "",
  63. token: "",
  64. };
  65. },
  66. onMounted() {
  67. this.ip =
  68. uni.getStorageSync("labsop_ip") ||
  69. process.uniEnv.VUE_APP_MicroSrvProxy_API;
  70. this.no = uni.getStorageSync("labsop_no") || "";
  71. this.tenant =
  72. uni.getStorageSync("labsop_tenant") || process.uniEnv.VUE_APP_TENANT;
  73. this.token =
  74. uni.getStorageSync("labsop_android_token") ||
  75. process.uniEnv.VUE_APP_TOKEN;
  76. },
  77. onShow() {
  78. this.ip =
  79. uni.getStorageSync("labsop_ip") ||
  80. process.uniEnv.VUE_APP_MicroSrvProxy_API;
  81. this.no = uni.getStorageSync("labsop_no") || "";
  82. this.tenant =
  83. uni.getStorageSync("labsop_tenant") || process.uniEnv.VUE_APP_TENANT;
  84. this.token =
  85. uni.getStorageSync("labsop_android_token") ||
  86. process.uniEnv.VUE_APP_TOKEN;
  87. },
  88. onLoad() {},
  89. methods: {
  90. // 激活引擎
  91. confirm() {
  92. if (!this.no) {
  93. uni.showToast({
  94. title: "终端编号不能为空",
  95. icon: "none",
  96. duration: 1000,
  97. });
  98. return;
  99. }
  100. module.activeEngine(
  101. {
  102. appId: "F4G44DgYsCFdZbfi4va9aE81bhTsRjHQvFUXxr9V5ym9",
  103. sdkKey: "CUjFXiqfJtDp6gZKUPKTSPLuVsKoyqw7WPgbQA5o7ebp",
  104. },
  105. (res) => {
  106. console.log(res);
  107. if (res.code == 0 || res.code == 90114) {
  108. uni.showModal({
  109. title: "提示",
  110. content: "确认设置" + this.no + "为当前系统的终端编号?",
  111. success: (res) => {
  112. if (res.confirm) {
  113. this.clearFace();
  114. uni.setStorageSync("labsop_ip", this.ip || "");
  115. uni.setStorageSync("labsop_no", this.no || "");
  116. uni.setStorageSync("labsop_tenant", this.tenant || "");
  117. uni.setStorageSync(
  118. "labsop_android_token",
  119. this.token || ""
  120. );
  121. uni.showToast({
  122. title: "保存成功",
  123. duration: 1000,
  124. });
  125. setTimeout(() => {
  126. plus.runtime.restart();
  127. }, 1000);
  128. }
  129. },
  130. });
  131. } else {
  132. uni.showToast({
  133. title: "激活失败,请重新确认激活",
  134. icon: "none",
  135. duration: 1000,
  136. });
  137. }
  138. }
  139. );
  140. },
  141. // 清空人脸库
  142. clearFace() {
  143. module.clearFace((res) => {
  144. console.log("清空人脸库结果", res);
  145. });
  146. },
  147. backHome() {
  148. uni.redirectTo({
  149. url: "/pages/home/index",
  150. });
  151. },
  152. },
  153. };
  154. </script>
  155. <style lang="scss" scoped>
  156. .setting-wrap {
  157. width: 100%;
  158. height: 100vh;
  159. background: #fff;
  160. .header {
  161. background: skyblue;
  162. width: 100%;
  163. height: 12.6vh;
  164. box-sizing: border-box;
  165. display: flex;
  166. .name {
  167. flex: 1;
  168. display: flex;
  169. align-items: center;
  170. justify-content: center;
  171. font-size: 1.6vw;
  172. color: #fff;
  173. }
  174. .activation-btn {
  175. font-size: 1.6vw;
  176. letter-spacing: 2px;
  177. color: #fff;
  178. width: 15vw;
  179. height: 100%;
  180. background: #395294;
  181. display: flex;
  182. align-items: center;
  183. justify-content: center;
  184. }
  185. }
  186. .lab-input-wrap {
  187. padding: 8vh 6vw 0 6vw;
  188. display: flex;
  189. flex-wrap: wrap;
  190. .input-col {
  191. width: 50%;
  192. display: flex;
  193. margin-bottom: 40px;
  194. padding-right: 40px;
  195. .title {
  196. width: 9vw;
  197. font-size: 1.4vw;
  198. margin-right: 20px;
  199. text-align: right;
  200. }
  201. .input-box {
  202. flex: 1;
  203. border-bottom: 1px solid #ccc;
  204. .lab-input {
  205. padding-left: 4px;
  206. padding-bottom: 10px;
  207. }
  208. }
  209. }
  210. }
  211. .required::before {
  212. margin-right: 4px;
  213. color: red;
  214. content: "*";
  215. font-size: 20px;
  216. }
  217. }
  218. </style>