workbench.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. <template>
  2. <view>
  3. <!-- 工作台头图 -->
  4. <view class="top">
  5. <image :src="header"></image>
  6. </view>
  7. <!-- 工作台矿切换 -->
  8. <!-- <view v-if="app_mine_code == 'ningmeijituan'">
  9. <scroll-view scroll-x>
  10. <view class="tab">
  11. <view class="item" @click="change_active(index,item.code)" v-for="(item,index) in tab" :key="index">
  12. <view class="text" :class="active == index?'active':''">{{item.name}}</view>
  13. </view>
  14. </view>
  15. </scroll-view>
  16. </view> -->
  17. <!-- nav -->
  18. <view class="section">
  19. <view class="list">
  20. <view class="item" v-for="(item,index) in nav" :key="index" @click="go_link(item)">
  21. <view class="icon">
  22. <image :src="item.icon" mode="aspectFill"></image>
  23. </view>
  24. <view class="name">
  25. <view class="num"
  26. v-if="item.link.indexOf('http://oa_system.nxmy.com:8011/?m=ying&d=we&num=daiban&hideheader=true') != -1 && num_1 > 0">
  27. {{num_1}}
  28. </view>
  29. <view class="num"
  30. v-if="item.link.indexOf('http://oa_system.nxmy.com:8011/?m=ying&d=we&num=todo&hideheader=true') != -1 && num_2 > 0">
  31. {{num_2}}
  32. </view>
  33. <view class="num" v-if="item.link.indexOf('closed_loop_management') != -1 && num_3 > 0">
  34. {{num_3}}
  35. </view>
  36. <view class="name_title">{{item.title}}</view>
  37. <view class="sub_title">{{item.sub_title}}</view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="section" v-for="(item,index) in module" :key="index">
  43. <view class="title">
  44. <view class="icon">
  45. <image :src="item.icon" mode=""></image>
  46. </view>
  47. <view class="text">{{item.title}}</view>
  48. </view>
  49. <view class="list">
  50. <view class="item" v-for="(item_2,index_2) in item.children" :key="index_2" @click="go_link(item_2)">
  51. <view class="icon">
  52. <image :src="item_2.icon" mode=""></image>
  53. </view>
  54. <view class="name">
  55. <view class="name_title">{{item_2.title}}</view>
  56. <view class="sub_title">{{item_2.sub_title}}</view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <!-- 宁煤信息平台登录框 -->
  62. <uni-popup ref="popup" type="center" @maskClick="maskClick">
  63. <view class="login_box">
  64. <view class="input_box">
  65. <view class="label">工号:</view>
  66. <view class="box">
  67. {{staff_num}}
  68. </view>
  69. </view>
  70. <view class="input_box">
  71. <view class="label">登录密码(宁煤信息平台):</view>
  72. <view class="box">
  73. <input type="password" v-model="password" />
  74. </view>
  75. </view>
  76. <view class="btn" @click="login()">确认</view>
  77. </view>
  78. </uni-popup>
  79. </view>
  80. </template>
  81. <script>
  82. import {
  83. set_base_url
  84. } from '@/common/set_base_url.js'
  85. import time from "@/common/time.js"
  86. import {
  87. diffTime
  88. } from "@/common/time.js"
  89. import {
  90. goToLink
  91. } from "@/common/common.js"
  92. export default {
  93. data() {
  94. return {
  95. // 默认煤矿
  96. app_mine_code: "",
  97. // 当前煤矿编码
  98. mine_code: "",
  99. base_url: "",
  100. tab: [{
  101. name: "宁煤公司",
  102. code: "ningmeijituan"
  103. },
  104. {
  105. name: "羊场湾煤矿",
  106. code: "yangchangwan"
  107. },
  108. {
  109. name: "枣泉煤矿",
  110. code: "zaoquan"
  111. },
  112. {
  113. name: "清水营煤矿",
  114. code: "qingshuiying"
  115. },
  116. {
  117. name: "金家渠煤矿",
  118. code: "jinjiaqu"
  119. },
  120. {
  121. name: "石槽村煤矿",
  122. code: "shicaocun"
  123. },
  124. {
  125. name: "金凤煤矿",
  126. code: "jinfeng"
  127. },
  128. {
  129. name: "物业公司",
  130. code: "wuyegongsi"
  131. },
  132. {
  133. name: "宁东运营部",
  134. code: "ningdongyunying"
  135. }
  136. ],
  137. active: 0,
  138. // 头部图片
  139. header: "",
  140. nav: [],
  141. module: [],
  142. num_1: 0,
  143. num_2: 0,
  144. num_3: 0,
  145. staff_num: "",
  146. password: "",
  147. url: "",
  148. app_id: "",
  149. gps: "",
  150. deviceID: "",
  151. phoneType: ""
  152. };
  153. },
  154. onLoad() {
  155. this.staff_num = uni.getStorageSync('user').staff_num
  156. // 初始化当前煤矿编码
  157. this.app_mine_code = uni.getStorageSync('mine_code')
  158. this.mine_code = uni.getStorageSync('mine_code')
  159. this.base_url = set_base_url(this.app_mine_code)
  160. this.get_workbench_index()
  161. },
  162. onShow() {
  163. this.get_workflow_todo_query()
  164. },
  165. methods: {
  166. maskClick() {
  167. this.password = ""
  168. },
  169. login() {
  170. // #ifdef APP-PLUS
  171. if (this.password == '') {
  172. uni.showToast({
  173. icon: "none",
  174. title: "密码不能为空!"
  175. })
  176. return
  177. }
  178. this.$refs.popup.close()
  179. // 获取gps
  180. uni.getLocation({
  181. type: 'wgs84',
  182. success: (res) => {
  183. console.log('当前位置的经度:' + res.longitude);
  184. console.log('当前位置的纬度:' + res.latitude);
  185. this.gps = res.longitude + ',' + res.latitude
  186. // 获取设备信息
  187. plus.device.getInfo({
  188. success: (e) => {
  189. console.log(JSON.stringify(e.uuid));
  190. console.log(plus.device.model)
  191. this.deviceID = JSON.stringify(e.uuid)
  192. this.phoneType = plus.device.model
  193. uni.request({
  194. method: "POST",
  195. url: "http://mtyyxs.shnxmyjt.com:33300/api/OAuth/Login",
  196. header: {
  197. 'Content-Type': 'application/json;charset=UTF-8',
  198. 'caller': 'UnifiedPortal'
  199. },
  200. data: {
  201. phoneType: this.phoneType,
  202. password: this.password,
  203. gps: this.gps,
  204. userID: this.staff_num,
  205. resolvingPower: "851*393",
  206. deviceID: this.deviceID,
  207. ip: "112312313"
  208. },
  209. success: (res) => {
  210. console.log(this.password)
  211. console.log(res)
  212. if (res.data.code = '11002') {
  213. uni.showToast({
  214. icon: "none",
  215. title: res.data.msg
  216. })
  217. if (res.data.data.length > 20) {
  218. uni.setStorageSync('ningmei_token', res
  219. .data.data)
  220. uni.setStorageSync(
  221. 'ningmei_token_time',
  222. new Date().format("yyyy-MM-dd")
  223. )
  224. uni.navigateTo({
  225. url: "../../index/ningMeiXinXiPingTai/ningMeiXinXiPingTai",
  226. success: (res) => {
  227. // 通过eventChannel向被打开页面传送数据
  228. res.eventChannel
  229. .emit(
  230. 'acceptDataFromOpenerPage', {
  231. data: this
  232. .url
  233. })
  234. }
  235. })
  236. }
  237. }
  238. }
  239. })
  240. }
  241. });
  242. }
  243. })
  244. // #endif
  245. },
  246. change_active(index, code) {
  247. this.active = index
  248. this.mine_code = code
  249. // 根据矿编码切换首页接口不同的请求基础路径
  250. this.base_url = set_base_url(this.mine_code)
  251. this.get_workbench_index()
  252. },
  253. // 获取基础数据
  254. // get_workbench_index() {
  255. // this.$api.workbench_index({
  256. // }).then((res) => {
  257. // // console.log(res.data.data)
  258. // this.header = res.data.data.header
  259. // this.nav = res.data.data.nav
  260. // this.module = res.data.data.module
  261. // })
  262. // },
  263. get_workbench_index() {
  264. // uni.showLoading({
  265. // mask: true
  266. // })
  267. uni.request({
  268. url: this.base_url + "/workbench/index",
  269. header:{
  270. 'accesskey': "b364b449a18af327867f7edc3431b541"
  271. },
  272. success: (res) => {
  273. // uni.hideLoading()
  274. // console.log(res.data.data)
  275. this.header = res.data.data.header
  276. this.nav = res.data.data.nav
  277. this.module = res.data.data.module
  278. }
  279. })
  280. },
  281. // 获取消息提醒数量
  282. get_workflow_todo_query() {
  283. // 闭环管理
  284. this.$api.five_fixed_fiveFixedNewCategory({
  285. }).then((res) => {
  286. // console.log(res.data.content.data)
  287. let data = res.data.content.data
  288. let num = 0
  289. data.forEach((item, index) => {
  290. num = num + item.no_num
  291. })
  292. this.num_3 = num
  293. if (this.mine_code == 'ningdongyunying') {
  294. if (this.num_3 > 0) {
  295. uni.showTabBarRedDot({
  296. index: 2,
  297. })
  298. }
  299. }
  300. })
  301. this.$api.workflow_todo_query({
  302. staff_num: uni.getStorageSync('user').staff_num,
  303. query_type: 2
  304. }).then((res) => {
  305. this.num_1 = res.data.content.data
  306. if (this.mine_code == 'ningdongyunying') {
  307. if (this.num_1 > 0) {
  308. uni.showTabBarRedDot({
  309. index: 2,
  310. })
  311. }
  312. }
  313. })
  314. this.$api.workflow_todo_query({
  315. staff_num: uni.getStorageSync('user').staff_num,
  316. query_type: 1
  317. }).then((res) => {
  318. this.num_2 = res.data.content.data
  319. if (this.mine_code == 'ningdongyunying') {
  320. if (this.num_2 > 0) {
  321. uni.showTabBarRedDot({
  322. index: 2,
  323. })
  324. }
  325. }
  326. })
  327. },
  328. // 宁煤信息平台
  329. go_link(item) {
  330. let link = item.link
  331. if (link.indexOf("nativeApp://") != -1) {
  332. let app_name = link.match(/nativeApp:\/\/(\S*)\?/)[1]
  333. let app_down_link = link.split('?')[1]
  334. // #ifdef APP
  335. if (plus.os.name == 'Android') {
  336. plus.runtime.launchApplication({
  337. pname: app_name
  338. }, (e) => {
  339. console.log('Open system default browser failed: ' + e.message)
  340. uni.showModal({
  341. title: app_name,
  342. content: '未安装此应用、是否下载?',
  343. success: (res) => {
  344. if (res.confirm) {
  345. console.log('用户点击确定');
  346. uni.navigateTo({
  347. url: "../../index/h5/h5?url=" + app_down_link
  348. })
  349. } else if (res.cancel) {
  350. console.log('用户点击取消');
  351. }
  352. }
  353. });
  354. })
  355. }
  356. // #endif
  357. } else if (link.indexOf("http://mtyyxs.shnxmyjt.com") != -1) {
  358. console.log("信息平台")
  359. this.url = item
  360. // 有登录记录
  361. let token = uni.getStorageSync('ningmei_token')
  362. let time = uni.getStorageSync('ningmei_token_time')
  363. // 30天刷新一次
  364. let diffTimeShow = diffTime(time, new Date().format("yyyy-MM-dd")).split(' ')[0];
  365. console.log(diffTimeShow)
  366. if (token.length > 20 && diffTimeShow < 30) {
  367. uni.navigateTo({
  368. url: "../../index/ningMeiXinXiPingTai/ningMeiXinXiPingTai",
  369. success: (res) => {
  370. // 通过eventChannel向被打开页面传送数据
  371. res.eventChannel.emit('acceptDataFromOpenerPage', {
  372. data: this.url
  373. })
  374. }
  375. })
  376. } else {
  377. this.$refs.popup.open()
  378. }
  379. } else {
  380. goToLink(item, this.mine_code)
  381. }
  382. },
  383. },
  384. }
  385. </script>
  386. <style lang="scss">
  387. page {
  388. background-color: #F2FAF7;
  389. margin-bottom: 20rpx;
  390. }
  391. .top {
  392. image {
  393. width: 750rpx;
  394. height: 270rpx;
  395. display: block;
  396. }
  397. }
  398. .tab {
  399. margin-top: 20rpx;
  400. display: flex;
  401. background-color: #FFFFFF;
  402. box-sizing: border-box;
  403. padding: 0 20rpx;
  404. .item {
  405. background-color: #FFFFFF;
  406. .text {
  407. box-sizing: border-box;
  408. height: 90rpx;
  409. line-height: 90rpx;
  410. width: 188rpx;
  411. text-align: center;
  412. overflow: hidden;
  413. white-space: nowrap;
  414. text-overflow: ellipsis;
  415. font-size: 30rpx;
  416. color: #666666;
  417. }
  418. .active {
  419. font-weight: 700;
  420. color: #000000;
  421. border-bottom: 4rpx solid #009FE8;
  422. }
  423. }
  424. }
  425. .section {
  426. margin-top: 20rpx;
  427. background-color: #FFFFFF;
  428. padding: 25rpx;
  429. .title {
  430. display: flex;
  431. align-items: center;
  432. height: 90rpx;
  433. .icon {
  434. margin-right: 20rpx;
  435. image {
  436. width: 50rpx;
  437. height: 50rpx;
  438. display: block;
  439. }
  440. }
  441. .text {
  442. font-weight: 700;
  443. font-size: 34rpx;
  444. }
  445. }
  446. .list {
  447. margin-top: 30rpx;
  448. width: 700rpx;
  449. overflow: hidden;
  450. .item {
  451. float: left;
  452. margin-bottom: 30rpx;
  453. width: 350rpx;
  454. display: flex;
  455. align-items: center;
  456. height: 140rpx;
  457. .icon {
  458. margin-bottom: 10rpx;
  459. image {
  460. width: 90rpx;
  461. height: 90rpx;
  462. display: block;
  463. }
  464. }
  465. .name {
  466. position: relative;
  467. margin-left: 20rpx;
  468. .num {
  469. z-index: 10;
  470. position: absolute;
  471. top: -10rpx;
  472. right: -50rpx;
  473. width: 40rpx;
  474. text-align: center;
  475. line-height: 40rpx;
  476. background-color: #F56C6C;
  477. border-radius: 50%;
  478. color: #FFF;
  479. font-size: 26rpx;
  480. }
  481. .name_title {
  482. font-size: 28rpx;
  483. margin-bottom: 10rpx;
  484. }
  485. .sub_title {
  486. font-size: 24rpx;
  487. color: #999;
  488. }
  489. }
  490. }
  491. .item:nth-child(2n) {
  492. box-sizing: border-box;
  493. border-left: 1rpx solid #F2FAF7;
  494. padding-left: 40rpx;
  495. }
  496. }
  497. }
  498. .login_box {
  499. width: 500rpx;
  500. padding: 30rpx 50rpx;
  501. border-radius: 20rpx;
  502. margin: 0 auto;
  503. background-color: #FFFFFF;
  504. .input_box {
  505. margin-bottom: 30rpx;
  506. .label {
  507. color: #6C6F74;
  508. margin-bottom: 20rpx;
  509. }
  510. .box {
  511. background: #FFFFFF;
  512. border-radius: 8rpx;
  513. border: 2rpx solid #E9EBF2;
  514. box-sizing: border-box;
  515. padding: 20rpx 25rpx;
  516. }
  517. }
  518. .btn {
  519. width: 500rpx;
  520. margin: 0 auto;
  521. border-radius: 8rpx;
  522. background-color: #009FE8;
  523. line-height: 90rpx;
  524. color: #FFFFFF;
  525. text-align: center;
  526. }
  527. }
  528. </style>