mine.vue 19 KB

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