my.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  1. <template>
  2. <view>
  3. <!-- 背景图 -->
  4. <view class="top">
  5. <image src="./icon/bg.png" mode="aspectFill"></image>
  6. </view>
  7. <view class="content">
  8. <view class="user" v-if="user">
  9. <view class="left">
  10. <view class="img">
  11. <image v-if="user.avatar" :src="user.avatar" mode="aspectFill"></image>
  12. <view class="avatar" v-if="!user.avatar" :style="{backgroundColor:bgColor[1]}">
  13. {{user.name.split('').pop()}}
  14. </view>
  15. </view>
  16. <view class="info">
  17. <view class="name">{{user.name}}</view>
  18. <view class="section">{{user.section}}</view>
  19. </view>
  20. </view>
  21. <view class="right">
  22. <view class="btn" @click="go_information()">
  23. <view class="icon">
  24. <uni-icons type="person-filled" color="#fff"></uni-icons>
  25. </view>
  26. <view class="text">个人中心</view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="section_1">
  31. <view class="title">本月使用信息</view>
  32. <view class="box">
  33. <view class="item">
  34. <view class="num">{{use.h}} <text> h </text> {{use.m}} <text> min</text></view>
  35. <view class="tip">使用时长</view>
  36. </view>
  37. <view class="item">
  38. <view class="num">{{use.times || '1'}}</view>
  39. <view class="tip">使用次数</view>
  40. </view>
  41. <view class="item">
  42. <view class="num">{{use.submit_count}}</view>
  43. <view class="tip">提交单据数</view>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="section_2">
  48. <view class="inner_1">
  49. <view class="title">
  50. <view class="icon">
  51. <image src="./icon/time.png" mode=""></image>
  52. </view>
  53. <view class="text">最近使用</view>
  54. </view>
  55. <view class="box">
  56. <view class="item" v-if="recently_used.length > 0" v-for="(item,index) in recently_used" :key="index" @click="go_OA(item)">
  57. <view class="name">{{item.title}}</view>
  58. <view class="icon">
  59. <uni-icons type="right" color="#fff" size="16"></uni-icons>
  60. </view>
  61. </view>
  62. <view v-if="recently_used.length == 0" style="line-height: 80rpx;color: #FFFFFF;padding: 0 20rpx;font-size: 28rpx;">暂无使用记录。</view>
  63. </view>
  64. </view>
  65. <view class="inner_2" @click="go_integral()">
  66. <view class="num">{{total}}</view>
  67. <view class="text">积分</view>
  68. </view>
  69. </view>
  70. <view class="section_3" v-if="mine_code != 'ningdongyunying'" @click="go_downhole_statistics()">
  71. <view class="title">
  72. <view class="icon">
  73. <uni-icons type="map-pin-ellipse" color="#fff"></uni-icons>
  74. </view>
  75. <view class="text">当前位置:{{downhole.position}}</view>
  76. </view>
  77. <view class="box">
  78. <view class="item">
  79. <view class="num">{{downhole.h}} <text> h</text> {{downhole.m}} <text> min</text></view>
  80. <view class="tip">本月下井时长</view>
  81. </view>
  82. <view class="item">
  83. <view class="num">{{downhole.times}}</view>
  84. <view class="tip">本月下井次数</view>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. <view class="content">
  90. <view class="section_4">
  91. <view class="list">
  92. <view class="item" @click="clear_cache()">
  93. <view class="icon">
  94. <image src="./icon/icon_1.png" mode="aspectFill"></image>
  95. </view>
  96. <view class="text">
  97. 清除缓存
  98. </view>
  99. </view>
  100. <view class="item" @click="tell()">
  101. <view class="icon">
  102. <image src="./icon/icon_2.png" mode="aspectFill"></image>
  103. </view>
  104. <view class="text">服务电话</view>
  105. </view>
  106. <view class="item" @click="go_feedback()">
  107. <view class="icon">
  108. <image src="./icon/icon_3.png" mode="aspectFill"></image>
  109. </view>
  110. <view class="text">建议反馈</view>
  111. </view>
  112. <view class="item" @click="go_update_log()">
  113. <view class="icon">
  114. <image src="./icon/icon_4.png" mode="aspectFill"></image>
  115. </view>
  116. <view class="text">更新日志</view>
  117. </view>
  118. <view class="item" @click="go_m_repassword()">
  119. <view class="icon">
  120. <image src="./icon/icon_5.png" mode="aspectFill"></image>
  121. </view>
  122. <view class="text">修改密码</view>
  123. </view>
  124. <view class="item" @click="login_out()">
  125. <view class="icon">
  126. <image src="./icon/icon_6.png" mode="aspectFill"></image>
  127. </view>
  128. <view class="text">退出登陆</view>
  129. </view>
  130. <view class="item" @click="go_m_download()">
  131. <view class="icon">
  132. <image src="./icon/icon_7.png" mode="aspectFill"></image>
  133. </view>
  134. <view class="text">下载二维码</view>
  135. </view>
  136. </view>
  137. </view>
  138. </view>
  139. </view>
  140. </template>
  141. <script>
  142. import {
  143. set_mine
  144. } from '@/common/set_base_url.js'
  145. export default {
  146. data() {
  147. return {
  148. // 当前煤矿编码
  149. mine_code: "",
  150. // 用户基本信息
  151. user: {},
  152. bgColor: [],
  153. // 总积分
  154. total: 0,
  155. // 下井定位卡号
  156. people_num: "",
  157. // 矿编码
  158. mine: "",
  159. // 下井数据
  160. downhole: {
  161. position: "-",
  162. h: "0",
  163. m: "0",
  164. times: "0"
  165. },
  166. // 使用时长次数
  167. use: {
  168. times: "0",
  169. h: "0",
  170. m: "0",
  171. submit_count:"0"
  172. },
  173. // 最近使用
  174. recently_used:[]
  175. };
  176. },
  177. onLoad() {
  178. // console.log(set_mine(uni.getStorageSync('mine_code')))
  179. this.mine = set_mine(uni.getStorageSync('mine_code'))
  180. // 初始化当前煤矿编码
  181. this.mine_code = uni.getStorageSync('mine_code')
  182. // 判断会否登录、没有则跳转至登录页
  183. const Authorization = uni.getStorageSync('Authorization')
  184. if (Authorization == '') {
  185. uni.showToast({
  186. icon: "none",
  187. title: "用户未登录"
  188. })
  189. setTimeout(function() {
  190. uni.redirectTo({
  191. url: "../../my/login/login"
  192. })
  193. }, 1500)
  194. }
  195. // 设置头像
  196. for (let i = 0; i < 2; i++) {
  197. // 获取随机色
  198. let r = parseInt(Math.random() * 256)
  199. let g = parseInt(Math.random() * 256)
  200. let b = parseInt(Math.random() * 256)
  201. // ES6 字符串拼接
  202. // this.bgColor = `rgba(${r},${g},${b},0.3)`
  203. let color = "rgba(" + r + "," + g + "," + b + "," + 0.3 + ")"
  204. // console.log(color)
  205. this.bgColor.push(color)
  206. }
  207. // 获取用户基本信息
  208. this.user = uni.getStorageSync('user');
  209. // 查询使用时长
  210. this.get_user_selectRecordDuration()
  211. //查询员工积分
  212. this.get_staff_integral_query(),
  213. // 获取个人信息
  214. this.$api.user_getUinfo({
  215. staff_num: uni.getStorageSync('user').staff_num
  216. }).then((res) => {
  217. this.people_num = res.data.data.people_code
  218. // 获取当前位置
  219. this.get_downhole()
  220. })
  221. // 获取常用列表
  222. this.get_workflow_recently_used()
  223. },
  224. methods: {
  225. // 个人信息
  226. go_information() {
  227. uni.navigateTo({
  228. url: "../../my/personal_information/personal_information"
  229. })
  230. },
  231. // 查询使用时长
  232. get_user_selectRecordDuration() {
  233. this.$api.user_selectRecordDuration({
  234. }).then((res) => {
  235. // console.log(res.data.data)
  236. this.use.h = res.data.data.hours
  237. this.use.m = res.data.data.minutes
  238. this.use.times = res.data.data.frequency
  239. })
  240. },
  241. // 退出登录
  242. login_out() {
  243. uni.clearStorageSync('Authorization');
  244. uni.showToast({
  245. icon: "none",
  246. title: "退出登录"
  247. })
  248. // 跳转登录页
  249. setTimeout(() => {
  250. uni.redirectTo({
  251. url: "../../my/login/login"
  252. })
  253. }, 1000)
  254. },
  255. // 拨打服务电话
  256. tell() {
  257. uni.makePhoneCall({
  258. phoneNumber: '18152480670'
  259. });
  260. },
  261. // 修改密码
  262. go_m_repassword() {
  263. uni.navigateTo({
  264. url: "../../my/repassword/repassword"
  265. })
  266. },
  267. // 清除缓存
  268. clear_cache() {
  269. // uni.showLoading({
  270. // mask:true
  271. // })
  272. // setTimeout(()=>{
  273. // uni.hideLoading()
  274. // uni.showToast({
  275. // icon:"none",
  276. // title:"清除完成"
  277. // })
  278. // },1500)
  279. let that = this;
  280. plus.cache.calculate(function(size) {
  281. let sizeCache = parseInt(size);
  282. if (sizeCache == 0) {
  283. that.fileSizeString = "0B";
  284. } else if (sizeCache < 1024) {
  285. that.fileSizeString = sizeCache + "B";
  286. } else if (sizeCache < 1048576) {
  287. that.fileSizeString = (sizeCache / 1024).toFixed(2) + "K";
  288. } else if (sizeCache < 1073741824) {
  289. that.fileSizeString = (sizeCache / 1048576).toFixed(2) + "M";
  290. } else {
  291. that.fileSizeString = (sizeCache / 1073741824).toFixed(2) + "G";
  292. }
  293. console.log(sizeCache)
  294. });
  295. let os = plus.os.name;
  296. if (os == 'Android') {
  297. let main = plus.android.runtimeMainActivity();
  298. let sdRoot = main.getCacheDir();
  299. let files = plus.android.invoke(sdRoot, "listFiles");
  300. let len = files.length;
  301. for (let i = 0; i < len; i++) {
  302. let filePath = '' + files[i]; // 没有找到合适的方法获取路径,这样写可以转成文件路径
  303. plus.io.resolveLocalFileSystemURL(filePath, function(entry) {
  304. if (entry.isDirectory) {
  305. entry.removeRecursively(function(entry) { //递归删除其下的所有文件及子目录
  306. uni.showToast({
  307. title: '缓存清理完成',
  308. duration: 2000
  309. });
  310. that.getStorageSize(); // 重新计算缓存
  311. }, function(e) {
  312. console.log(e.message)
  313. });
  314. } else {
  315. entry.remove();
  316. }
  317. }, function(e) {
  318. console.log('文件路径读取失败')
  319. });
  320. }
  321. } else { // ios
  322. }
  323. },
  324. // 建议反馈
  325. go_feedback() {
  326. uni.navigateTo({
  327. url: "../../origanization/OA/h5/h5",
  328. success: (res) => {
  329. // 通过eventChannel向被打开页面传送数据
  330. res.eventChannel.emit('acceptDataFromOpenerPage', {
  331. url: 'http://oa_system.nxjiewei.com:8011/?m=ying&d=we&mnum=ndyybbug&show=we&hideheader=true',
  332. title: "建议反馈"
  333. })
  334. }
  335. })
  336. },
  337. // 更新日志
  338. go_update_log() {
  339. uni.navigateTo({
  340. url: "../../my/version_record/version_record"
  341. })
  342. },
  343. //查询员工积分
  344. get_staff_integral_query() {
  345. this.$api.staff_integral_query({
  346. staff_num: uni.getStorageSync('user').staff_num
  347. }).then((res) => {
  348. // console.log(res)
  349. this.total = res.data.content.data.integral_sum
  350. })
  351. },
  352. // 积分详情
  353. go_integral() {
  354. uni.navigateTo({
  355. url: "../../index/integral/integral?total=" + this.total
  356. })
  357. },
  358. // 获取当前位置
  359. get_downhole() {
  360. this.$p_api.peopleTotalNum({
  361. people_code: this.people_num,
  362. mine: ""
  363. }).then((res) => {
  364. // console.log(res)
  365. if (res.data.data.position == null) {
  366. if(this.people_num == ""){
  367. this.downhole.position = "请点击绑定定位卡"
  368. }else{
  369. this.downhole.position = "未在井下"
  370. }
  371. } else {
  372. this.downhole.position = res.data.data.data.position
  373. }
  374. this.downhole.h = res.data.data.hours
  375. this.downhole.m = res.data.data.minutes
  376. this.downhole.times = res.data.data.total
  377. })
  378. },
  379. go_downhole_statistics() {
  380. uni.navigateTo({
  381. url: "../../production/personnel_orientation/downhole_statistics/downhole_statistics?people_num=" +
  382. this.people_num + "&depart_name=" + this.user.section + "&name=" + this.user.name +
  383. "&mine=" + this.mine
  384. })
  385. },
  386. // 获取常用列表
  387. get_workflow_recently_used(){
  388. this.$api.workflow_recently_used({
  389. staff_num:this.user.staff_num
  390. }).then((res)=>{
  391. // console.log(res.data.content.data)
  392. this.recently_used = res.data.content.data.list
  393. this.use.submit_count = res.data.content.data.submit_count
  394. })
  395. },
  396. go_OA(item){
  397. // console.log(item)
  398. uni.navigateTo({
  399. url: "../../origanization/OA/h5/h5",
  400. success: (res) => {
  401. // 通过eventChannel向被打开页面传送数据
  402. res.eventChannel.emit('acceptDataFromOpenerPage', {
  403. url: item.url,
  404. title: item.title
  405. })
  406. }
  407. })
  408. },
  409. // 下载二维码
  410. go_m_download(){
  411. uni.navigateTo({
  412. url:"../../my/download/download"
  413. })
  414. }
  415. }
  416. }
  417. </script>
  418. <style lang="scss">
  419. .top {
  420. z-index: -1;
  421. position: fixed;
  422. top: 1;
  423. left: 0;
  424. image {
  425. width: 750rpx;
  426. height: 746rpx;
  427. }
  428. }
  429. .content {
  430. width: 749rpx;
  431. .user {
  432. margin-bottom: 40rpx;
  433. box-sizing: border-box;
  434. padding-left: 25rpx;
  435. padding-top: 25rpx;
  436. display: flex;
  437. justify-content: space-between;
  438. align-items: baseline;
  439. .left {
  440. display: flex;
  441. align-items: center;
  442. .img {
  443. width: 130rpx;
  444. height: 130rpx;
  445. border-radius: 50%;
  446. background: #DCDCDC;
  447. border: 1px solid #FFFFFF;
  448. overflow: hidden;
  449. text-align: center;
  450. line-height: 130rpx;
  451. font-size: 56rpx;
  452. font-weight: 700;
  453. color: #FFFFFF;
  454. image {
  455. width: 100%;
  456. height: 100%;
  457. display: block;
  458. }
  459. .avatar {
  460. width: 100%;
  461. height: 100%;
  462. }
  463. }
  464. .info {
  465. margin-left: 20rpx;
  466. color: #fff;
  467. .name {
  468. font-size: 38rpx;
  469. font-weight: 700;
  470. }
  471. .section {
  472. margin-top: 20rpx;
  473. font-size: 24rpx;
  474. }
  475. }
  476. }
  477. .right {
  478. background-color: rgba(255, 255, 255, .3);
  479. border-radius: 25rpx 0rpx 0rpx 25rpx;
  480. padding: 5rpx 20rpx 5rpx 20rpx;
  481. .btn {
  482. display: flex;
  483. align-items: center;
  484. color: #FFFFFF;
  485. .icon {}
  486. .text {
  487. font-size: 24rpx;
  488. }
  489. }
  490. }
  491. }
  492. .section_1 {
  493. width: 749rpx;
  494. height: 220rpx;
  495. background-image: url(./icon/section_1.png);
  496. background-size: cover;
  497. background-repeat: no-repeat;
  498. box-sizing: border-box;
  499. padding: 10rpx 20rpx;
  500. .title {
  501. padding-left: 20rpx;
  502. height: 60rpx;
  503. line-height: 60rpx;
  504. font-size: 28rpx;
  505. color: #fff;
  506. border-bottom: 1rpx solid rgba(255,255,255,.5);
  507. }
  508. .box {
  509. display: flex;
  510. .item {
  511. width: 236rpx;
  512. text-align: center;
  513. height: 130rpx;
  514. border-right: 1rpx solid rgba(255,255,255,.5);
  515. color: #FFFFFF;
  516. display: flex;
  517. flex-direction: column;
  518. justify-content: center;
  519. .num {
  520. font-size: 44rpx;
  521. font-weight: 700;
  522. text {
  523. font-size: 24rpx;
  524. }
  525. }
  526. .tip {
  527. font-size: 24rpx;
  528. }
  529. }
  530. .item:last-child {
  531. border-right: none;
  532. }
  533. }
  534. }
  535. .section_2 {
  536. box-sizing: border-box;
  537. padding: 20rpx;
  538. display: flex;
  539. justify-content: space-between;
  540. .inner_1 {
  541. width: 510rpx;
  542. height: 220rpx;
  543. background-image: url(./icon/section_2_inner_1.png);
  544. background-size: 100% 100%;
  545. background-repeat: no-repeat;
  546. .title {
  547. display: flex;
  548. align-items: center;
  549. height: 70rpx;
  550. font-size: 28rpx;
  551. color: #fff;
  552. padding-left: 20rpx;
  553. border-bottom: 1rpx solid rgba(255,255,255,.5);
  554. .icon {
  555. image {
  556. width: 28rpx;
  557. height: 28rpx;
  558. display: block;
  559. }
  560. }
  561. .text {
  562. margin-left: 10rpx;
  563. font-size: 28rpx;
  564. }
  565. }
  566. .box {
  567. width: 510rpx;
  568. display: flex;
  569. flex-wrap: wrap;
  570. .item {
  571. width: 255rpx;
  572. height: 70rpx;
  573. display: flex;
  574. justify-content: space-between;
  575. align-items: center;
  576. color: #FFFFFF;
  577. box-sizing: border-box;
  578. padding: 0 10rpx;
  579. border-bottom: 1rpx solid rgba(255,255,255,.5);
  580. border-right: 1rpx solid rgba(255,255,255,.5);
  581. .name {
  582. width: 200rpx;
  583. //超过一行省略号
  584. overflow: hidden;
  585. white-space: nowrap;
  586. text-overflow: ellipsis;
  587. font-size: 28rpx;
  588. }
  589. .icon {}
  590. }
  591. .item:nth-child(2n) {
  592. border-right: none;
  593. }
  594. .item:nth-child(3) {
  595. border-bottom: none;
  596. }
  597. .item:nth-child(4) {
  598. border-bottom: none;
  599. }
  600. }
  601. }
  602. .inner_2 {
  603. margin-top: -4rpx;
  604. margin-right: -10rpx;
  605. width: 200rpx;
  606. height: 250rpx;
  607. background-image: url(./icon/section_2_inner_2.png);
  608. background-size: 100% 100%;
  609. background-repeat: no-repeat;
  610. color: #FFFFFF;
  611. text-align: center;
  612. .num {
  613. height: 140rpx;
  614. line-height: 140rpx;
  615. font-size: 44rpx;
  616. font-weight: 700;
  617. }
  618. .text {
  619. height: 50rpx;
  620. line-height: 50rpx;
  621. font-size: 34rpx;
  622. }
  623. }
  624. }
  625. .section_3 {
  626. margin: -15rpx auto 0;
  627. width: 710rpx;
  628. height: 220rpx;
  629. background-image: url(./icon/section_3.png);
  630. background-size: 100% 100%;
  631. background-repeat: no-repeat;
  632. .title {
  633. display: flex;
  634. align-items: center;
  635. height: 60rpx;
  636. font-size: 24rpx;
  637. color: #fff;
  638. padding-left: 20rpx;
  639. .icon {
  640. image {
  641. width: 28rpx;
  642. height: 28rpx;
  643. display: block;
  644. }
  645. }
  646. .text {
  647. margin-left: 10rpx;
  648. font-size: 28rpx;
  649. }
  650. }
  651. .box {
  652. display: flex;
  653. .item {
  654. width: 355rpx;
  655. text-align: center;
  656. height: 140rpx;
  657. color: #FFFFFF;
  658. display: flex;
  659. flex-direction: column;
  660. justify-content: center;
  661. .num {
  662. font-size: 44rpx;
  663. font-weight: 700;
  664. text {
  665. font-size: 24rpx;
  666. }
  667. }
  668. .tip {
  669. margin-top: 10rpx;
  670. font-size: 24rpx;
  671. }
  672. }
  673. }
  674. }
  675. .section_4 {
  676. margin: 25rpx auto 40rpx;
  677. width: 710rpx;
  678. background-color: #FFFFFF;
  679. box-shadow: 10rpx 10rpx 16rpx 6rpx rgba(0, 0, 0, 0.13);
  680. border-radius: 20rpx;
  681. .list {
  682. overflow: hidden;
  683. box-sizing: border-box;
  684. padding: 30rpx 0;
  685. .item {
  686. margin-right: 30rpx;
  687. margin-bottom: 30rpx;
  688. float: left;
  689. width: 155rpx;
  690. text-align: center;
  691. .icon {
  692. margin: 0 auto;
  693. width: 80rpx;
  694. height: 80rpx;
  695. border-radius: 50%;
  696. overflow: hidden;
  697. image {
  698. width: 80rpx;
  699. height: 80rpx;
  700. display: block;
  701. }
  702. }
  703. .text {
  704. font-size: 28rpx;
  705. color: #666666;
  706. }
  707. }
  708. .item:nth-child(4n) {
  709. margin-right: 0;
  710. }
  711. }
  712. }
  713. }
  714. </style>