mine.vue 16 KB

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