mine.vue 16 KB

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