mine.vue 18 KB

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