homePage.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. <template>
  2. <view class="headerView">
  3. <u-navbar title="首页" v-show="false"></u-navbar>
  4. <!-- 头部 -->
  5. <view class="header">
  6. <view class="main">
  7. <view class="title">
  8. <view class="name" @click="changeShow()">
  9. <view class="text">
  10. 你好,{{userInfo.name}}!
  11. </view>
  12. <view class="icon">
  13. <u-icon name='arrow-down' color="#fff" size="28"></u-icon>
  14. </view>
  15. </view>
  16. <view class="options" v-if="show==true" >
  17. <view v-if="false" @click="changeShow4()">订阅</view>
  18. <view @click="changeShow5()">扫码</view>
  19. <view v-if="false" @click="changeShow2()">修改openId</view>
  20. <view @click="logout()">退出账号</view>
  21. </view>
  22. <view class="qr-code" v-if="false">
  23. <!-- <img src="@/assets/img/riLine-qr-scan-line@1x.png" alt=""> -->
  24. <u-icon name="scan" size="48" color="#fff"></u-icon>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <u-popup v-model="showpopup" class="" mode="bottom"
  30. border-radius="14"
  31. :closeable="true" >
  32. <view class="scantitle">连续扫码</view>
  33. <view class="list">
  34. <view class=" list-infos">
  35. <view class="infos-head">
  36. <view class="name">
  37. {{nowscan.title?nowscan.title:'扫码后出当前结果'}}
  38. </view>
  39. <view class="name">
  40. 编号:{{nowscan.code}}
  41. </view>
  42. </view>
  43. <view class="infos-head infos-head2" style="margin-bottom: 12rpx;">
  44. <view class="name">
  45. 上次巡检:{{nowscan.experimentLastTime}}
  46. </view>
  47. <view class="name" v-show="nowscan.experimentPeriod">
  48. 周期:{{nowscan.experimentPeriod}}天
  49. </view>
  50. </view>
  51. <view class="infos">
  52. <view class="infos-1">
  53. <view class="infos-item">
  54. <view class="item-name">
  55. 厂家:
  56. </view>
  57. <view class="item-value">
  58. {{nowscan.manufactor}}
  59. </view>
  60. </view>
  61. <view class="infos-item">
  62. <view class="item-name">
  63. 单位:
  64. </view>
  65. <view class="item-value">
  66. {{nowscan.unit}}
  67. </view>
  68. </view>
  69. </view>
  70. <view class="infos-2">
  71. <view class="infos-item">
  72. <view class="item-name">
  73. 规格:
  74. </view>
  75. <view class="item-value">
  76. {{nowscan.specifications}}
  77. </view>
  78. </view>
  79. <view class="infos-item">
  80. <view class="item-name">
  81. 型号:
  82. </view>
  83. <view class="item-value">
  84. {{nowscan.model}}
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. <camera mode="scanCode" resolution='medium'
  92. @scancode="takeCode" v-if="showpopup"
  93. device-position="back" flash="off" @error="error"
  94. style="width: 100%; height: 300px;"></camera>
  95. </u-popup>
  96. <!-- 宫格 -->
  97. <view class="gird" >
  98. <!-- 公告 -->
  99. <view class="notice" v-if="false" >
  100. <ujp-notice-bar mode="horizontal"
  101. bg-color="#6290f7" color="#fff"
  102. :list="['库存PDA设备将于2023年4月1日升级维护']"></ujp-notice-bar>
  103. <!-- <u-icon name="volume-up-fill" size="40" color="#fff"></u-icon>
  104. <text></text> -->
  105. </view>
  106. <template v-if="role('3')">
  107. <view class="item" @click="gotoUrl('pages/projectDepartment/exportProcess/exportProcess')">
  108. <view class="title">
  109. 出库审核
  110. <u-badge type="error" :absolute="false" style=" position: unset; padding: 2px 3px;" :fontSize="36"
  111. :isCenter="true" :count="badgeGet.outApproveList"></u-badge>
  112. </view>
  113. <view class="hint">
  114. 审批出库申请单据
  115. </view>
  116. <view class="img">
  117. <img src="@/assets/img/projectGird2.png" alt="">
  118. </view>
  119. </view>
  120. </template>
  121. <template v-if="role('2')">
  122. <view class="item" @click="gotoUrl('pages/projectDepartment/exportApplication/exportApplication')">
  123. <view class="title">
  124. 出库申请
  125. </view>
  126. <view class="hint">
  127. 提交出库申请单据
  128. </view>
  129. <view class="img">
  130. <img src="@/assets/img/projectGird1.png" alt="">
  131. </view>
  132. </view>
  133. <view class="item" @click="gotoUrl('pages/projectDepartment/exportReturn/exportReturn')">
  134. <view class="title">
  135. 设备归还
  136. </view>
  137. <view class="hint">
  138. 提交设备归还单据
  139. </view>
  140. <view class="img">
  141. <img src="@/assets/img/projectGird3.png" alt="">
  142. </view>
  143. </view>
  144. </template>
  145. <template v-if="role('1')">
  146. <view class="item" @click="gotoUrl('pages/storeManagement/equipmentDelivery/equipmentDelivery')">
  147. <view class="title">
  148. 设备出库
  149. <u-badge type="error" :absolute="false" style=" position: unset; padding: 2px 3px;" :fontSize="36"
  150. :isCenter="true" :count="badgeGet.outWaitList"></u-badge>
  151. </view>
  152. <view class="hint">
  153. 申请物品登记核准出库
  154. </view>
  155. <view class="img">
  156. <img src="@/assets/img/girdH1.png" alt="">
  157. </view>
  158. </view>
  159. <view class="item" @click="gotoUrl('pages/storeManagement/equipmentEnter/equipmentEnter')">
  160. <view class="title">
  161. 设备入库
  162. <u-badge type="error" :absolute="false" style=" position: unset; padding: 2px 3px;" :fontSize="36"
  163. :isCenter="true" :count="badgeGet.inWaitList"></u-badge>
  164. </view>
  165. <view class="hint">
  166. 申购采购收货入库登记
  167. </view>
  168. <view class="img">
  169. <img src="@/assets/img/girdH2.png" alt="">
  170. </view>
  171. </view>
  172. <view class="item" @click="gotoUrl('pages/storeManagement/equipmentInspection/equipmentInspection')" >
  173. <view class="title">
  174. 设备巡检
  175. <u-badge type="error" :absolute="false" style=" position: unset; padding: 2px 3px;" :fontSize="36"
  176. :isCenter="true" :count="badgeGet.deviceList"></u-badge>
  177. </view>
  178. <view class="hint">
  179. 当前物品计量库存盘点
  180. </view>
  181. <view class="img">
  182. <img src="@/assets/img/girdH3.png" alt="">
  183. </view>
  184. </view>
  185. </template>
  186. <view class="item" @click="gotoUrl('pages/otherFunctions/equipmentRetrieval/equipmentRetrieval')">
  187. <view class="title">
  188. 设备检索
  189. </view>
  190. <view class="hint">
  191. 库存物品信息检索
  192. </view>
  193. <view class="img">
  194. <img src="@/assets/img/projectGird4.png" alt="">
  195. </view>
  196. </view>
  197. </view>
  198. <!-- 其他功能 -->
  199. <view class="other-functions" v-if="role('other')">
  200. <view class="title">
  201. 其他功能
  202. </view>
  203. <view class="function-gird">
  204. <view class="item">
  205. <img src="@/assets/img/riLine-file-add-line@1x.png" alt="">
  206. <text>新增巡检</text>
  207. </view>
  208. <view class="item">
  209. <img src="@/assets/img/riLine-printer-line@1x.png" alt="">
  210. <text>打印标签</text>
  211. </view>
  212. <view class="item">
  213. <img src="@/assets/img/riLine-spam-line@1x.png" alt="">
  214. <text>故障申报</text>
  215. </view>
  216. <view class="item">
  217. <img src="@/assets/img/riLine-arrow-left-right-line@1x.png" alt="">
  218. <text>设备移交</text>
  219. </view>
  220. </view>
  221. </view>
  222. </view>
  223. </template>
  224. <script>
  225. import * as API from '@/apis/pagejs/index.js'
  226. import ujpNoticeBar from "@/pages/otherFunctions/components/u-notice-bar.vue"
  227. export default {
  228. data() {
  229. return {
  230. scanFunctionIsUseable:true,
  231. nowscan:{
  232. "title": "",
  233. "specifications": "",
  234. "experimentLastTime":"",
  235. "manufactor": "",
  236. "unit": "",
  237. "model": "",
  238. "code": "",
  239. },
  240. showpopup:false,
  241. show:false,
  242. badgeexportProcess:0,
  243. userInfo:{
  244. name:""
  245. },
  246. badgeGet:{
  247. },
  248. badgeList:[
  249. {
  250. url:"/mobile/out/outApproveList",
  251. role:"3",
  252. key:"outApproveList",
  253. page:{
  254. pageIndex: 1,
  255. pageSize: 0,
  256. status: 0,
  257. }
  258. },
  259. {
  260. url:"/mobile/out/outWaitList",
  261. role:"1",
  262. key:"outWaitList",
  263. page:{
  264. pageIndex: 1,
  265. pageSize: 0,
  266. status: 0,
  267. }
  268. },
  269. {
  270. url:"/mobile/in/inWaitList",
  271. role:"1",
  272. key:"inWaitList",
  273. page:{
  274. pageIndex: 1,
  275. pageSize: 0,
  276. status: 0,
  277. }
  278. },
  279. {
  280. url:"/mobile/inspection/deviceList",
  281. role:"1",
  282. key:"deviceList",
  283. page:{
  284. pageIndex: 1,
  285. pageSize: 0,
  286. healthStatus: 5,
  287. }
  288. }
  289. ]
  290. }
  291. },
  292. components:{
  293. ujpNoticeBar
  294. },
  295. onLoad() {
  296. this.userInfo=this.carhelp.getPersonInfo()
  297. //this.getUserDepartmentList()
  298. this.getInfo()
  299. },
  300. onReady() {
  301. // #ifdef MP-WEIXIN
  302. wx.getSetting({
  303. success: res => {
  304. console.log("onReady2")
  305. if (!res.authSetting['scope.camera']) {
  306. wx.authorize({
  307. scope: 'scope.camera',
  308. success () {
  309. // 用户已经同意小程序使用摄像头
  310. },
  311. fail () {
  312. // 用户拒绝了小程序使用摄像头
  313. }
  314. })
  315. }
  316. }
  317. })
  318. // #endif
  319. },
  320. onShow(){
  321. this.badgeGetMethodApi()
  322. },
  323. methods: {
  324. badgeGetMethodApi(){
  325. var tdate=new Date( +new Date() + 8 * 3600 * 1000 ).toJSON().substr(0,15).replace("T"," ")
  326. var token_tdate=this.carhelp.get("badgeGet_token_tdate");//每60分钟存储一次token
  327. if(token_tdate&&token_tdate==tdate){
  328. this.badgeGetMethod();
  329. this.$forceUpdate()
  330. }else{
  331. for(var i in this.badgeList){
  332. var obj=this.badgeList[i]
  333. if(this.role(obj.role)){
  334. this.carhelp.set("badgeGet_token_tdate",tdate);
  335. this.urlgetlisg(obj)
  336. }
  337. }
  338. }
  339. },
  340. urlgetlisg(obj){
  341. API.urlgetlisg(obj.page,obj.url).then((res) => {
  342. var count=res.data.recordsTotal;
  343. this.badgeGet[obj.key]=count;
  344. this.carhelp.set("badgeList_"+obj.key,count)
  345. this.$forceUpdate()
  346. }).catch(error => {
  347. })
  348. },
  349. badgeGetMethod(){
  350. for(var i in this.badgeList){
  351. var obj=this.badgeList[i]
  352. this.badgeGet[obj.key]=this.carhelp.get("badgeList_"+obj.key);
  353. }
  354. },
  355. error(e) {
  356. console.log(e);
  357. },
  358. role(val){
  359. if(this.userInfo.type!=null&&this.userInfo.type!=undefined){
  360. var index=this.userInfo.type.split(',').indexOf(val)
  361. return index>-1
  362. }else{
  363. return false
  364. }
  365. },
  366. getInfo(){
  367. API.findByOpenId({
  368. openId: this.carhelp.getOpenId(),
  369. noerror:true,
  370. }).then((res) => {
  371. this.carhelp.setPersonInfo(res.data.regUser );
  372. this.userInfo=this.carhelp.getPersonInfo()
  373. this.badgeGetMethodApi()
  374. }).catch(error => {
  375. uni.hideLoading();
  376. //this.getPhone()
  377. })
  378. },
  379. logout(){
  380. this.changeShow()
  381. uni.showModal({
  382. title: '提示',
  383. content: '确认是否退出?',
  384. success: res=> {
  385. if (res.confirm) {
  386. //付钱 改为组件
  387. this.logoutApi();
  388. } else if (res.cancel) {
  389. console.log('用户点击取消');
  390. }
  391. }
  392. });
  393. },
  394. logoutApi(){
  395. uni.showLoading({
  396. title: "加载中",
  397. mask: true,
  398. })
  399. var data = {
  400. };
  401. API.logout(data).then((res) => {
  402. this.carhelp.logoff();
  403. uni.redirectTo({
  404. url:"/pages/index/index"
  405. })
  406. }).catch(error => {
  407. uni.showToast({
  408. title: error
  409. })
  410. })
  411. },
  412. changeShow(){
  413. this.show=!this.show
  414. },
  415. changeShow4(openId){
  416. uni.requestSubscribeMessage({
  417. tmplIds: ['YJo0Ji-N--n27fGB41pFVCCvFCNlsJwwScN1mD13Uu4'],
  418. success (res) { }
  419. })
  420. },
  421. changeShow5(){
  422. this.showpopup=true
  423. },
  424. changeShow3(openId){
  425. this.carhelp.setOpenId(openId);
  426. this.carhelp.logoff();
  427. uni.redirectTo({
  428. url:"/pages/index/index"
  429. })
  430. },
  431. changeShow2(){
  432. var _this=this
  433. uni.showModal({
  434. title: '输入openId',
  435. editable: true,
  436. //content: '这是一个模态弹窗',
  437. success: function(res) {
  438. if (res.confirm) {
  439. if(res.content){
  440. _this.changeShow3(res.content)
  441. }
  442. } else if (res.cancel) {
  443. console.log('用户点击取消');
  444. }
  445. }
  446. });
  447. },
  448. gotoscan(val) {
  449. // #ifdef H5
  450. this.gotoscanH5(val)
  451. // #endif
  452. // #ifdef MP-WEIXIN
  453. this.gotoscanMP(val)
  454. // #endif
  455. },
  456. takeCode(e){
  457. console.log(e);
  458. if(this.scanFunctionIsUseable) {
  459. this.scanFunctionIsUseable = false;
  460. // 对扫码结果进行处理
  461. console.log(e.detail.result);
  462. this.getscan(this.takeCodeJp(e.detail.result))
  463. // 扫码间隔两秒
  464. setTimeout(() => {
  465. this.scanFunctionIsUseable = true;
  466. }, 1000)
  467. }
  468. },
  469. gotoscanMP(val){
  470. this.showpopup=true;
  471. // const ctx = uni.createCameraContext();
  472. // ctx.takePhoto({
  473. // quality: 'high',
  474. // success: (res) => {
  475. // this.src = res.tempImagePath
  476. // }
  477. // });
  478. },
  479. getscan(val) {
  480. this.showpopup=true;
  481. uni.showLoading({
  482. title: "加载中",
  483. mask: true,
  484. })
  485. API.queryDeviceByCode({
  486. code: val,
  487. }).then((res) => {
  488. uni.hideLoading();
  489. if (res.data.deviceInfo) {
  490. console.log(res.data.deviceInfo)
  491. this.nowscan=res.data.deviceInfo;
  492. uni.showToast({
  493. title: "添加成功",
  494. icon: "none"
  495. })
  496. } else {
  497. uni.showToast({
  498. title: "二维码无效",
  499. icon: "none"
  500. })
  501. }
  502. }).catch(error => {
  503. uni.showToast({
  504. title: error,
  505. icon: "none"
  506. })
  507. })
  508. },
  509. gotoscanH5(val) {
  510. console.log('111')
  511. var _this = this;
  512. uni.showModal({
  513. title: '提示',
  514. editable: true,
  515. //content: '这是一个模态弹窗',
  516. success: function(res) {
  517. if (res.confirm) {
  518. _this.getscan(res.content)
  519. } else if (res.cancel) {
  520. console.log('用户点击取消');
  521. }
  522. }
  523. });
  524. },
  525. }
  526. }
  527. </script>
  528. <style >
  529. page{
  530. background-color: rgba(1,122,255,1);
  531. padding-bottom: 100rpx;
  532. }
  533. </style>
  534. <style lang="scss" scoped>
  535. .options{
  536. width: 260rpx;
  537. line-height: 60rpx;
  538. //text-align: center;
  539. padding:8rpx 0px 8rpx 16rpx;
  540. background-color: #fff;
  541. color: rgba(65, 80, 88, 1);
  542. font-family: Microsoft Yahei;
  543. position: absolute;
  544. top: 228rpx;
  545. border-radius: 1px;
  546. //right: 24rpx;
  547. box-shadow:5px 5px 10px gray;
  548. }
  549. .headerView{
  550. //background:linear-gradient(180deg, rgba(0,45,194,1) 0%,rgba(0,59,254,1) 49%,rgba(1,122,255,1) 100%);
  551. background-color: rgba(1,122,255,1);
  552. }
  553. page{
  554. background-color: rgba(1,122,255,1);
  555. padding-bottom: 100rpx;
  556. }
  557. // 头部
  558. .header{
  559. width: 100%;
  560. height: 289px;
  561. background:linear-gradient(180deg, rgba(0,45,194,1) 0%,rgba(0,59,254,1) 49%,rgba(1,122,255,1) 100%);
  562. padding: 0 40rpx;
  563. .main{
  564. width: 100%;
  565. height: 100%;
  566. background: url(@/assets/img/background.png) no-repeat;
  567. background-position: top -70rpx right -50rpx;
  568. position: relative;
  569. background-position-y: 20px;
  570. padding-top: 20rpx;
  571. }
  572. .title{
  573. //margin-top: 60px;
  574. padding-top: 60px;
  575. display: flex;
  576. justify-content: space-between;
  577. align-items: center;
  578. color: rgba(255, 255, 255, 1);
  579. line-height: 88rpx;
  580. .name{
  581. display: flex;
  582. font-size: 40rpx;
  583. }
  584. .qr-code{
  585. display: flex;
  586. }
  587. }
  588. }
  589. // 宫格
  590. .gird{
  591. // 公告
  592. .notice{
  593. overflow: hidden;
  594. width: 100%;
  595. display: flex;
  596. align-items: center;
  597. background-color: #6290f7;
  598. color: rgba(255, 255, 255, 1);
  599. font-weight: bold;
  600. border-radius: 8px;
  601. height: 80rpx;
  602. line-height: 80rpx;
  603. padding: 0 24rpx;
  604. // position: absolute;
  605. bottom: 260rpx;
  606. left: 0;
  607. right: 0;
  608. margin-bottom: 40rpx;
  609. text{
  610. font-size: 28rpx;
  611. width: 542px;
  612. margin-left: 16rpx;
  613. white-space: nowrap;
  614. overflow: hidden;
  615. text-overflow: ellipsis;
  616. }
  617. }
  618. padding: 0 40rpx;
  619. display: flex;
  620. justify-content: space-between;
  621. flex-wrap: wrap;
  622. margin-top: -124rpx;
  623. .item{
  624. width: 720rpx;
  625. height: 100px;
  626. background-color: rgba(255, 255, 255, 1);
  627. border-radius: 8px;
  628. padding: 32rpx 24rpx;
  629. position: relative;
  630. margin-bottom: 30rpx;
  631. .title{
  632. color: rgba(16, 16, 16, 1);
  633. font-size: 44rpx;
  634. margin-bottom: 8rpx;
  635. font-family: 'Alibaba-PuHuiTi-Regular';
  636. }
  637. .hint{
  638. color: rgba(106, 121, 142, 1);
  639. font-size: 32rpx;
  640. margin-bottom: 44rpx;
  641. }
  642. .img{
  643. width: 75px;
  644. height: 75px;
  645. position: absolute;
  646. right: 24rpx;
  647. bottom: 24rpx;
  648. img{
  649. width: 100%;
  650. height: 100%;
  651. }
  652. }
  653. }
  654. }
  655. // 其他功能
  656. .other-functions{
  657. padding: 0 40rpx;
  658. .title{
  659. color: rgba(255, 255, 255, 1);
  660. font-size: 36rpx;
  661. margin-bottom: 16rpx;
  662. }
  663. .function-gird{
  664. display: flex;
  665. flex-wrap: wrap;
  666. justify-content: space-between;
  667. .item{
  668. display: flex;
  669. align-items: center;
  670. justify-content: center;
  671. width: 320rpx;
  672. height: 80rpx;
  673. line-height: 80rpx;
  674. margin-bottom: 24rpx;
  675. color: rgba(255, 255, 255, 1);
  676. border-radius: 8px;
  677. background-color: rgba(255, 255, 255, 0.25);
  678. text-align: center;
  679. border: 1px solid rgba(255, 255, 255, 0.35);
  680. img{
  681. width: 32rpx;
  682. height: 32rpx;
  683. margin-right: 8rpx;
  684. }
  685. }
  686. }
  687. }
  688. </style>