fingerprint.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <!-- 指纹 -->
  2. <template>
  3. <view id="fingerprint">
  4. <view class="fingerprint_one" v-if="pageType==1">
  5. <view class="fingerprint_one_li" @click="goPage(item)" v-for="(item,index) in fingerprintList" :key="index">
  6. <view class="fingerprint_one_li_l">{{item.name}}</view>
  7. <view :class="item.isConfig?'colorB':'colorA'">{{item.isConfig?'已配置':'无'}}</view>
  8. <img class="fingerprint_one_li_r" src="@/images/icon_04.png">
  9. </view>
  10. </view>
  11. <view class="tip_tow" v-if="pageType==2">
  12. <view class="tip_tow_l">提醒</view>
  13. <view class="tip_tow_l">请选中门禁点击【指纹采集】并在当前门禁上录入指纹</view>
  14. </view>
  15. <view class="fingerprint_tow" v-if="pageType==2">
  16. <view class="input_tip">请选择可采集的指纹门禁:</view>
  17. <input class="input_search" type="text" v-model="dialogForm.searchValue" placeholder="请输入门禁名称" @blur="searchGuard()"/>
  18. <view class="fingerprint_tow_border_li" v-for="(item2,index2) in yesUseList" @click="selectGuard(item2,index2)" :key="index2">
  19. <view :class="item2.isCheck?'colorD':'colorC'">{{item2.subName +'+'+ item2.hardName}}</view>
  20. <img v-if="item2.isCheck" class="fingerprint_tow_border_li_r" src="@/images/icon_xzwt_xz.png">
  21. </view>
  22. </view>
  23. <view v-if="pageType==1" class="tip_one">至少添加一个指纹才可以通过指纹开锁</view>
  24. <view v-if="pageType==1" class="out-button" @click="fingerprintGtherSyncFun">确定</view>
  25. <view v-if="pageType==2" class="out-button" @click="gather">指纹采集</view>
  26. <!-- 指纹采集遮罩-->
  27. <view class="shade-outfire" v-if="dialogVisible">
  28. <view class="null-box" @click="dialogClose()"></view>
  29. <view class="shade-outfire-n">
  30. <view class="shade-outfire-n-t">门禁名称</view>
  31. <img class="shade-outfire-n-t2" src="@/images/icon_zw_bk.png" />
  32. <img class="shade-outfire-n-m" src="@/images/icon_wd_zw.png" />
  33. <view class="shade-outfire-n-b">指纹采集中...</view>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import { config } from '@/api/request/config.js'
  40. import {fingerprintQeryMySubList,fingerprintGther,fingerprintQueryList,fingerprintGtherSync} from '@/api/index.js'
  41. export default {
  42. data() {
  43. return {
  44. //页面状态
  45. pageType:1,
  46. //签名
  47. checked:true,
  48. name:'',
  49. dialogVisible:false,
  50. dialogForm:{
  51. searchValue:'',
  52. },
  53. fingerprintList:[
  54. {
  55. name:'第一个指纹',
  56. num:1,
  57. isConfig:false,
  58. },
  59. {
  60. name:'第二个指纹',
  61. num:2,
  62. isConfig:false,
  63. },
  64. {
  65. name:'第三个指纹',
  66. num:3,
  67. isConfig:false,
  68. },
  69. {
  70. name:'第四个指纹',
  71. num:4,
  72. isConfig:false,
  73. },
  74. {
  75. name:'第五个指纹',
  76. num:5,
  77. isConfig:false,
  78. },
  79. ],
  80. yesUseList:[],
  81. fingerNum:null,//第几个指纹
  82. }
  83. },
  84. onLoad() {
  85. this.impowerUseList();
  86. this.fingerprintClick();
  87. },
  88. onShow(){
  89. },
  90. methods: {
  91. //指紋采集
  92. gather(){
  93. let rest=this.yesUseList.some(v=>v.isCheck==true)
  94. if(rest){
  95. this.dialogVisible=true;
  96. this.fingerprintGtherFun()
  97. }else{
  98. uni.showToast({
  99. mask:true,
  100. icon:"none",
  101. position:"center",
  102. title: '请先选择门禁名称!',
  103. duration: 3000
  104. });
  105. }
  106. },
  107. dialogClose(){
  108. this.dialogVisible=false;
  109. },
  110. searchGuard(){
  111. this.impowerUseList();
  112. },
  113. selectGuard(d,index){
  114. let _this=this;
  115. //选中
  116. d.isCheck=!d.isCheck
  117. this.$set(this.yesUseList,index,d)
  118. //循环实现单选
  119. if(_this.yesUseList[index].isCheck==true){
  120. _this.yesUseList.forEach(function(item2) {
  121. if(item2.hardId==_this.yesUseList[index].hardId){
  122. item2.isCheck=true
  123. }else{
  124. item2.isCheck=false
  125. }
  126. })
  127. }
  128. console.log(this.yesUseList)
  129. },
  130. //查询用户指纹录取数据
  131. async fingerprintClick(){
  132. let _this=this;
  133. const {data} = await fingerprintQueryList(uni.getStorageSync('userId'));
  134. if(data.code == 200){
  135. if(data.rows.length>0){
  136. _this.fingerprintList.forEach(function(item){
  137. data.rows.forEach(function(item2){
  138. if(item.num==item2.fingerNum){
  139. item.isConfig=true;
  140. }
  141. })
  142. })
  143. }
  144. }
  145. },
  146. //指纹采集
  147. async fingerprintGtherFun(){
  148. let _this=this;
  149. let obj={}
  150. this.yesUseList.forEach(function(item){
  151. if(item.isCheck){
  152. obj.hardId=item.hardId
  153. obj.num=_this.fingerNum
  154. }
  155. })
  156. const {data} = await fingerprintGther(obj)
  157. if(data.code == 200){
  158. _this.dialogVisible=false;
  159. _this.pageType=1;
  160. _this.fingerprintClick();
  161. }else if(data.code==500){
  162. _this.dialogVisible=false;
  163. uni.showToast({
  164. mask:true,
  165. icon:"none",
  166. position:"center",
  167. title: data.msg,
  168. duration: 5000
  169. });
  170. }
  171. },
  172. //指纹同步
  173. async fingerprintGtherSyncFun(){
  174. let _this=this;
  175. const {data} = await fingerprintGtherSync(uni.getStorageSync('userId'))
  176. if(data.code == 200){
  177. uni.redirectTo({
  178. url: '/pages/mine',
  179. });
  180. }
  181. },
  182. //查询当前用户已授权门禁列表
  183. async impowerUseList(){
  184. let _this=this;
  185. const {data} = await fingerprintQeryMySubList(_this.dialogForm)
  186. if(data.code == 200){
  187. _this.yesUseList=data.data;
  188. console.log(_this.yesUseList)
  189. _this.yesUseList.forEach(function(item){
  190. item.isCheck=false;
  191. })
  192. }
  193. },
  194. //页面跳转
  195. goPage(d){
  196. this.pageType=2;
  197. this.fingerNum=d.num;
  198. },
  199. },
  200. }
  201. </script>
  202. <style lang="stylus" scoped>
  203. #fingerprint{
  204. height: 100%;
  205. width: 100%;
  206. display: flex;
  207. flex-direction: column;
  208. overflow-y: scroll;
  209. .fingerprint_one{
  210. width: 710rpx;
  211. height: 507rpx;
  212. background: #FFFFFF;
  213. border-radius: 20rpx;
  214. margin: 20rpx;
  215. .fingerprint_one_li{
  216. display: flex;
  217. justify-content: flex-start;
  218. align-items: center;
  219. height: 100rpx;
  220. margin: 0 20rpx;
  221. border-bottom: 1px solid #E0E0E0;
  222. .fingerprint_one_li_l{
  223. font-size: 30rpx;
  224. font-family: PingFang SC;
  225. font-weight: 500;
  226. color: #333333;
  227. text-align: left;
  228. flex: 1;
  229. }
  230. .fingerprint_one_li_r{
  231. width: 12rpx;
  232. height: 24rpx;
  233. }
  234. .colorA{
  235. font-size: 26rpx;
  236. font-family: PingFang SC;
  237. font-weight: 500;
  238. color: #999999;
  239. text-align: right;
  240. margin-right: 40rpx;
  241. flex: 1;
  242. }
  243. .colorB{
  244. font-size: 26rpx;
  245. font-family: PingFang SC;
  246. font-weight: 500;
  247. color: #0183FA;
  248. text-align: right;
  249. margin-right: 40rpx;
  250. flex: 1;
  251. }
  252. }
  253. .fingerprint_one_li:last-child{
  254. border-bottom: none;
  255. }
  256. }
  257. .tip_tow{
  258. margin: 10rpx 0;
  259. .tip_tow_l{
  260. font-size: 24rpx;
  261. font-family: PingFang SC;
  262. font-weight: 500;
  263. color: #FF0000;
  264. line-height: 36rpx;
  265. text-align: left;
  266. margin-left: 36rpx;
  267. }
  268. }
  269. .fingerprint_tow{
  270. width: 710rpx;
  271. background: #FFFFFF;
  272. border-radius: 10px;
  273. margin: 0 20rpx;
  274. padding: 0 20rpx;
  275. box-sizing: border-box;
  276. overflow: hidden;
  277. .input_tip{
  278. font-size: 30rpx;
  279. font-family: PingFang SC;
  280. font-weight: 500;
  281. color: #333333;
  282. line-height: 30rpx;
  283. margin: 34rpx 0;
  284. }
  285. .input_search{
  286. width: 670rpx;
  287. height: 80rpx;
  288. background: #FFFFFF;
  289. border: 1px solid #E0E0E0;
  290. border-radius: 10rpx;
  291. padding-left: 20rpx;
  292. box-sizing: border-box;
  293. margin-bottom: 32rpx;
  294. }
  295. .fingerprint_tow_border_li{
  296. height: 100rpx;
  297. display: flex;
  298. justify-content: space-between;
  299. align-items: center;
  300. margin: 0 20rpx;
  301. border-bottom: 1px solid #E0E0E0;
  302. .fingerprint_tow_border_li_l{}
  303. .fingerprint_tow_border_li_r{
  304. width: 30rpx;
  305. height: 20rpx;
  306. }
  307. .colorC{
  308. font-size: 30rpx;
  309. font-family: PingFang SC;
  310. font-weight: 500;
  311. color: #333333;
  312. }
  313. .colorD{
  314. font-size: 30rpx;
  315. font-family: PingFang SC;
  316. font-weight: 500;
  317. color: #0183FA;
  318. }
  319. }
  320. .fingerprint_tow_border_li:last-child{
  321. border-bottom: none;
  322. }
  323. }
  324. .tip_one{
  325. font-size: 28rpx;
  326. font-family: PingFang SC;
  327. font-weight: 500;
  328. color: #FF0000;
  329. line-height: 30rpx;
  330. margin-top: 36rpx;
  331. text-align: center;
  332. }
  333. .out-button{
  334. position absolute
  335. bottom:140rpx;
  336. left:25rpx;
  337. width:700rpx;
  338. height:100rpx;
  339. line-height:100rpx;
  340. border-radius:10rpx;
  341. text-align center
  342. background #0183FA;
  343. color:#FFFFFF;
  344. font-size: 30rpx;
  345. margin:0 auto;
  346. }
  347. /* 指纹采集 */
  348. .shade-outfire {
  349. height: 100%;
  350. width: 100%;
  351. position: fixed;
  352. display: flex;
  353. flex-direction: column;
  354. z-index: 10;
  355. background: rgba(0, 0, 0, 0.2);
  356. .null-box {
  357. flex: 1;
  358. }
  359. .shade-outfire-n {
  360. width: 625rpx;
  361. height: 550rpx;
  362. background: #FFFFFF;
  363. border-radius: 20rpx;
  364. position: absolute;
  365. top: 370rpx;
  366. left: 62rpx;
  367. .shade-outfire-n-t {
  368. font-size: 30rpx;
  369. font-family: PingFang SC;
  370. font-weight: 500;
  371. color: #333333;
  372. text-align: center;
  373. margin-top: 32rpx;
  374. }
  375. .shade-outfire-n-t2 {
  376. width: 182rpx;
  377. height: 202rpx;
  378. position: absolute;
  379. left: 222rpx;
  380. top: 106rpx;
  381. }
  382. .shade-outfire-n-m {
  383. width: 84rpx;
  384. height: 108rpx;
  385. position: absolute;
  386. left: 266rpx;
  387. top: 150rpx;
  388. }
  389. .shade-outfire-n-b {
  390. width: 100%;
  391. font-size: 30rpx;
  392. font-family: PingFang SC;
  393. font-weight: 500;
  394. color: #0183FA;
  395. text-align: center;
  396. position: absolute;
  397. top: 358rpx;
  398. }
  399. }
  400. }
  401. }
  402. </style>