fingerprint.vue 9.7 KB

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