fingerprint.vue 9.3 KB

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