mine.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. <!-- 我的 -->
  2. <template>
  3. <view id="mine">
  4. <view class="top-max-big-box" v-if="pageType">
  5. <!--老师-->
  6. <view class="top-max-box-two" v-if="userType==1&&certification.auditStatus">
  7. <view class="user-img-box" @click="selectImage">
  8. <img v-if="userData.avatar" :src="userData.avatarUrl">
  9. <img v-else src="@/images/icon_01.png">
  10. <view>{{userData.avatar?'编辑':'未上传'}}</view>
  11. </view>
  12. <view class="name-box">
  13. <view>{{userData.userName}}</view>
  14. <view>{{userData.professional}}丨{{userData.deptName}}</view>
  15. </view>
  16. </view>
  17. <!--学生-->
  18. <view class="user-top-max-box-one" v-if="userType==2">
  19. <view class="back-posi"></view>
  20. <view class="top-max-box-one">
  21. <view class="user-img-box" @click="selectImage">
  22. <img v-if="userData.avatar" :src="userData.avatarUrl">
  23. <img v-else src="@/images/icon_01.png">
  24. <view>{{userData.avatar?'编辑':'未上传'}}</view>
  25. </view>
  26. <view class="name-box">
  27. <view class="name-box-min">
  28. <view>{{userData.userName}}</view>
  29. <view :class="userData.status == 2?'view-color-one':(userData.status == 3?'view-color-two':(userData.status == 1?'view-color-tree':''))">{{userData.status == 2?'负面清单':(userData.status == 3?'黑名单':(userData.status == 1?'正常':''))}}</view>
  30. </view>
  31. <view class="name-box-user">{{userData.professional}}丨{{userData.deptName}}</view>
  32. </view>
  33. </view>
  34. <view class="num-max-box">
  35. <view class="min-num-box" @click="goUserPage(1)">
  36. <view class="min-num-view color-one">{{creditScore}}</view>
  37. <view class="bottom-min-num-view">
  38. <img class="img-one" src="@/images/icon_wd_xyf.png">
  39. <view>信用分</view>
  40. </view>
  41. </view>
  42. <view class="null-p"></view>
  43. <view class="min-num-box" @click="goUserPage(2)">
  44. <view class="min-num-view color-two">{{bonusPoints}}</view>
  45. <view class="bottom-min-num-view">
  46. <img class="img-two" src="@/images/icon_wd_jlf.png">
  47. <view>奖励分</view>
  48. </view>
  49. </view>
  50. <view class="null-p"></view>
  51. <view class="min-num-box" @click="goUserPage(3)">
  52. <view class="min-num-view">扫一扫</view>
  53. <view class="bottom-min-num-view">
  54. <img class="img-two" src="@/images/icon_wd_dh.png">
  55. <view>兑换礼品</view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="button-max-big-box">
  61. <view class="button-max-box" @click="goPage('alarm')" v-if="userType==1">
  62. <img class="left-img" src="@/images/icon_003.png">
  63. <view>预警记录</view>
  64. <view class="view-three-one" v-if="securityAlertNum>0">{{securityAlertNum}}</view>
  65. <img class="right-img" src="@/images/icon_04.png">
  66. </view>
  67. <view class="button-max-box" @click="goPage('laboratory')" v-if="userType==1">
  68. <img class="left-img" src="@/images/icon_002.png">
  69. <view>我的实验室</view>
  70. <view class="view-three-two" v-if="adminSubCount>0">{{adminSubCount}}</view>
  71. <img class="right-img" src="@/images/icon_04.png">
  72. </view>
  73. <view class="button-max-box" @click="goPage('record')" v-if="userType==1">
  74. <img class="left-img" src="@/images/icon_004.png">
  75. <view>预案执行记录</view>
  76. <view class="view-three-two" v-if="wranDoCount>0">{{wranDoCount}}</view>
  77. <img class="right-img" src="@/images/icon_04.png">
  78. </view>
  79. <view class="button-max-box" @click="goPage('faceImage')">
  80. <img class="left-img" src="@/images/icon_001.png">
  81. <view>身份验证</view>
  82. <view class="view-three-type" :class="!ifFaceFeature?'colorA':'marginType'">{{!ifFaceFeature?'去认证':'已认证'}}</view>
  83. <img class="right-img" src="@/images/icon_04.png">
  84. </view>
  85. <!-- <view class="button-max-box" @click="goPage('signature')">
  86. <img class="left-img" src="@/images/icon_wd_dzqm.png">
  87. <view>电子签名</view>
  88. <view class="view-three-type" :class="!isUpload?'colorA':'marginType'">{{!isUpload?'未上传':'已上传'}}</view>
  89. <img class="right-img" src="@/images/icon_04.png">
  90. </view> -->
  91. <view class="button-max-box" @click="fingerprintClick()">
  92. <img class="left-img" src="@/images/icon_wd_zw.png">
  93. <view>指纹</view>
  94. <view class="view-three-type" :class="Quantity>0?'marginType':'colorA'">{{Quantity>0?'已配置'+Quantity+'个':''}}</view>
  95. <img class="right-img" src="@/images/icon_04.png">
  96. </view>
  97. </view>
  98. </view>
  99. <view class="out-button" @click="clickOut">退出登录</view>
  100. <tab-bar></tab-bar>
  101. </view>
  102. </template>
  103. <script>
  104. import { config } from '@/api/request/config.js'
  105. import { logout,studentinfoFacemy,simpleInfo,getSafeWarnList,getMyPointsLogInfo,querySignature,fingerprintQuantity,fingerprintQueryList} from '@/api/index.js'
  106. import { tabBar } from '@/component/tabBar.vue'
  107. export default {
  108. components: {
  109. tabBar
  110. },
  111. data() {
  112. return {
  113. //页面状态
  114. pageType:false,
  115. //认证数据
  116. certification:{
  117. },
  118. userType:0,
  119. userData:{
  120. deptName: "",
  121. professional: "",
  122. userName: "",
  123. },
  124. securityAlertNum:0,
  125. adminSubCount:0,
  126. wranDoCount:0,
  127. //奖励分
  128. bonusPoints:0,
  129. //信用分
  130. creditScore:0,
  131. //用户签名
  132. signatureUrl:'',
  133. // 人脸
  134. ifFaceFeature:"",
  135. //签名
  136. isUpload:"",
  137. Quantity:0,//指纹录取数量
  138. }
  139. },
  140. onLoad() {
  141. },
  142. onShow(){
  143. if(uni.getStorageSync('token')&&uni.getStorageSync('userId')&&uni.getStorageSync('userType')){
  144. this.userType = uni.getStorageSync('userType')
  145. this.studentinfoFacemy();
  146. this.simpleInfo();
  147. //this.querySignature();
  148. }else{
  149. uni.removeStorageSync('token');
  150. uni.removeStorageSync('userId');
  151. uni.removeStorageSync('userType');
  152. uni.redirectTo({
  153. url: '/pages/login',
  154. });
  155. }
  156. },
  157. methods: {
  158. //学生端-信用分/奖励分/扫一扫按钮
  159. goUserPage(type){
  160. uni.showToast({
  161. title: '暂未开放',
  162. mask:true,
  163. icon:"none",
  164. duration: 2000
  165. });
  166. // let self = this;
  167. // if(type == 1){
  168. // uni.navigateTo({
  169. // url: '/pages_student/mine/creditPoints',
  170. // });
  171. // }else if(type == 2){
  172. // uni.navigateTo({
  173. // url: '/pages_student/mine/rewardPoints',
  174. // });
  175. // }else if(type == 3){
  176. // uni.scanCode({
  177. // onlyFromCamera: true,
  178. // success: function (res) {
  179. // uni.navigateTo({
  180. // url: '/pages_student/mine/codeSuccess?q='+encodeURIComponent(JSON.stringify(res.result))
  181. // });
  182. // }
  183. // });
  184. // }
  185. },
  186. //获取个人信息
  187. async simpleInfo(){
  188. const {data} = await simpleInfo();
  189. if(data.code == 200){
  190. this.userData = data.data;
  191. this.userData.avatar=data.data.avatar;
  192. this.userData.avatarUrl=config.base_url+data.data.avatar;
  193. console.log(config.base_url)
  194. console.log(this.userData.avatarUrl)
  195. if(this.userType == 1){
  196. this.getSafeWarnList();
  197. }else if(this.userType == 2){
  198. //this.getMyPointsLogInfo();
  199. }
  200. if(data.data.count){
  201. this.adminSubCount = data.data.count.adminSubCount;
  202. this.wranDoCount = data.data.count.wranDoCount;
  203. }
  204. this.pageType = true;
  205. }
  206. },
  207. //查询用户指纹录取数量
  208. async fingerprintQuantityFun(){
  209. let _this=this;
  210. const {data} = await fingerprintQuantity(uni.getStorageSync('userId'));
  211. if(data.code == 200){
  212. _this.Quantity=data.data;
  213. }
  214. },
  215. //查询用户指纹录取数据
  216. async fingerprintClick(){
  217. let _this=this;
  218. const {data} = await fingerprintQueryList(uni.getStorageSync('userId'));
  219. if(data.code == 200){
  220. uni.navigateTo({
  221. url: '/pages/fingerprint',//指纹信息
  222. });
  223. }
  224. },
  225. //查询用户电子签名
  226. async querySignature(){
  227. let _this=this;
  228. const {data} = await querySignature();
  229. if(data.code == 200){
  230. _this.isUpload=data.data.isUpload;
  231. _this.signatureUrl=data.data.signature;
  232. }
  233. },
  234. //获取个人奖励分/信用分
  235. async getMyPointsLogInfo(){
  236. const {data} = await getMyPointsLogInfo();
  237. if(data.code == 200){
  238. this.bonusPoints = data.data.bonusPoints;
  239. this.creditScore = data.data.creditScore;
  240. }
  241. },
  242. //获取报警信息列表
  243. async getSafeWarnList(){
  244. let obj = {
  245. pageNum:1,
  246. pageSize:1,
  247. count:0,
  248. groupStatus:1,
  249. };
  250. const {data} = await getSafeWarnList(obj);
  251. if(data.code == 200){
  252. if(data.rows[0]){
  253. this.securityAlertNum = data.rows[0].todayHappenCount;
  254. }else{
  255. this.securityAlertNum = 0;
  256. }
  257. }
  258. },
  259. //获取当前身份人脸验证状态与学生卡上传状态
  260. async studentinfoFacemy(){
  261. let obj = {
  262. studentsId:uni.getStorageSync('userId')
  263. }
  264. const {data} = await studentinfoFacemy(obj)
  265. if(data.code == 200){
  266. this.certification = data.data;
  267. this.ifFaceFeature = data.data.ifFaceFeature;
  268. }
  269. },
  270. //退出按钮
  271. clickOut(){
  272. let self = this;
  273. uni.showModal({
  274. // title: '确认要退出吗?',
  275. content: '确认要退出吗',
  276. cancelColor:"#999",
  277. confirmColor:"#0183FA",
  278. success: function (res) {
  279. if (res.confirm) {
  280. self.logout();
  281. } else if (res.cancel) {
  282. }
  283. }
  284. });
  285. },
  286. //退出登录
  287. async logout() {
  288. let self = this;
  289. const {data} = await logout();
  290. if(data.code == 200){
  291. uni.removeStorageSync('token');
  292. uni.removeStorageSync('userId');
  293. uni.removeStorageSync('userType');
  294. uni.redirectTo({
  295. url: '/pages/login',
  296. });
  297. }
  298. },
  299. //页面跳转
  300. goPage(type){
  301. if(type == 'pointsRecord'){//积分记录
  302. uni.navigateTo({
  303. url: '/pages_student/mine/pointsRecord',
  304. });
  305. }else if(type == 'faceImage'){//身份验证
  306. uni.navigateTo({
  307. url: '/pages/faceImage',
  308. });
  309. }else if(type == 'laboratory'){
  310. uni.navigateTo({
  311. url: '/pages_manage/workbench/laboratory/meLaboratory',//我的实验室
  312. });
  313. }else if(type == 'alarm'){
  314. // uni.navigateTo({
  315. // url: '/pages_manage/workbench/securityAlert/securityAlertList',//安全警报
  316. // });
  317. uni.navigateTo({
  318. url: '/pages/earlyWarningManage/earlyWarningList',//安全警报
  319. });
  320. }else if(type == 'record'){
  321. uni.navigateTo({
  322. url: '/pages_manage/workbench/plan/planList',//预案执行记录
  323. });
  324. }else if(type == 'signature'){
  325. uni.navigateTo({
  326. url: '/pages_manage/workbench/signature/signature?item='+this.signatureUrl,//电子签名
  327. });
  328. }
  329. },
  330. // 头像上传
  331. selectImage() {
  332. let self = this;
  333. wx.chooseImage({
  334. count: 1,
  335. sizeType: ["original", "compressed"],
  336. sourceType: ["album", "camera"],
  337. success: function(res) {
  338. let tempFilePaths = res.tempFilePaths[0];
  339. self.uploadImg(tempFilePaths);
  340. }
  341. });
  342. },
  343. async uploadImg(tempFilePaths){
  344. var self = this;
  345. uni.showLoading({
  346. title: '上传中',
  347. mask: true
  348. });
  349. uni.uploadFile({
  350. url: config.base_url+'/base/file/upload', //仅为示例,非真实的接口地址
  351. header:{'Authorization':uni.getStorageSync('token')},
  352. filePath: tempFilePaths,
  353. name: 'file',
  354. formData: {
  355. 'user': 'test'
  356. },
  357. success: (uploadFileRes) => {
  358. let res = JSON.parse(uploadFileRes.data);
  359. if(res.code == 200){
  360. uni.navigateTo({
  361. url: '/pages/avatar?src='+config.base_url+res.data.url,//预案执行记录
  362. });
  363. }else{
  364. uni.showToast({
  365. title: res.msg,
  366. icon:"none",
  367. mask:true,
  368. duration: 2000
  369. });
  370. }
  371. },
  372. fail: err => {},
  373. complete: () => {
  374. uni.hideLoading()
  375. }
  376. });
  377. },
  378. },
  379. }
  380. </script>
  381. <style lang="stylus" scoped>
  382. #mine{
  383. height:100%;
  384. .top-max-big-box{
  385. /*background:#ffffff;*/
  386. .user-top-max-box-one{
  387. overflow hidden
  388. background url("@/images/img_wd_bg.png") no-repeat
  389. background-size:100%;
  390. height:350rpx;
  391. .top-max-box-one{
  392. background #fff
  393. margin:40rpx 40rpx 0;
  394. z-index:1;
  395. height:180rpx;
  396. border-top-right-radius 20rpx
  397. border-top-left-radius 20rpx
  398. display flex
  399. overflow hidden
  400. .user-img-box{
  401. height:120rpx;
  402. width:100rpx;
  403. margin:30rpx 53rpx 0 22rpx;
  404. img{
  405. height:100rpx;
  406. width:100rpx;
  407. border-radius:50%;
  408. }
  409. view{
  410. font-size:22rpx;
  411. color:#666666;
  412. text-align center
  413. line-height:22rpx;
  414. margin-top:10rpx;
  415. }
  416. }
  417. .name-box{
  418. margin-top:30rpx;
  419. .name-box-min{
  420. display flex
  421. overflow hidden
  422. margin-bottom:11rpx;
  423. view:nth-child(1){
  424. height:48rpx;
  425. line-height:48rpx;
  426. font-size: 30rpx;
  427. color: #333;
  428. }
  429. view:nth-child(2){
  430. height:30rpx;
  431. line-height:30rpx;
  432. font-size:20rpx;
  433. padding:0 20rpx;
  434. margin:9rpx 0 9rpx 20rpx;
  435. }
  436. view-color-one{
  437. background #FDD255;
  438. }
  439. view-color-two{
  440. background #A2A2A2;
  441. }
  442. view-color-tree{
  443. background #0183FA;
  444. }
  445. }
  446. .name-box-user{
  447. line-height:41rpx;
  448. font-size: 22rpx;
  449. color: #333;
  450. }
  451. }
  452. }
  453. .num-max-box{
  454. width:670rpx;
  455. background #fff
  456. border-bottom-right-radius 20rpx
  457. border-bottom-left-radius 20rpx
  458. height:130rpx;
  459. margin:0 40rpx;
  460. display flex
  461. .min-num-box{
  462. flex:1;
  463. .min-num-view{
  464. margin-top:30rpx;
  465. height:30rpx;
  466. line-height:30rpx;
  467. font-size:22rpx;
  468. text-align center
  469. }
  470. .color-one{
  471. font-weight:700;
  472. font-size:26rpx;
  473. color:#2B99FE;
  474. }
  475. .color-two{
  476. font-weight:700;
  477. font-size:26rpx;
  478. color:#FDD255;
  479. }
  480. .bottom-min-num-view{
  481. display flex
  482. margin-top:20rpx;
  483. .img-one{
  484. width:25rpx;
  485. height:28rpx;
  486. margin: 0 10rpx 0 58rpx;
  487. }
  488. .img-two{
  489. width:28rpx;
  490. height:26rpx;
  491. margin: 0 10rpx 0 59rpx;
  492. }
  493. view{
  494. font-size:22rpx;
  495. }
  496. }
  497. }
  498. }
  499. .null-p{
  500. background #dedede
  501. height:30rpx;
  502. width:2rpx;
  503. margin:50rpx 0 0;
  504. }
  505. }
  506. .top-max-box-two{
  507. background url("@/images/img_wd_bg.png")
  508. background-size:100%;
  509. height:245rpx;
  510. display flex
  511. overflow hidden
  512. .user-img-box{
  513. height:120rpx;
  514. width:100rpx;
  515. margin:50rpx 53rpx 0 22rpx;
  516. img{
  517. height:100rpx;
  518. width:100rpx;
  519. border-radius:50%;
  520. }
  521. view{
  522. font-size:22rpx;
  523. color:#fff;
  524. text-align center
  525. line-height:22rpx;
  526. margin-top:10rpx;
  527. }
  528. }
  529. .name-box{
  530. margin-top:50rpx;
  531. view:nth-child(1){
  532. line-height:48rpx;
  533. margin-bottom:11rpx;
  534. font-size: 30rpx;
  535. color: #fff;
  536. }
  537. view:nth-child(2){
  538. line-height:41rpx;
  539. font-size: 22rpx;
  540. color: #fff;
  541. }
  542. }
  543. }
  544. .button-max-big-box{
  545. background #fff
  546. padding:0 20rpx;
  547. margin-top:30rpx;
  548. .button-max-box{
  549. height:100rpx;
  550. display flex
  551. border-top:1rpx solid #e0e0e0;
  552. .left-img{
  553. height:30rpx;
  554. width:30rpx;
  555. margin:34rpx 44rpx 0 0;
  556. }
  557. view{
  558. line-height:100rpx;
  559. }
  560. view:nth-child(2){
  561. flex:1;
  562. color:#333333;
  563. font-size: 30rpx;
  564. }
  565. .right-img{
  566. height:24rpx;
  567. width:12rpx;
  568. margin:39rpx 0 0 0;
  569. }
  570. .colorA{
  571. color:#E45656!important;
  572. }
  573. .marginType{
  574. margin-right:12rpx;
  575. }
  576. .view-three-one{
  577. width:30rpx;
  578. height:30rpx;
  579. text-align center
  580. background #FF4552
  581. border-radius:50%;
  582. font-size:20rpx;
  583. line-height:30rpx;
  584. color:#fff;
  585. margin:36rpx 20rpx;
  586. }
  587. .view-three-two{
  588. width:30rpx;
  589. height:30rpx;
  590. text-align center
  591. border-radius:50%;
  592. font-size:20rpx;
  593. line-height:30rpx;
  594. color:#999;
  595. margin:36rpx 20rpx;
  596. }
  597. .view-three-type{
  598. width:120rpx;
  599. text-align center;
  600. color:#CCCCCC;
  601. font-size: 26rpx;
  602. }
  603. }
  604. .button-max-box:nth-child(1){
  605. border:none;
  606. }
  607. }
  608. }
  609. .out-button{
  610. position absolute
  611. bottom:140rpx;
  612. left:25rpx;
  613. width:700rpx;
  614. height:100rpx;
  615. line-height:100rpx;
  616. border-radius:10rpx;
  617. text-align center
  618. background #E0E0E0
  619. color:#0183FA;
  620. font-size: 30rpx;
  621. margin:0 auto;
  622. }
  623. }
  624. </style>