workbench.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  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.nxjiewei.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.nxjiewei.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. success: (res) => {
  270. uni.hideLoading()
  271. // console.log(res.data.data)
  272. this.header = res.data.data.header
  273. this.nav = res.data.data.nav
  274. this.module = res.data.data.module
  275. }
  276. })
  277. },
  278. // 获取消息提醒数量
  279. get_workflow_todo_query() {
  280. // 闭环管理
  281. this.$api.five_fixed_fiveFixedNewCategory({
  282. }).then((res) => {
  283. // console.log(res.data.content.data)
  284. let data = res.data.content.data
  285. let num = 0
  286. data.forEach((item, index) => {
  287. num = num + item.no_num
  288. })
  289. this.num_3 = num
  290. if (this.mine_code == 'ningdongyunying') {
  291. if (this.num_3 > 0) {
  292. uni.showTabBarRedDot({
  293. index: 2,
  294. })
  295. }
  296. }
  297. })
  298. this.$api.workflow_todo_query({
  299. staff_num: uni.getStorageSync('user').staff_num,
  300. query_type: 2
  301. }).then((res) => {
  302. this.num_1 = res.data.content.data
  303. if (this.mine_code == 'ningdongyunying') {
  304. if (this.num_1 > 0) {
  305. uni.showTabBarRedDot({
  306. index: 2,
  307. })
  308. }
  309. }
  310. })
  311. this.$api.workflow_todo_query({
  312. staff_num: uni.getStorageSync('user').staff_num,
  313. query_type: 1
  314. }).then((res) => {
  315. this.num_2 = res.data.content.data
  316. if (this.mine_code == 'ningdongyunying') {
  317. if (this.num_2 > 0) {
  318. uni.showTabBarRedDot({
  319. index: 2,
  320. })
  321. }
  322. }
  323. })
  324. },
  325. // 宁煤信息平台
  326. go_link(item) {
  327. let link = item.link
  328. if (link.indexOf("nativeApp://") != -1) {
  329. let app_name = link.match(/nativeApp:\/\/(\S*)\?/)[1]
  330. let app_down_link = link.split('?')[1]
  331. // #ifdef APP
  332. if (plus.os.name == 'Android') {
  333. plus.runtime.launchApplication({
  334. pname: app_name
  335. }, (e) => {
  336. console.log('Open system default browser failed: ' + e.message)
  337. uni.showModal({
  338. title: app_name,
  339. content: '未安装此应用、是否下载?',
  340. success: (res) => {
  341. if (res.confirm) {
  342. console.log('用户点击确定');
  343. uni.navigateTo({
  344. url: "../../index/h5/h5?url=" + app_down_link
  345. })
  346. } else if (res.cancel) {
  347. console.log('用户点击取消');
  348. }
  349. }
  350. });
  351. })
  352. }
  353. // #endif
  354. } else if (link.indexOf("http://mtyyxs.shnxmyjt.com") != -1) {
  355. console.log("信息平台")
  356. this.url = item
  357. // 有登录记录
  358. let token = uni.getStorageSync('ningmei_token')
  359. let time = uni.getStorageSync('ningmei_token_time')
  360. // 30天刷新一次
  361. let diffTimeShow = diffTime(time, new Date().format("yyyy-MM-dd")).split(' ')[0];
  362. console.log(diffTimeShow)
  363. if (token.length > 20 && diffTimeShow < 30) {
  364. uni.navigateTo({
  365. url: "../../index/ningMeiXinXiPingTai/ningMeiXinXiPingTai",
  366. success: (res) => {
  367. // 通过eventChannel向被打开页面传送数据
  368. res.eventChannel.emit('acceptDataFromOpenerPage', {
  369. data: this.url
  370. })
  371. }
  372. })
  373. } else {
  374. this.$refs.popup.open()
  375. }
  376. } else {
  377. goToLink(item, this.mine_code)
  378. }
  379. },
  380. },
  381. }
  382. </script>
  383. <style lang="scss">
  384. page {
  385. background-color: #F2FAF7;
  386. margin-bottom: 20rpx;
  387. }
  388. .top {
  389. image {
  390. width: 750rpx;
  391. height: 270rpx;
  392. display: block;
  393. }
  394. }
  395. .tab {
  396. margin-top: 20rpx;
  397. display: flex;
  398. background-color: #FFFFFF;
  399. box-sizing: border-box;
  400. padding: 0 20rpx;
  401. .item {
  402. background-color: #FFFFFF;
  403. .text {
  404. box-sizing: border-box;
  405. height: 90rpx;
  406. line-height: 90rpx;
  407. width: 188rpx;
  408. text-align: center;
  409. overflow: hidden;
  410. white-space: nowrap;
  411. text-overflow: ellipsis;
  412. font-size: 30rpx;
  413. color: #666666;
  414. }
  415. .active {
  416. font-weight: 700;
  417. color: #000000;
  418. border-bottom: 4rpx solid #009FE8;
  419. }
  420. }
  421. }
  422. .section {
  423. margin-top: 20rpx;
  424. background-color: #FFFFFF;
  425. padding: 25rpx;
  426. .title {
  427. display: flex;
  428. align-items: center;
  429. height: 90rpx;
  430. .icon {
  431. margin-right: 20rpx;
  432. image {
  433. width: 50rpx;
  434. height: 50rpx;
  435. display: block;
  436. }
  437. }
  438. .text {
  439. font-weight: 700;
  440. font-size: 34rpx;
  441. }
  442. }
  443. .list {
  444. margin-top: 30rpx;
  445. width: 700rpx;
  446. overflow: hidden;
  447. .item {
  448. float: left;
  449. margin-bottom: 30rpx;
  450. width: 350rpx;
  451. display: flex;
  452. align-items: center;
  453. height: 140rpx;
  454. .icon {
  455. margin-bottom: 10rpx;
  456. image {
  457. width: 90rpx;
  458. height: 90rpx;
  459. display: block;
  460. }
  461. }
  462. .name {
  463. position: relative;
  464. margin-left: 20rpx;
  465. .num {
  466. z-index: 10;
  467. position: absolute;
  468. top: -10rpx;
  469. right: -50rpx;
  470. width: 40rpx;
  471. text-align: center;
  472. line-height: 40rpx;
  473. background-color: #F56C6C;
  474. border-radius: 50%;
  475. color: #FFF;
  476. font-size: 26rpx;
  477. }
  478. .name_title {
  479. font-size: 28rpx;
  480. margin-bottom: 10rpx;
  481. }
  482. .sub_title {
  483. font-size: 24rpx;
  484. color: #999;
  485. }
  486. }
  487. }
  488. .item:nth-child(2n) {
  489. box-sizing: border-box;
  490. border-left: 1rpx solid #F2FAF7;
  491. padding-left: 40rpx;
  492. }
  493. }
  494. }
  495. .login_box {
  496. width: 500rpx;
  497. padding: 30rpx 50rpx;
  498. border-radius: 20rpx;
  499. margin: 0 auto;
  500. background-color: #FFFFFF;
  501. .input_box {
  502. margin-bottom: 30rpx;
  503. .label {
  504. color: #6C6F74;
  505. margin-bottom: 20rpx;
  506. }
  507. .box {
  508. background: #FFFFFF;
  509. border-radius: 8rpx;
  510. border: 2rpx solid #E9EBF2;
  511. box-sizing: border-box;
  512. padding: 20rpx 25rpx;
  513. }
  514. }
  515. .btn {
  516. width: 500rpx;
  517. margin: 0 auto;
  518. border-radius: 8rpx;
  519. background-color: #009FE8;
  520. line-height: 90rpx;
  521. color: #FFFFFF;
  522. text-align: center;
  523. }
  524. }
  525. </style>