workbench.vue 13 KB

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