mine.vue 13 KB

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