Forráskód Böngészése

✨ 分销:相关逻辑接入 100%

YunaiV 1 éve
szülő
commit
74b450ec3c

+ 12 - 12
pages.json

@@ -309,18 +309,6 @@
 						"group": "用户中心"
 					}
 				},
-				{
-					"path": "wallet/commission",
-					"style": {
-						"navigationBarTitleText": "我的佣金"
-					},
-					"meta": {
-						"auth": true,
-						"sync": true,
-						"title": "用户佣金",
-						"group": "分销中心"
-					}
-				},
 				{
 					"path": "wallet/score",
 					"style": {
@@ -349,6 +337,18 @@
 						"group": "分销商城"
 					}
 				},
+                {
+                  "path": "wallet",
+                  "style": {
+                    "navigationBarTitleText": "我的佣金"
+                  },
+                  "meta": {
+                    "auth": true,
+                    "sync": true,
+                    "title": "用户佣金",
+                    "group": "分销中心"
+                  }
+                },
 				{
 					"path": "goods",
 					"style": {

+ 0 - 290
pages/commission/apply.vue

@@ -1,290 +0,0 @@
-<!-- 申请分销商  -->
-<template>
-  <s-layout title="申请分销商" class="apply-wrap" navbar="inner">
-    <s-empty
-      v-if="state.error === 1"
-      paddingTop="0"
-      icon="/static/comment-empty.png"
-      text="未开启分销商申请"
-    ></s-empty>
-
-    <view v-if="state.error === 0" class="distribution-apply-wrap">
-      <view class="apply-header">
-        <view class="header-box ss-flex">
-          <image
-            class="bg-img"
-            :src="sheep.$url.cdn(state.background)"
-            mode="widthFix"
-            @load="onImgLoad"
-          ></image>
-          <view class="heaer-title">申请分销商</view>
-        </view>
-      </view>
-      <view class="apply-box bg-white" :style="{ marginTop: state.imgHeight + 'rpx' }">
-        <uni-forms
-          label-width="200"
-          :model="state.model"
-          :rules="state.rules"
-          border
-          class="form-box"
-        >
-          <view class="item-box">
-            <uni-forms-item
-              v-for="(item, index) in state.formList"
-              :key="index"
-              :label="item.name"
-              :required="true"
-              :label-position="item.type == 'image' ? 'top' : 'left'"
-            >
-              <uni-easyinput
-                v-if="item.type !== 'image'"
-                :inputBorder="false"
-                :type="item.type"
-                :styles="{ disableColor: '#fff' }"
-                placeholderStyle="color:#BBBBBB;font-size:28rpx;line-height:normal"
-                v-model="item.value"
-                :placeholder="`请填写${item.name}`"
-              />
-              <s-uploader
-                v-if="item.type === 'image'"
-                v-model:url="item.value"
-                fileMediatype="image"
-                limit="1"
-                mode="grid"
-                :imageStyles="{ width: '168rpx', height: '168rpx' }"
-                class="file-picker"
-              />
-            </uni-forms-item>
-          </view>
-        </uni-forms>
-        <label class="ss-flex ss-m-t-20" v-if="state.protocol?.status == 1" @tap="onChange">
-          <radio
-            :checked="state.isAgree"
-            color="var(--ui-BG-Main)"
-            style="transform: scale(0.6)"
-            @tap.stop="onChange"
-          />
-          <view class="agreement-text ss-flex">
-            <view class="ss-m-r-4">勾选代表同意</view>
-            <view
-              class="tcp-text"
-              @tap.stop="
-                sheep.$router.go('/pages/public/richtext', {
-                  id: state.protocol.id,
-                  title: state.protocol.title,
-                })
-              "
-            >
-              《{{ state.protocol.title }}》
-            </view>
-          </view>
-        </label>
-        <su-fixed bottom placeholder>
-          <view class="submit-box ss-flex ss-row-center ss-p-30">
-            <button class="submit-btn ss-reset-button ui-BG-Main ui-Shadow-Main" @tap="submit">
-              {{ submitText }}
-            </button>
-          </view>
-        </su-fixed>
-      </view>
-    </view>
-  </s-layout>
-</template>
-
-<script setup>
-  import sheep from '@/sheep';
-  import { onLoad } from '@dcloudio/uni-app';
-  import { computed, reactive } from 'vue';
-  import { isEmpty } from 'lodash';
-
-  const state = reactive({
-    error: -1,
-    status: '-',
-    config: {},
-    isAgree: false,
-    formList: [],
-    protocol: {},
-    applyInfo: [],
-    background: '',
-    imgHeight: 400,
-  });
-  const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
-
-  //勾选协议
-  function onChange() {
-    state.isAgree = !state.isAgree;
-  }
-
-  const submitText = computed(() => {
-    if (state.status === 'normal') return '修改信息';
-    if (state.status === 'needinfo') return '提交审核';
-    if (state.status === 'reject') return '重新提交';
-    return '';
-  });
-
-  async function getAgentForm() {
-    const { error, data } = await sheep.$api.commission.form();
-    state.error = error;
-    if (error === 0) {
-      state.status = data.status;
-      state.background = data.background;
-      state.formList = data.form;
-      state.applyInfo = data.applyInfo;
-      state.protocol = data.protocol;
-
-      if (data.protocol.status != 1) {
-        state.isAgree = true;
-      }
-      mergeFormList();
-    }
-  }
-  function onImgLoad(e) {
-    state.imgHeight = (e.detail.height / e.detail.width) * 750 - 88 - statusBarHeight;
-  }
-
-  async function submit() {
-    if (!state.isAgree) {
-      sheep.$helper.toast('请同意申请协议');
-      return;
-    }
-
-    const validate = state.formList.every((item) => {
-      if (isEmpty(item.value)) {
-        if (item.type !== 'image') {
-          sheep.$helper.toast(`请填写${item.name}`);
-        } else {
-          sheep.$helper.toast(`请上传${item.name}`);
-        }
-        return false;
-      }
-      return true;
-    });
-
-    if (!validate) {
-      return;
-    }
-
-    const { error } = await sheep.$api.commission.apply({
-      data: state.formList,
-    });
-    if (error === 0) {
-      sheep.$router.back();
-    }
-  }
-
-  onLoad(() => {
-    getAgentForm();
-  });
-
-  // 初始化formData
-  function mergeFormList() {
-    state.formList.forEach((form) => {
-      const apply = state.applyInfo.find(
-        (info) => info.type === form.type && info.name === form.name,
-      );
-      if (typeof apply !== 'undefined') form.value = apply.value;
-    });
-  }
-</script>
-
-<style lang="scss" scoped>
-  :deep() {
-    .uni-forms-item__label .label-text {
-      font-size: 28rpx !important;
-      color: #333333 !important;
-      line-height: normal !important;
-    }
-
-    .file-picker__progress {
-      height: 0 !important;
-    }
-
-    .uni-list-item__content-title {
-      font-size: 28rpx !important;
-      color: #333333 !important;
-      line-height: normal !important;
-    }
-
-    .uni-icons {
-      font-size: 40rpx !important;
-    }
-
-    .is-disabled {
-      color: #333333;
-    }
-  }
-
-  .distribution-apply-wrap {
-    // height: 100vh;
-    // width: 100vw;
-    // position: absolute;
-    // left: 0;
-    // top: 0;
-    // background-color: #fff;
-    // overflow-y: auto;
-
-    .submit-btn {
-      width: 690px;
-      height: 86rpx;
-      border-radius: 43rpx;
-    }
-    .apply-header {
-      position: absolute;
-      left: 0;
-      top: 0;
-    }
-    .header-box {
-      width: 100%;
-      position: relative;
-      .bg-img {
-        width: 750rpx;
-      }
-
-      .heaer-title {
-        position: absolute;
-        left: 30rpx;
-        top: 50%;
-        transform: translateY(-50%);
-        font-size: 50rpx;
-        font-weight: bold;
-        color: #ffffff;
-        z-index: 11;
-
-        &::before {
-          content: '';
-          width: 51rpx;
-          height: 8rpx;
-          background: #ffffff;
-          border-radius: 4rpx;
-          position: absolute;
-          z-index: 12;
-          bottom: -20rpx;
-        }
-      }
-    }
-
-    .apply-box {
-      padding: 0 40rpx;
-
-      .item-box {
-        border-bottom: 2rpx solid #eee;
-      }
-    }
-  }
-
-  .agreement-text {
-    font-size: 24rpx;
-    color: #c4c4c4;
-    line-height: normal;
-
-    .tcp-text {
-      color: var(--ui-BG-Main);
-    }
-  }
-
-  .card-image {
-    width: 140rpx;
-    height: 140rpx;
-    border-radius: 50%;
-  }
-</style>

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 151 - 147
pages/commission/commission-ranking.vue


+ 0 - 11
pages/commission/components/commission-info.vue

@@ -9,16 +9,6 @@
 				</view>
 				<view class="ss-flex-col">
 					<view class="user-name">{{ userInfo.nickname }}</view>
-					<view class="user-info-box ss-flex">
-						<view class="tag-box ss-flex" v-if="agentInfo.level_info">
-							<image v-if="agentInfo.level_info?.image" class="tag-img"
-								:src="sheep.$url.cdn(agentInfo.level_info?.image)" mode="aspectFill">
-							</image>
-							<text class="tag-title">{{ agentInfo.level_info?.name }}</text>
-						</view>
-						<view class="ss-iconfont uicon-arrow-right" style="color: #fff; font-size: 28rpx">
-						</view>
-					</view>
 				</view>
 			</view>
 		</view>
@@ -30,7 +20,6 @@
 	import { computed, reactive } from 'vue';
 
 	const userInfo = computed(() => sheep.$store('user').userInfo);
-	const agentInfo = computed(() => sheep.$store('user').agentInfo);
 	const headerBg = sheep.$url.css('/static/img/shop/commission/background.png');
 
 	const state = reactive({

+ 1 - 1
pages/commission/components/commission-menu.vue

@@ -31,7 +31,7 @@
 			{
 				img: '/static/img/shop/commission/commission_icon2.png',
 				title: '佣金明细',
-				path: '/pages/user/wallet/commission',
+				path: '/pages/commission/wallet',
 			},
 			{
 				img: '/static/img/shop/commission/commission_icon3.png',

+ 136 - 109
pages/commission/goods.vue

@@ -1,123 +1,150 @@
-<!-- 页面  -->
+<!-- 分销商品列表  -->
 <template>
-	<s-layout title="推广商品" :onShareAppMessage="state.shareInfo">
-		<view class="goods-item ss-m-20" v-for="item in state.pagination.data" :key="item.id">
-			<s-goods-item size="lg" :img="item.picUrl" :title="item.name" :subTitle="item.subtitle" :price="item.price"
-				:originPrice="item.original_price" priceColor="#333"
-				@tap="sheep.$router.go('/pages/goods/index', { id: item.id })">
-				<template #rightBottom>
-					<view class="ss-flex ss-row-between">
-						<view class="commission-num">预计佣金:¥{{ item.commission }}</view>
-						<button class="ss-reset-button share-btn ui-BG-Main-Gradient" @tap.stop="onShareGoods(item)">
-							分享赚
-						</button>
-					</view>
-				</template>
-			</s-goods-item>
-		</view>
-		<s-empty v-if="state.pagination.total === 0" icon="/static/goods-empty.png" text="暂无推广商品"></s-empty>
-		<!-- 加载更多 -->
-		<uni-load-more v-if="state.pagination.total > 0" :status="state.loadStatus" :content-text="{
+  <s-layout title="推广商品" :onShareAppMessage="state.shareInfo">
+    <view class="goods-item ss-m-20" v-for="item in state.pagination.list" :key="item.id">
+      <s-goods-item
+        size="lg"
+        :img="item.picUrl"
+        :title="item.name"
+        :subTitle="item.introduction"
+        :price="item.price"
+        :originPrice="item.marketPrice"
+        priceColor="#333"
+        @tap="sheep.$router.go('/pages/goods/index', { id: item.id })"
+      >
+        <template #rightBottom>
+          <view class="ss-flex ss-row-between">
+            <view class="commission-num" v-if="item.brokerageMinPrice === undefined">预计佣金:计算中</view>
+            <view class="commission-num" v-else-if="item.brokerageMinPrice === item.brokerageMaxPrice">
+              预计佣金:{{ fen2yuan(item.brokerageMinPrice) }}
+            </view>
+            <view class="commission-num" v-else>
+              预计佣金:{{ fen2yuan(item.brokerageMinPrice) }} ~ {{ fen2yuan(item.brokerageMaxPrice) }}
+            </view>
+            <button
+              class="ss-reset-button share-btn ui-BG-Main-Gradient"
+              @tap.stop="onShareGoods(item)"
+            >
+              分享赚
+            </button>
+          </view>
+        </template>
+      </s-goods-item>
+    </view>
+    <s-empty
+      v-if="state.pagination.total === 0"
+      icon="/static/goods-empty.png"
+      text="暂无推广商品"
+    />
+    <!-- 加载更多 -->
+    <uni-load-more
+      v-if="state.pagination.total > 0"
+      :status="state.loadStatus"
+      :content-text="{
         contentdown: '上拉加载更多',
-      }" @tap="loadmore" />
-	</s-layout>
+      }"
+      @tap="loadMore"
+    />
+  </s-layout>
 </template>
 
 <script setup>
-	import sheep from '@/sheep';
-	import $share from '@/sheep/platform/share';
-	import {
-		onLoad,
-		onReachBottom
-	} from '@dcloudio/uni-app';
-	import {
-		computed,
-		reactive
-	} from 'vue';
-	import _ from 'lodash';
-	import {
-		showShareModal
-	} from '@/sheep/hooks/useModal';
+  import sheep from '@/sheep';
+  import $share from '@/sheep/platform/share';
+  import { onLoad, onReachBottom } from '@dcloudio/uni-app';
+  import { reactive } from 'vue';
+  import _ from 'lodash';
+  import { showShareModal } from '@/sheep/hooks/useModal';
+  import SpuApi from '@/sheep/api/product/spu';
+  import BrokerageApi from '@/sheep/api/trade/brokerage';
+  import { fen2yuan } from '../../sheep/hooks/useGoods';
 
-	const state = reactive({
-		pagination: {
-			data: [],
-			current_page: 1,
-			total: 1,
-			last_page: 1,
-		},
-		loadStatus: '',
-		shareInfo: {},
-	});
+  const state = reactive({
+    pagination: {
+      list: [],
+      total: 0,
+      pageNo: 1,
+      pageSize: 1,
+    },
+    loadStatus: '',
+    shareInfo: {},
+  });
 
-	function onShareGoods(goodsInfo) {
-		state.shareInfo = $share.getShareInfo({
-			title: goodsInfo.title,
-			image: sheep.$url.cdn(goodsInfo.image),
-			desc: goodsInfo.subtitle,
-			params: {
-				page: '2',
-				query: goodsInfo.id,
-			},
-		}, {
-			type: 'goods', // 商品海报
-			title: goodsInfo.title, // 商品标题
-			image: sheep.$url.cdn(goodsInfo.image), // 商品主图
-			price: goodsInfo.price[0], // 商品价格
-			original_price: goodsInfo.original_price, // 商品原价
-		}, );
-		showShareModal();
-	}
-	async function getGoodsList(page = 1, list_rows = 8) {
-		state.pagination.current_page = page;
-		state.loadStatus = 'loading';
-		let res = await sheep.$api.commission.goods({
-			pageSize: list_rows,
-			pageNo: page,
-		});
-		if (res.code === 0) {
-			let orderList = _.concat(state.pagination.data, res.data.list);
-			state.pagination = {
-				...res.data,
-				data: orderList,
-			};
-			if (state.pagination.data.length < state.pagination.total) {
-				state.loadStatus = 'more';
-			} else {
-				state.loadStatus = 'noMore';
-			}
-		}
-	}
+  // TODO 芋艿:分享的接入
+  function onShareGoods(goodsInfo) {
+    state.shareInfo = $share.getShareInfo(
+      {
+        title: goodsInfo.title,
+        image: sheep.$url.cdn(goodsInfo.image),
+        desc: goodsInfo.subtitle,
+        params: {
+          page: '2',
+          query: goodsInfo.id,
+        },
+      },
+      {
+        type: 'goods', // 商品海报
+        title: goodsInfo.title, // 商品标题
+        image: sheep.$url.cdn(goodsInfo.image), // 商品主图
+        price: goodsInfo.price[0], // 商品价格
+        original_price: goodsInfo.original_price, // 商品原价
+      },
+    );
+    showShareModal();
+  }
 
-	onLoad(async () => {
-		getGoodsList();
-	});
+  async function getGoodsList() {
+    state.loadStatus = 'loading';
+    let { code, data } = await SpuApi.getSpuPage({
+      pageSize: state.pagination.pageSize,
+      pageNo: state.pagination.pageNo,
+    });
+    if (code !== 0) {
+      return;
+    }
+    state.pagination.list = _.concat(state.pagination.list, data.list);
+    state.pagination.total = data.total;
+    state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
+    // 补充分佣金额
+    data.list.forEach((item) => {
+      BrokerageApi.getProductBrokeragePrice(item.id).then((res) => {
+        item.brokerageMinPrice = res.data.brokerageMinPrice;
+        item.brokerageMaxPrice = res.data.brokerageMaxPrice;
+      });
+    });
+  }
 
-	// 加载更多
-	function loadmore() {
-		if (state.loadStatus !== 'noMore') {
-			getGoodsList(state.pagination.current_page + 1);
-		}
-	}
+  onLoad(() => {
+    getGoodsList();
+  });
 
-	// 上拉加载更多
-	onReachBottom(() => {
-		loadmore();
-	});
+  // 加载更多
+  function loadMore() {
+    if (state.loadStatus === 'noMore') {
+      return;
+    }
+    state.pagination.pageNo++;
+    getGoodsList();
+  }
+
+  // 上拉加载更多
+  onReachBottom(() => {
+    loadMore();
+  });
 </script>
 
 <style lang="scss" scoped>
-	.goods-item {
-		.commission-num {
-			font-size: 24rpx;
-			font-weight: 500;
-			color: $red;
-		}
+  .goods-item {
+    .commission-num {
+      font-size: 24rpx;
+      font-weight: 500;
+      color: $red;
+    }
 
-		.share-btn {
-			width: 120rpx;
-			height: 50rpx;
-			border-radius: 25rpx;
-		}
-	}
-</style>
+    .share-btn {
+      width: 120rpx;
+      height: 50rpx;
+      border-radius: 25rpx;
+    }
+  }
+</style>

+ 319 - 405
pages/commission/order.vue

@@ -1,417 +1,331 @@
-<!-- 分销订单  -->
+<!-- 分销 - 订单明细 -->
 <template>
-	<s-layout title="分销订单" :class="state.scrollTop ? 'order-warp' : ''" navbar="inner">
-		<view class="header-box" :style="[
+  <s-layout title="分销订单" :class="state.scrollTop ? 'order-warp' : ''" navbar="inner">
+    <view
+      class="header-box"
+      :style="[
         {
           marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
           paddingTop: Number(statusBarHeight + 108) + 'rpx',
         },
-      ]">
-			<!-- 团队数据总览 -->
-			<view class="team-data-box ss-flex ss-col-center ss-row-between" style="width:100%">
-				<view class="data-card" style="width:100%">
-					<view class="total-item" style="width:100%">
-						<view class="item-title" style='text-align: center;'>累计推广订单(单)</view>
-						<view class="total-num" style='text-align: center;'>
-							{{ state.totals||state.pagination.total|| 0 }}
-						</view>
-					</view>
-					<!-- 		<view class="category-item ss-flex">
-						<view class="ss-flex-1">
-							<view class="item-title">一级订单</view>
-							<view class="category-num">
-								{{ state.agentInfo.child_order_count_1 || 0 }}
-							</view>
-						</view>
-						<view class="ss-flex-1">
-							<view class="item-title">二级订单</view>
-							<view class="category-num">
-								{{ state.agentInfo.child_order_count_2 || 0 }}
-							</view>
-						</view>
-					</view> -->
-				</view>
-				<!-- 			<view class="data-card">
-					<view class="total-item">
-						<view class="item-title">团队订单金额(元)</view>
-						<view class="total-num">
-							{{ state.agentInfo.child_order_money_all || '0.00' }}
-						</view>
-					</view>
-					<view class="category-item ss-flex">
-						<view class="ss-flex-1">
-							<view class="item-title">一级订单</view>
-							<view class="category-num">
-								{{ state.agentInfo.child_order_money_1 || '0.00' }}
-							</view>
-						</view>
-						<view class="ss-flex-1">
-							<view class="item-title">二级订单</view>
-							<view class="category-num">
-								{{ state.agentInfo.child_order_money_2 || '0.00' }}
-							</view>
-						</view>
-					</view>
-				</view> -->
-			</view>
-			<!-- 自购 -->
-			<!-- 		<view class="direct-box ss-flex ss-row-between">
-				<view class="direct-item">
-					<view class="item-title">自购分销订单数量(单)</view>
-					<view class="item-value">
-						{{ state.agentInfo.child_order_count_0 || 0 }}
-					</view>
-				</view>
-				<view class="direct-item">
-					<view class="item-title">自购分销订单金额(元)</view>
-					<view class="item-value">
-						{{ state.agentInfo.child_order_money_0 || '0.00' }}
-					</view>
-				</view>
-			</view> -->
-		</view>
-
-		<!-- tab -->
-		<su-sticky bgColor="#fff">
-			<su-tabs :list="tabMaps" :scrollable="false" :current="state.currentTab" @change="onTabsChange">
-			</su-tabs>
-		</su-sticky>
-
-		<!-- 订单 -->
-		<view class="order-box">
-			<view class="order-item" v-for="item in state.pagination.data" :key="item">
-				<view class="order-header">
-					<view class="no-box ss-flex ss-col-center ss-row-between">
-						<text class="order-code">订单编号:{{ item.order.order_sn }}</text>
-						<text class="order-state">{{ item.order_item.status_text }}</text>
-					</view>
-					<view class="order-from ss-flex ss-col-center ss-row-between">
-						<view class="from-user ss-flex ss-col-center">
-							<text>下单人:</text>
-							<image class="user-avatar" :src="sheep.$url.cdn(item.buyer.avatar)" mode="aspectFill">
-							</image>
-							<text class="user-name">{{ item.buyer.nickname }}</text>
-						</view>
-						<view class="order-time">{{ item.create_time }}</view>
-					</view>
-				</view>
-				<s-goods-item class="border-bottom" :img="item.order_item.goods_image"
-					:title="item.order_item.goods_title" :skuText="item.order_item.goods_sku_text"
-					:price="item.order_item.goods_price" :num="item.order_item.goods_num">
-					<template #rightBottom>
-						<view class="ss-flex commission-box ss-row-between ss-m-t-10">
-							<view class="ss-flex">
-								<text class="name">佣金:</text>
-								<text class="commission-num">{{ item.rewards[0]?.commission }}</text>
-							</view>
-							<view class="order-status">
-								{{ item.commission_order_status_text }}
-							</view>
-						</view>
-					</template>
-				</s-goods-item>
-			</view>
-			<!-- 数据为空 -->
-			<s-empty v-if="state.pagination.total === 0" icon="/static/order-empty.png" text="暂无订单">
-			</s-empty>
-			<!-- 加载更多 -->
-			<uni-load-more v-if="state.pagination.total > 0" :status="state.loadStatus" :content-text="{
+      ]"
+    >
+      <!-- 团队数据总览 -->
+      <view class="team-data-box ss-flex ss-col-center ss-row-between" style="width: 100%">
+        <view class="data-card" style="width: 100%">
+          <view class="total-item" style="width: 100%">
+            <view class="item-title" style="text-align: center">累计推广订单(单)</view>
+            <view class="total-num" style="text-align: center">
+              {{ state.totals }}
+            </view>
+          </view>
+        </view>
+      </view>
+    </view>
+
+    <!-- tab -->
+    <su-sticky bgColor="#fff">
+      <su-tabs
+        :list="tabMaps"
+        :scrollable="false"
+        :current="state.currentTab"
+        @change="onTabsChange"
+      >
+      </su-tabs>
+    </su-sticky>
+
+    <!-- 订单 -->
+    <view class="order-box">
+      <view class="order-item" v-for="item in state.pagination.list" :key="item">
+        <view class="order-header">
+          <view class="no-box ss-flex ss-col-center ss-row-between">
+            <text class="order-code">订单编号:{{ item.bizId }}</text>
+            <text class="order-state">
+              {{
+                item.status === 0 ? '待结算'
+                  : item.status === 1 ? '已结算' : '已取消'
+              }}
+              ( 佣金 {{ fen2yuan(item.price) }} 元 )
+            </text>
+          </view>
+          <view class="order-from ss-flex ss-col-center ss-row-between">
+            <view class="from-user ss-flex ss-col-center">
+              <text>{{ item.title }}</text>
+            </view>
+            <view class="order-time">
+              {{ sheep.$helper.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss') }}
+            </view>
+          </view>
+        </view>
+      </view>
+      <!-- 数据为空 -->
+      <s-empty v-if="state.pagination.total === 0" icon="/static/order-empty.png" text="暂无订单" />
+      <!-- 加载更多 -->
+      <uni-load-more
+        v-if="state.pagination.total > 0"
+        :status="state.loadStatus"
+        :content-text="{
           contentdown: '上拉加载更多',
-        }" @tap="loadmore" />
-		</view>
-		<!-- </view> -->
-	</s-layout>
+        }"
+        @tap="loadMore"
+      />
+    </view>
+  </s-layout>
 </template>
 
 <script setup>
-	import sheep from '@/sheep';
-	import {
-		onLoad,
-		onReachBottom
-	} from '@dcloudio/uni-app';
-	import {
-		computed,
-		reactive,
-	} from 'vue';
-	import _ from 'lodash';
-	import {
-		onPageScroll
-	} from '@dcloudio/uni-app';
-
-	const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
-	const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
-	onPageScroll((e) => {
-		if (e.scrollTop > 100) {
-			state.scrollTop = false;
-		} else {
-			state.scrollTop = true;
-		}
-	});
-
-	const state = reactive({
-		totals: 0,
-		pagination: {
-			data: [],
-			current_page: 1,
-			total: '',
-			last_page: 1,
-		},
-		loadStatus: '',
-		currentTab: 0,
-		agentInfo: {},
-		scrollTop: false,
-	});
-
-	const tabMaps = [{
-			name: '全部',
-			value: 'all',
-		},
-		// {
-		// 	name: '不计入',
-		// 	value: 'no'
-		// },
-		{
-			name: '待结算',
-			value: 'yes',
-		},
-		{
-			name: '已结算',
-			value: 'back',
-		},
-		// {
-		// 	name: '已取消',
-		// 	value: 'cancel',
-		// },
-	];
-	// 切换选项卡
-	function onTabsChange(e) {
-		state.pagination = {
-			data: [],
-			current_page: 1,
-			total: 0,
-			last_page: 1,
-		};
-		state.currentTab = e.index;
-		getOrderList();
-	}
-
-	// 获取订单列表
-	async function getOrderList(page = 1, list_rows = 5) {
-		// todo @芋艿:没有测试数据,还需对接请求参数,和返回的数据字段
-		state.loadStatus = 'loading';
-		let res = await sheep.$api.commission.order({
-			// type: tabMaps[state.currentTab].value,
-			pageSize: list_rows,
-			pageNo: page,
-			// status
-			// bizType
-		});
-		if (res.code === 0) {
-			let orderList = _.concat(state.pagination.data, res.data.list);
-			state.pagination = {
-				...res.data,
-				data: orderList,
-			};
-			state.totals = res.data.total;
-			console.log(state)
-			if (state.pagination.data.length < state.totals) {
-				state.loadStatus = 'more';
-			} else {
-				state.loadStatus = 'noMore';
-			}
-		}
-	}
-
-	async function getAgentInfo() {
-		const {
-			error,
-			data,
-			msg
-		} = await sheep.$api.commission.agent();
-		if (error === 0) {
-			state.agentInfo = data;
-		}
-	}
-
-	onLoad(() => {
-		// getAgentInfo();
-		getOrderList();
-	});
-
-	// 加载更多
-	function loadmore() {
-		if (state.loadStatus !== 'noMore') {
-			getOrderList(state.pagination.current_page + 1);
-		}
-	}
-
-	// 上拉加载更多
-	onReachBottom(() => {
-		loadmore();
-	});
+  import sheep from '@/sheep';
+  import { onLoad, onReachBottom } from '@dcloudio/uni-app';
+  import { reactive } from 'vue';
+  import _ from 'lodash';
+  import { onPageScroll } from '@dcloudio/uni-app';
+  import { resetPagination } from '@/sheep/util';
+  import BrokerageApi from '@/sheep/api/trade/brokerage';
+  import { fen2yuan } from '../../sheep/hooks/useGoods';
+
+  const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
+  const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
+
+  onPageScroll((e) => {
+    state.scrollTop = e.scrollTop <= 100;
+  });
+
+  const state = reactive({
+    totals: 0, // 累计推广订单(单)
+    scrollTop: false,
+
+    currentTab: 0,
+    loadStatus: '',
+    pagination: {
+      list: [],
+      total: 0,
+      pageNo: 1,
+      pageSize: 1,
+    },
+  });
+
+  const tabMaps = [
+    {
+      name: '全部',
+      value: 'all',
+    },
+    {
+      name: '待结算',
+      value: '0', // 待结算
+    },
+    {
+      name: '已结算',
+      value: '1', // 已结算
+    },
+  ];
+
+  // 切换选项卡
+  function onTabsChange(e) {
+    resetPagination(state.pagination);
+    state.currentTab = e.index;
+    getOrderList();
+  }
+
+  // 获取订单列表
+  async function getOrderList() {
+    state.loadStatus = 'loading';
+    let { code, data } = await BrokerageApi.getBrokerageRecordPage({
+      pageSize: state.pagination.pageSize,
+      pageNo: state.pagination.pageSize,
+      bizType: 1, // 获得推广佣金
+      status: state.currentTab > 0 ? state.currentTab : undefined,
+    });
+    if (code !== 0) {
+      return;
+    }
+    state.pagination.list = _.concat(state.pagination.list, data.list);
+    state.pagination.total = data.total;
+    state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
+    if (state.currentTab === 0) {
+      state.totals = data.total;
+    }
+  }
+
+  onLoad(() => {
+    getOrderList();
+  });
+
+  // 加载更多
+  function loadMore() {
+    if (state.loadStatus === 'noMore') {
+      return;
+    }
+    state.pagination.pageNo++;
+    getOrderList();
+  }
+
+  // 上拉加载更多
+  onReachBottom(() => {
+    loadMore();
+  });
 </script>
 
 <style lang="scss" scoped>
-	.header-box {
-		box-sizing: border-box;
-		padding: 0 20rpx 20rpx 20rpx;
-		width: 750rpx;
-		background: v-bind(headerBg) no-repeat,
-			linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
-		background-size: 750rpx 100%;
-
-		// 团队信息总览
-		.team-data-box {
-			.data-card {
-				width: 305rpx;
-				background: #ffffff;
-				border-radius: 20rpx;
-				padding: 20rpx;
-
-				.total-item {
-					margin-bottom: 30rpx;
-
-					.item-title {
-						font-size: 24rpx;
-						font-weight: 500;
-						color: #999999;
-						line-height: normal;
-						margin-bottom: 20rpx;
-					}
-
-					.total-num {
-						font-size: 38rpx;
-						font-weight: 500;
-						color: #333333;
-						font-family: OPPOSANS;
-					}
-				}
-
-				.category-num {
-					font-size: 26rpx;
-					font-weight: 500;
-					color: #333333;
-					font-family: OPPOSANS;
-				}
-			}
-		}
-
-		// 直推
-		.direct-box {
-			margin-top: 20rpx;
-
-			.direct-item {
-				width: 340rpx;
-				background: #ffffff;
-				border-radius: 20rpx;
-				padding: 20rpx;
-				box-sizing: border-box;
-
-				.item-title {
-					font-size: 22rpx;
-					font-weight: 500;
-					color: #999999;
-					margin-bottom: 6rpx;
-				}
-
-				.item-value {
-					font-size: 38rpx;
-					font-weight: 500;
-					color: #333333;
-					font-family: OPPOSANS;
-				}
-			}
-		}
-	}
-
-	// 订单
-	.order-box {
-		.order-item {
-			background: #ffffff;
-			border-radius: 10rpx;
-			margin: 20rpx;
-
-			.order-footer {
-				padding: 20rpx;
-				font-size: 24rpx;
-				color: #999;
-			}
-
-			.order-header {
-				.no-box {
-					padding: 20rpx;
-
-					.order-code {
-						font-size: 26rpx;
-						font-weight: 500;
-						color: #333333;
-					}
-
-					.order-state {
-						font-size: 26rpx;
-						font-weight: 500;
-						color: var(--ui-BG-Main);
-					}
-				}
-
-				.order-from {
-					padding: 20rpx;
-
-					.from-user {
-						font-size: 24rpx;
-						font-weight: 400;
-						color: #666666;
-
-						.user-avatar {
-							width: 26rpx;
-							height: 26rpx;
-							border-radius: 50%;
-							margin-right: 8rpx;
-						}
-
-						.user-name {
-							font-size: 24rpx;
-							font-weight: 400;
-							color: #999999;
-						}
-					}
-
-					.order-time {
-						font-size: 24rpx;
-						font-weight: 400;
-						color: #999999;
-					}
-				}
-			}
-
-			.commission-box {
-				.name {
-					font-size: 24rpx;
-					font-weight: 400;
-					color: #999999;
-				}
-			}
-
-			.commission-num {
-				font-size: 30rpx;
-				font-weight: 500;
-				color: $red;
-				font-family: OPPOSANS;
-
-				&::before {
-					content: '¥';
-					font-size: 22rpx;
-				}
-			}
-
-			.order-status {
-				line-height: 30rpx;
-				padding: 0 10rpx;
-				border-radius: 30rpx;
-				margin-left: 20rpx;
-				font-size: 24rpx;
-				color: var(--ui-BG-Main);
-			}
-		}
-	}
-</style>
+  .header-box {
+    box-sizing: border-box;
+    padding: 0 20rpx 20rpx 20rpx;
+    width: 750rpx;
+    background: v-bind(headerBg) no-repeat,
+      linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
+    background-size: 750rpx 100%;
+
+    // 团队信息总览
+    .team-data-box {
+      .data-card {
+        width: 305rpx;
+        background: #ffffff;
+        border-radius: 20rpx;
+        padding: 20rpx;
+
+        .total-item {
+          margin-bottom: 30rpx;
+
+          .item-title {
+            font-size: 24rpx;
+            font-weight: 500;
+            color: #999999;
+            line-height: normal;
+            margin-bottom: 20rpx;
+          }
+
+          .total-num {
+            font-size: 38rpx;
+            font-weight: 500;
+            color: #333333;
+            font-family: OPPOSANS;
+          }
+        }
+
+        .category-num {
+          font-size: 26rpx;
+          font-weight: 500;
+          color: #333333;
+          font-family: OPPOSANS;
+        }
+      }
+    }
+
+    // 直推
+    .direct-box {
+      margin-top: 20rpx;
+
+      .direct-item {
+        width: 340rpx;
+        background: #ffffff;
+        border-radius: 20rpx;
+        padding: 20rpx;
+        box-sizing: border-box;
+
+        .item-title {
+          font-size: 22rpx;
+          font-weight: 500;
+          color: #999999;
+          margin-bottom: 6rpx;
+        }
+
+        .item-value {
+          font-size: 38rpx;
+          font-weight: 500;
+          color: #333333;
+          font-family: OPPOSANS;
+        }
+      }
+    }
+  }
+
+  // 订单
+  .order-box {
+    .order-item {
+      background: #ffffff;
+      border-radius: 10rpx;
+      margin: 20rpx;
+
+      .order-footer {
+        padding: 20rpx;
+        font-size: 24rpx;
+        color: #999;
+      }
+
+      .order-header {
+        .no-box {
+          padding: 20rpx;
+
+          .order-code {
+            font-size: 26rpx;
+            font-weight: 500;
+            color: #333333;
+          }
+
+          .order-state {
+            font-size: 26rpx;
+            font-weight: 500;
+            color: var(--ui-BG-Main);
+          }
+        }
+
+        .order-from {
+          padding: 20rpx;
+
+          .from-user {
+            font-size: 24rpx;
+            font-weight: 400;
+            color: #666666;
+
+            .user-avatar {
+              width: 26rpx;
+              height: 26rpx;
+              border-radius: 50%;
+              margin-right: 8rpx;
+            }
+
+            .user-name {
+              font-size: 24rpx;
+              font-weight: 400;
+              color: #999999;
+            }
+          }
+
+          .order-time {
+            font-size: 24rpx;
+            font-weight: 400;
+            color: #999999;
+          }
+        }
+      }
+
+      .commission-box {
+        .name {
+          font-size: 24rpx;
+          font-weight: 400;
+          color: #999999;
+        }
+      }
+
+      .commission-num {
+        font-size: 30rpx;
+        font-weight: 500;
+        color: $red;
+        font-family: OPPOSANS;
+
+        &::before {
+          content: '¥';
+          font-size: 22rpx;
+        }
+      }
+
+      .order-status {
+        line-height: 30rpx;
+        padding: 0 10rpx;
+        border-radius: 30rpx;
+        margin-left: 20rpx;
+        font-size: 24rpx;
+        color: var(--ui-BG-Main);
+      }
+    }
+  }
+</style>

+ 61 - 62
pages/commission/promoter.vue

@@ -4,33 +4,33 @@
 			<view class="redBg bg-color">
 				<view class="header">
 					<view class="nav acea-row row-center-wrapper" style='display:flex'>
-						<view class="item" :class="state.active === index ? 'font-color' : ''"
-							v-for="(item, index) in state.navList" :key="index" @click="switchTap(index)">
+						<view class="item" :class="state.currentTab === index ? 'font-color' : ''"
+							v-for="(item, index) in tabMaps" :key="index" @click="switchTap(index)">
 							{{ item }}
 						</view>
 					</view>
 					<!-- top3 排名 -->
 					<view class="rank acea-row row-bottom row-around">
-						<view class="item" v-show="state.Two.id">
+						<view class="item" v-show="state.two.id">
 							<view class="pictrue">
-								<image :src="state.Two.avatar"></image>
+								<image :src="state.two.avatar"></image>
 							</view>
-							<view class="name line1">{{state.Two.nickname}}</view>
-							<view class="num">{{ state.Two.brokerageUserCount }}人</view>
+							<view class="name line1">{{state.two.nickname}}</view>
+							<view class="num">{{ state.two.brokerageUserCount }}人</view>
 						</view>
-						<view class="item" v-show="state.One.id">
+						<view class="item" v-show="state.one.id">
 							<view class="pictrue">
-								<image :src="state.One.avatar"></image>
+								<image :src="state.one.avatar"></image>
 							</view>
-							<view class="name line1">{{state.One.nickname}}</view>
-							<view class="num">{{ state.One.brokerageUserCount }}人</view>
+							<view class="name line1">{{state.one.nickname}}</view>
+							<view class="num">{{ state.one.brokerageUserCount }}人</view>
 						</view>
-						<view class="item" v-show="state.Three.id">
+						<view class="item" v-show="state.three.id">
 							<view class="pictrue">
-								<image :src="state.Three.avatar"></image>
+								<image :src="state.three.avatar"></image>
 							</view>
-							<view class="name line1">{{state.Three.nickname}}</view>
-							<view class="num">{{ state.Three.brokerageUserCount }}人</view>
+							<view class="name line1">{{state.three.nickname}}</view>
+							<view class="num">{{ state.three.brokerageUserCount }}人</view>
 						</view>
 					</view>
 				</view>
@@ -54,66 +54,57 @@
 
 <script setup>
 	import sheep from '@/sheep';
-	import $share from '@/sheep/platform/share';
-	import {
-		onLoad,
-		onReachBottom
-	} from '@dcloudio/uni-app';
-	import {
-		computed,
-		reactive
-	} from 'vue';
-	import _ from 'lodash';
-
-	const state = reactive({
-		navList: ["周榜", "月榜"],
-		active: 0,
-		page: 1,
-		limit: 10,
-		type: 'week',
-		loading: false,
-		loadend: false,
+  import { onLoad } from '@dcloudio/uni-app';
+  import { reactive } from 'vue';
+  import BrokerageApi from '@/sheep/api/trade/brokerage';
+
+  const tabMaps = ['周排行', '月排行'];
+
+  const state = reactive({
+    currentTab: 0,
+
 		rankList: [],
 		times: [],
-		One: {}, // 排名第一
-		Two: {}, // 排名第二
-		Three: {}, // 排名第三
+
+		one: {}, // 排名第一
+		two: {}, // 排名第二
+		three: {}, // 排名第三
 	});
 
 	function switchTap(index) {
-		if (state.active === index) {
+		if (state.currentTab === index) {
 			return;
 		}
-		state.active = index;
-		// week
-		state.type = index ? 'month' : 'week';
-		// this.page = 1;
-		// this.loadend = false;
-		// this.$set(this, 'rankList', []);
-		// this.Two = {};
-		// this.One = {};
-		// this.Three = {};
+		state.currentTab = index;
 		calculateTimes();
-		getRanklist();
-	}
-
-
-	function getRanklist() {
-		// todo @芋艿:编码传参
-		sheep.$api.commission.getBrokerageRankNumber({
-			pageNo: state.page,
-			pageSize: state.limit,
-			'times[0]': state.times[0],
-			'times[1]': state.times[1],
-		}).then(res => {
-			console.log(res)
-		})
+		getRankList();
 	}
 
+	async function getRankList() {
+    // 重置数据
+    state.one = {};
+    state.two = {};
+    state.three = {};
+    state.rankList = [];
+    // 查询
+    const { code, data } = await BrokerageApi.getBrokerageUserRankPageByUserCount({
+      pageNo: 1,
+      pageSize: 10,
+      'times[0]': state.times[0],
+      'times[1]': state.times[1],
+    });
+    if (code !== 0) {
+      return;
+    }
+    state.rankList = data.list;
+    state.one = state.rankList.shift() || {};
+    state.two = state.rankList.shift() || {};
+    state.trhee = state.rankList.shift() || {};
+  }
 
 	function calculateTimes() {
 		let times;
-		if (state.type === 'week') {
+		if (state.currentTab === 0) {
 			times = getWeekTimes();
 		} else {
 			times = getMonthTimes();
@@ -121,10 +112,17 @@
 		state.times = [formatDate(times[0]), formatDate(times[1])]
 	}
 
+  onLoad(function () {
+    calculateTimes();
+    getRankList();
+  });
+
 	function formatDate(date) {
 		return sheep.$helper.timeFormat(date, 'yyyy-mm-dd hh:MM:ss');
 	}
-	// 此处可考虑抽离
+
+  // TODO 芋艿:此处可考虑抽离
+  // 此处可考虑抽离
 	/**
 	 * 获得当前周的开始和结束时间
 	 */
@@ -149,6 +147,7 @@
 		const endDate = new Date(nextMonth.getTime() - 1);
 		return [startDate, endDate]
 	}
+  // TODO 芋艿:css 需要优化下;并且展示样式有问题
 </script>
 
 <style lang='scss' scoped>

+ 1 - 1
pages/commission/team.vue

@@ -1,4 +1,4 @@
-<!-- 页面  -->
+<!-- 页面 TODO 芋艿:检查未开发 -->
 <template>
 	<s-layout title="我的团队" :class="state.scrollTop ? 'team-wrap' : ''" navbar="inner">
 		<view class="header-box" :style="[

+ 84 - 101
pages/user/wallet/commission.vue → pages/commission/wallet.vue

@@ -1,3 +1,4 @@
+<!-- 分销 - 佣金明细 -->
 <template>
 	<s-layout class="wallet-wrap" title="佣金">
 		<!-- 钱包卡片 -->
@@ -6,10 +7,10 @@
 				<view class="card-head ss-flex ss-col-center">
 					<view class="card-title ss-m-r-10">当前佣金(元)</view>
 					<view @tap="state.showMoney = !state.showMoney" class="ss-eye-icon"
-						:class="state.showMoney ? 'cicon-eye' : 'cicon-eye-off'"></view>
+						:class="state.showMoney ? 'cicon-eye' : 'cicon-eye-off'" />
 				</view>
 				<view class="ss-flex ss-row-between ss-col-center ss-m-t-30">
-					<view class="money-num">{{ state.showMoney ? state.userInfo.withdrawPrice : '*****' }}</view>
+					<view class="money-num">{{ state.showMoney ? fen2yuan(state.summary.withdrawPrice || 0) : '*****' }}</view>
 					<view class="ss-flex">
 						<view class="ss-m-r-20">
 							<button class="ss-reset-button withdraw-btn" @tap="sheep.$router.go('/pages/pay/withdraw')">
@@ -25,62 +26,65 @@
 				<view class="ss-flex">
 					<view class="loading-money">
 						<view class="loading-money-title">冻结佣金</view>
-						<view class="loading-money-num">{{
-              state.showMoney ? state.userInfo.frozenPrice || '0.00' : '*****'
-            }}</view>
+						<view class="loading-money-num">
+              {{ state.showMoney ? fen2yuan(state.summary.frozenPrice || 0) : '*****' }}
+            </view>
 					</view>
 					<view class="loading-money ss-m-l-100">
 						<view class="loading-money-title">可提现佣金</view>
-						<view class="loading-money-num">{{
-              state.showMoney ? state.userInfo.brokeragePrice || '0.00' : '*****'
-            }}</view>
+						<view class="loading-money-num">
+              {{ state.showMoney ? fen2yuan(state.summary.brokeragePrice || 0) : '*****' }}
+            </view>
 					</view>
 				</view>
 			</view>
 		</view>
+
 		<su-sticky>
 			<!-- 统计 -->
 			<view class="filter-box ss-p-x-30 ss-flex ss-col-center ss-row-between">
-				<uni-datetime-picker v-model="state.data" type="daterange" @change="onChangeTime" :end="state.today">
+				<uni-datetime-picker v-model="state.date" type="daterange" @change="onChangeTime" :end="state.today">
 					<button class="ss-reset-button date-btn">
 						<text>{{ dateFilterText }}</text>
-						<text class="cicon-drop-down ss-seldate-icon"></text>
+						<text class="cicon-drop-down ss-seldate-icon" />
 					</button>
 				</uni-datetime-picker>
 
 				<view class="total-box">
+          <!-- TODO 芋艿:这里暂时不考虑做 -->
 					<!-- <view class="ss-m-b-10">总收入¥{{ state.pagination.income.toFixed(2) }}</view> -->
 					<!-- <view>总支出¥{{ (-state.pagination.expense).toFixed(2) }}</view> -->
 				</view>
 			</view>
-			<su-tabs :list="tabMaps" @change="onChangeTab" :scrollable="false" :current="state.currentTab"></su-tabs>
+			<su-tabs :list="tabMaps" @change="onChangeTab" :scrollable="false" :current="state.currentTab" />
 		</su-sticky>
 		<s-empty v-if="state.pagination.total === 0" icon="/static/data-empty.png" text="暂无数据"></s-empty>
-		<!-- 转余额弹框 -->
+
+    <!-- 转余额弹框 -->
 		<su-popup :show="state.showModal" type="bottom" round="20" @close="state.showModal = false" showClose>
 			<view class="ss-p-x-20 ss-p-y-30">
 				<view class="model-title ss-m-b-30 ss-m-l-20">转余额</view>
 				<view class="model-subtitle ss-m-b-100 ss-m-l-20">将您的佣金转到余额中继续消费</view>
 				<view class="input-box ss-flex ss-col-center border-bottom ss-m-b-70 ss-m-x-20">
 					<view class="unit">¥</view>
-					<uni-easyinput :inputBorder="false" class="ss-flex-1 ss-p-l-10" v-model="state.amount" type="number"
-						placeholder="请输入金额" />
+					<uni-easyinput :inputBorder="false" class="ss-flex-1 ss-p-l-10" v-model="state.price" type="number"
+                         placeholder="请输入金额" />
 				</view>
 				<button class="ss-reset-button model-btn ui-BG-Main-Gradient ui-Shadow-Main" @tap="onConfirm">
 					确定
 				</button>
 			</view>
 		</su-popup>
+
 		<!-- 钱包记录 -->
 		<view v-if="state.pagination.total > 0">
-			<view class="wallet-list ss-flex border-bottom" v-for="item in state.pagination.data" :key="item.id">
+			<view class="wallet-list ss-flex border-bottom" v-for="item in state.pagination.list" :key="item.id">
 				<view class="list-content">
 					<view class="title-box ss-flex ss-row-between ss-m-b-20">
-						<!-- {{ item.memo ? '-' + item.memo : '' }} -->
 						<text class="title ss-line-1">{{ item.title }}</text>
 						<view class="money">
-							<text v-if="item.amount >= 0" class="add">+{{ item.price }}</text>
-							<text v-else class="minus">{{ item.price }}</text>
+							<text v-if="item.price >= 0" class="add">+{{ fen2yuan(item.price) }}</text>
+							<text v-else class="minus">{{ fen2yuan(item.price) }}</text>
 						</view>
 					</view>
 					<text class="time">{{ sheep.$helper.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss') }}</text>
@@ -96,56 +100,45 @@
 </template>
 
 <script setup>
-	import {
-		computed,
-		reactive
-	} from 'vue';
-	import {
-		onLoad,
-		onReachBottom
-	} from '@dcloudio/uni-app';
+	import { computed, reactive } from 'vue';
+	import { onLoad, onReachBottom } from '@dcloudio/uni-app';
 	import sheep from '@/sheep';
 	import dayjs from 'dayjs';
 	import _ from 'lodash';
+  import BrokerageApi from '@/sheep/api/trade/brokerage';
+  import { fen2yuan } from '@/sheep/hooks/useGoods';
+  import { resetPagination } from '@/sheep/util';
 
 	const headerBg = sheep.$url.css('/static/img/shop/user/wallet_card_bg.png');
 
-	// 数据
-	const pagination = {
-		data: [],
-		current_page: 1,
-		total: 1,
-		last_page: 1,
-		expense: 0,
-		income: 0,
-	};
 	const state = reactive({
-		userInfo: {},
-		showMoney: false,
-		date: [],
+    showMoney: false,
+    summary: {}, // 分销信息
+
+    today: '',
+    date: [],
 		currentTab: 0,
-		pagination,
+		pagination: {
+      list: [],
+      total: 0,
+      pageNo: 1,
+      pageSize: 1,
+    },
 		loadStatus: '',
+
+    price: undefined,
 		showModal: false,
-		today: '',
 	});
 
 	const tabMaps = [{
 			name: '分佣',
-			value: 'all',
+			value: '1', // BrokerageRecordBizTypeEnum.ORDER
 		},
 		{
 			name: '提现',
-			value: 'income',
+			value: '2', // BrokerageRecordBizTypeEnum.WITHDRAW
 		}
-		// {
-		// 	name: '支出',
-		// 	value: 'expense',
-		// },
 	];
-	const userInfo = computed(() => sheep.$store('user').userInfo);
-
-	const agentInfo = computed(() => sheep.$store('user').agentInfo);
 
 	const dateFilterText = computed(() => {
 		if (state.date[0] === state.date[1]) {
@@ -155,36 +148,25 @@
 		}
 	});
 
-	async function getLogList(page = 1, list_rows = 4) {
+	async function getLogList() {
 		state.loadStatus = 'loading';
-		let ress = await sheep.$api.commission.getSummary();
-		state.userInfo = ress.data;
-		let res = await sheep.$api.user.wallet.log3({
-			// type: 'commission',
-			// tab: tabMaps[state.currentTab].value,
-			pageSize: list_rows,
-			pageNo: page,
-			// date: appendTimeHMS(state.date),
+		let { code, data } = await BrokerageApi.getBrokerageRecordPage({
+			pageSize: state.pagination.pageSize,
+			pageNo: state.pagination.pageNo,
+      bizType: tabMaps[state.currentTab].value,
+      'createTime[0]': state.date[0] + ' 00:00:00',
+      'createTime[1]': state.date[1] + ' 23:59:59',
 		});
-		if (res.code === 0) {
-			let list = _.concat(state.pagination.data, res.data.list);
-			state.pagination = {
-				current_page: page,
-				...res.data,
-				data: list,
-				// income: res.data.income,
-				// expense: res.data.expense,
-			};
-			if (state.pagination.data.length < state.pagination.total) {
-				state.loadStatus = 'more';
-			} else {
-				state.loadStatus = 'noMore';
-			}
+		if (code !== 0) {
+      return;
 		}
+    state.pagination.list = _.concat(state.pagination.list, data.list);
+    state.pagination.total = data.total;
+    state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
 	}
 
 	function onChangeTab(e) {
-		state.pagination = pagination;
+		resetPagination(state.pagination);
 		state.currentTab = e.index;
 		getLogList();
 	}
@@ -192,17 +174,13 @@
 	function onChangeTime(e) {
 		state.date[0] = e[0];
 		state.date[1] = e[e.length - 1];
-		state.pagination = pagination;
+    resetPagination(state.pagination);
 		getLogList();
 	}
 
-	function appendTimeHMS(arr) {
-		return [arr[0] + ' 00:00:00', arr[1] + ' 23:59:59'];
-	}
-
-	// 确认操作
+	// 确认操作(转账到余额)
 	async function onConfirm() {
-		if (state.amount <= 0) {
+		if (state.price <= 0) {
 			sheep.$helper.toast('请输入正确的金额');
 			return;
 		}
@@ -210,30 +188,33 @@
 			title: '提示',
 			content: '确认把您的佣金转入到余额钱包中?',
 			success: async function(res) {
-				if (res.confirm) {
-					const {
-						error
-					} = await sheep.$api.commission.transfer({
-						amount: state.amount,
-					});
-					if (error === 0) {
-						state.showModal = false;
-						sheep.$store('user').getInfo();
-						onChangeTab({
-							index: 0
-						});
-					}
+				if (!res.confirm) {
+          return;
 				}
-			},
+        const { code } = await BrokerageApi.createBrokerageWithdraw({
+          type: 1, // 钱包
+          price: state.price * 100,
+        });
+        if (code === 0) {
+          state.showModal = false;
+          await getAgentInfo();
+          onChangeTab({
+            index: 1
+          });
+        }
+			}
 		});
 	}
+
 	async function getAgentInfo() {
-		const {
-			code,
-			data
-		} = await sheep.$store('user').getAgentInfo();
+		const { code, data } = await BrokerageApi.getBrokerageUserSummary();
+    if (code !== 0) {
+      return;
+    }
+    state.summary = data;
 	}
-	onLoad(async (options) => {
+
+	onLoad(async () => {
 		state.today = dayjs().format('YYYY-MM-DD');
 		state.date = [state.today, state.today];
 		getLogList();
@@ -241,9 +222,11 @@
 	});
 
 	onReachBottom(() => {
-		if (state.loadStatus !== 'noMore') {
-			getLogList(state.pagination.current_page + 1);
+		if (state.loadStatus === 'noMore') {
+			return;
 		}
+    state.pagination.pageNo++;
+    getLogList();
 	});
 </script>
 

+ 1 - 67
sheep/api/commission.js

@@ -1,47 +1,6 @@
 import request from '@/sheep/request';
 
 export default {
-	// 分销商详情
-	agent: () =>
-		request({
-			url: 'commission/agent',
-			method: 'GET',
-			custom: {
-				showLoading: false,
-				showError: false,
-			},
-		}),
-	// 分销表单
-	form: () =>
-		request({
-			url: 'commission/agent/form',
-			method: 'GET',
-		}),
-	// 申请分销商
-	apply: (data) =>
-		request({
-			url: 'commission/agent/apply',
-			method: 'POST',
-			data,
-			custom: {
-				showSuccess: true,
-			},
-		}),
-	// 分销动态
-	log: (params) =>
-		request({
-			url: 'commission/log',
-			method: 'GET',
-			params,
-		}),
-
-	// 分销商品
-	goods: (params) =>
-		request({
-			url: '/app-api/product/spu/page',
-			method: 'GET',
-			params,
-		}),
 	// 我的团队
 	team: (params) =>
 		request({
@@ -49,34 +8,9 @@ export default {
 			method: 'GET',
 			params,
 		}),
-	// 佣金转余额
-	transfer: (data) =>
-		request({
-			url: 'commission/agent/transfer',
-			method: 'POST',
-			data,
-		}),
 	getSummary: (data) =>
 		request({
 			url: '/app-api/trade/brokerage-user/get-summary',
 			method: 'GET',
-		}),
-	getBrokerageRankNumber: (params) =>
-		request({
-			url: '/app-api/trade/brokerage-user/get-rank-by-price',
-			method: 'GET',
-			params
-		}),
-	getBrokerageRankList: (params) =>
-		request({
-			url: '/app-api/trade/brokerage-user/rank-page-by-price',
-			method: 'GET',
-			params
-		}),
-	getRanklist: (params) =>
-		request({
-			url: '/app-api/trade/brokerage-user/rank-page-by-user-count',
-			method: 'GET',
-			params
-		}),
+		})
 };

+ 55 - 4
sheep/api/trade/brokerage.js

@@ -15,14 +15,65 @@ const BrokerageApi = {
       method: 'GET',
     });
   },
-  // 分销订单
+  // 获得分销记录分页
   getBrokerageRecordPage: (params) => {
+    if (params.status === undefined) {
+      delete params.status
+    }
+    const queryString = Object.keys(params)
+      .map((key) => encodeURIComponent(key) + '=' + params[key])
+      .join('&');
     return request({
-      url: '/app-api/trade/brokerage-record/page',
+      url: `/app-api/trade/brokerage-record/page?${queryString}`,
       method: 'GET',
-      params,
     });
-  }
+  },
+  // 创建分销提现
+  createBrokerageWithdraw: (data) => {
+    return request({
+      url: '/app-api/trade/brokerage-withdraw/create',
+      method: 'POST',
+      data,
+    });
+  },
+  // 获得商品的分销金额
+  getProductBrokeragePrice: (spuId) => {
+    return request({
+      url: '/app-api/trade/brokerage-record/get-product-brokerage-price',
+      method: 'GET',
+      params: {
+        spuId
+      }
+    });
+  },
+  // 获得分销用户排行(基于佣金)
+  getRankByPrice: (params) => {
+    const queryString = `times=${params.times[0]}&times=${params.times[1]}`;
+    return request({
+      url: `/app-api/trade/brokerage-user/get-rank-by-price?${queryString}`,
+      method: 'GET',
+    });
+  },
+  // 获得分销用户排行分页(基于佣金)
+  getBrokerageUserChildSummaryPageByPrice: (params) => {
+    const queryString = Object.keys(params)
+      .map((key) => encodeURIComponent(key) + '=' + params[key])
+      .join('&');
+    return request({
+      url: `/app-api/trade/brokerage-user/rank-page-by-price?${queryString}`,
+      method: 'GET',
+    });
+  },
+  // 获得分销用户排行分页(基于用户量)
+  getBrokerageUserRankPageByUserCount: (params) => {
+    const queryString = Object.keys(params)
+      .map((key) => encodeURIComponent(key) + '=' + params[key])
+      .join('&');
+    return request({
+      url: `/app-api/trade/brokerage-user/rank-page-by-user-count?${queryString}`,
+      method: 'GET',
+    });
+  },
 }
 
 export default BrokerageApi

+ 0 - 7
sheep/api/user.js

@@ -264,13 +264,6 @@ export default {
 				params,
 				custom: {},
 			}),
-		log3: (params) =>
-			request({
-				url: '/app-api/trade/brokerage-record/page',
-				// url: 'pay/wallet-transaction/page',
-				method: 'GET',
-				params,
-			}),
 	},
 	account: {
 		info: (params) =>

+ 1 - 0
sheep/platform/share.js

@@ -12,6 +12,7 @@ const platformMap = ['H5', 'WechatOfficialAccount', 'WechatMiniProgram', 'App'];
 // 设置分享方式: 1=直接转发,2=海报,3=复制链接,...按需扩展
 const fromMap = ['forward', 'poster', 'link'];
 
+// TODO 芋艿:分享的接入
 // 设置分享信息参数
 const getShareInfo = (
   scene = {

+ 0 - 1
sheep/store/user.js

@@ -23,7 +23,6 @@ const defaultUserInfo = {
 	gender: 0, // 性别
 	mobile: '', // 手机号
 	money: '--', // 余额
-	commission: '--', // 佣金 TODO 芋艿:干掉
 	score: '--', // 积分
 	verification: {}, // 认证字段
 };

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott