order.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <!-- 分销订单 -->
  2. <template>
  3. <s-layout title="分销订单" :class="state.scrollTop ? 'order-warp' : ''" navbar="inner">
  4. <view class="header-box" :style="[
  5. {
  6. marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
  7. paddingTop: Number(statusBarHeight + 108) + 'rpx',
  8. },
  9. ]">
  10. <!-- 团队数据总览 -->
  11. <view class="team-data-box ss-flex ss-col-center ss-row-between" style="width:100%">
  12. <view class="data-card" style="width:100%">
  13. <view class="total-item" style="width:100%">
  14. <view class="item-title" style='text-align: center;'>累计推广订单(单)</view>
  15. <view class="total-num" style='text-align: center;'>
  16. {{ state.totals||state.pagination.total|| 0 }}
  17. </view>
  18. </view>
  19. <!-- <view class="category-item ss-flex">
  20. <view class="ss-flex-1">
  21. <view class="item-title">一级订单</view>
  22. <view class="category-num">
  23. {{ state.agentInfo.child_order_count_1 || 0 }}
  24. </view>
  25. </view>
  26. <view class="ss-flex-1">
  27. <view class="item-title">二级订单</view>
  28. <view class="category-num">
  29. {{ state.agentInfo.child_order_count_2 || 0 }}
  30. </view>
  31. </view>
  32. </view> -->
  33. </view>
  34. <!-- <view class="data-card">
  35. <view class="total-item">
  36. <view class="item-title">团队订单金额(元)</view>
  37. <view class="total-num">
  38. {{ state.agentInfo.child_order_money_all || '0.00' }}
  39. </view>
  40. </view>
  41. <view class="category-item ss-flex">
  42. <view class="ss-flex-1">
  43. <view class="item-title">一级订单</view>
  44. <view class="category-num">
  45. {{ state.agentInfo.child_order_money_1 || '0.00' }}
  46. </view>
  47. </view>
  48. <view class="ss-flex-1">
  49. <view class="item-title">二级订单</view>
  50. <view class="category-num">
  51. {{ state.agentInfo.child_order_money_2 || '0.00' }}
  52. </view>
  53. </view>
  54. </view>
  55. </view> -->
  56. </view>
  57. <!-- 自购 -->
  58. <!-- <view class="direct-box ss-flex ss-row-between">
  59. <view class="direct-item">
  60. <view class="item-title">自购分销订单数量(单)</view>
  61. <view class="item-value">
  62. {{ state.agentInfo.child_order_count_0 || 0 }}
  63. </view>
  64. </view>
  65. <view class="direct-item">
  66. <view class="item-title">自购分销订单金额(元)</view>
  67. <view class="item-value">
  68. {{ state.agentInfo.child_order_money_0 || '0.00' }}
  69. </view>
  70. </view>
  71. </view> -->
  72. </view>
  73. <!-- tab -->
  74. <su-sticky bgColor="#fff">
  75. <su-tabs :list="tabMaps" :scrollable="false" :current="state.currentTab" @change="onTabsChange">
  76. </su-tabs>
  77. </su-sticky>
  78. <!-- 订单 -->
  79. <view class="order-box">
  80. <view class="order-item" v-for="item in state.pagination.data" :key="item">
  81. <view class="order-header">
  82. <view class="no-box ss-flex ss-col-center ss-row-between">
  83. <text class="order-code">订单编号:{{ item.order.order_sn }}</text>
  84. <text class="order-state">{{ item.order_item.status_text }}</text>
  85. </view>
  86. <view class="order-from ss-flex ss-col-center ss-row-between">
  87. <view class="from-user ss-flex ss-col-center">
  88. <text>下单人:</text>
  89. <image class="user-avatar" :src="sheep.$url.cdn(item.buyer.avatar)" mode="aspectFill">
  90. </image>
  91. <text class="user-name">{{ item.buyer.nickname }}</text>
  92. </view>
  93. <view class="order-time">{{ item.create_time }}</view>
  94. </view>
  95. </view>
  96. <s-goods-item class="border-bottom" :img="item.order_item.goods_image"
  97. :title="item.order_item.goods_title" :skuText="item.order_item.goods_sku_text"
  98. :price="item.order_item.goods_price" :num="item.order_item.goods_num">
  99. <template #rightBottom>
  100. <view class="ss-flex commission-box ss-row-between ss-m-t-10">
  101. <view class="ss-flex">
  102. <text class="name">佣金:</text>
  103. <text class="commission-num">{{ item.rewards[0]?.commission }}</text>
  104. </view>
  105. <view class="order-status">
  106. {{ item.commission_order_status_text }}
  107. </view>
  108. </view>
  109. </template>
  110. </s-goods-item>
  111. </view>
  112. <!-- 数据为空 -->
  113. <s-empty v-if="state.pagination.total === 0" icon="/static/order-empty.png" text="暂无订单">
  114. </s-empty>
  115. <!-- 加载更多 -->
  116. <uni-load-more v-if="state.pagination.total > 0" :status="state.loadStatus" :content-text="{
  117. contentdown: '上拉加载更多',
  118. }" @tap="loadmore" />
  119. </view>
  120. <!-- </view> -->
  121. </s-layout>
  122. </template>
  123. <script setup>
  124. import sheep from '@/sheep';
  125. import {
  126. onLoad,
  127. onReachBottom
  128. } from '@dcloudio/uni-app';
  129. import {
  130. computed,
  131. reactive,
  132. } from 'vue';
  133. import _ from 'lodash';
  134. import {
  135. onPageScroll
  136. } from '@dcloudio/uni-app';
  137. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  138. const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
  139. onPageScroll((e) => {
  140. if (e.scrollTop > 100) {
  141. state.scrollTop = false;
  142. } else {
  143. state.scrollTop = true;
  144. }
  145. });
  146. const state = reactive({
  147. totals: 0,
  148. pagination: {
  149. data: [],
  150. current_page: 1,
  151. total: '',
  152. last_page: 1,
  153. },
  154. loadStatus: '',
  155. currentTab: 0,
  156. agentInfo: {},
  157. scrollTop: false,
  158. });
  159. const tabMaps = [{
  160. name: '全部',
  161. value: 'all',
  162. },
  163. // {
  164. // name: '不计入',
  165. // value: 'no'
  166. // },
  167. {
  168. name: '待结算',
  169. value: 'yes',
  170. },
  171. {
  172. name: '已结算',
  173. value: 'back',
  174. },
  175. // {
  176. // name: '已取消',
  177. // value: 'cancel',
  178. // },
  179. ];
  180. // 切换选项卡
  181. function onTabsChange(e) {
  182. state.pagination = {
  183. data: [],
  184. current_page: 1,
  185. total: 0,
  186. last_page: 1,
  187. };
  188. state.currentTab = e.index;
  189. getOrderList();
  190. }
  191. // 获取订单列表
  192. async function getOrderList(page = 1, list_rows = 5) {
  193. // todo @芋艿:没有测试数据,还需对接请求参数,和返回的数据字段
  194. state.loadStatus = 'loading';
  195. let res = await sheep.$api.commission.order({
  196. // type: tabMaps[state.currentTab].value,
  197. pageSize: list_rows,
  198. pageNo: page,
  199. // status
  200. // bizType
  201. });
  202. if (res.code === 0) {
  203. let orderList = _.concat(state.pagination.data, res.data.list);
  204. state.pagination = {
  205. ...res.data,
  206. data: orderList,
  207. };
  208. state.totals = res.data.total;
  209. console.log(state)
  210. if (state.pagination.data.length < state.totals) {
  211. state.loadStatus = 'more';
  212. } else {
  213. state.loadStatus = 'noMore';
  214. }
  215. }
  216. }
  217. async function getAgentInfo() {
  218. const {
  219. error,
  220. data,
  221. msg
  222. } = await sheep.$api.commission.agent();
  223. if (error === 0) {
  224. state.agentInfo = data;
  225. }
  226. }
  227. onLoad(() => {
  228. // getAgentInfo();
  229. getOrderList();
  230. });
  231. // 加载更多
  232. function loadmore() {
  233. if (state.loadStatus !== 'noMore') {
  234. getOrderList(state.pagination.current_page + 1);
  235. }
  236. }
  237. // 上拉加载更多
  238. onReachBottom(() => {
  239. loadmore();
  240. });
  241. </script>
  242. <style lang="scss" scoped>
  243. .header-box {
  244. box-sizing: border-box;
  245. padding: 0 20rpx 20rpx 20rpx;
  246. width: 750rpx;
  247. background: v-bind(headerBg) no-repeat,
  248. linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  249. background-size: 750rpx 100%;
  250. // 团队信息总览
  251. .team-data-box {
  252. .data-card {
  253. width: 305rpx;
  254. background: #ffffff;
  255. border-radius: 20rpx;
  256. padding: 20rpx;
  257. .total-item {
  258. margin-bottom: 30rpx;
  259. .item-title {
  260. font-size: 24rpx;
  261. font-weight: 500;
  262. color: #999999;
  263. line-height: normal;
  264. margin-bottom: 20rpx;
  265. }
  266. .total-num {
  267. font-size: 38rpx;
  268. font-weight: 500;
  269. color: #333333;
  270. font-family: OPPOSANS;
  271. }
  272. }
  273. .category-num {
  274. font-size: 26rpx;
  275. font-weight: 500;
  276. color: #333333;
  277. font-family: OPPOSANS;
  278. }
  279. }
  280. }
  281. // 直推
  282. .direct-box {
  283. margin-top: 20rpx;
  284. .direct-item {
  285. width: 340rpx;
  286. background: #ffffff;
  287. border-radius: 20rpx;
  288. padding: 20rpx;
  289. box-sizing: border-box;
  290. .item-title {
  291. font-size: 22rpx;
  292. font-weight: 500;
  293. color: #999999;
  294. margin-bottom: 6rpx;
  295. }
  296. .item-value {
  297. font-size: 38rpx;
  298. font-weight: 500;
  299. color: #333333;
  300. font-family: OPPOSANS;
  301. }
  302. }
  303. }
  304. }
  305. // 订单
  306. .order-box {
  307. .order-item {
  308. background: #ffffff;
  309. border-radius: 10rpx;
  310. margin: 20rpx;
  311. .order-footer {
  312. padding: 20rpx;
  313. font-size: 24rpx;
  314. color: #999;
  315. }
  316. .order-header {
  317. .no-box {
  318. padding: 20rpx;
  319. .order-code {
  320. font-size: 26rpx;
  321. font-weight: 500;
  322. color: #333333;
  323. }
  324. .order-state {
  325. font-size: 26rpx;
  326. font-weight: 500;
  327. color: var(--ui-BG-Main);
  328. }
  329. }
  330. .order-from {
  331. padding: 20rpx;
  332. .from-user {
  333. font-size: 24rpx;
  334. font-weight: 400;
  335. color: #666666;
  336. .user-avatar {
  337. width: 26rpx;
  338. height: 26rpx;
  339. border-radius: 50%;
  340. margin-right: 8rpx;
  341. }
  342. .user-name {
  343. font-size: 24rpx;
  344. font-weight: 400;
  345. color: #999999;
  346. }
  347. }
  348. .order-time {
  349. font-size: 24rpx;
  350. font-weight: 400;
  351. color: #999999;
  352. }
  353. }
  354. }
  355. .commission-box {
  356. .name {
  357. font-size: 24rpx;
  358. font-weight: 400;
  359. color: #999999;
  360. }
  361. }
  362. .commission-num {
  363. font-size: 30rpx;
  364. font-weight: 500;
  365. color: $red;
  366. font-family: OPPOSANS;
  367. &::before {
  368. content: '¥';
  369. font-size: 22rpx;
  370. }
  371. }
  372. .order-status {
  373. line-height: 30rpx;
  374. padding: 0 10rpx;
  375. border-radius: 30rpx;
  376. margin-left: 20rpx;
  377. font-size: 24rpx;
  378. color: var(--ui-BG-Main);
  379. }
  380. }
  381. }
  382. </style>