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