mine.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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. let self = this;
  161. if(type == 1){
  162. uni.navigateTo({
  163. url: '/pages_student/mine/creditPoints',
  164. });
  165. }else if(type == 2){
  166. uni.navigateTo({
  167. url: '/pages_student/mine/rewardPoints',
  168. });
  169. }else if(type == 3){
  170. uni.scanCode({
  171. onlyFromCamera: true,
  172. success: function (res) {
  173. uni.navigateTo({
  174. url: '/pages_student/mine/codeSuccess?q='+encodeURIComponent(JSON.stringify(res.result))
  175. });
  176. }
  177. });
  178. }
  179. },
  180. //获取个人信息
  181. async simpleInfo(){
  182. const {data} = await simpleInfo();
  183. if(data.code == 200){
  184. this.userData = data.data;
  185. this.userData.avatar=data.data.avatar;
  186. this.userData.avatarUrl=config.base_url+data.data.avatar;
  187. console.log(config.base_url)
  188. console.log(this.userData.avatarUrl)
  189. if(this.userType == 1){
  190. this.getSafeWarnList();
  191. }else if(this.userType == 2){
  192. this.getMyPointsLogInfo();
  193. }
  194. if(data.data.count){
  195. this.adminSubCount = data.data.count.adminSubCount;
  196. this.wranDoCount = data.data.count.wranDoCount;
  197. }
  198. this.pageType = true;
  199. }
  200. },
  201. //查询用户指纹录取数量
  202. async fingerprintQuantityFun(){
  203. let _this=this;
  204. const {data} = await fingerprintQuantity(uni.getStorageSync('userId'));
  205. if(data.code == 200){
  206. _this.Quantity=data.data;
  207. }
  208. },
  209. //查询用户指纹录取数据
  210. async fingerprintClick(){
  211. let _this=this;
  212. const {data} = await fingerprintQueryList(uni.getStorageSync('userId'));
  213. if(data.code == 200){
  214. uni.navigateTo({
  215. url: '/pages/fingerprint',//指纹信息
  216. });
  217. }
  218. },
  219. //查询用户电子签名
  220. async querySignature(){
  221. let _this=this;
  222. const {data} = await querySignature();
  223. if(data.code == 200){
  224. _this.isUpload=data.data.isUpload;
  225. _this.signatureUrl=data.data.signature;
  226. }
  227. },
  228. //获取个人奖励分/信用分
  229. async getMyPointsLogInfo(){
  230. const {data} = await getMyPointsLogInfo();
  231. if(data.code == 200){
  232. this.bonusPoints = data.data.bonusPoints;
  233. this.creditScore = data.data.creditScore;
  234. }
  235. },
  236. //获取报警信息列表
  237. async getSafeWarnList(){
  238. let obj = {
  239. pageNum:1,
  240. pageSize:1,
  241. count:0,
  242. groupStatus:1,
  243. };
  244. const {data} = await getSafeWarnList(obj);
  245. if(data.code == 200){
  246. if(data.rows[0]){
  247. this.securityAlertNum = data.rows[0].todayHappenCount;
  248. }else{
  249. this.securityAlertNum = 0;
  250. }
  251. }
  252. },
  253. //获取当前身份人脸验证状态与学生卡上传状态
  254. async studentinfoFacemy(){
  255. let obj = {
  256. studentsId:uni.getStorageSync('userId')
  257. }
  258. const {data} = await studentinfoFacemy(obj)
  259. if(data.code == 200){
  260. this.certification = data.data;
  261. this.ifFaceFeature = data.data.ifFaceFeature;
  262. }
  263. },
  264. //退出按钮
  265. clickOut(){
  266. let self = this;
  267. uni.showModal({
  268. // title: '确认要退出吗?',
  269. content: '确认要退出吗',
  270. cancelColor:"#999",
  271. confirmColor:"#0183FA",
  272. success: function (res) {
  273. if (res.confirm) {
  274. self.logout();
  275. } else if (res.cancel) {
  276. }
  277. }
  278. });
  279. },
  280. //退出登录
  281. async logout() {
  282. let self = this;
  283. const {data} = await logout();
  284. if(data.code == 200){
  285. uni.removeStorageSync('token');
  286. uni.removeStorageSync('userId');
  287. uni.removeStorageSync('userType');
  288. uni.redirectTo({
  289. url: '/pages/login',
  290. });
  291. }
  292. },
  293. //页面跳转
  294. goPage(type){
  295. if(type == 'pointsRecord'){//积分记录
  296. uni.navigateTo({
  297. url: '/pages_student/mine/pointsRecord',
  298. });
  299. }else if(type == 'faceImage'){//身份验证
  300. uni.navigateTo({
  301. url: '/pages/faceImage',
  302. });
  303. }else if(type == 'laboratory'){
  304. uni.navigateTo({
  305. url: '/pages_manage/workbench/laboratory/meLaboratory',//我的实验室
  306. });
  307. }else if(type == 'alarm'){
  308. // uni.navigateTo({
  309. // url: '/pages_manage/workbench/securityAlert/securityAlertList',//安全警报
  310. // });
  311. uni.navigateTo({
  312. url: '/pages/earlyWarningManage/earlyWarningList',//安全警报
  313. });
  314. }else if(type == 'record'){
  315. uni.navigateTo({
  316. url: '/pages_manage/workbench/plan/planList',//预案执行记录
  317. });
  318. }else if(type == 'signature'){
  319. uni.navigateTo({
  320. url: '/pages_manage/workbench/signature/signature?item='+this.signatureUrl,//电子签名
  321. });
  322. }
  323. },
  324. // 头像上传
  325. selectImage() {
  326. let self = this;
  327. wx.chooseImage({
  328. count: 1,
  329. sizeType: ["original", "compressed"],
  330. sourceType: ["album", "camera"],
  331. success: function(res) {
  332. let tempFilePaths = res.tempFilePaths[0];
  333. self.uploadImg(tempFilePaths);
  334. }
  335. });
  336. },
  337. async uploadImg(tempFilePaths){
  338. var self = this;
  339. uni.showLoading({
  340. title: '上传中',
  341. mask: true
  342. });
  343. uni.uploadFile({
  344. url: config.base_url+'/base/file/upload', //仅为示例,非真实的接口地址
  345. header:{'Authorization':uni.getStorageSync('token')},
  346. filePath: tempFilePaths,
  347. name: 'file',
  348. formData: {
  349. 'user': 'test'
  350. },
  351. success: (uploadFileRes) => {
  352. let res = JSON.parse(uploadFileRes.data);
  353. if(res.code == 200){
  354. uni.navigateTo({
  355. url: '/pages/avatar?src='+config.base_url+res.data.url,//预案执行记录
  356. });
  357. }else{
  358. uni.showToast({
  359. title: res.msg,
  360. icon:"none",
  361. mask:true,
  362. duration: 2000
  363. });
  364. }
  365. },
  366. fail: err => {},
  367. complete: () => {
  368. uni.hideLoading()
  369. }
  370. });
  371. },
  372. },
  373. }
  374. </script>
  375. <style lang="stylus" scoped>
  376. #mine{
  377. height:100%;
  378. .top-max-big-box{
  379. /*background:#ffffff;*/
  380. .user-top-max-box-one{
  381. overflow hidden
  382. background url("@/images/img_wd_bg.png") no-repeat
  383. background-size:100%;
  384. height:350rpx;
  385. .top-max-box-one{
  386. background #fff
  387. margin:40rpx 40rpx 0;
  388. z-index:1;
  389. height:180rpx;
  390. border-top-right-radius 20rpx
  391. border-top-left-radius 20rpx
  392. display flex
  393. overflow hidden
  394. .user-img-box{
  395. height:120rpx;
  396. width:100rpx;
  397. margin:30rpx 53rpx 0 22rpx;
  398. img{
  399. height:100rpx;
  400. width:100rpx;
  401. border-radius:50%;
  402. }
  403. view{
  404. font-size:22rpx;
  405. color:#666666;
  406. text-align center
  407. line-height:22rpx;
  408. margin-top:10rpx;
  409. }
  410. }
  411. .name-box{
  412. margin-top:30rpx;
  413. .name-box-min{
  414. display flex
  415. overflow hidden
  416. margin-bottom:11rpx;
  417. view:nth-child(1){
  418. height:48rpx;
  419. line-height:48rpx;
  420. font-size: 30rpx;
  421. color: #333;
  422. }
  423. view:nth-child(2){
  424. height:30rpx;
  425. line-height:30rpx;
  426. font-size:20rpx;
  427. padding:0 20rpx;
  428. margin:9rpx 0 9rpx 20rpx;
  429. }
  430. view-color-one{
  431. background #FDD255;
  432. }
  433. view-color-two{
  434. background #A2A2A2;
  435. }
  436. view-color-tree{
  437. background #0183FA;
  438. }
  439. }
  440. .name-box-user{
  441. line-height:41rpx;
  442. font-size: 22rpx;
  443. color: #333;
  444. }
  445. }
  446. }
  447. .num-max-box{
  448. width:670rpx;
  449. background #fff
  450. border-bottom-right-radius 20rpx
  451. border-bottom-left-radius 20rpx
  452. height:130rpx;
  453. margin:0 40rpx;
  454. display flex
  455. .min-num-box{
  456. flex:1;
  457. .min-num-view{
  458. margin-top:30rpx;
  459. height:30rpx;
  460. line-height:30rpx;
  461. font-size:22rpx;
  462. text-align center
  463. }
  464. .color-one{
  465. font-weight:700;
  466. font-size:26rpx;
  467. color:#2B99FE;
  468. }
  469. .color-two{
  470. font-weight:700;
  471. font-size:26rpx;
  472. color:#FDD255;
  473. }
  474. .bottom-min-num-view{
  475. display flex
  476. margin-top:20rpx;
  477. .img-one{
  478. width:25rpx;
  479. height:28rpx;
  480. margin: 0 10rpx 0 58rpx;
  481. }
  482. .img-two{
  483. width:28rpx;
  484. height:26rpx;
  485. margin: 0 10rpx 0 59rpx;
  486. }
  487. view{
  488. font-size:22rpx;
  489. }
  490. }
  491. }
  492. }
  493. .null-p{
  494. background #dedede
  495. height:30rpx;
  496. width:2rpx;
  497. margin:50rpx 0 0;
  498. }
  499. }
  500. .top-max-box-two{
  501. background url("@/images/img_wd_bg.png")
  502. background-size:100%;
  503. height:245rpx;
  504. display flex
  505. overflow hidden
  506. .user-img-box{
  507. height:120rpx;
  508. width:100rpx;
  509. margin:50rpx 53rpx 0 22rpx;
  510. img{
  511. height:100rpx;
  512. width:100rpx;
  513. border-radius:50%;
  514. }
  515. view{
  516. font-size:22rpx;
  517. color:#fff;
  518. text-align center
  519. line-height:22rpx;
  520. margin-top:10rpx;
  521. }
  522. }
  523. .name-box{
  524. margin-top:50rpx;
  525. view:nth-child(1){
  526. line-height:48rpx;
  527. margin-bottom:11rpx;
  528. font-size: 30rpx;
  529. color: #fff;
  530. }
  531. view:nth-child(2){
  532. line-height:41rpx;
  533. font-size: 22rpx;
  534. color: #fff;
  535. }
  536. }
  537. }
  538. .button-max-big-box{
  539. background #fff
  540. padding:0 20rpx;
  541. margin-top:30rpx;
  542. .button-max-box{
  543. height:100rpx;
  544. display flex
  545. border-top:1rpx solid #e0e0e0;
  546. .left-img{
  547. height:30rpx;
  548. width:30rpx;
  549. margin:34rpx 44rpx 0 0;
  550. }
  551. view{
  552. line-height:100rpx;
  553. }
  554. view:nth-child(2){
  555. flex:1;
  556. color:#333333;
  557. font-size: 30rpx;
  558. }
  559. .right-img{
  560. height:24rpx;
  561. width:12rpx;
  562. margin:39rpx 0 0 0;
  563. }
  564. .colorA{
  565. color:#E45656!important;
  566. }
  567. .marginType{
  568. margin-right:12rpx;
  569. }
  570. .view-three-one{
  571. width:30rpx;
  572. height:30rpx;
  573. text-align center
  574. background #FF4552
  575. border-radius:50%;
  576. font-size:20rpx;
  577. line-height:30rpx;
  578. color:#fff;
  579. margin:36rpx 20rpx;
  580. }
  581. .view-three-two{
  582. width:30rpx;
  583. height:30rpx;
  584. text-align center
  585. border-radius:50%;
  586. font-size:20rpx;
  587. line-height:30rpx;
  588. color:#999;
  589. margin:36rpx 20rpx;
  590. }
  591. .view-three-type{
  592. width:120rpx;
  593. text-align center;
  594. color:#CCCCCC;
  595. font-size: 26rpx;
  596. }
  597. }
  598. .button-max-box:nth-child(1){
  599. border:none;
  600. }
  601. }
  602. }
  603. .out-button{
  604. position absolute
  605. bottom:140rpx;
  606. left:25rpx;
  607. width:700rpx;
  608. height:100rpx;
  609. line-height:100rpx;
  610. border-radius:10rpx;
  611. text-align center
  612. background #E0E0E0
  613. color:#0183FA;
  614. font-size: 30rpx;
  615. margin:0 auto;
  616. }
  617. }
  618. </style>