mine.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  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.avatar">
  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="goPage('upStudentCard')" v-if="userType==2&&certification.auditStatus">
  92. <img class="left-img" src="@/images/icon_03.png">
  93. <view>学生卡绑定</view>
  94. <view class="view-three-type" :class="certification.auditStatus.code == 2 || certification.auditStatus.code == 3?'colorA':'marginType'">
  95. {{certification.auditStatus.code == 0?'待审核':(certification.auditStatus.code == 1?'已绑定':(certification.auditStatus.code == 2?'未通过':(certification.auditStatus.code == 3?'去绑定':'')))}}
  96. </view>
  97. <img class="right-img" v-if="certification.auditStatus.code == 2 || certification.auditStatus.code == 3" src="@/images/icon_04.png">
  98. </view>
  99. <view class="button-max-box" @click="fingerprintClick()">
  100. <img class="left-img" src="@/images/icon_wd_zw.png">
  101. <view>指纹</view>
  102. <view class="view-three-type" :class="Quantity>0?'marginType':'colorA'">{{Quantity>0?'已配置'+Quantity+'个':''}}</view>
  103. <img class="right-img" src="@/images/icon_04.png">
  104. </view>
  105. </view>
  106. </view>
  107. <view class="out-button" @click="clickOut">退出登录</view>
  108. <tab-bar></tab-bar>
  109. </view>
  110. </template>
  111. <script>
  112. import { config } from '@/api/request/config.js'
  113. import { logout,studentinfoFacemy,simpleInfo,getSafeWarnList,getMyPointsLogInfo,querySignature,fingerprintQuantity,fingerprintQueryList} from '@/api/index.js'
  114. import { tabBar } from '@/component/tabBar.vue'
  115. export default {
  116. components: {
  117. tabBar
  118. },
  119. data() {
  120. return {
  121. //页面状态
  122. pageType:false,
  123. //认证数据
  124. certification:{
  125. },
  126. userType:0,
  127. userData:{
  128. deptName: "",
  129. professional: "",
  130. userName: "",
  131. },
  132. securityAlertNum:0,
  133. adminSubCount:0,
  134. wranDoCount:0,
  135. //奖励分
  136. bonusPoints:0,
  137. //信用分
  138. creditScore:0,
  139. //用户签名
  140. signatureUrl:'',
  141. // 人脸
  142. ifFaceFeature:"",
  143. //签名
  144. isUpload:"",
  145. Quantity:0,//指纹录取数量
  146. }
  147. },
  148. onLoad() {
  149. },
  150. onShow(){
  151. if(uni.getStorageSync('token')&&uni.getStorageSync('userId')&&uni.getStorageSync('userType')){
  152. this.userType = uni.getStorageSync('userType')
  153. this.studentinfoFacemy();
  154. this.simpleInfo();
  155. this.querySignature();
  156. }else{
  157. uni.removeStorageSync('token');
  158. uni.removeStorageSync('userId');
  159. uni.removeStorageSync('userType');
  160. uni.redirectTo({
  161. url: '/pages/login',
  162. });
  163. }
  164. },
  165. methods: {
  166. //学生端-信用分/奖励分/扫一扫按钮
  167. goUserPage(type){
  168. let self = this;
  169. if(type == 1){
  170. uni.navigateTo({
  171. url: '/pages_student/mine/creditPoints',
  172. });
  173. }else if(type == 2){
  174. uni.navigateTo({
  175. url: '/pages_student/mine/rewardPoints',
  176. });
  177. }else if(type == 3){
  178. uni.scanCode({
  179. onlyFromCamera: true,
  180. success: function (res) {
  181. uni.navigateTo({
  182. url: '/pages_student/mine/codeSuccess?q='+encodeURIComponent(JSON.stringify(res.result))
  183. });
  184. }
  185. });
  186. }
  187. },
  188. //获取个人信息
  189. async simpleInfo(){
  190. const {data} = await simpleInfo();
  191. if(data.code == 200){
  192. this.userData = data.data;
  193. this.userData.avatar=data.data.avatar;
  194. this.userData.avatarUrl=config.base_url+data.data.avatar;
  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 == 'upStudentCard'){//学生卡上传
  302. // if(this.certification.auditStatus.code == 2||this.certification.auditStatus.code == 3){
  303. uni.navigateTo({
  304. url: '/pages_student/mine/upStudentCard',
  305. });
  306. // }
  307. }else if(type == 'pointsRecord'){//积分记录
  308. uni.navigateTo({
  309. url: '/pages_student/mine/pointsRecord',
  310. });
  311. }else if(type == 'faceImage'){//人脸图像
  312. uni.navigateTo({
  313. url: '/pages/faceImage',
  314. });
  315. }else if(type == 'laboratory'){
  316. uni.navigateTo({
  317. url: '/pages_manage/workbench/laboratory/meLaboratory',//我的实验室
  318. });
  319. }else if(type == 'alarm'){
  320. uni.navigateTo({
  321. url: '/pages_manage/workbench/securityAlert/securityAlertList',//安全警报
  322. });
  323. }else if(type == 'record'){
  324. uni.navigateTo({
  325. url: '/pages_manage/workbench/plan/planList',//预案执行记录
  326. });
  327. }else if(type == 'signature'){
  328. uni.navigateTo({
  329. url: '/pages_manage/workbench/signature/signature?item='+this.signatureUrl,//电子签名
  330. });
  331. }
  332. },
  333. // 头像上传
  334. selectImage() {
  335. let self = this;
  336. wx.chooseImage({
  337. count: 1,
  338. sizeType: ["original", "compressed"],
  339. sourceType: ["album", "camera"],
  340. success: function(res) {
  341. let tempFilePaths = res.tempFilePaths[0];
  342. self.uploadImg(tempFilePaths);
  343. }
  344. });
  345. },
  346. async uploadImg(tempFilePaths){
  347. var self = this;
  348. uni.showLoading({
  349. title: '上传中',
  350. mask: true
  351. });
  352. uni.uploadFile({
  353. url: config.base_url+'/base/file/upload', //仅为示例,非真实的接口地址
  354. header:{'Authorization':uni.getStorageSync('token')},
  355. filePath: tempFilePaths,
  356. name: 'file',
  357. formData: {
  358. 'user': 'test'
  359. },
  360. success: (uploadFileRes) => {
  361. let res = JSON.parse(uploadFileRes.data);
  362. if(res.code == 200){
  363. uni.navigateTo({
  364. url: '/pages/avatar?src='+config.base_url+res.data.url,//预案执行记录
  365. });
  366. }else{
  367. uni.showToast({
  368. title: res.msg,
  369. icon:"none",
  370. mask:true,
  371. duration: 2000
  372. });
  373. }
  374. },
  375. fail: err => {},
  376. complete: () => {
  377. uni.hideLoading()
  378. }
  379. });
  380. },
  381. },
  382. }
  383. </script>
  384. <style lang="stylus" scoped>
  385. #mine{
  386. height:100%;
  387. .top-max-big-box{
  388. /*background:#ffffff;*/
  389. .user-top-max-box-one{
  390. overflow hidden
  391. background url("@/images/img_wd_bg.png") no-repeat
  392. background-size:100%;
  393. height:350rpx;
  394. .top-max-box-one{
  395. background #fff
  396. margin:40rpx 40rpx 0;
  397. z-index:1;
  398. height:180rpx;
  399. border-top-right-radius 20rpx
  400. border-top-left-radius 20rpx
  401. display flex
  402. overflow hidden
  403. .user-img-box{
  404. height:120rpx;
  405. width:100rpx;
  406. margin:30rpx 53rpx 0 22rpx;
  407. img{
  408. height:100rpx;
  409. width:100rpx;
  410. border-radius:50%;
  411. }
  412. view{
  413. font-size:22rpx;
  414. color:#666666;
  415. text-align center
  416. line-height:22rpx;
  417. margin-top:10rpx;
  418. }
  419. }
  420. .name-box{
  421. margin-top:30rpx;
  422. .name-box-min{
  423. display flex
  424. overflow hidden
  425. margin-bottom:11rpx;
  426. view:nth-child(1){
  427. height:48rpx;
  428. line-height:48rpx;
  429. font-size: 30rpx;
  430. color: #333;
  431. }
  432. view:nth-child(2){
  433. height:30rpx;
  434. line-height:30rpx;
  435. font-size:20rpx;
  436. padding:0 20rpx;
  437. margin:9rpx 0 9rpx 20rpx;
  438. }
  439. view-color-one{
  440. background #FDD255;
  441. }
  442. view-color-two{
  443. background #A2A2A2;
  444. }
  445. view-color-tree{
  446. background #0183FA;
  447. }
  448. }
  449. .name-box-user{
  450. line-height:41rpx;
  451. font-size: 22rpx;
  452. color: #333;
  453. }
  454. }
  455. }
  456. .num-max-box{
  457. width:670rpx;
  458. background #fff
  459. border-bottom-right-radius 20rpx
  460. border-bottom-left-radius 20rpx
  461. height:130rpx;
  462. margin:0 40rpx;
  463. display flex
  464. .min-num-box{
  465. flex:1;
  466. .min-num-view{
  467. margin-top:30rpx;
  468. height:30rpx;
  469. line-height:30rpx;
  470. font-size:22rpx;
  471. text-align center
  472. }
  473. .color-one{
  474. font-weight:700;
  475. font-size:26rpx;
  476. color:#2B99FE;
  477. }
  478. .color-two{
  479. font-weight:700;
  480. font-size:26rpx;
  481. color:#FDD255;
  482. }
  483. .bottom-min-num-view{
  484. display flex
  485. margin-top:20rpx;
  486. .img-one{
  487. width:25rpx;
  488. height:28rpx;
  489. margin: 0 10rpx 0 58rpx;
  490. }
  491. .img-two{
  492. width:28rpx;
  493. height:26rpx;
  494. margin: 0 10rpx 0 59rpx;
  495. }
  496. view{
  497. font-size:22rpx;
  498. }
  499. }
  500. }
  501. }
  502. .null-p{
  503. background #dedede
  504. height:30rpx;
  505. width:2rpx;
  506. margin:50rpx 0 0;
  507. }
  508. }
  509. .top-max-box-two{
  510. background url("@/images/img_wd_bg.png")
  511. background-size:100%;
  512. height:245rpx;
  513. display flex
  514. overflow hidden
  515. .user-img-box{
  516. height:120rpx;
  517. width:100rpx;
  518. margin:50rpx 53rpx 0 22rpx;
  519. img{
  520. height:100rpx;
  521. width:100rpx;
  522. border-radius:50%;
  523. }
  524. view{
  525. font-size:22rpx;
  526. color:#fff;
  527. text-align center
  528. line-height:22rpx;
  529. margin-top:10rpx;
  530. }
  531. }
  532. .name-box{
  533. margin-top:50rpx;
  534. view:nth-child(1){
  535. line-height:48rpx;
  536. margin-bottom:11rpx;
  537. font-size: 30rpx;
  538. color: #fff;
  539. }
  540. view:nth-child(2){
  541. line-height:41rpx;
  542. font-size: 22rpx;
  543. color: #fff;
  544. }
  545. }
  546. }
  547. .button-max-big-box{
  548. background #fff
  549. padding:0 20rpx;
  550. margin-top:30rpx;
  551. .button-max-box{
  552. height:100rpx;
  553. display flex
  554. border-top:1rpx solid #e0e0e0;
  555. .left-img{
  556. height:30rpx;
  557. width:30rpx;
  558. margin:34rpx 44rpx 0 0;
  559. }
  560. view{
  561. line-height:100rpx;
  562. }
  563. view:nth-child(2){
  564. flex:1;
  565. color:#333333;
  566. font-size: 30rpx;
  567. }
  568. .right-img{
  569. height:24rpx;
  570. width:12rpx;
  571. margin:39rpx 0 0 0;
  572. }
  573. .colorA{
  574. color:#E45656!important;
  575. }
  576. .marginType{
  577. margin-right:12rpx;
  578. }
  579. .view-three-one{
  580. width:30rpx;
  581. height:30rpx;
  582. text-align center
  583. background #FF4552
  584. border-radius:50%;
  585. font-size:20rpx;
  586. line-height:30rpx;
  587. color:#fff;
  588. margin:36rpx 20rpx;
  589. }
  590. .view-three-two{
  591. width:30rpx;
  592. height:30rpx;
  593. text-align center
  594. border-radius:50%;
  595. font-size:20rpx;
  596. line-height:30rpx;
  597. color:#999;
  598. margin:36rpx 20rpx;
  599. }
  600. .view-three-type{
  601. width:120rpx;
  602. text-align center;
  603. color:#CCCCCC;
  604. font-size: 26rpx;
  605. }
  606. }
  607. .button-max-box:nth-child(1){
  608. border:none;
  609. }
  610. }
  611. }
  612. .out-button{
  613. position absolute
  614. bottom:140rpx;
  615. left:25rpx;
  616. width:700rpx;
  617. height:100rpx;
  618. line-height:100rpx;
  619. border-radius:10rpx;
  620. text-align center
  621. background #E0E0E0
  622. color:#0183FA;
  623. font-size: 30rpx;
  624. margin:0 auto;
  625. }
  626. }
  627. </style>