order.vue 11 KB

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