mine.vue 16 KB

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