fingerprint.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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. this.dialogVisible=true;
  94. this.fingerprintGtherFun()
  95. },
  96. dialogClose(){
  97. this.dialogVisible=false;
  98. },
  99. searchGuard(){
  100. this.impowerUseList();
  101. },
  102. selectGuard(d,index){
  103. let _this=this;
  104. //选中
  105. d.isCheck=!d.isCheck
  106. this.$set(this.yesUseList,index,d)
  107. //循环实现单选
  108. if(_this.yesUseList[index].isCheck==true){
  109. _this.yesUseList.forEach(function(item2) {
  110. if(item2.hardId==_this.yesUseList[index].hardId){
  111. item2.isCheck=true
  112. }else{
  113. item2.isCheck=false
  114. }
  115. })
  116. }
  117. console.log(this.yesUseList)
  118. },
  119. //查询用户指纹录取数据
  120. async fingerprintClick(){
  121. let _this=this;
  122. const {data} = await fingerprintQueryList(uni.getStorageSync('userId'));
  123. if(data.code == 200){
  124. if(data.rows.length>0){
  125. _this.fingerprintList.forEach(function(item){
  126. data.rows.forEach(function(item2){
  127. if(item.num==item2.fingerNum){
  128. item.isConfig=true;
  129. }
  130. })
  131. })
  132. }
  133. }
  134. },
  135. //指纹采集
  136. async fingerprintGtherFun(){
  137. let _this=this;
  138. let obj={}
  139. this.yesUseList.forEach(function(item){
  140. if(item.isCheck){
  141. obj.hardId=item.hardId
  142. obj.num=_this.fingerNum
  143. }
  144. })
  145. const {data} = await fingerprintGther(obj)
  146. if(data.code == 200){
  147. _this.dialogVisible=false;
  148. _this.pageType=1;
  149. _this.fingerprintClick();
  150. }else if(data.code==500){
  151. _this.dialogVisible=false;
  152. uni.showToast({
  153. mask:true,
  154. icon:"none",
  155. position:"center",
  156. title: data.msg,
  157. duration: 5000
  158. });
  159. }
  160. },
  161. //指纹同步
  162. async fingerprintGtherSyncFun(){
  163. let _this=this;
  164. const {data} = await fingerprintGtherSync(uni.getStorageSync('userId'))
  165. if(data.code == 200){
  166. uni.redirectTo({
  167. url: '/pages/mine',
  168. });
  169. }
  170. },
  171. //查询当前用户已授权门禁列表
  172. async impowerUseList(){
  173. let _this=this;
  174. const {data} = await fingerprintQeryMySubList(_this.dialogForm)
  175. if(data.code == 200){
  176. _this.yesUseList=data.data;
  177. _this.yesUseList.forEach(function(item){
  178. item.isCheck=false;
  179. })
  180. }
  181. },
  182. //页面跳转
  183. goPage(d){
  184. this.pageType=2;
  185. this.fingerNum=d.num;
  186. },
  187. },
  188. }
  189. </script>
  190. <style lang="stylus" scoped>
  191. #fingerprint{
  192. height: 100%;
  193. width: 100%;
  194. display: flex;
  195. flex-direction: column;
  196. overflow-y: scroll;
  197. .fingerprint_one{
  198. width: 710rpx;
  199. height: 507rpx;
  200. background: #FFFFFF;
  201. border-radius: 20rpx;
  202. margin: 20rpx;
  203. .fingerprint_one_li{
  204. display: flex;
  205. justify-content: flex-start;
  206. align-items: center;
  207. height: 100rpx;
  208. margin: 0 20rpx;
  209. border-bottom: 1px solid #E0E0E0;
  210. .fingerprint_one_li_l{
  211. font-size: 30rpx;
  212. font-family: PingFang SC;
  213. font-weight: 500;
  214. color: #333333;
  215. text-align: left;
  216. flex: 1;
  217. }
  218. .fingerprint_one_li_r{
  219. width: 12rpx;
  220. height: 24rpx;
  221. }
  222. .colorA{
  223. font-size: 26rpx;
  224. font-family: PingFang SC;
  225. font-weight: 500;
  226. color: #999999;
  227. text-align: right;
  228. margin-right: 40rpx;
  229. flex: 1;
  230. }
  231. .colorB{
  232. font-size: 26rpx;
  233. font-family: PingFang SC;
  234. font-weight: 500;
  235. color: #0183FA;
  236. text-align: right;
  237. margin-right: 40rpx;
  238. flex: 1;
  239. }
  240. }
  241. .fingerprint_one_li:last-child{
  242. border-bottom: none;
  243. }
  244. }
  245. .tip_tow{
  246. margin: 10rpx 0;
  247. .tip_tow_l{
  248. font-size: 24rpx;
  249. font-family: PingFang SC;
  250. font-weight: 500;
  251. color: #FF0000;
  252. line-height: 36rpx;
  253. text-align: left;
  254. margin-left: 36rpx;
  255. }
  256. }
  257. .fingerprint_tow{
  258. width: 710rpx;
  259. background: #FFFFFF;
  260. border-radius: 10px;
  261. margin: 0 20rpx;
  262. padding: 0 20rpx;
  263. box-sizing: border-box;
  264. overflow: hidden;
  265. .input_tip{
  266. font-size: 30rpx;
  267. font-family: PingFang SC;
  268. font-weight: 500;
  269. color: #333333;
  270. line-height: 30rpx;
  271. margin: 34rpx 0;
  272. }
  273. .input_search{
  274. width: 670rpx;
  275. height: 80rpx;
  276. background: #FFFFFF;
  277. border: 1px solid #E0E0E0;
  278. border-radius: 10rpx;
  279. padding-left: 20rpx;
  280. box-sizing: border-box;
  281. margin-bottom: 32rpx;
  282. }
  283. .fingerprint_tow_border_li{
  284. height: 100rpx;
  285. display: flex;
  286. justify-content: space-between;
  287. align-items: center;
  288. margin: 0 20rpx;
  289. border-bottom: 1px solid #E0E0E0;
  290. .fingerprint_tow_border_li_l{}
  291. .fingerprint_tow_border_li_r{
  292. width: 30rpx;
  293. height: 20rpx;
  294. }
  295. .colorC{
  296. font-size: 30rpx;
  297. font-family: PingFang SC;
  298. font-weight: 500;
  299. color: #333333;
  300. }
  301. .colorD{
  302. font-size: 30rpx;
  303. font-family: PingFang SC;
  304. font-weight: 500;
  305. color: #0183FA;
  306. }
  307. }
  308. .fingerprint_tow_border_li:last-child{
  309. border-bottom: none;
  310. }
  311. }
  312. .tip_one{
  313. font-size: 28rpx;
  314. font-family: PingFang SC;
  315. font-weight: 500;
  316. color: #FF0000;
  317. line-height: 30rpx;
  318. margin-top: 36rpx;
  319. text-align: center;
  320. }
  321. .out-button{
  322. position absolute
  323. bottom:140rpx;
  324. left:25rpx;
  325. width:700rpx;
  326. height:100rpx;
  327. line-height:100rpx;
  328. border-radius:10rpx;
  329. text-align center
  330. background #0183FA;
  331. color:#FFFFFF;
  332. font-size: 30rpx;
  333. margin:0 auto;
  334. }
  335. /* 指纹采集 */
  336. .shade-outfire {
  337. height: 100%;
  338. width: 100%;
  339. position: fixed;
  340. display: flex;
  341. flex-direction: column;
  342. z-index: 10;
  343. background: rgba(0, 0, 0, 0.2);
  344. .null-box {
  345. flex: 1;
  346. }
  347. .shade-outfire-n {
  348. width: 625rpx;
  349. height: 550rpx;
  350. background: #FFFFFF;
  351. border-radius: 20rpx;
  352. position: absolute;
  353. top: 370rpx;
  354. left: 62rpx;
  355. .shade-outfire-n-t {
  356. font-size: 30rpx;
  357. font-family: PingFang SC;
  358. font-weight: 500;
  359. color: #333333;
  360. text-align: center;
  361. margin-top: 32rpx;
  362. }
  363. .shade-outfire-n-t2 {
  364. width: 182rpx;
  365. height: 202rpx;
  366. position: absolute;
  367. left: 222rpx;
  368. top: 106rpx;
  369. }
  370. .shade-outfire-n-m {
  371. width: 84rpx;
  372. height: 108rpx;
  373. position: absolute;
  374. left: 266rpx;
  375. top: 150rpx;
  376. }
  377. .shade-outfire-n-b {
  378. width: 100%;
  379. font-size: 30rpx;
  380. font-family: PingFang SC;
  381. font-weight: 500;
  382. color: #0183FA;
  383. text-align: center;
  384. position: absolute;
  385. top: 358rpx;
  386. }
  387. }
  388. }
  389. }
  390. </style>