mine.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  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="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 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,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. this.fingerprintQuantityFun();
  157. }else{
  158. uni.removeStorageSync('token');
  159. uni.removeStorageSync('userId');
  160. uni.removeStorageSync('userType');
  161. uni.redirectTo({
  162. url: '/pages/login',
  163. });
  164. }
  165. },
  166. methods: {
  167. //学生端-信用分/奖励分/扫一扫按钮
  168. goUserPage(type){
  169. let self = this;
  170. if(type == 1){
  171. uni.navigateTo({
  172. url: '/pages_student/mine/creditPoints',
  173. });
  174. }else if(type == 2){
  175. uni.navigateTo({
  176. url: '/pages_student/mine/rewardPoints',
  177. });
  178. }else if(type == 3){
  179. uni.scanCode({
  180. onlyFromCamera: true,
  181. success: function (res) {
  182. uni.navigateTo({
  183. url: '/pages_student/mine/codeSuccess?q='+encodeURIComponent(JSON.stringify(res.result))
  184. });
  185. }
  186. });
  187. }
  188. },
  189. //获取个人信息
  190. async simpleInfo(){
  191. const {data} = await simpleInfo();
  192. if(data.code == 200){
  193. this.userData = data.data;
  194. this.userData.avatar=data.data.avatar;
  195. this.userData.avatarUrl=config.base_url+data.data.avatar;
  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. console.log(_this.certification.isUpload)
  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. console.log('用户点击确定');
  284. } else if (res.cancel) {
  285. console.log('用户点击取消');
  286. }
  287. }
  288. });
  289. },
  290. //退出登录
  291. async logout() {
  292. let self = this;
  293. const {data} = await logout();
  294. if(data.code == 200){
  295. uni.removeStorageSync('token');
  296. uni.removeStorageSync('userId');
  297. uni.removeStorageSync('userType');
  298. uni.redirectTo({
  299. url: '/pages/login',
  300. });
  301. }
  302. },
  303. //页面跳转
  304. goPage(type){
  305. if(type == 'upStudentCard'){//学生卡上传
  306. // if(this.certification.auditStatus.code == 2||this.certification.auditStatus.code == 3){
  307. uni.navigateTo({
  308. url: '/pages_student/mine/upStudentCard',
  309. });
  310. // }
  311. }else if(type == 'pointsRecord'){//积分记录
  312. uni.navigateTo({
  313. url: '/pages_student/mine/pointsRecord',
  314. });
  315. }else if(type == 'faceImage'){//人脸图像
  316. uni.navigateTo({
  317. url: '/pages/faceImage',
  318. });
  319. }else if(type == 'laboratory'){
  320. uni.navigateTo({
  321. url: '/pages_manage/workbench/laboratory/meLaboratory',//我的实验室
  322. });
  323. }else if(type == 'alarm'){
  324. uni.navigateTo({
  325. url: '/pages_manage/workbench/securityAlert/securityAlertList',//安全警报
  326. });
  327. }else if(type == 'record'){
  328. uni.navigateTo({
  329. url: '/pages_manage/workbench/plan/planList',//预案执行记录
  330. });
  331. }else if(type == 'signature'){
  332. uni.navigateTo({
  333. url: '/pages_manage/workbench/signature/signature?item='+this.signatureUrl,//电子签名
  334. });
  335. }
  336. },
  337. // 头像上传
  338. selectImage() {
  339. let self = this;
  340. wx.chooseImage({
  341. count: 1,
  342. sizeType: ["original", "compressed"],
  343. sourceType: ["album", "camera"],
  344. success: function(res) {
  345. console.log("res1",res)
  346. let tempFilePaths = res.tempFilePaths[0];
  347. self.uploadImg(tempFilePaths);
  348. }
  349. });
  350. },
  351. async uploadImg(tempFilePaths){
  352. var self = this;
  353. uni.showLoading({
  354. title: '上传中',
  355. mask: true
  356. });
  357. uni.uploadFile({
  358. url: config.base_url+'/file/upload', //仅为示例,非真实的接口地址
  359. header:{'Authorization':uni.getStorageSync('token')},
  360. filePath: tempFilePaths,
  361. name: 'file',
  362. formData: {
  363. 'user': 'test'
  364. },
  365. success: (uploadFileRes) => {
  366. let res = JSON.parse(uploadFileRes.data);
  367. if(res.code == 200){
  368. uni.navigateTo({
  369. url: '/pages/avatar?src='+config.base_url+res.data.url,//预案执行记录
  370. });
  371. }else{
  372. uni.showToast({
  373. title: res.msg,
  374. icon:"none",
  375. mask:true,
  376. duration: 2000
  377. });
  378. }
  379. },
  380. fail: err => {},
  381. complete: () => {
  382. uni.hideLoading()
  383. }
  384. });
  385. },
  386. },
  387. }
  388. </script>
  389. <style lang="stylus" scoped>
  390. #mine{
  391. height:100%;
  392. .top-max-big-box{
  393. /*background:#ffffff;*/
  394. .user-top-max-box-one{
  395. overflow hidden
  396. background url("@/images/img_wd_bg.png") no-repeat
  397. background-size:100%;
  398. height:350rpx;
  399. .top-max-box-one{
  400. background #fff
  401. margin:40rpx 40rpx 0;
  402. z-index:1;
  403. height:180rpx;
  404. border-top-right-radius 20rpx
  405. border-top-left-radius 20rpx
  406. display flex
  407. overflow hidden
  408. .user-img-box{
  409. height:120rpx;
  410. width:100rpx;
  411. margin:30rpx 53rpx 0 22rpx;
  412. img{
  413. height:100rpx;
  414. width:100rpx;
  415. border-radius:50%;
  416. }
  417. view{
  418. font-size:22rpx;
  419. color:#666666;
  420. text-align center
  421. line-height:22rpx;
  422. margin-top:10rpx;
  423. }
  424. }
  425. .name-box{
  426. margin-top:30rpx;
  427. .name-box-min{
  428. display flex
  429. overflow hidden
  430. margin-bottom:11rpx;
  431. view:nth-child(1){
  432. height:48rpx;
  433. line-height:48rpx;
  434. font-size: 30rpx;
  435. color: #333;
  436. }
  437. view:nth-child(2){
  438. height:30rpx;
  439. line-height:30rpx;
  440. font-size:20rpx;
  441. padding:0 20rpx;
  442. margin:9rpx 0 9rpx 20rpx;
  443. }
  444. view-color-one{
  445. background #FDD255;
  446. }
  447. view-color-two{
  448. background #A2A2A2;
  449. }
  450. view-color-tree{
  451. background #0183FA;
  452. }
  453. }
  454. .name-box-user{
  455. line-height:41rpx;
  456. font-size: 22rpx;
  457. color: #333;
  458. }
  459. }
  460. }
  461. .num-max-box{
  462. width:670rpx;
  463. background #fff
  464. border-bottom-right-radius 20rpx
  465. border-bottom-left-radius 20rpx
  466. height:130rpx;
  467. margin:0 40rpx;
  468. display flex
  469. .min-num-box{
  470. flex:1;
  471. .min-num-view{
  472. margin-top:30rpx;
  473. height:30rpx;
  474. line-height:30rpx;
  475. font-size:22rpx;
  476. text-align center
  477. }
  478. .color-one{
  479. font-weight:700;
  480. font-size:26rpx;
  481. color:#2B99FE;
  482. }
  483. .color-two{
  484. font-weight:700;
  485. font-size:26rpx;
  486. color:#FDD255;
  487. }
  488. .bottom-min-num-view{
  489. display flex
  490. margin-top:20rpx;
  491. .img-one{
  492. width:25rpx;
  493. height:28rpx;
  494. margin: 0 10rpx 0 58rpx;
  495. }
  496. .img-two{
  497. width:28rpx;
  498. height:26rpx;
  499. margin: 0 10rpx 0 59rpx;
  500. }
  501. view{
  502. font-size:22rpx;
  503. }
  504. }
  505. }
  506. }
  507. .null-p{
  508. background #dedede
  509. height:30rpx;
  510. width:2rpx;
  511. margin:50rpx 0 0;
  512. }
  513. }
  514. .top-max-box-two{
  515. background url("@/images/img_wd_bg.png")
  516. background-size:100%;
  517. height:245rpx;
  518. display flex
  519. overflow hidden
  520. .user-img-box{
  521. height:120rpx;
  522. width:100rpx;
  523. margin:50rpx 53rpx 0 22rpx;
  524. img{
  525. height:100rpx;
  526. width:100rpx;
  527. border-radius:50%;
  528. }
  529. view{
  530. font-size:22rpx;
  531. color:#fff;
  532. text-align center
  533. line-height:22rpx;
  534. margin-top:10rpx;
  535. }
  536. }
  537. .name-box{
  538. margin-top:50rpx;
  539. view:nth-child(1){
  540. line-height:48rpx;
  541. margin-bottom:11rpx;
  542. font-size: 30rpx;
  543. color: #fff;
  544. }
  545. view:nth-child(2){
  546. line-height:41rpx;
  547. font-size: 22rpx;
  548. color: #fff;
  549. }
  550. }
  551. }
  552. .button-max-big-box{
  553. background #fff
  554. padding:0 20rpx;
  555. margin-top:30rpx;
  556. .button-max-box{
  557. height:100rpx;
  558. display flex
  559. border-top:1rpx solid #e0e0e0;
  560. .left-img{
  561. height:30rpx;
  562. width:30rpx;
  563. margin:34rpx 44rpx 0 0;
  564. }
  565. view{
  566. line-height:100rpx;
  567. }
  568. view:nth-child(2){
  569. flex:1;
  570. color:#333333;
  571. font-size: 30rpx;
  572. }
  573. .right-img{
  574. height:24rpx;
  575. width:12rpx;
  576. margin:39rpx 0 0 0;
  577. }
  578. .colorA{
  579. color:#E45656!important;
  580. }
  581. .marginType{
  582. margin-right:12rpx;
  583. }
  584. .view-three-one{
  585. width:30rpx;
  586. height:30rpx;
  587. text-align center
  588. background #FF4552
  589. border-radius:50%;
  590. font-size:20rpx;
  591. line-height:30rpx;
  592. color:#fff;
  593. margin:36rpx 20rpx;
  594. }
  595. .view-three-two{
  596. width:30rpx;
  597. height:30rpx;
  598. text-align center
  599. border-radius:50%;
  600. font-size:20rpx;
  601. line-height:30rpx;
  602. color:#999;
  603. margin:36rpx 20rpx;
  604. }
  605. .view-three-type{
  606. width:120rpx;
  607. text-align center;
  608. color:#CCCCCC;
  609. font-size: 26rpx;
  610. }
  611. }
  612. .button-max-box:nth-child(1){
  613. border:none;
  614. }
  615. }
  616. }
  617. .out-button{
  618. position absolute
  619. bottom:140rpx;
  620. left:25rpx;
  621. width:700rpx;
  622. height:100rpx;
  623. line-height:100rpx;
  624. border-radius:10rpx;
  625. text-align center
  626. background #E0E0E0
  627. color:#0183FA;
  628. font-size: 30rpx;
  629. margin:0 auto;
  630. }
  631. }
  632. </style>