home.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. <template>
  2. <view class="container">
  3. <u-navbar bgColor="#fff" :placeholder="true" @leftClick="scan">
  4. <view slot="left">
  5. <u-icon name="scan" color="#333" size="32"></u-icon>
  6. </view>
  7. <view slot="center" style="color:#333;font-size: 36rpx;">
  8. 开门柜管理
  9. </view>
  10. </u-navbar>
  11. <!-- 统计信息 -->
  12. <view class="total">
  13. <view class="total-sale flex flex-start ">
  14. <view class="sale-item">
  15. <view class="sale-name">
  16. 今日总收益(元)
  17. </view>
  18. <view class="sale-num">
  19. {{$xy.delMoney(total.day.salesPrice)}}
  20. </view>
  21. </view>
  22. <view class="sale-item">
  23. <view class="sale-name">
  24. 本月总收益(元)
  25. </view>
  26. <view class="sale-num">
  27. {{$xy.delMoney(total.month.salesPrice)}}
  28. </view>
  29. </view>
  30. <view class="sale-more" @click="$tab.navigateTo('/pages/globalPages/moreData')">
  31. 更多数据
  32. <image src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/white-more.png"
  33. mode="widthFix"></image>
  34. </view>
  35. <view @click="update" :class="[load?'update load':'update']">
  36. <image src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/update.png"
  37. mode="heightFix"></image>
  38. </view>
  39. </view>
  40. <view class="refund-order flex flex-start">
  41. <view class="refund-item" @click="$tab.navigateTo('/pages/order/refundList')">
  42. <view class="refund-num">
  43. ¥{{$xy.delMoney(total.day.refundMoney)}}
  44. </view>
  45. <view class="refund-name">
  46. 今日退款
  47. </view>
  48. </view>
  49. <view class="refund-item" @click="$tab.navigateTo('/pages/order/orderQuery')">
  50. <view class="refund-num">
  51. {{total.day.orderNum}}
  52. </view>
  53. <view class="refund-name">
  54. 今日订单数
  55. </view>
  56. </view>
  57. </view>
  58. <view class="notice" @click="goRisk">
  59. <view>
  60. <u-notice-bar :text="notice" color="#CB7506" bgColor="#fff" speed="80" mode="link"
  61. @close="noticeClose">
  62. </u-notice-bar>
  63. </view>
  64. <!-- <view class="notice-tips flex justify-around align-center" v-if="tipsCount.riskOrderNum>0">
  65. <view>
  66. {{tipsCount.riskOrderNum}}
  67. </view>
  68. </view> -->
  69. <view class="notice-tips flex justify-around align-center" v-if="tipsCount.riskOrderNum>0">
  70. <u-badge numberType="overflow" bgColor="#E60012" max="99" :value="tipsCount.riskOrderNum"></u-badge>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- 常用菜单 -->
  75. <view class="useful-menu" v-if="operMenu.length>0">
  76. <view class="flex justify-between flex-wrap">
  77. <view class="useful-menu-item flex justify-between align-center" v-for="(item,index) in operMenu"
  78. :key="item.id" @click="menuClick(item)">
  79. <view class="image">
  80. <u-image width="75rpx" height="75rpx" :src="iconList[item.name]" mode="widthFix"
  81. :lazy-load="true">
  82. </u-image>
  83. </view>
  84. <view class="menu-name">{{item.name}}</view>
  85. <!-- <view class="tips flex justify-around align-center" v-if="tips(item.name)>0">
  86. <view>
  87. {{tips(item.name)}}
  88. </view>
  89. </view> -->
  90. <u-badge absolute :offset="[-2,-2]" is-dot bgColor="#E60012" v-if="tips(item.name)>0"></u-badge>
  91. <!-- <u-badge numberType="overflow" :absolute="true" :offset="[-4,-4]" bgColor="#E60012" max="99" :value="tips(item.name)"></u-badge> -->
  92. </view>
  93. </view>
  94. </view>
  95. <!--便捷功能 -->
  96. <view class="menu" v-if="usefMenu.length>0">
  97. <view class="menu-title">
  98. 便捷功能
  99. </view>
  100. <view class="menu-content flex justify-start">
  101. <view class="menu-item" v-for="(item,index) in usefMenu" :key="item.id" @click="menuClick(item)">
  102. <view class="image">
  103. <u-image width="57rpx" height="57rpx" :src="iconList[item.name]" mode="widthFix"
  104. :lazy-load="true">
  105. </u-image>
  106. </view>
  107. <view>{{item.name}}</view>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. </template>
  113. <script>
  114. import {
  115. allCount
  116. } from "@/api/device/device.js"
  117. import {
  118. tipsCount
  119. } from "@/api/order/order.js"
  120. tipsCount
  121. export default {
  122. data() {
  123. return {
  124. tabArr: [{
  125. name: '今日',
  126. id: 0
  127. },
  128. {
  129. name: '本月',
  130. id: 1
  131. }
  132. ],
  133. current: 0,
  134. //菜单对应图片路径
  135. iconList: {
  136. '退款审核': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/refund.png',
  137. '异常订单': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/risk.png',
  138. '客诉处理': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/cc.png',
  139. '补货管理': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/replenishment.png',
  140. '增加设备': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/menu-icon (9).png',
  141. '增加点位': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/menu-icon (8).png',
  142. '团队管理': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/menu-icon (4).png',
  143. '加盟商': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/menu-icon (2).png',
  144. '流量卡管理': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/menu-icon (5).png',
  145. '会员管理': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/menu-icon (1).png',
  146. '运营仓': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/menu-icon (7).png',
  147. '黑名单管理': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/menu-icon (3).png',
  148. '营销管理': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/menu-icon (6).png',
  149. '费用账单': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/menu-icon (10).png',
  150. '商品建模': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/goods-model.png',
  151. '订单管理': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/order-man.png',
  152. // '商品统计': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/goods-total.png',
  153. '销售统计': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/device-total.png',
  154. //暂时使用
  155. '激活管理': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/menu-icon (6).png',
  156. '商品清单': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/menu-icon (7).png',
  157. '常见错误码': 'https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/menu-icon (3).png',
  158. },
  159. tempTotal: {},
  160. total: {
  161. day: {
  162. orderNum: 0,
  163. refundMoney: 0,
  164. salesPrice: 0
  165. },
  166. month: {
  167. orderNum: 0,
  168. refundMoney: 0,
  169. salesPrice: 0
  170. }
  171. },
  172. riskNum: 0,
  173. noticeShow: false,
  174. load: false,
  175. timer: null,
  176. tipsCount: {
  177. refundNum: 0,
  178. complaintsNum: 0,
  179. outOfStockNum: 0,
  180. riskOrderNum: 0
  181. }
  182. }
  183. },
  184. computed: {
  185. //运营任务菜单
  186. operMenu() {
  187. return this.getMenu('首页', '运营任务')
  188. },
  189. //便捷菜单
  190. usefMenu() {
  191. return this.getMenu('首页', '便捷功能')
  192. },
  193. //消息
  194. notice() {
  195. let msg = '您有新的消息~'
  196. if (this.tipsCount.riskOrderNum > 0) {
  197. msg = `您有${this.tipsCount.riskOrderNum}个待办订单需处理!`
  198. } else {
  199. msg = '无待办事项~'
  200. }
  201. return msg
  202. }
  203. },
  204. created() {
  205. this.getTotalData() //顶部统计数据
  206. this.getNum() //常用菜单角标
  207. },
  208. methods: {
  209. //更新统计数据
  210. update() {
  211. if (this.timer) {
  212. clearTimeout(this.timer)
  213. }
  214. this.load = true;
  215. this.timer = setTimeout(() => {
  216. this.load = false;
  217. }, 1000)
  218. this.getTotalData()
  219. this.getNum() //常用菜单角标
  220. },
  221. onshow() {
  222. this.getTotalData()
  223. this.getNum()
  224. },
  225. //统计数据
  226. getTotalData() {
  227. allCount().then(res => {
  228. this.total = res.data
  229. })
  230. },
  231. tips(name) {
  232. let num = 0;
  233. switch (name) {
  234. case '退款审核':
  235. num = this.tipsCount.refundNum
  236. break;
  237. case '异常订单':
  238. num = this.tipsCount.riskOrderNum
  239. break;
  240. case '客诉处理':
  241. num = this.tipsCount.complaintsNum
  242. break;
  243. case '补货管理':
  244. num = this.tipsCount.outOfStockNum
  245. break;
  246. default:
  247. break;
  248. }
  249. return num
  250. },
  251. //常用功能角标数据
  252. getNum() {
  253. tipsCount().then(res => {
  254. this.tipsCount = res.data
  255. }).catch(err => {
  256. this.tipsCount = {
  257. refundNum: 0,
  258. complaintsNum: 0,
  259. outOfStockNum: 0,
  260. riskOrderNum: 0
  261. }
  262. })
  263. },
  264. getMenu(menu1, menu2) {
  265. let menu = []
  266. if (this.$store.state.permission.permissions_menu && this.$store.state.permission.permissions_menu != '[]') {
  267. let allMenu = JSON.parse(this.$store.state.permission.permissions_menu);
  268. if (allMenu.find(i => i.name == menu1) && allMenu.find(i => i.name == menu1).children) {
  269. let homeMenu = allMenu.find(i => i.name == menu1).children;
  270. if (homeMenu.find(i => i.name == menu2) && homeMenu.find(i => i.name == menu2).children) {
  271. menu = homeMenu.find(i => i.name == menu2).children
  272. }
  273. }
  274. }
  275. return menu
  276. },
  277. scan() {
  278. uni.scanCode({
  279. success: (res) => {
  280. let deviceId = res.result.split('=')[1]
  281. if (deviceId) {
  282. this.$tab.navigateTo(`/pages/activeDevice/bindDevice?id=${deviceId}`)
  283. } else {
  284. this.$modal.msg('该二维码无效~')
  285. }
  286. }
  287. });
  288. },
  289. tabChange(e) {
  290. this.current = e.id
  291. this.switchTotal(this.current)
  292. },
  293. menuClick(e) {
  294. if (e.name == '补货管理') {
  295. this.$tab.navigateTo('/pages/replenish/replenishmentManagement')
  296. return
  297. }
  298. if (e.name == '退款审核') {
  299. this.$tab.navigateTo('/pages/order/refundList')
  300. return
  301. }
  302. if (e.name == '异常订单') {
  303. this.$tab.navigateTo('/pages/order/riskOrder')
  304. return
  305. }
  306. if (e.name == '增加点位') {
  307. this.$tab.navigateTo('/pages/point/point')
  308. return
  309. }
  310. if (e.name == '商品建模') {
  311. this.$tab.navigateTo('/pages/commodity/auditList')
  312. return
  313. }
  314. if (e.name == '订单管理') {
  315. this.$tab.navigateTo('/pages/order/orderQuery')
  316. return
  317. }
  318. if (e.name == '销售统计') {
  319. this.$tab.navigateTo('/pages/globalPages/statistics')
  320. return
  321. }
  322. if (e.name == '设备统计') {
  323. this.$tab.navigateTo('/pages/globalPages/deviceStatistics')
  324. return
  325. }
  326. if (e.name == '激活管理') {
  327. this.$tab.navigateTo('/pages/activeDevice/deviceManage')
  328. return
  329. }
  330. if (e.name == '商品清单') {
  331. this.$tab.navigateTo('/pages/commodity/commoditylist')
  332. return
  333. }
  334. if (e.name == '常见错误码') {
  335. this.$tab.navigateTo('/pages/globalPages/errCode')
  336. return
  337. }
  338. this.$modal.msg('功能开发中,尽请期待~')
  339. },
  340. clearStor() {
  341. try {
  342. uni.clearStorageSync();
  343. } catch (e) {
  344. console.log(e)
  345. }
  346. },
  347. noticeClose() {
  348. this.noticeShow = false
  349. },
  350. goRisk() {
  351. if (this.tipsCount.riskOrderNum > 0) {
  352. this.$tab.navigateTo('/pages/order/riskOrder')
  353. }
  354. }
  355. }
  356. }
  357. </script>
  358. <style lang="scss" scoped>
  359. @keyframes rotate {
  360. from {
  361. transform: rotate(0deg);
  362. }
  363. to {
  364. transform: rotate(359deg);
  365. }
  366. }
  367. /deep/.u-notice-bar {
  368. padding: 9px 12rpx !important;
  369. }
  370. .container {
  371. padding-bottom: 88rpx;
  372. position: relative;
  373. .nav-style {
  374. font-size: 32rpx;
  375. font-weight: bold;
  376. color: #fff;
  377. }
  378. // 统计信息
  379. .total {
  380. width: 724rpx;
  381. margin-left: 14rpx;
  382. overflow: hidden;
  383. border-radius: 14rpx;
  384. background-color: #fff;
  385. margin-top: 10rpx;
  386. .total-sale {
  387. width: 724rpx;
  388. height: 205rpx;
  389. background: url('https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/home/home-bg.png') no-repeat left top;
  390. background-size: 100% 100%;
  391. position: relative;
  392. .sale-item {
  393. margin-top: 46rpx;
  394. padding-left: 30rpx;
  395. .sale-name {
  396. font-size: 26rpx;
  397. font-weight: 500;
  398. color: #EEEDFF;
  399. line-height: 26rpx;
  400. }
  401. .sale-num {
  402. line-height: 50rpx;
  403. font-size: 50rpx;
  404. font-weight: 800;
  405. color: #FFFFFF;
  406. margin-top: 55rpx;
  407. }
  408. }
  409. .sale-more {
  410. font-size: 26rpx;
  411. font-weight: 500;
  412. color: #FFFFFF;
  413. padding-right: 18rpx;
  414. position: absolute;
  415. right: 12rpx;
  416. top: 22rpx;
  417. line-height: 26rpx;
  418. image {
  419. width: 24rpx;
  420. height: 24rpx;
  421. position: absolute;
  422. right: 0;
  423. top: 0;
  424. }
  425. }
  426. .update {
  427. width: 50rpx;
  428. height: 50rpx;
  429. position: absolute;
  430. right: 16rpx;
  431. bottom: 16rpx;
  432. &.load {
  433. animation: rotate 1s linear;
  434. animation-iteration-count: 3;
  435. }
  436. image {
  437. width: 50rpx;
  438. height: 50rpx;
  439. }
  440. }
  441. }
  442. .refund-order {
  443. padding-left: 34rpx;
  444. overflow: hidden;
  445. padding-bottom: 26rpx;
  446. .refund-item {
  447. text-align: center;
  448. color: #2E2E2E;
  449. margin-top: 68rpx;
  450. &:nth-child(1) {
  451. margin-right: 70rpx;
  452. }
  453. .refund-num {
  454. font-size: 36rpx;
  455. font-weight: 800;
  456. line-height: 32rpx;
  457. }
  458. .refund-name {
  459. font-size: 28rpx;
  460. font-weight: 500;
  461. line-height: 28rpx;
  462. margin-top: 27rpx;
  463. }
  464. }
  465. }
  466. .notice {
  467. width: 100%;
  468. position: relative;
  469. // .notice-tips {
  470. // padding: 10rpx;
  471. // color: #fff;
  472. // font-size: 24rpx;
  473. // text-align: center;
  474. // position: absolute;
  475. // right: 56rpx;
  476. // top: 50%;
  477. // transform: translateY(-50%);
  478. // z-index: 999;
  479. // background-color: #fff;
  480. // >view {
  481. // width: 36rpx;
  482. // height: 36rpx;
  483. // background-color: #E60012;
  484. // border-radius: 36rpx;
  485. // line-height: 36rpx;
  486. // }
  487. // }
  488. .notice-tips {
  489. padding: 10rpx;
  490. text-align: center;
  491. position: absolute;
  492. right: 40rpx;
  493. top: 50%;
  494. transform: translateY(-54%);
  495. z-index: 999;
  496. background-color: #fff;
  497. }
  498. }
  499. }
  500. //常用菜单
  501. .useful-menu {
  502. width: 724rpx;
  503. margin-left: 14rpx;
  504. .useful-menu-item {
  505. margin-top: 20rpx;
  506. width: 352rpx;
  507. height: 168rpx;
  508. background: #FFFFFF;
  509. box-shadow: 0px 0px 10px 0px rgba(174, 201, 255, 0.2);
  510. border-radius: 14rpx;
  511. padding: 0 66rpx 0 46rpx;
  512. position: relative;
  513. >.image {
  514. width: 75rpx;
  515. height: 75rpx;
  516. }
  517. >.menu-name {
  518. font-size: 32rpx;
  519. font-weight: 500;
  520. color: #333333;
  521. }
  522. .tips {
  523. // width: 40rpx;
  524. // height: 40rpx;
  525. // background-color: #E60012;
  526. // color: #fff;
  527. // font-size: 24rpx;
  528. // text-align: center;
  529. // line-height: 28rpx;
  530. // border-radius: 40rpx;
  531. // position: absolute;
  532. // right: -8rpx;
  533. // top: -8rpx;
  534. // padding: 6rpx;
  535. width: 40rpx;
  536. height: 40rpx;
  537. position: absolute;
  538. right: -8rpx;
  539. top: -8rpx;
  540. padding: 6rpx;
  541. }
  542. }
  543. }
  544. // 便捷功能
  545. .menu {
  546. width: 724rpx;
  547. margin-left: 14rpx;
  548. background: #FFFFFF;
  549. box-shadow: 0px 0px 10rpx 0px rgba(174, 201, 255, 0.2);
  550. border-radius: 14rpx;
  551. display: flex;
  552. flex-flow: row nowrap;
  553. justify-content: space-around;
  554. margin-top: 20rpx;
  555. position: relative;
  556. padding: 101rpx 36rpx 0rpx;
  557. .menu-title {
  558. font-size: 28rpx;
  559. font-weight: 800;
  560. color: #000;
  561. position: absolute;
  562. left: 28rpx;
  563. top: 28rpx;
  564. }
  565. .menu-item {
  566. margin-bottom: 48rpx;
  567. }
  568. .menu-content {
  569. width: 100%;
  570. flex-flow: row wrap;
  571. }
  572. .menu-item {
  573. text-align: center;
  574. width: 25%;
  575. display: flex;
  576. flex-direction: column;
  577. align-items: center;
  578. >.image {
  579. width: 57rpx;
  580. height: 57rpx;
  581. }
  582. >view {
  583. color: #333;
  584. font-size: 24rpx;
  585. line-height: 24rpx;
  586. font-size: 28rpx;
  587. line-height: 28rpx;
  588. margin-top: 16rpx;
  589. }
  590. }
  591. }
  592. }
  593. </style>