order.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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 #bottom>
  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. onPageScroll((e) => {
  149. if (e.scrollTop > 100) {
  150. state.scrollTop = false;
  151. } else {
  152. state.scrollTop = true;
  153. }
  154. });
  155. const state = reactive({
  156. pagination: {
  157. data: [],
  158. current_page: 1,
  159. total: 1,
  160. last_page: 1,
  161. },
  162. loadStatus: '',
  163. currentTab: 0,
  164. agentInfo: {},
  165. scrollTop: false,
  166. });
  167. const tabMaps = [
  168. {
  169. name: '全部',
  170. value: 'all',
  171. },
  172. // {
  173. // name: '不计入',
  174. // value: 'no'
  175. // },
  176. {
  177. name: '已计入',
  178. value: 'yes',
  179. },
  180. {
  181. name: '已扣除',
  182. value: 'back',
  183. },
  184. {
  185. name: '已取消',
  186. value: 'cancel',
  187. },
  188. ];
  189. // 切换选项卡
  190. function onTabsChange(e) {
  191. state.pagination = {
  192. data: [],
  193. current_page: 1,
  194. total: 1,
  195. last_page: 1,
  196. };
  197. state.currentTab = e.index;
  198. getOrderList();
  199. }
  200. // 获取订单列表
  201. async function getOrderList(page = 1, list_rows = 5) {
  202. state.loadStatus = 'loading';
  203. let res = await sheep.$api.commission.order({
  204. type: tabMaps[state.currentTab].value,
  205. list_rows,
  206. page,
  207. });
  208. if (res.error === 0) {
  209. let orderList = _.concat(state.pagination.data, res.data.data);
  210. state.pagination = {
  211. ...res.data,
  212. data: orderList,
  213. };
  214. if (state.pagination.current_page < state.pagination.last_page) {
  215. state.loadStatus = 'more';
  216. } else {
  217. state.loadStatus = 'noMore';
  218. }
  219. }
  220. }
  221. async function getAgentInfo() {
  222. const { error, data, msg } = 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("sheep.$url.css('/static/img/shop/user/withdraw_bg.png')") 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>