mine.vue 18 KB

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