mine.vue 18 KB

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