order.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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">
  12. <view class="data-card">
  13. <view class="total-item">
  14. <view class="item-title">团队订单数量(单)</view>
  15. <view class="total-num">
  16. {{ state.agentInfo.child_order_count_all || 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. pagination: {
  148. data: [],
  149. current_page: 1,
  150. total: 1,
  151. last_page: 1,
  152. },
  153. loadStatus: '',
  154. currentTab: 0,
  155. agentInfo: {},
  156. scrollTop: false,
  157. });
  158. const tabMaps = [{
  159. name: '全部',
  160. value: 'all',
  161. },
  162. // {
  163. // name: '不计入',
  164. // value: 'no'
  165. // },
  166. {
  167. name: '已计入',
  168. value: 'yes',
  169. },
  170. {
  171. name: '已扣除',
  172. value: 'back',
  173. },
  174. {
  175. name: '已取消',
  176. value: 'cancel',
  177. },
  178. ];
  179. // 切换选项卡
  180. function onTabsChange(e) {
  181. state.pagination = {
  182. data: [],
  183. current_page: 1,
  184. total: 1,
  185. last_page: 1,
  186. };
  187. state.currentTab = e.index;
  188. getOrderList();
  189. }
  190. // 获取订单列表
  191. async function getOrderList(page = 1, list_rows = 5) {
  192. state.loadStatus = 'loading';
  193. let res = await sheep.$api.commission.order({
  194. type: tabMaps[state.currentTab].value,
  195. list_rows,
  196. page,
  197. });
  198. if (res.error === 0) {
  199. let orderList = _.concat(state.pagination.data, res.data.data);
  200. state.pagination = {
  201. ...res.data,
  202. data: orderList,
  203. };
  204. if (state.pagination.current_page < state.pagination.last_page) {
  205. state.loadStatus = 'more';
  206. } else {
  207. state.loadStatus = 'noMore';
  208. }
  209. }
  210. }
  211. async function getAgentInfo() {
  212. const {
  213. error,
  214. data,
  215. msg
  216. } = await sheep.$api.commission.agent();
  217. if (error === 0) {
  218. state.agentInfo = data;
  219. }
  220. }
  221. onLoad(() => {
  222. getAgentInfo();
  223. getOrderList();
  224. });
  225. // 加载更多
  226. function loadmore() {
  227. if (state.loadStatus !== 'noMore') {
  228. getOrderList(state.pagination.current_page + 1);
  229. }
  230. }
  231. // 上拉加载更多
  232. onReachBottom(() => {
  233. loadmore();
  234. });
  235. </script>
  236. <style lang="scss" scoped>
  237. .header-box {
  238. box-sizing: border-box;
  239. padding: 0 20rpx 20rpx 20rpx;
  240. width: 750rpx;
  241. background: v-bind(headerBg) no-repeat,
  242. linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  243. background-size: 750rpx 100%;
  244. // 团队信息总览
  245. .team-data-box {
  246. .data-card {
  247. width: 305rpx;
  248. background: #ffffff;
  249. border-radius: 20rpx;
  250. padding: 20rpx;
  251. .total-item {
  252. margin-bottom: 30rpx;
  253. .item-title {
  254. font-size: 24rpx;
  255. font-weight: 500;
  256. color: #999999;
  257. line-height: normal;
  258. margin-bottom: 20rpx;
  259. }
  260. .total-num {
  261. font-size: 38rpx;
  262. font-weight: 500;
  263. color: #333333;
  264. font-family: OPPOSANS;
  265. }
  266. }
  267. .category-num {
  268. font-size: 26rpx;
  269. font-weight: 500;
  270. color: #333333;
  271. font-family: OPPOSANS;
  272. }
  273. }
  274. }
  275. // 直推
  276. .direct-box {
  277. margin-top: 20rpx;
  278. .direct-item {
  279. width: 340rpx;
  280. background: #ffffff;
  281. border-radius: 20rpx;
  282. padding: 20rpx;
  283. box-sizing: border-box;
  284. .item-title {
  285. font-size: 22rpx;
  286. font-weight: 500;
  287. color: #999999;
  288. margin-bottom: 6rpx;
  289. }
  290. .item-value {
  291. font-size: 38rpx;
  292. font-weight: 500;
  293. color: #333333;
  294. font-family: OPPOSANS;
  295. }
  296. }
  297. }
  298. }
  299. // 订单
  300. .order-box {
  301. .order-item {
  302. background: #ffffff;
  303. border-radius: 10rpx;
  304. margin: 20rpx;
  305. .order-footer {
  306. padding: 20rpx;
  307. font-size: 24rpx;
  308. color: #999;
  309. }
  310. .order-header {
  311. .no-box {
  312. padding: 20rpx;
  313. .order-code {
  314. font-size: 26rpx;
  315. font-weight: 500;
  316. color: #333333;
  317. }
  318. .order-state {
  319. font-size: 26rpx;
  320. font-weight: 500;
  321. color: var(--ui-BG-Main);
  322. }
  323. }
  324. .order-from {
  325. padding: 20rpx;
  326. .from-user {
  327. font-size: 24rpx;
  328. font-weight: 400;
  329. color: #666666;
  330. .user-avatar {
  331. width: 26rpx;
  332. height: 26rpx;
  333. border-radius: 50%;
  334. margin-right: 8rpx;
  335. }
  336. .user-name {
  337. font-size: 24rpx;
  338. font-weight: 400;
  339. color: #999999;
  340. }
  341. }
  342. .order-time {
  343. font-size: 24rpx;
  344. font-weight: 400;
  345. color: #999999;
  346. }
  347. }
  348. }
  349. .commission-box {
  350. .name {
  351. font-size: 24rpx;
  352. font-weight: 400;
  353. color: #999999;
  354. }
  355. }
  356. .commission-num {
  357. font-size: 30rpx;
  358. font-weight: 500;
  359. color: $red;
  360. font-family: OPPOSANS;
  361. &::before {
  362. content: '¥';
  363. font-size: 22rpx;
  364. }
  365. }
  366. .order-status {
  367. line-height: 30rpx;
  368. padding: 0 10rpx;
  369. border-radius: 30rpx;
  370. margin-left: 20rpx;
  371. font-size: 24rpx;
  372. color: var(--ui-BG-Main);
  373. }
  374. }
  375. }
  376. </style>