index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <div id="agent_income_container">
  3. <!-- 筛选模块-->
  4. <div class="filter_container margin-xs flex">
  5. <view class='cu-tag round padding' v-for="(filter,index) in filter_list" :key="index"
  6. :class="{'bg-orange':filter_action==filter.id,'bg-white':filter_action != filter.id}"
  7. @click="change_filter(filter.id)"
  8. >
  9. {{ filter.name }}
  10. </view>
  11. <button class="cu-btn" @click="show_datetime_picker">自定义时间
  12. <text class="cuIcon-unfold"></text>
  13. </button>
  14. </div>
  15. <!-- 全部累计订单模块-->
  16. <div class="profit_container text-center">
  17. <view>
  18. <text class="text-normal margin-xl">
  19. <template v-if="filter_date">{{ filter_date }}</template>
  20. <template v-else>{{ filter_list[filter_action - 1].name }}</template>
  21. 累计订单
  22. </text>
  23. </view>
  24. <view>
  25. <text class="text-bold text-sl text-price">{{ userinfo.order_counts }}</text>
  26. </view>
  27. </div>
  28. <!-- 小title-->
  29. <div class="line_container padding">
  30. <div>
  31. <text class="text-sm text-gray">订单记录</text>
  32. <van-divider customStyle="border:.1px solid;margin:0px;"/>
  33. </div>
  34. </div>
  35. <!-- 列表-->
  36. <view class="solid-bottom padding-lr-sm" v-for="(item,index) in order_list" :key="index">
  37. <van-card>
  38. <view slot="thumb" class="cu-avatar lg round margin-left"
  39. style="background-image:url(https://img.shuimuai.com/web/icon_dingdan.png);"></view>
  40. <view slot="title" class="flex justify-between">
  41. <view>
  42. <text class="text-normal">消费产品 &emsp;</text>
  43. <text>{{ item.goods_name }}</text>
  44. </view>
  45. <view>
  46. <text class="text-normal text-sm under_line" @click="to_detail(item.sn)">订单详情</text>
  47. </view>
  48. </view>
  49. <view slot="num" class="flex justify-between align-end">
  50. <view>
  51. <view>
  52. <text class="text-sm text-normal">买家&emsp;</text>
  53. <text class="text-sm text-normal">{{ item.user_name }}</text>
  54. </view>
  55. <text class="text-gray text-sm">{{ item.create_time }}</text>
  56. </view>
  57. <view>
  58. <text class="text-normal text-sm margin-right">订单总价</text>
  59. <text class="text-xxl">{{ item.price }}</text>
  60. </view>
  61. </view>
  62. </van-card>
  63. </view>
  64. <van-calendar
  65. :show="calendar_show"
  66. type="range"
  67. @close="do_calendar_close"
  68. @confirm="do_calendar_confirm"
  69. ></van-calendar>
  70. </div>
  71. </template>
  72. <script>
  73. import {agentOrderList} from "../../../../requests/agent";
  74. import util from '@/utils/index'
  75. var $this
  76. export default {
  77. name: "agent_income_container",
  78. components: {},
  79. data() {
  80. return {
  81. filter_list: [
  82. {
  83. id: 1,
  84. name: "全部"
  85. },
  86. {
  87. id: 2,
  88. name: "今日",
  89. start_time: Math.round(new Date(new Date(new Date().toLocaleDateString()).getTime()).getTime() / 1000),
  90. end_time: Math.round(new Date(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1).getTime() / 1000)
  91. },
  92. {
  93. id: 3,
  94. name: "昨日",
  95. start_time: Math.round(new Date(new Date(new Date().toLocaleDateString()).getTime() - 24 * 60 * 60 * 1000).getTime() / 1000),
  96. end_time: Math.round(new Date(new Date(new Date().toLocaleDateString()).getTime() - 1000).getTime() / 1000)
  97. },
  98. {
  99. id: 4,
  100. name: "近七日",
  101. start_time: Math.round(new Date(new Date(new Date().toLocaleDateString()).getTime() - 7 * 24 * 60 * 60 * 1000).getTime() / 1000),
  102. end_time: Math.round(new Date(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1).getTime() / 1000)
  103. }
  104. ],
  105. filter_action: 1,
  106. order_counts: 0,
  107. order_list: [],
  108. calendar_show: false,
  109. start_time: "",
  110. end_time: "",
  111. filter_date: "",
  112. //最小日期应该为用户使用的第一个月开始
  113. min_date: false,
  114. }
  115. },
  116. methods: {
  117. //修改筛选时间
  118. change_filter($id) {
  119. $this.filter_date = ""
  120. $this.filter_action = $id
  121. $this.filter_date.forEach(($val, $index) => {
  122. if ($val['id'] == $id) {
  123. $this.get_order_list($val['start_time'], $val['end_time'])
  124. }
  125. })
  126. },
  127. // 自定义筛选时间
  128. show_datetime_picker() {
  129. $this.filter_action = 0
  130. $this.calendar_show = true
  131. },
  132. // 关闭日历选择
  133. do_calendar_close() {
  134. $this.calendar_show = false
  135. },
  136. formatDate(date) {
  137. date = new Date(date);
  138. return `${date.getMonth() + 1}/${date.getDate()}`;
  139. },
  140. // 选择日历后
  141. do_calendar_confirm($event) {
  142. let [start, end] = $event.mp.detail;
  143. $this.filter_date = $this.formatDate(start) + '-' + $this.formatDate(end)
  144. $this.start_time = Math.round(new Date(start).getTime() / 1000)
  145. $this.end_time = Math.round(new Date(end).getTime() / 1000)
  146. $this.get_order_list($this.start_time, $this.end_time)
  147. $this.calendar_show = false
  148. },
  149. // 跳转订单详情
  150. to_detail($id) {
  151. mpvue.navigateTo({
  152. url: "/pages/agent/extend/detail/main?sn=" + $id
  153. })
  154. },
  155. //获取订单列表
  156. get_order_list($start_time, $end_time) {
  157. let $params = {}
  158. if ($start_time && $end_time) {
  159. $params['start_time'] = $start_time
  160. $params['end_time'] = $end_time
  161. }
  162. agentOrderList($params).then((res) => {
  163. let $data = res.data
  164. let $result = $data.data;
  165. $this.order_counts = $result.count;
  166. let $list = $result.list;
  167. $list.forEach(($val, $index) => {
  168. $list[$index]['create_time'] = util.formatTime($val['create_time'])
  169. })
  170. $this.order_list = $list
  171. })
  172. }
  173. },
  174. mounted() {
  175. $this.min_date = new Date(2020, 1, 1).getTime()
  176. },
  177. created() {
  178. $this = this
  179. }
  180. }
  181. </script>
  182. <style scoped>
  183. @import "index.css";
  184. </style>