order.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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" style="width: 100%">
  15. <view class="data-card" style="width: 100%">
  16. <view class="total-item" style="width: 100%">
  17. <view class="item-title" style="text-align: center">累计推广订单(单)</view>
  18. <view class="total-num" style="text-align: center">
  19. {{ state.totals }}
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- tab -->
  26. <su-sticky bgColor="#fff">
  27. <su-tabs
  28. :list="tabMaps"
  29. :scrollable="false"
  30. :current="state.currentTab"
  31. @change="onTabsChange"
  32. >
  33. </su-tabs>
  34. </su-sticky>
  35. <!-- 订单 -->
  36. <view class="order-box">
  37. <view class="order-item" v-for="item in state.pagination.list" :key="item">
  38. <view class="order-header">
  39. <view class="no-box ss-flex ss-col-center ss-row-between">
  40. <text class="order-code">订单编号:{{ item.bizId }}</text>
  41. <text class="order-state">
  42. {{ item.status === 0 ? '待结算' : item.status === 1 ? '已结算' : '已取消' }}
  43. ( 佣金 {{ fen2yuan(item.price) }} 元 )
  44. </text>
  45. </view>
  46. <view class="order-from ss-flex ss-col-center ss-row-between">
  47. <view class="from-user ss-flex ss-col-center">
  48. <text>{{ item.title }}</text>
  49. </view>
  50. <view class="order-time">
  51. {{ sheep.$helper.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss') }}
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <!-- 数据为空 -->
  57. <s-empty v-if="state.pagination.total === 0" icon="/static/order-empty.png" text="暂无订单" />
  58. <!-- 加载更多 -->
  59. <uni-load-more
  60. v-if="state.pagination.total > 0"
  61. :status="state.loadStatus"
  62. :content-text="{
  63. contentdown: '上拉加载更多',
  64. }"
  65. @tap="loadMore"
  66. />
  67. </view>
  68. </s-layout>
  69. </template>
  70. <script setup>
  71. import sheep from '@/sheep';
  72. import { onLoad, onPageScroll, onReachBottom } from '@dcloudio/uni-app';
  73. import { reactive } from 'vue';
  74. import _ from 'lodash-es';
  75. import { resetPagination } from '@/sheep/util';
  76. import BrokerageApi from '@/sheep/api/trade/brokerage';
  77. import { fen2yuan } from '../../sheep/hooks/useGoods';
  78. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  79. const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
  80. onPageScroll((e) => {
  81. state.scrollTop = e.scrollTop <= 100;
  82. });
  83. const state = reactive({
  84. totals: 0, // 累计推广订单(单)
  85. scrollTop: false,
  86. currentTab: 0,
  87. loadStatus: '',
  88. pagination: {
  89. list: [],
  90. total: 0,
  91. pageNo: 1,
  92. pageSize: 8,
  93. },
  94. });
  95. const tabMaps = [
  96. {
  97. name: '全部',
  98. value: -1,
  99. },
  100. {
  101. name: '待结算',
  102. value: 0, // 待结算
  103. },
  104. {
  105. name: '已结算',
  106. value: 1, // 已结算
  107. },
  108. ];
  109. // 切换选项卡
  110. function onTabsChange(e) {
  111. resetPagination(state.pagination);
  112. state.currentTab = e.index;
  113. getOrderList();
  114. }
  115. // 获取订单列表
  116. async function getOrderList() {
  117. state.loadStatus = 'loading';
  118. const tab = tabMaps[state.currentTab];
  119. const queryParams = {
  120. pageSize: state.pagination.pageSize,
  121. pageNo: state.pagination.pageNo,
  122. bizType: 1, // 获得推广佣金
  123. status: tab.value,
  124. }
  125. if (tab.value < 0) {
  126. delete queryParams.status;
  127. }
  128. const { code, data } = await BrokerageApi.getBrokerageRecordPage(queryParams);
  129. if (code !== 0) {
  130. return;
  131. }
  132. state.pagination.list = _.concat(state.pagination.list, data.list);
  133. state.pagination.total = data.total;
  134. state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
  135. if (state.currentTab === 0) {
  136. state.totals = data.total;
  137. }
  138. }
  139. onLoad(() => {
  140. getOrderList();
  141. });
  142. // 加载更多
  143. function loadMore() {
  144. if (state.loadStatus === 'noMore') {
  145. return;
  146. }
  147. state.pagination.pageNo++;
  148. getOrderList();
  149. }
  150. // 上拉加载更多
  151. onReachBottom(() => {
  152. loadMore();
  153. });
  154. </script>
  155. <style lang="scss" scoped>
  156. .header-box {
  157. box-sizing: border-box;
  158. padding: 0 20rpx 20rpx 20rpx;
  159. width: 750rpx;
  160. background: v-bind(headerBg) no-repeat,
  161. linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  162. background-size: 750rpx 100%;
  163. // 团队信息总览
  164. .team-data-box {
  165. .data-card {
  166. width: 305rpx;
  167. background: #ffffff;
  168. border-radius: 20rpx;
  169. padding: 20rpx;
  170. .total-item {
  171. margin-bottom: 30rpx;
  172. .item-title {
  173. font-size: 24rpx;
  174. font-weight: 500;
  175. color: #999999;
  176. line-height: normal;
  177. margin-bottom: 20rpx;
  178. }
  179. .total-num {
  180. font-size: 38rpx;
  181. font-weight: 500;
  182. color: #333333;
  183. font-family: OPPOSANS;
  184. }
  185. }
  186. .category-num {
  187. font-size: 26rpx;
  188. font-weight: 500;
  189. color: #333333;
  190. font-family: OPPOSANS;
  191. }
  192. }
  193. }
  194. // 直推
  195. .direct-box {
  196. margin-top: 20rpx;
  197. .direct-item {
  198. width: 340rpx;
  199. background: #ffffff;
  200. border-radius: 20rpx;
  201. padding: 20rpx;
  202. box-sizing: border-box;
  203. .item-title {
  204. font-size: 22rpx;
  205. font-weight: 500;
  206. color: #999999;
  207. margin-bottom: 6rpx;
  208. }
  209. .item-value {
  210. font-size: 38rpx;
  211. font-weight: 500;
  212. color: #333333;
  213. font-family: OPPOSANS;
  214. }
  215. }
  216. }
  217. }
  218. // 订单
  219. .order-box {
  220. .order-item {
  221. background: #ffffff;
  222. border-radius: 10rpx;
  223. margin: 20rpx;
  224. .order-footer {
  225. padding: 20rpx;
  226. font-size: 24rpx;
  227. color: #999;
  228. }
  229. .order-header {
  230. .no-box {
  231. padding: 20rpx;
  232. .order-code {
  233. font-size: 26rpx;
  234. font-weight: 500;
  235. color: #333333;
  236. }
  237. .order-state {
  238. font-size: 26rpx;
  239. font-weight: 500;
  240. color: var(--ui-BG-Main);
  241. }
  242. }
  243. .order-from {
  244. padding: 20rpx;
  245. .from-user {
  246. font-size: 24rpx;
  247. font-weight: 400;
  248. color: #666666;
  249. .user-avatar {
  250. width: 26rpx;
  251. height: 26rpx;
  252. border-radius: 50%;
  253. margin-right: 8rpx;
  254. }
  255. .user-name {
  256. font-size: 24rpx;
  257. font-weight: 400;
  258. color: #999999;
  259. }
  260. }
  261. .order-time {
  262. font-size: 24rpx;
  263. font-weight: 400;
  264. color: #999999;
  265. }
  266. }
  267. }
  268. .commission-box {
  269. .name {
  270. font-size: 24rpx;
  271. font-weight: 400;
  272. color: #999999;
  273. }
  274. }
  275. .commission-num {
  276. font-size: 30rpx;
  277. font-weight: 500;
  278. color: $red;
  279. font-family: OPPOSANS;
  280. &::before {
  281. content: '¥';
  282. font-size: 22rpx;
  283. }
  284. }
  285. .order-status {
  286. line-height: 30rpx;
  287. padding: 0 10rpx;
  288. border-radius: 30rpx;
  289. margin-left: 20rpx;
  290. font-size: 24rpx;
  291. color: var(--ui-BG-Main);
  292. }
  293. }
  294. }
  295. </style>