index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. <template>
  2. <view class="rf-index">
  3. <view class="index">
  4. <view class="header">
  5. <view class="header-warp">
  6. <view class="header-left">
  7. <view class="uni-list">
  8. <view class="uni-list-cell">
  9. <view class="uni-list-cell-db">
  10. <picker @change="bindPickerChange" :value="index" :range="array">
  11. <view class="uni-input">{{array[index]}}</view>
  12. </picker>
  13. <image src="../../static/images/downicon.png" mode="" class="icon"></image>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="header-bar header-center">首页</view>
  19. <view class="header-right">
  20. <image src="../../static/images/seticon.png" mode="" class="icon"></image>
  21. </view>
  22. </view>
  23. <view class="user">
  24. <view class="user-left">
  25. <image src="" mode="" class="usericon"></image>
  26. <view class="message">
  27. <view class="name">猪猪虾</view>
  28. <view class="tele">151123165441</view>
  29. </view>
  30. </view>
  31. <view class="user-right">
  32. <image src="../../static/images/scan.png" mode="" class="sacnicon"></image>
  33. <view class="txt">
  34. 验证码核销
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="" style="height: 100px;"></view>
  40. <view class="index-content">
  41. <!-- 关键指数 -->
  42. <view class="exponent">
  43. <view class="title-warp">
  44. <view class="name">
  45. 关键指数
  46. </view>
  47. <view class="time">
  48. 数据截至:2020.07.03 <text class="hour">10:10</text>
  49. </view>
  50. </view>
  51. <view class="exponent-list">
  52. <view class="item seale">
  53. <view class="left">
  54. <view class="title">
  55. 销售总额
  56. </view>
  57. <view class="num">
  58. 1848,123
  59. </view>
  60. <view class="ratio">
  61. <view class="detail">
  62. <image src="../../static/images/down.png" class="icon"> 10% <text class="compare">同比上月</text>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="right">
  67. <image src="../../static/images/sealenum.png" mode="" class="logoicon"></image>
  68. </view>
  69. </view>
  70. <view class="item order">
  71. <view class="left">
  72. <view class="title">
  73. 销售总额
  74. </view>
  75. <view class="num">
  76. 1848,123
  77. </view>
  78. <view class="ratio">
  79. <view class="detail">
  80. <image src="../../static/images/down.png" class="icon"> 10% <text class="compare">同比上月</text>
  81. </view>
  82. </view>
  83. </view>
  84. <view class="right">
  85. <image src="../../static/images/sealenum.png" mode="" class="logoicon"></image>
  86. </view>
  87. </view>
  88. <view class="item todayseale">
  89. <view class="left">
  90. <view class="title">
  91. 销售总额
  92. </view>
  93. <view class="num">
  94. 1848,123
  95. </view>
  96. <view class="ratio">
  97. <view class="detail">
  98. <image src="../../static/images/down.png" class="icon"> 10% <text class="compare">同比上月</text>
  99. </view>
  100. </view>
  101. </view>
  102. <view class="right">
  103. <image src="../../static/images/sealenum.png" mode="" class="logoicon"></image>
  104. </view>
  105. </view>
  106. <view class="item todayorder">
  107. <view class="left">
  108. <view class="title">
  109. 销售总额
  110. </view>
  111. <view class="num">
  112. 1848,123
  113. </view>
  114. <view class="ratio">
  115. <view class="detail">
  116. <image src="../../static/images/down.png" class="icon"> 10% <text class="compare">同比上月</text>
  117. </view>
  118. </view>
  119. </view>
  120. <view class="right">
  121. <image src="../../static/images/sealenum.png" mode="" class="logoicon"></image>
  122. </view>
  123. </view>
  124. </view>
  125. </view>
  126. <!-- 待处理事物 -->
  127. <view class="something">
  128. <view class="title">
  129. 待处理事物
  130. </view>
  131. <view class="todo-list">
  132. <view class="item">
  133. <view class="title">
  134. 带发货订单
  135. </view>
  136. <view class="num">
  137. 1802
  138. </view>
  139. </view>
  140. <view class="item">
  141. <view class="title">
  142. 带发货订单
  143. </view>
  144. <view class="num">
  145. 1802
  146. </view>
  147. </view>
  148. <view class="item">
  149. <view class="title">
  150. 带发货订单
  151. </view>
  152. <view class="num">
  153. 1802
  154. </view>
  155. </view>
  156. </view>
  157. </view>
  158. <!-- 数据概况 -->
  159. <view class="data">
  160. <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
  161. <view class="qiun-title-dot-light">数据概况</view>
  162. </view>
  163. <view class="echarts">
  164. <view class="title">
  165. <view class="left">
  166. <text class="future">未来七天预定:<text class="num">0</text>
  167. <text class="yesterday">昨日全天:<text class="daynum">0</text></text>
  168. </text>
  169. </view>
  170. <view class="right">
  171. <view class="today-icon"></view><text class="title">今日</text>
  172. <view class="yesterday-icon"></view><text class="title">昨日</text>
  173. </view>
  174. </view>
  175. <view class="qiun-charts">
  176. <canvas canvas-id="canvasLineA" id="canvasLineA" class="charts" @touchstart="touchLineA"></canvas>
  177. </view>
  178. </view>
  179. </view>
  180. <!-- 商品销售占比 -->
  181. <view class="shop-echarts-warp">
  182. <view class="title">
  183. 商品销售占比
  184. </view>
  185. <view class="shop-echarts">
  186. <canvas canvas-id="shopecharts" id="shopecharts" class="shopecharts" @touchstart="touchPie"></canvas>
  187. </view>
  188. </view>
  189. <view id="testecharts"></view>
  190. <view class="" style="height: 40rpx;"></view>
  191. </view>
  192. </view>
  193. <!--页面加载动画-->
  194. <!-- <rf-loading v-if="loading"></rf-loading> -->
  195. </view>
  196. </template>
  197. <script>
  198. import uCharts from '../../js_sdk/u-charts/u-charts/u-charts';
  199. let _self;
  200. let canvaLineA = null;
  201. let canvaPie = null;
  202. export default {
  203. name: 'Header',
  204. data() {
  205. return {
  206. array: ['中国', '美国', '巴西', '日本'],
  207. index: 0,
  208. cWidth: '',
  209. cHeight: '',
  210. pixelRatio: 1, // 像素比
  211. // 饼图数据
  212. bWidth: '',
  213. bHeight: ''
  214. };
  215. },
  216. // 此处定义传入的数据
  217. props: {
  218. shoplist: {
  219. type: Object,
  220. value: null,
  221. },
  222. },
  223. // 页面生命周期 监听页面加载
  224. onLoad() {
  225. _self = this;
  226. this.cWidth = uni.upx2px(690); // upx2px 转换为px
  227. this.cHeight = uni.upx2px(300);
  228. this.bWidth = uni.upx2px(690);
  229. this.bHeight = uni.upx2px(300);
  230. this.getServerData();
  231. },
  232. methods: {
  233. bindPickerChange: function(e) {
  234. console.log('picker发送选择改变,携带值为', e.target.value);
  235. this.index = e.target.value;
  236. },
  237. getList() {
  238. console.log(1);
  239. },
  240. seting() {
  241. console.log('设置');
  242. },
  243. // 数据处理
  244. getServerData() {
  245. uni.request({
  246. url: 'https://www.ucharts.cn/data.json',
  247. data: {},
  248. success: function(res) {
  249. console.log(res);
  250. let LineA = {
  251. categories: [],
  252. series: [],
  253. };
  254. //这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
  255. LineA.categories = res.data.data.LineA.categories;
  256. LineA.series = res.data.data.LineA.series;
  257. _self.showLineA('canvasLineA', LineA);
  258. let pie = {
  259. series: [],
  260. };
  261. pie.series = res.data.data.Pie.series;
  262. _self.showPie('shopecharts', pie);
  263. },
  264. fail: () => {
  265. _self.tips = '网络错误,小程序端请检查合法域名';
  266. },
  267. });
  268. },
  269. // 图表
  270. showLineA(canvasId, chartData) {
  271. canvaLineA = new uCharts({
  272. $this: _self,
  273. canvasId: canvasId,
  274. type: 'line',
  275. fontSize: 12,
  276. legend: {
  277. show: false,
  278. },
  279. dataLabel: false, // 图表中是否显示数据
  280. duration: 500,
  281. dataPointShape: false, // 折点
  282. background: '#FFFFFF',
  283. pixelRatio: _self.pixelRatio,
  284. categories: chartData.categories, // x轴数据
  285. series: chartData.series, // 值
  286. animation: true,
  287. xAxis: {
  288. type: 'grid',
  289. disableGrid: true,
  290. },
  291. yAxis: {
  292. gridType: 'solid',
  293. gridColor: '#CCCCCC',
  294. min: 0,
  295. max: 180,
  296. format: (val) => {
  297. return val.toFixed(0) + '元';
  298. },
  299. },
  300. width: _self.cWidth * _self.pixelRatio,
  301. height: _self.cHeight * _self.pixelRatio,
  302. extra: {
  303. line: {
  304. type: 'curve', // 平滑曲线; straight直线
  305. },
  306. },
  307. });
  308. },
  309. touchLineA(e) {
  310. canvaLineA.showToolTip(e, {
  311. format: function(item, category) {
  312. return category + ' ' + item.name + ':' + item.data;
  313. },
  314. });
  315. },
  316. // 饼图
  317. showPie(canvasId, chartData) {
  318. canvaPie = new uCharts({
  319. $this: _self,
  320. canvasId: canvasId,
  321. type: 'pie',
  322. fontSize: 11,
  323. legend: {
  324. show: true,
  325. position: 'left',
  326. margin: 10,
  327. itemGap: 20,
  328. },
  329. background: '#FFFFFF',
  330. pixelRatio: _self.pixelRatio,
  331. series: chartData.series,
  332. animation: true,
  333. width: _self.cWidth * _self.pixelRatio,
  334. height: _self.cHeight * _self.pixelRatio,
  335. dataLabel: true,
  336. extra: {
  337. pie: {
  338. lableWidth: 15,
  339. },
  340. },
  341. });
  342. },
  343. touchPie(e) {
  344. canvaPie.showToolTip(e, {
  345. format: function(item) {
  346. return item.name + ':' + item.data;
  347. },
  348. });
  349. },
  350. },
  351. };
  352. </script>
  353. <style lang="scss" scoped>
  354. .header {
  355. width: 100%;
  356. padding: 0 30rpx;
  357. background-color: $barColor;
  358. position: fixed;
  359. top: 0;
  360. box-sizing: border-box;
  361. z-index: 99;
  362. .header-warp {
  363. display: flex;
  364. height: 80rpx;
  365. color: #231726;
  366. background-color: #ffcc01;
  367. .header-left {
  368. font-size: 28rpx;
  369. .uni-list-cell-db {
  370. height: 80rpx;
  371. font-size: 28rpx;
  372. display: flex;
  373. justify-content: center;
  374. align-items: center;
  375. background-color: $barColor;
  376. border-bottom: transparent;
  377. .icon {
  378. width: 17rpx;
  379. height: 12rpx;
  380. margin-left: 10rpx;
  381. }
  382. }
  383. }
  384. .header-center {
  385. flex: 1;
  386. font-size: 36rpx;
  387. font-weight: 700;
  388. text-align: center;
  389. line-height: 80rpx;
  390. }
  391. .header-right {
  392. display: flex;
  393. justify-content: center;
  394. align-items: center;
  395. .icon {
  396. width: 40rpx;
  397. height: 40rpx;
  398. }
  399. }
  400. }
  401. .user {
  402. padding: 30rpx;
  403. display: flex;
  404. justify-content: space-between;
  405. align-items: center;
  406. .user-left {
  407. display: flex;
  408. justify-content: center;
  409. align-items: center;
  410. .usericon {
  411. width: 100rpx;
  412. height: 100rpx;
  413. border-radius: 50%;
  414. background-color: #ffffff;
  415. }
  416. .message {
  417. margin-left: 32rpx;
  418. color: #2c1b0a;
  419. .name {
  420. font-size: 30rpx;
  421. font-weight: 700;
  422. }
  423. .tele {
  424. font-size: 24rpx;
  425. }
  426. }
  427. }
  428. .user-right {
  429. display: flex;
  430. justify-content: center;
  431. align-items: center;
  432. flex-direction: column;
  433. .sacnicon {
  434. width: 40rpx;
  435. height: 40rpx;
  436. }
  437. .txt {
  438. font-size: 24rpx;
  439. margin-top: 20rpx;
  440. }
  441. }
  442. }
  443. }
  444. .index {
  445. background-color: #fafafa;
  446. .index-content {
  447. padding: 0 30rpx;
  448. .exponent {
  449. margin-top: 20rpx;
  450. .title-warp {
  451. display: flex;
  452. justify-content: space-between;
  453. align-items: center;
  454. padding: 30rpx 0;
  455. .name {
  456. font-size: 32rpx;
  457. font-weight: 700;
  458. }
  459. .time {
  460. font-size: 24rpx;
  461. color: #191919;
  462. .hour {
  463. margin-left: 15rpx;
  464. }
  465. }
  466. }
  467. .exponent-list {
  468. display: flex;
  469. flex-wrap: wrap;
  470. .item {
  471. width: 320rpx;
  472. border-radius: 10rpx;
  473. color: #ffffff;
  474. display: flex;
  475. justify-content: space-between;
  476. align-items: center;
  477. padding: 25rpx;
  478. box-sizing: border-box;
  479. margin-bottom: 32rpx;
  480. &:nth-child(odd) {
  481. margin-right: 44rpx;
  482. }
  483. &:nth-child(3),
  484. &:nth-child(4) {
  485. margin-bottom: 0;
  486. }
  487. .left {
  488. .title {
  489. font-size: 24rpx;
  490. }
  491. .num {
  492. font-size: 36rpx;
  493. font-weight: 700;
  494. margin-top: 5rpx;
  495. }
  496. .ratio {
  497. margin-top: 10rpx;
  498. font-size: 20rpx;
  499. .detail {
  500. display: flex;
  501. justify-content: center;
  502. align-items: center;
  503. .icon {
  504. width: 12rpx;
  505. height: 16rpx;
  506. margin-right: 5rpx;
  507. }
  508. .compare {
  509. margin-left: 10rpx;
  510. font-size: 20rpx;
  511. }
  512. }
  513. }
  514. }
  515. .right {
  516. width: 90rpx;
  517. height: 90rpx;
  518. border-radius: 50%;
  519. background-color: rgba($color: #ffffff, $alpha: 0.2);
  520. display: flex;
  521. justify-content: center;
  522. align-items: center;
  523. .logoicon {
  524. width: 44rpx;
  525. height: 53rpx;
  526. }
  527. }
  528. }
  529. .seale {
  530. background-image: linear-gradient(to top right, #e379d0, #f767b1);
  531. }
  532. .order {
  533. background-image: linear-gradient(to top right, #f38867, #fca43d);
  534. }
  535. .todayseale {
  536. background-image: linear-gradient(to top right, #9859fd, #d98afa);
  537. }
  538. .todayorder {
  539. background-image: linear-gradient(to top right, #17c1b1, #40e98f);
  540. }
  541. }
  542. }
  543. .something {
  544. margin-top: 30rpx;
  545. .title {
  546. font-size: 32rpx;
  547. font-weight: 700;
  548. color: $titleColor;
  549. }
  550. .todo-list {
  551. display: flex;
  552. justify-content: center;
  553. align-items: center;
  554. margin-top: 30rpx;
  555. background-color: #ffffff;
  556. box-sizing: border-box;
  557. padding: 43rpx 30rpx;
  558. border-radius: 10rpx;
  559. .item {
  560. width: 33.33%;
  561. display: flex;
  562. justify-content: center;
  563. align-items: center;
  564. flex-direction: column;
  565. .title {
  566. color: $subheadColor;
  567. font-size: 30rpx;
  568. }
  569. .num {
  570. color: $titleColor;
  571. }
  572. }
  573. }
  574. }
  575. .data {
  576. margin-top: 40rpx;
  577. .echarts {
  578. background-color: #ffffff;
  579. border-radius: 10rpx;
  580. }
  581. .title {
  582. display: flex;
  583. justify-content: space-between;
  584. color: #333333;
  585. padding-top: 30rpx;
  586. padding-left: 15rpx;
  587. padding-bottom: 30rpx;
  588. box-sizing: border-box;
  589. .left {
  590. .future {
  591. font-size: 26rpx;
  592. .num {
  593. font-size: 30rpx;
  594. }
  595. .yesterday {
  596. margin-left: 10rpx;
  597. }
  598. }
  599. }
  600. .right {
  601. display: flex;
  602. justify-content: center;
  603. align-items: center;
  604. box-sizing: border-box;
  605. .today-icon {
  606. width: 20rpx;
  607. height: 9rpx;
  608. background-color: #ff9c2f;
  609. margin-right: 10rpx;
  610. }
  611. .title {
  612. font-size: 20rpx;
  613. margin-right: 20rpx;
  614. }
  615. .yesterday-icon {
  616. width: 20rpx;
  617. height: 9rpx;
  618. background-color: #b15cfa;
  619. margin-left: 10rpx;
  620. }
  621. .title {
  622. font-size: 20rpx;
  623. }
  624. }
  625. }
  626. .qiun-title-dot-light {
  627. color: $titleColor;
  628. font-size: 32rpx;
  629. font-weight: 700;
  630. padding-bottom: 25rpx;
  631. }
  632. /* 样式的width和height一定要与定义的cWidth和cHeight相对应 */
  633. .qiun-charts {
  634. width: 690rpx;
  635. height: 300rpx;
  636. }
  637. .charts {
  638. width: 690rpx;
  639. height: 300rpx;
  640. }
  641. }
  642. .shop-echarts-warp {
  643. background-color: #ffffff;
  644. border-radius: 10rpx;
  645. margin-top: 40rpx;
  646. .title {
  647. padding: 40rpx 24rpx 30rpx;
  648. font-size: 26rpx;
  649. color: $titleColor;
  650. }
  651. .shop-echarts {
  652. width: 690rpx;
  653. height: 300rpx;
  654. }
  655. .shopecharts {
  656. width: 690rpx;
  657. height: 300rpx;
  658. }
  659. }
  660. }
  661. }
  662. </style>