HomePage.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <div class="content">
  3. <div class="sm">
  4. <van-search v-model="searchValue" @search="onSearch" placeholder="点击搜索单号" />
  5. <img @click="wxScanCode()" src="@/assets/user/u4.png" alt="">
  6. </div>
  7. <!-- 显示 -->
  8. <div class="echarts1">
  9. <div id="myChart1"></div>
  10. <div id="myChart2"></div>
  11. </div>
  12. <!-- 图标 -->
  13. <div class="icon">
  14. <div class="icon-box">
  15. <router-link to="storage">
  16. <span class="span">
  17. <img src="@/assets/user/u32.png" alt="">
  18. </span>
  19. <p>快件入库</p>
  20. </router-link>
  21. </div>
  22. <div class="icon-box">
  23. <router-link to="Removal">
  24. <span class="span">
  25. <img src="@/assets/user/u35.png" alt="">
  26. </span>
  27. <p>快件出库</p>
  28. </router-link>
  29. </div>
  30. <div class="icon-box">
  31. <router-link to="DeliveryInquiry">
  32. <span class="span">
  33. <img src="@/assets/user/u38.png" alt="">
  34. </span>
  35. <p>派件查询</p>
  36. </router-link>
  37. </div>
  38. <div class="icon-box">
  39. <router-link to="SignA">
  40. <span class="span">
  41. <img src="@/assets/user/u41.png" alt="">
  42. </span>
  43. <p>派件签收</p>
  44. </router-link>
  45. </div>
  46. </div>
  47. </div>
  48. </template>
  49. <script>
  50. import { appFindYourShipment, appStatistics, getSysUserInfoByUserIdAPI, getWxConfig } from '../../api/index'
  51. import {
  52. Toast,
  53. Dialog
  54. } from 'vant'
  55. // vue 专用版本JS-SDK
  56. import wx from "weixin-jsapi";
  57. export default {
  58. data() {
  59. return {
  60. deliveryList: [],//派件
  61. collectList: [],//揽收
  62. searchValue: "", //搜索单号的值
  63. expressMap: {}, //收件
  64. mailMap: {}, //寄件
  65. }
  66. },
  67. async mounted() {
  68. // 数据图表
  69. const resValue = await appStatistics({ deliveryPeopleId: localStorage.getItem('courierId') })
  70. const { dispatchStatistics = [], pickupStatistics = [] } = resValue.data
  71. let signSuccessfully = 0; // 签收成功
  72. let outOfDelivery = 0; // 派送中
  73. let deliveryFailure = 0; // 派送失败
  74. dispatchStatistics.forEach(({ expressStatus, number }) => {
  75. if (expressStatus == "1") {
  76. outOfDelivery = number
  77. } else if (expressStatus == "2") {
  78. signSuccessfully = number
  79. } else if (expressStatus == "4") {
  80. deliveryFailure = number
  81. }
  82. })
  83. let waiteCollecte = 0 //待揽收
  84. let noCollecte = 0 //未揽收
  85. let collecteSuccess = 0 //揽收成功
  86. pickupStatistics.forEach(({ express_status, number }) => {
  87. if (express_status == "1") {
  88. waiteCollecte = number
  89. noCollecte = number
  90. } else if (express_status == "2") {
  91. collecteSuccess = number
  92. }
  93. })
  94. // 页面加载完成唤醒微信扫一扫
  95. //本地 注释 服务器 放开
  96. setTimeout(() => {
  97. let myChart = this.$echarts.init(document.getElementById('myChart1'))
  98. var option = {
  99. tooltip: {
  100. // show: false,
  101. trigger: 'item'
  102. },
  103. legend: {
  104. top: '65%',
  105. left: '30%',
  106. orient: 'vertical',
  107. icon: 'circle',
  108. itemGap: 6,
  109. textStyle: {
  110. fontSize: 10,
  111. }
  112. },
  113. series: [{
  114. name: '数据',
  115. type: 'pie',
  116. center: ["50%", "35%"],
  117. radius: ['40%', '60%'],
  118. avoidLabelOverlap: false,
  119. label: {
  120. normal: {
  121. show: true,
  122. position: 'center',
  123. color: '#4c4a4a',
  124. formatter: '{active|' + '今日累计收件' + '}' + '\n\r' + '{total|' + signSuccessfully +
  125. '}',
  126. rich: {
  127. total: {
  128. fontSize: 12,
  129. fontWeight: 'bold',
  130. color: '#454c5c'
  131. },
  132. active: {
  133. fontSize: 10,
  134. color: '#6c7a89',
  135. lineHeight: 30,
  136. },
  137. }
  138. },
  139. emphasis: { //中间文字显示
  140. show: true,
  141. }
  142. },
  143. color: ['#07daf9', '#f98407', '#f9df07', '#079bf9'],
  144. labelLine: {
  145. show: false
  146. },
  147. data: [{
  148. value: signSuccessfully,
  149. name: '签收成功'
  150. },
  151. {
  152. value: outOfDelivery,
  153. name: '派送中'
  154. },
  155. {
  156. value: deliveryFailure,
  157. name: '派送失败'
  158. },]
  159. }]
  160. }
  161. myChart.setOption(option)
  162. let myChart2 = this.$echarts.init(document.getElementById('myChart2'))
  163. var option2 = {
  164. tooltip: {
  165. trigger: 'item'
  166. },
  167. legend: {
  168. top: '65%',
  169. left: '30%',
  170. orient: 'vertical',
  171. icon: 'circle',
  172. itemGap: 6,
  173. textStyle: {
  174. fontSize: 10,
  175. }
  176. },
  177. series: [{
  178. name: '数据',
  179. type: 'pie',
  180. center: ["50%", "35%"],
  181. radius: ['40%', '60%'],
  182. avoidLabelOverlap: false,
  183. label: {
  184. normal: {
  185. show: true,
  186. position: 'center',
  187. color: '#4c4a4a',
  188. formatter: '{active|' + '今日累计下单' + '}' + '\n\r' + '{total|' + collecteSuccess +
  189. '}',
  190. rich: {
  191. total: {
  192. fontSize: 12,
  193. fontWeight: 'bold',
  194. color: '#454c5c'
  195. },
  196. active: {
  197. fontSize: 10,
  198. color: '#6c7a89',
  199. lineHeight: 30,
  200. },
  201. }
  202. },
  203. emphasis: { //中间文字显示
  204. show: true,
  205. }
  206. },
  207. color: ['#07daf9', '#f98407', '#f9df07', '#079bf9'],
  208. labelLine: {
  209. show: false
  210. },
  211. data: [{
  212. value: collecteSuccess,
  213. name: '揽收成功'
  214. },
  215. {
  216. value: waiteCollecte,
  217. name: '待揽收'
  218. },
  219. {
  220. value: noCollecte,
  221. name: '未揽收'
  222. },
  223. ]
  224. }]
  225. }
  226. myChart2.setOption(option2)
  227. }, 500)
  228. },
  229. methods: {
  230. // 点击搜索icon
  231. wxScanCode() {
  232. wx.scanQRCode({
  233. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  234. scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
  235. success: (res) => {
  236. //alert(res)
  237. console.log(res, '==============')
  238. var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
  239. if (result.indexOf(",") != -1) {
  240. let result1 = res.resultStr.split(",");
  241. result = result1[result1.length - 1];
  242. }
  243. this.wxScanCodeA(result)
  244. },
  245. error: function (res) {
  246. console.log(res, 'error++++++++++');
  247. }
  248. });
  249. console.log('qwe')
  250. },
  251. // 点击搜索icon
  252. async wxScanCodeA(result) {
  253. const res = await appFindYourShipment({ expressNo: result }, { emulateJSON: true })
  254. if (res.msg == 'success' && res.data) {
  255. this.$store.state.shipment = res
  256. this.$router.push('ScannerResult')
  257. } else {
  258. Toast('找不到此单号')
  259. }
  260. },
  261. // 搜索
  262. async onSearch() {
  263. const res = await appFindYourShipment({ expressNo: this.searchValue }, { emulateJSON: true })
  264. if (res.msg == 'success' && res.data) {
  265. this.$store.state.shipment = res
  266. this.$router.push('ScannerResult')
  267. } else {
  268. Toast('找不到此单号')
  269. }
  270. }
  271. },
  272. // async getUser() {
  273. // const res = await getSysUserInfoByUserIdAPI({ userId: localStorage.getItem("userId") })
  274. // this.$store.state.user = res.sysUserInfo
  275. // console.log(this.$store.state.user, 'this.$state.state.user')
  276. // }
  277. //单号搜索
  278. // onSearch(val) {
  279. // this.$router.push({
  280. // path: '/Sysearch',
  281. // query: {
  282. // expressNo: val,
  283. // searchType: "1" //1.搜索全部 2.搜索快件 3.搜索寄件
  284. // }
  285. // })
  286. // },
  287. }
  288. </script>
  289. <style scoped lang="less">
  290. .content {
  291. padding: 0.25rem .37rem;
  292. .sm {
  293. display: flex;
  294. margin-bottom: .2rem;
  295. justify-content: space-between;
  296. /deep/.van-search {
  297. width: 100%;
  298. height: .76rem;
  299. border-radius: 25px;
  300. overflow: hidden;
  301. padding: 0rem;
  302. background-color: white;
  303. .van-search__content {
  304. background-color: white;
  305. }
  306. input {
  307. background-color: white;
  308. }
  309. }
  310. img {
  311. width: .4rem;
  312. height: .4rem;
  313. position: relative;
  314. top: .18rem;
  315. margin-left: .1rem;
  316. }
  317. }
  318. .echarts1 {
  319. width: 100%;
  320. height: 4.2rem;
  321. background: white;
  322. display: flex;
  323. #myChart1,
  324. #myChart2 {
  325. // width: 100%;
  326. // height: 100%;
  327. width: 50%;
  328. height: 200px;
  329. // margin: 0 auto;
  330. }
  331. }
  332. .icon {
  333. font-size: .26rem;
  334. display: flex;
  335. flex-wrap: wrap;
  336. justify-content: space-between;
  337. background: white;
  338. padding: .3rem .6rem 0rem;
  339. margin-top: .3rem;
  340. border-radius: .05rem;
  341. &-box {
  342. width: 35%;
  343. text-align: center;
  344. display: block;
  345. margin-bottom: .3rem;
  346. color: #333;
  347. a {
  348. display: flex;
  349. justify-content: center;
  350. align-items: center;
  351. flex-direction: column;
  352. &:link {
  353. color: #000;
  354. }
  355. .span {
  356. background-color: #00c4b8;
  357. width: 1.8rem;
  358. height: 1.8rem;
  359. border-radius: 50%;
  360. display: flex;
  361. justify-content: center;
  362. align-items: center;
  363. img {
  364. width: 1rem;
  365. height: 1rem;
  366. }
  367. }
  368. p {
  369. margin-top: 4px;
  370. }
  371. }
  372. }
  373. }
  374. }
  375. </style>