mine.vue 19 KB

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