order.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. <template>
  2. <view class="content">
  3. <!-- <view class="navbar coupon">
  4. <view class="nav-item grenn" v-if="tabCurrentIndex == 0">
  5. 一级总业绩:
  6. <text>{{ one_price }}</text>
  7. </view>
  8. <view class="nav-item black" v-if="tabCurrentIndex == 1">
  9. 二级总业绩:
  10. <text>{{ two_price }}</text>
  11. </view>
  12. </view> -->
  13. <!-- <view class="navbar">
  14. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}:{{item.number}}人</view>
  15. </view> -->
  16. <view class="order">
  17. <view class="mony"><text style="font-size: 36rpx;">¥</text>{{ total_pay_price || '0' }}</view>
  18. <view class="total">总金额</view>
  19. <view class="top-box">
  20. <view class="box">
  21. <view class="box-1">订单总数</view>
  22. <view class="box-2">{{ nums || '0' }}</view>
  23. </view>
  24. <view class="box">
  25. <view class="box-1">下级订单数</view>
  26. <view class="box-2">{{one_num || '0'}}</view>
  27. </view>
  28. <!-- <view class="box">
  29. <view class="box-1">二级订单数</view>
  30. <view class="box-2">{{two_num || '0'}}</view>
  31. </view> -->
  32. </view>
  33. <view class="top-box">
  34. <view class="box">
  35. <view class="box-1">返佣总额</view>
  36. <view class="box-2"><text class="sym">¥</text>{{return_num || '0'}}</view>
  37. </view>
  38. <view class="box">
  39. <view class="box-1">下级总金额</view>
  40. <view class="box-2"><text class="sym">¥</text>{{one_price || '0'}}</view>
  41. </view>
  42. <!-- <view class="box">
  43. <view class="box-1">二级总金额</view>
  44. <view class="box-2"><text class="sym">¥</text>{{two_price || '0'}}</view>
  45. </view> -->
  46. </view>
  47. </view>
  48. <!-- 下拉框 -->
  49. <view class="down-box flex">
  50. <!-- <picker @change="timeChange" style="flex: 1;" :range="timelist">
  51. <view class="check">
  52. {{timelist[timevalue] || '时间'}}
  53. <view class="triangle"></view>
  54. </view>
  55. </picker> -->
  56. <view class="date-box">
  57. <view class="date-frame">
  58. <view class="date-list">
  59. <view class="date-list-cell">
  60. <view class="date-list-cell-db">
  61. <picker mode="date" :value="startDate" start="2001-01" fields="month" @change="bindDateChange1">
  62. <view class="uni-input">{{startDate}}</view>
  63. </picker>
  64. </view>
  65. </view>
  66. </view>
  67. --
  68. <view class="date-list">
  69. <view class="date-list-cell">
  70. <view class="date-list-cell-db">
  71. <picker mode="date" :value="endDate" start="2001-01" fields="month" @change="bindDateChange2">
  72. <view class="uni-input">{{endDate}}</view>
  73. </picker>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <picker @change="typeChange" style="flex: 1;" :range="typelist">
  80. <view class="check">
  81. {{typelist[typevalue] || '订单类型'}}
  82. <view class="triangle"></view>
  83. </view>
  84. </picker>
  85. </view>
  86. <swiper :style="{ height: maxheight + 'px' }" class="swiper-box">
  87. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  88. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  89. <!-- 空白页 -->
  90. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  91. <!-- 订单列表 -->
  92. <view v-for="(item, index) in tabItem.orderList" :key="index" class="order-item">
  93. <view class="order-tpl">
  94. <view class="time">{{ item.time }}</view>
  95. <view class="count">本月累计推广订单:{{ item.count }}单</view>
  96. </view>
  97. <view v-for="ls in item.child" class="title-list">
  98. <view class="title-box">
  99. <view class="flex">
  100. <view class="order_id">订单编号:{{ ls.order_id }}</view>
  101. <!-- 0:待发货;1:待收货;2:已收货;3:待评价 -->
  102. <!-- {{ ls.status == 0 ? '待付款' : ls.status == 1 ? '待发货' : ls.status == 2 ? '待收货' : ls.status == 3 ? '待评价' : ls.status == 4 ? '已完成' :'退款' }} -->
  103. <view class="status" v-if="ls.refund_status == 0">
  104. <view v-if="ls.paid == 1">{{ls.status == 0 ? '待发货' : ls.status == 1 ? '待收货' : ls.status == 2 ? '已收货' : '待评价'}}</view>
  105. <view v-else>未支付</view>
  106. </view>
  107. <view class="status" v-else>{{ls.refund_status == 1 ? '退款中' :'退款成功'}}</view>
  108. </view>
  109. <view class="flex_item order-list">
  110. <view class="title-avatar">
  111. <image :src="ls.avatar"></image>
  112. </view>
  113. <view class="order-info">
  114. <view class="flex">
  115. <view class="nickname">{{ ls.nickname }}</view>
  116. <view class="number">
  117. 返佣:
  118. <text>{{ ls.number }}</text>
  119. </view>
  120. </view>
  121. <view class="flex">
  122. <view>{{ ls.time }}</view>
  123. <view>订单金额:{{ ls.pay_price }}</view>
  124. </view>
  125. </view>
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  131. </scroll-view>
  132. </swiper-item>
  133. </swiper>
  134. </view>
  135. </template>
  136. <script>
  137. import { order, orderCount } from '@/api/team.js';
  138. import { mapState, mapMutations } from 'vuex';
  139. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  140. import empty from '@/components/empty';
  141. import { getTime } from '@/utils/rocessor.js';
  142. // 获取当前时间的秒数
  143. const time = Math.floor(new Date().getTime() / 1000);
  144. export default {
  145. components: {
  146. empty,
  147. uniLoadMore
  148. },
  149. filters: {
  150. lastTime: function(value) {
  151. const day = Math.floor((time - value) / 60 / 60 / 24);
  152. return day == 0 ? '今天登陆' : day + '天前登陆';
  153. }
  154. },
  155. onReady() {
  156. // 初始化获取页面宽度
  157. uni.createSelectorQuery()
  158. .select('.content')
  159. .fields({
  160. size: true
  161. },
  162. data => {
  163. console.log(data);
  164. // 保存头部高度
  165. this.maxheight = data.height - Math.floor((data.width / 750) * 480);
  166. console.log(this.maxheight);
  167. }
  168. )
  169. .exec();
  170. },
  171. data() {
  172. return {
  173. // 头部图高度
  174. maxheight: '',
  175. tabCurrentIndex: 0,
  176. navList: [{
  177. state: 0,
  178. text: '一级',
  179. loadingType: 'more',
  180. orderList: [],
  181. number: 0,
  182. page: 1, //当前页数
  183. limit: 10 //每次信息条数
  184. }],
  185. all: '',
  186. list: '',
  187. total: '',
  188. totalLevel: '',
  189. img: 'http://kaifa.crmeb.net/uploads/attach/2019/08/20190807/723adbdd4e49a0f9394dfc700ab5dba3.png',
  190. total_pay_price: '', // 总金额
  191. one_price: '', // 一级总金额
  192. two_price: '', // 二级总金额
  193. one_num: '', // 一级订单总数
  194. two_num: '', // 二级订单总数
  195. nums: '', // 订单总数
  196. return_num: '', // 返佣总额
  197. timelist: ['全部', '今天', '昨天', '最近7天', '最近30天', '本月', '本年'],
  198. typelist: ['全部', '下级订单'],
  199. timevalue: '',
  200. typevalue: '',
  201. type: '', // 订单类型
  202. dateDay: [], // 传的时间参数
  203. startDate: '开始时间',
  204. endDate: '结束时间',
  205. start: '',
  206. end: '',
  207. val1: '',
  208. val2: '',
  209. timedata: '',
  210. };
  211. },
  212. onLoad(options) {
  213. this.loadData();
  214. // 推广订单数据
  215. orderCount({}).then(({data}) => {
  216. // 总金额
  217. this.total_pay_price = data[0].count;
  218. // 订单总数
  219. this.nums = data[1].count;
  220. // 返佣总金额
  221. this.return_num = data[2].count;
  222. // 一级总金额
  223. this.one_price = data[3].count;
  224. // 一级订单数
  225. this.one_num = data[4].count;
  226. // 二级总金额
  227. this.two_price = data[5].count;
  228. // 二级订单数
  229. this.two_num = data[6].count;
  230. })
  231. },
  232. onShow() {
  233. },
  234. methods: {
  235. //选择开始时间
  236. bindDateChange1: function(e) {
  237. console.log(11)
  238. let obj = this;
  239. let val = e.detail.value;
  240. obj.val1 = e.detail.value;
  241. // var reg = /-/g;
  242. obj.startDate = e.detail.value;
  243. console.log(obj.startDate,965)
  244. var formatDate1 = new Date(obj.val1);
  245. var formatDate2 = new Date(obj.timedata);
  246. console.log(obj.val1, obj.timedata, '开始时间不得大于现在时间');
  247. console.log(formatDate1, formatDate2, '开始时间不得大于现在时间');
  248. if (formatDate1 > formatDate2) {
  249. console.log(11);
  250. uni.showToast({
  251. title: '开始时间不得大于现在时间',
  252. duration: 2000,
  253. position: 'top',
  254. icon: 'none'
  255. });
  256. } else {
  257. console.log(22);
  258. }
  259. },
  260. //选择结束时间
  261. bindDateChange2: function(e) {
  262. console.log(11)
  263. let obj = this;
  264. if (obj.val1 == '') {
  265. uni.showToast({
  266. title: '请先选择开始时间',
  267. duration: 2000,
  268. position: 'top',
  269. icon: 'none'
  270. });
  271. } else {
  272. let val = e.detail.value;
  273. obj.val2 = e.detail.value;
  274. // var reg = /-/g;
  275. // obj.endDate = val.replace(reg, '\/');
  276. obj.endDate = e.detail.value
  277. console.log(obj.endDate, 22);
  278. var formatDate1 = new Date(obj.val1);
  279. var formatDate2 = new Date(obj.timedata);
  280. var formatDate3 = new Date(obj.val2);
  281. console.log(obj.val1, obj.val2, obj.timedata, '123');
  282. console.log(formatDate1, formatDate3, formatDate2, '456');
  283. let arr = []
  284. arr[0] = this.startDate;
  285. arr[1] = this.endDate;
  286. this.dateDay = arr.join(';')
  287. console.log(this.dateDay,664853)
  288. if (formatDate1 > formatDate2) {
  289. uni.showToast({
  290. title: '开始时间不得大于现在时间',
  291. duration: 2000,
  292. position: 'top',
  293. icon: 'none'
  294. });
  295. } else {
  296. if (formatDate3 < formatDate1) {
  297. // console.log(111)
  298. uni.showToast({
  299. title: '结束时间要大于开始时间',
  300. duration: 2000,
  301. position: 'top',
  302. icon: 'none'
  303. });
  304. }
  305. if (formatDate3 > formatDate2) {
  306. uni.showToast({
  307. title: '结束时间不得大于现在时间',
  308. duration: 2000,
  309. position: 'top',
  310. icon: 'none'
  311. });
  312. } else {
  313. let index = this.tabCurrentIndex;
  314. let navItem = this.navList[index];
  315. navItem.orderList = [];
  316. navItem.loadingType = 'more'
  317. this.loadData()
  318. }
  319. }
  320. }
  321. },
  322. //获取日期
  323. getDate() {
  324. let date = new Date();
  325. let dateYear = date.getFullYear(); //获取年
  326. let dateMonth = date.getMonth() + 1; //获取月
  327. let dateDate = date.getDate(); //获取当日
  328. this.timedata = dateYear + '-' + dateMonth + '-' + dateDate;
  329. },
  330. //类型选择
  331. typeChange(e) {
  332. // console.log(e)
  333. this.typevalue = e.detail.value;
  334. this.type = e.detail.value;
  335. if (this.type == 0) {
  336. this.type = ''
  337. }
  338. let index = this.tabCurrentIndex;
  339. let navItem = this.navList[index];
  340. navItem.orderList = [];
  341. navItem.loadingType = 'more'
  342. this.loadData()
  343. },
  344. // 页面跳转
  345. navto(e) {
  346. uni.navigateTo({
  347. url: e
  348. });
  349. },
  350. //获取收入支出信息
  351. async loadData(source) {
  352. let obj = this;
  353. //这里是将订单挂载到tab列表下
  354. let index = this.tabCurrentIndex;
  355. let navItem = this.navList[index];
  356. let state = navItem.state;
  357. // if (source === 'tabChange' && navItem.loaded === true) {
  358. // //tab切换只有第一次需要加载数据
  359. // return;
  360. // }
  361. // if (navItem.loadingType === 'loading') {
  362. // //防止重复加载
  363. // return;
  364. // }
  365. if (navItem.loadingType === 'noMore') {
  366. //防止重复加载
  367. return;
  368. }
  369. // 修改当前对象状态为加载中
  370. // navItem.loadingType = 'loading';
  371. order({
  372. date: obj.dateDay,
  373. orderType: obj.type,
  374. })
  375. .then(({
  376. data
  377. }) => {
  378. // let arr = data.list.map(e => {
  379. // e.lastTimeString = getTime(e.lastTime);
  380. // return e;
  381. // });
  382. let arr = data.list;
  383. navItem.orderList = navItem.orderList.concat(data.list);
  384. console.log(navItem.orderList, 'navItem.orderList');
  385. navItem.loadingType = 'noMore';
  386. // if (navItem.limit == data.length) {
  387. // //判断是否还有数据, 有改为 more, 没有改为noMore
  388. // navItem.loadingType = 'more';
  389. // return;
  390. // } else {
  391. // //判断是否还有数据, 有改为 more, 没有改为noMore
  392. // navItem.loadingType = 'noMore';
  393. // }
  394. // this.$set(navItem, 'loaded', true);
  395. })
  396. .catch(e => {
  397. console.log(e);
  398. });
  399. },
  400. //swiper 切换
  401. changeTab(e) {
  402. this.tabCurrentIndex = e.target.current;
  403. this.loadData('tabChange');
  404. },
  405. //顶部tab点击
  406. tabClick(index) {
  407. this.tabCurrentIndex = index;
  408. }
  409. }
  410. };
  411. </script>
  412. <style lang="scss">
  413. page {
  414. background: #f8f8f8;
  415. height: 100%;
  416. }
  417. .content-money {
  418. padding-bottom: 30rpx;
  419. background: $page-color-base;
  420. .buttom-box {
  421. background-color: #ffffff;
  422. text-align: center;
  423. margin: 0 30rpx;
  424. padding: 30rpx 0;
  425. border-radius: $border-radius-sm;
  426. margin-top: -60rpx;
  427. .buttom {
  428. font-size: $font-lg;
  429. flex-grow: 1;
  430. .money {
  431. font-weight: bold;
  432. font-size: 32rpx;
  433. color: #db1935;
  434. }
  435. }
  436. .text {
  437. color: #666666;
  438. }
  439. .interval {
  440. width: 2rpx;
  441. height: 60rpx;
  442. background-color: #eeeeee;
  443. }
  444. .icon {
  445. height: 50rpx;
  446. width: 48rpx;
  447. margin: 0 auto;
  448. .icon-img {
  449. width: 100%;
  450. height: 100%;
  451. }
  452. }
  453. }
  454. }
  455. .money-box {
  456. background: #bc253a;
  457. height: 320rpx;
  458. color: #ffffff;
  459. text-align: center;
  460. font-size: 35rpx;
  461. padding-top: 60rpx;
  462. .money_img {
  463. width: 100%;
  464. height: 120rpx;
  465. text-align: center;
  466. padding-top: 50rpx;
  467. padding-bottom: 135rpx;
  468. image {
  469. width: 120rpx;
  470. height: 120rpx;
  471. border: 4rpx solid #fd5f6f;
  472. border-radius: 50%;
  473. }
  474. }
  475. .money_name {
  476. width: 100%;
  477. text-align: center;
  478. font-size: 40rpx;
  479. padding-bottom: 25rpx;
  480. }
  481. }
  482. .navbar {
  483. display: flex;
  484. height: 40px;
  485. padding: 0 5px;
  486. background: #fff;
  487. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  488. position: relative;
  489. z-index: 10;
  490. .nav-item {
  491. flex: 1;
  492. display: flex;
  493. justify-content: center;
  494. align-items: center;
  495. height: 100%;
  496. font-size: 15px;
  497. color: $font-color-dark;
  498. position: relative;
  499. &.current {
  500. color: $font-color;
  501. background-color: #dcdfe6;
  502. // color: #FC2A3F;
  503. // &:after {
  504. // content: '';
  505. // position: absolute;
  506. // left: 50%;
  507. // bottom: 0;
  508. // transform: translateX(-50%);
  509. // width: 44px;
  510. // height: 0;
  511. // border-bottom: 2px solid #FC2A3F;
  512. // }
  513. }
  514. }
  515. .grenn {
  516. background: #2fbd5b;
  517. }
  518. .black {
  519. background: #434343;
  520. }
  521. .grenn,
  522. .black {
  523. color: #ffffff;
  524. text-align: left;
  525. }
  526. }
  527. // 列表
  528. .order {
  529. background-color: $base-color;
  530. text-align: center;
  531. padding: 48rpx 25rpx;
  532. height: 400rpx;
  533. color: #ffffff;
  534. .mony {
  535. font-size: 45rpx;
  536. font-weight: bold;
  537. // margin-bottom: 20rpx;
  538. line-height: 1;
  539. }
  540. .total {
  541. font-size: 30rpx;
  542. font-weight: 500;
  543. }
  544. .top-box {
  545. display: flex;
  546. justify-content: space-around;
  547. margin-top: 28rpx;
  548. .box {
  549. width: 25%;
  550. .box-1 {
  551. font-size: 30rpx;
  552. margin-bottom: 10rpx;
  553. font-weight: 500;
  554. }
  555. .box-2 {
  556. font-size: 36rpx;
  557. font-weight: bold;
  558. line-height: 1;
  559. }
  560. }
  561. }
  562. .sym {
  563. font-size: 30rpx;
  564. }
  565. }
  566. .down-box {
  567. width: 750rpx;
  568. height: 80rpx;
  569. background-color: #FFFFFF;
  570. .date-box {
  571. flex: 1;
  572. font-size: 28rpx;
  573. font-weight: 500;
  574. color: rgba(51, 51, 51, 1);
  575. .date-frame {
  576. display: flex;
  577. align-items: center;
  578. justify-content: space-evenly;
  579. }
  580. }
  581. .check {
  582. flex: 1;
  583. display: flex;
  584. justify-content: center;
  585. align-items: center;
  586. font-size: 28rpx;
  587. font-weight: 500;
  588. color: rgba(51, 51, 51, 1);
  589. .triangle {
  590. margin-left: 10rpx;
  591. width: 0;
  592. height: 0;
  593. border-style: solid;
  594. border-width: 10rpx;
  595. margin-top: 14rpx;
  596. border-color: #333333 transparent transparent transparent;
  597. }
  598. }
  599. }
  600. .swiper-box {
  601. font-size: 28rpx;
  602. .order-item {
  603. line-height: 1.5;
  604. .order-tpl {
  605. padding: 25rpx 0rpx;
  606. padding-bottom: 15rpx !important;
  607. .count {
  608. color: #999999;
  609. }
  610. }
  611. .title-list {
  612. background-color: #ffffff;
  613. width: 100%;
  614. padding: 20rpx 30rpx;
  615. margin-top: 15rpx;
  616. .title-box {
  617. .order_id {
  618. color: #999999;
  619. padding-bottom: 15rpx;
  620. }
  621. .status {
  622. color: #F9273F;
  623. }
  624. .order-list {
  625. .title-avatar {
  626. width: 100rpx;
  627. height: 100rpx;
  628. margin-right: 25rpx;
  629. image {
  630. width: 100%;
  631. height: 100%;
  632. border-radius: 100%;
  633. }
  634. }
  635. .order-info {
  636. color: #999999;
  637. width: 80%;
  638. padding-left: 25rpx;
  639. .nickname {
  640. font-size: 32rpx;
  641. color: #333333;
  642. padding-bottom: 15rpx;
  643. width: 50%;
  644. }
  645. .number {
  646. text {
  647. color: #fa2740;
  648. }
  649. }
  650. }
  651. }
  652. }
  653. }
  654. .money {
  655. color: #db1935;
  656. font-size: $font-lg;
  657. }
  658. }
  659. }
  660. .list-scroll-content {
  661. height: 100%;
  662. padding: 0rpx 25rpx;
  663. }
  664. .content {
  665. height: 100%;
  666. .empty-content {
  667. background-color: #ffffff;
  668. }
  669. }
  670. </style>