xiaomei 1 year ago
parent
commit
c1400a3d49
3 changed files with 810 additions and 272 deletions
  1. 306 83
      src/pages/shoppingMall/index.vue
  2. 271 69
      src/pagesC/shoppingMallType/index.vue
  3. 233 120
      src/pagesC/shoppingMallType/p_details.vue

+ 306 - 83
src/pages/shoppingMall/index.vue

@@ -1,3 +1,4 @@
+<!-- type 1拼多多 2淘宝 -->
 <template>
   <div class="container">
     <div
@@ -24,10 +25,11 @@
     <div class="head" v-show="head">
       <p class="title">商城购物</p>
     </div>
-    <div class="nav_box flex_r flex_jb">
+    <!-- 平台-start -->
+    <div class="nav_box flex_r">
       <div
         class="item flex_c flex_ac"
-        v-for="(i, s) in tabs"
+        v-for="(i, s) in platform"
         :key="s"
         @click="goto(i.url + '&name=' + i.name)"
       >
@@ -44,16 +46,20 @@
         <div class="tit1">{{ i.text }}</div>
       </div>
     </div>
-    <div class="flex_r flex_jb flex_ac">
+    <!-- 平台-end -->
+    <!-- 平台切换-start -->
+    <div class="flex_r flex_ac">
       <div
         :class="navIndex == s ? 'nav nav-active' : 'nav'"
-        v-for="(i, s) in tabs"
+        v-for="(i, s) in platform"
         :key="s"
-        @click="navIndex = s"
+        @click="changeNav(i, s)"
       >
         <span>{{ i.name }}</span>
       </div>
     </div>
+    <!-- 平台切换-end -->
+    <!-- 平台下分类-start -->
     <div class="sort_box flex_r flex_jb flex_ac">
       <div
         :class="sortIndex == s ? 'sort sort-active' : 'sort'"
@@ -64,52 +70,125 @@
         <span>{{ i.cat_name }}</span>
       </div>
     </div>
+    <!-- 平台下分类-end -->
     <view class="product-list" v-if="goods.length > 0">
       <view
         class="product"
         v-for="(i, s) in goods"
         :key="s"
-        @click="NavToGoodsDetail(i.goods_sign)"
+        @click="NavToGoodsDetail(i)"
       >
-        <view class="image-view">
+        <view class="image-view" v-if="platformObj.type == 1">
           <image class="product-image" :src="i.goods_image_url"></image>
         </view>
+        <view class="image-view" v-else-if="platformObj.type == 2">
+          <image
+            class="product-image"
+            :src="i.item_basic_info.pict_url"
+          ></image>
+        </view>
         <view class="content-view">
           <view :class="['product-title', 'ellipsis2']">
             <span class="product-type">
-              {{ tabs[navIndex].name }}
+              {{ platformObj.name }}
             </span>
-            <span>{{ i.goods_name }}</span>
+            <span v-if="platformObj.type == 1">{{ i.goods_name }}</span>
+            <span v-else-if="platformObj.type == 2">{{
+              i.item_basic_info.title
+            }}</span>
           </view>
-          <view class="quan_box flex_r flex_ac">
-            <view class="quan" v-if="i.has_coupon">
-              <span class="pl">券</span>
-              <span>¥{{ i.coupon_discount / 100 }}</span>
+          <!-- 拼多多 -->
+          <template v-if="platformObj.type == 1">
+            <view class="quan_box flex_r flex_as flex_wrap">
+              <view class="quan" v-if="i.has_coupon">
+                <span class="pl">券</span>
+                <span>¥{{ i.coupon_discount / 100 }}</span>
+              </view>
+              <view class="quan">
+                <span>赠付宝:</span>
+                <span>
+                  {{
+                    Math.floor(
+                      (i.min_group_price / 100) *
+                        (i.promotion_rate / 1000) *
+                        platformObj.ratio *
+                        100
+                    ) / 100
+                  }}
+                </span>
+              </view>
+              <view class="quan">
+                <span>赠茶宝:</span>
+                <span>
+                  {{
+                    Math.floor(
+                      (i.min_group_price / 100 - i.coupon_discount / 100) *
+                        platformObj.chabao *
+                        100
+                    ) / 100
+                  }}
+                </span>
+              </view>
             </view>
-            <view class="quan">
-              <span>返现</span>
-              <span
-                >¥
+            <view class="product-price">
+              <text class="product-price-original">
                 {{
                   Math.floor(
-                    (i.min_group_price / 100) * (i.promotion_rate / 1000) * radio * 100
+                    (i.min_group_price / 100 - i.coupon_discount / 100) * 100
                   ) / 100
                 }}
-              </span>
+              </text>
+              <text class="product-price-favour"
+                >¥{{ i.min_group_price / 100 }}</text
+              >
             </view>
-          </view>
-          <view class="product-price">
-            <text class="product-price-original">
-              {{
-                Math.floor(
-                  (i.min_group_price / 100 - i.coupon_discount / 100) * 100
-                ) / 100
-              }}
-            </text>
-            <text class="product-price-favour"
-              >¥{{ i.min_group_price / 100 }}</text
-            >
-          </view>
+          </template>
+          <!-- 淘宝 -->
+          <template v-else-if="platformObj.type == 2">
+            <view class="quan_box flex_r flex_as flex_wrap">
+              <view class="quan" v-if="i.coupon_discount > 0">
+                <span class="pl">券</span>
+                <span>¥{{ i.coupon_discount }}</span>
+              </view>
+              <view class="quan">
+                <span>赠付宝:</span>
+                <span>
+                  {{
+                    Math.floor(
+                      ((i.price_promotion_info.final_promotion_price *
+                        i.publish_info.income_rate) /
+                        100) *
+                        platformObj.ratio *
+                        100
+                    ) / 100
+                  }}
+                </span>
+              </view>
+              <view class="quan">
+                <span>赠茶宝:</span>
+                <span>
+                  {{
+                    Math.floor(
+                      i.price_promotion_info.final_promotion_price *
+                        platformObj.chabao *
+                        100
+                    ) / 100
+                  }}
+                </span>
+              </view>
+            </view>
+            <view class="product-price">
+              <text class="product-price-original">
+                <!-- // Math.floor(
+                  //   (i.min_group_price / 100 - i.coupon_discount / 100) * 100
+                  // ) / 100 -->
+                {{ i.price_promotion_info.final_promotion_price }}
+              </text>
+              <text class="product-price-favour">
+                ¥{{ i.price_promotion_info.zk_final_price }}
+              </text>
+            </view>
+          </template>
         </view>
       </view>
     </view>
@@ -126,30 +205,47 @@ export default {
   components: { notGoods },
   data() {
     return {
-      goods: [], // 精品推荐
+      goods: [], // 商品列表
       haveGoods: false, // 是否有商品
-      tabs: [], //分类
-      navIndex: 0,
-      sort: [], //分类
-      sortIndex: 0,
+      platform: [], //平台
+      navIndex: 0, // 平台索引
+      sort: [], //分类
+      sortIndex: 0, // 分类索引
       head: false,
-      cat_id: 0,
       keyword: "", // 搜索关键字
-      banner: {},
-      radio: 0
+      banner: {}, // 顶部背景图
+      ratio: 0, // 比例
+      platformObj: {
+        type: 1,
+      }, // 选中平台
+      catObj: {
+        cat_id: 0,
+        cat_name: "",
+      }, //选中的分类
     };
   },
   async onShow() {
-    this.getIcon()
+    // this.platform = [];
+    // this.navIndex = 0;
+    // this.platformObj = {
+    //   type: 1,
+    // };
+    // this.sortIndex = 0;
+    // this.sort = [];
+    // this.catObj = {
+    //   cat_id: 0,
+    //   cat_name: "",
+    // };
+
+    this.getIcon();
     uni.setTabBarStyle({
       color: "#999",
       selectedColor: "#E68B1E",
     });
-    page = 1;
-    this.goods = [];
+    // page = 1;
+    // this.goods = [];
     this.duoduoCats();
     this.goodsDay();
-    
   },
   onLoad(da) {
     this.getIcon();
@@ -157,6 +253,8 @@ export default {
       color: "#999",
       selectedColor: "#E68B1E",
     });
+    this.duoduoCats();
+    this.goodsDay();
   },
   onHide() {},
   onPageScroll(e) {
@@ -167,31 +265,64 @@ export default {
     }
   },
   methods: {
-    // 分类
+    // 获取平台
     getIcon() {
       post("v1/cashback/getIcon").then((res) => {
         if (res.code === 0) {
-          this.tabs = res.data;
-          console.log(this.tabs);
-          
-          this.radio = this.tabs[this.navIndex].ratio
-          console.log(this.radio);
-          
+          this.platform = res.data;
+          console.log(this.platform);
+          this.platformObj = this.platform[this.navIndex];
+          this.ratio = this.platform[this.navIndex].ratio;
+          console.log(this.ratio);
         } else {
           this.$toast(res.msg);
         }
       });
     },
+    // 获取拼多多平台下的分类
     duoduoCats() {
       post("v1/cashback/duoduoCats").then((res) => {
         if (res.code === 0) {
-          this.sort = res.data.cats;
+          if (this.platformObj.type == 1) {
+            this.sort = res.data.cats;
+          }
           this.banner = res.data.banner[0];
         } else {
           this.$toast(res.msg);
         }
       });
     },
+    // 获取淘宝平台下的分类
+    taobaoCats() {
+      post("v1/cashback/taobaoCats").then((res) => {
+        if (res.code === 0) {
+          this.sort = res.data.cats;
+          this.catObj = this.sort[0];
+        } else {
+          this.$toast(res.msg);
+        }
+      });
+    },
+    // 切换平台
+    changeNav(item, index) {
+      this.sortIndex = 0;
+      this.catObj = {
+        cat_id: 0,
+        cat_name: "",
+      };
+      this.sort = [];
+      this.platformObj = item;
+      this.navIndex = index;
+      if (this.platformObj.type == 1) {
+        this.duoduoCats();
+      } else if (this.platformObj.type == 2) {
+        this.taobaoCats();
+      }
+      page = 1;
+      this.goods = [];
+      this.goodsDay();
+    },
+    // 跳转
     toPage(url) {
       this.goto(url);
     },
@@ -200,30 +331,43 @@ export default {
       this.goods = [];
       this.goodsDay();
     },
+    // 搜索/切换分类
     search(item, index) {
+      this.catObj = item;
       this.sortIndex = index;
       page = 1;
       this.goods = [];
-      this.cat_id = item.cat_id;
       this.goodsDay();
     },
     // 获取商品列表
     goodsDay() {
       uni.showLoading();
       let that = this;
-      let data = { p: page, cat_id: this.cat_id, keyword: this.keyword };
-      post("v1/cashback/duoduoList", data)
-        .then((res) => {
-          uni.hideLoading();
-          if (res.code === 0) {
-            let obj = JSON.parse(res.data).goods_search_response.goods_list;
-            console.log(obj);
-
-            if (page <= 1) that.goods = [];
-            if (obj.length > 0) {
-              obj.forEach((e) => {
-                that.goods.push(e);
-              });
+      let data = {};
+      if (this.platformObj.type == 1) {
+        // post("v1/cashback/taobaoList",{cat:"女装"}).then((res) => {
+        data = { p: page, cat_id: this.catObj.cat_id, keyword: this.keyword };
+        post("v1/cashback/duoduoList", data)
+          .then((res) => {
+            uni.hideLoading();
+            if (res.code === 0) {
+              let obj = JSON.parse(res.data).goods_search_response.goods_list;
+              console.log(obj);
+
+              if (page <= 1) that.goods = [];
+              if (obj.length > 0) {
+                obj.forEach((e) => {
+                  that.goods.push(e);
+                });
+              } else {
+                if (page == 1) {
+                  that.haveGoods = true;
+                  page = -1;
+                } else {
+                  page = -1;
+                  this.$toast("暂无更多");
+                }
+              }
             } else {
               if (page == 1) {
                 that.haveGoods = true;
@@ -233,26 +377,103 @@ export default {
                 this.$toast("暂无更多");
               }
             }
-          } else {
-            if (page == 1) {
-              that.haveGoods = true;
-              page = -1;
+          })
+          .catch((e) => {
+            uni.hideLoading();
+          });
+      } else if (this.platformObj.type == 2) {
+        this.catObj.cat_name
+          ? (data = {
+              p: page,
+              cat: this.catObj.cat_name,
+              keyword: this.keyword,
+            })
+          : (data = { p: page, keyword: this.keyword });
+
+        post("v1/cashback/taobaoList", data)
+          .then((res) => {
+            uni.hideLoading();
+            if (res.code === 0) {
+              console.log(JSON.parse(res.data));
+              let obj = JSON.parse(res.data)
+                .tbk_dg_material_optional_upgrade_response.result_list.map_data;
+              console.log(obj);
+
+              obj.map((i) => {
+                let arr =
+                  i.price_promotion_info?.final_promotion_path_list
+                    ?.final_promotion_path_map_data || [];
+
+                if (arr.length > 0) {
+                  for (let ii = 0; ii < arr.length; ii++) {
+                    if (arr[ii].promotion_title == "商品券") {
+                      i.coupon_discount = arr[ii].promotion_fee;
+                      i.promotion_start_time = arr[ii].promotion_start_time;
+                      i.promotion_end_time = arr[ii].promotion_end_time;
+                    }
+                  }
+                } else {
+                  i.coupon_discount = 0;
+                  i.promotion_start_time = 0;
+                  i.promotion_end_time = 0;
+                }
+                return i;
+              });
+              if (page <= 1) that.goods = [];
+              if (obj.length > 0) {
+                obj.forEach((e) => {
+                  that.goods.push(e);
+                });
+              } else {
+                if (page == 1) {
+                  that.haveGoods = true;
+                  page = -1;
+                } else {
+                  page = -1;
+                  this.$toast("暂无更多");
+                }
+              }
             } else {
-              page = -1;
-              this.$toast("暂无更多");
+              if (page == 1) {
+                that.haveGoods = true;
+                page = -1;
+              } else {
+                page = -1;
+                this.$toast("暂无更多");
+              }
             }
-          }
-        })
-        .catch((e) => {
-          uni.hideLoading();
-        });
+          })
+          .catch((e) => {
+            uni.hideLoading();
+          });
+      }
     },
     // 跳转到商品详情页
-    NavToGoodsDetail(goods_sign) {
-      this.goto("/pagesC/shoppingMallType/p_details", {
-        goods_sign,
-        type: this.tabs[this.navIndex].type,
-      });
+    NavToGoodsDetail(item) {
+      if (this.platformObj.type == 1) {
+        this.goto("/pagesC/shoppingMallType/p_details", {
+          goods_sign: item.goods_sign,
+          type: this.platformObj.type,
+        });
+      } else if (this.platformObj.type == 2) {
+        this.goto("/pagesC/shoppingMallType/p_details", {
+          item_id: item.item_id,
+          type: this.platformObj.type,
+          annual_vol: item.item_basic_info.annual_vol,
+          yj_price:
+            Math.floor(
+              ((item.price_promotion_info.final_promotion_price *
+                item.publish_info.income_rate) /
+                100) *
+                this.platformObj.ratio *
+                100
+            ) / 100 || 0,
+          goods_price: item.price_promotion_info.final_promotion_price,
+          coupon_discount: item.coupon_discount,
+          promotion_start_time: item.promotion_start_time,
+          promotion_end_time: item.promotion_end_time,
+        });
+      }
     },
   },
   //页面上拉触底事件的处理函数
@@ -361,15 +582,17 @@ page {
   }
 
   .quan_box {
+    min-height: 88rpx;
     font-size: 20rpx;
     color: #e90406;
-    margin: 16rpx 0 0;
+    margin: 12rpx 0 0;
 
     .quan {
       padding: 2rpx 8rpx;
       border-radius: 8rpx;
       border: 1rpx solid rgba($color: #e90406, $alpha: 0.3);
       margin-right: 10rpx;
+      margin-top: 6rpx;
 
       .pl {
         padding-right: 10rpx;

+ 271 - 69
src/pagesC/shoppingMallType/index.vue

@@ -1,3 +1,4 @@
+<!-- type 1拼多多 2淘宝 -->
 <template>
   <div class="container">
     <view class="hander-top">
@@ -44,7 +45,7 @@
     <div class="nav_box flex_r flex_jb">
       <div
         class="item flex_c flex_ac"
-        v-for="(i, s) in tabs"
+        v-for="(i, s) in Channels"
         :key="s"
         @click="clickPd(i)"
       >
@@ -74,12 +75,18 @@
         class="product flex_r flex_jb flex_ac"
         v-for="(i, s) in goods"
         :key="s"
-        @click="NavToGoodsDetail(i.goods_sign)"
+        @click="NavToGoodsDetail(i)"
       >
-        <view class="image-view">
+        <view class="image-view" v-if="typeObj.type == 1">
           <image class="product-image" :src="i.goods_image_url"></image>
         </view>
-        <view class="content-view flex_c flex_jb">
+        <view class="image-view" v-if="typeObj.type == 2">
+          <image
+            class="product-image"
+            :src="i.item_basic_info.pict_url"
+          ></image>
+        </view>
+        <view class="content-view flex_c flex_jb" v-if="typeObj.type == 1">
           <view :class="['product-title', 'ellipsis2']">
             <span class="product-type">
               {{ typeObj.name }}
@@ -101,23 +108,87 @@
             </view>
             <view class="buyed"> {{ i.sales_tip }}人已购 </view>
           </view>
-          <view class="quan_box flex_r flex_ac">
+          <view class="quan_box flex_r flex_as flex_wrap">
             <view class="quan" v-if="i.has_coupon">
               <span class="pl">券</span>
               <span>¥{{ i.coupon_discount / 100 }}</span>
             </view>
             <view class="quan">
-              <span>返现</span>
-              <span
-                >¥{{
+              <span>赠付宝:</span>
+              <span>{{
+                Math.floor(
+                  (i.min_group_price / 100) *
+                    (i.promotion_rate / 1000) *
+                    ratio *
+                    100
+                ) / 100
+              }}</span>
+            </view>
+            <view class="quan">
+              <span>赠茶宝:</span>
+              <span>
+                {{
+                  Math.floor((i.min_group_price / 100 - i.coupon_discount / 100) * chabao_ratio * 100) /
+                  100
+                }}
+              </span>
+            </view>
+          </view>
+          <view class="shop"> {{ i.mall_name }} </view>
+        </view>
+        <view class="content-view flex_c flex_jb" v-else-if="typeObj.type == 2">
+          <view :class="['product-title', 'ellipsis2']">
+            <span class="product-type">
+              {{ typeObj.name }}
+            </span>
+            {{ i.item_basic_info.title }}
+          </view>
+          <view class="flex_r flex_jb flex_ae">
+            <view class="product-price">
+              <text class="product-price-original">
+                {{ i.price_promotion_info.final_promotion_price }}
+              </text>
+              <text class="product-price-favour"
+                >¥{{ i.price_promotion_info.zk_final_price }}</text
+              >
+            </view>
+            <view class="buyed">
+              {{ i.item_basic_info.annual_vol }}人已购
+            </view>
+          </view>
+          <view class="quan_box flex_r flex_as flex_wrap">
+            <view class="quan" v-if="i.coupon_discount > 0">
+              <span class="pl">券</span>
+              <span>¥{{ i.coupon_discount }}</span>
+            </view>
+            <view class="quan">
+              <span>赠付宝:</span>
+              <span>
+                {{
                   Math.floor(
-                    (i.min_group_price / 100) * (i.promotion_rate / 1000) *radio * 100
+                    ((i.price_promotion_info.final_promotion_price *
+                      i.publish_info.income_rate) /
+                      100) *
+                      ratio *
+                      100
                   ) / 100
-                }}</span
-              >
+                }}
+              </span>
+            </view>
+            <view class="quan">
+              <span>赠茶宝:</span>
+              <span>
+                {{
+                  Math.floor(
+                    i.price_promotion_info.final_promotion_price *
+                      chabao_ratio *
+                      100
+                  ) / 100
+                }}
+              </span>
             </view>
           </view>
-          <view class="shop"> {{ i.mall_name }} </view>
+          <view class="shop"> {{ i.item_basic_info.shop_title }} </view>
         </view>
       </view>
     </view>
@@ -165,37 +236,34 @@ export default {
     return {
       goods: [], // 精品推荐
       haveGoods: false, // 是否有商品
-      tabs: [],
-      navIndex: 0,
+      Channels: [], // 频道列表数据
       sort: [], // 小分类
-      sortIndex: 0,
+      sortIndex: 0, // 分类索引
       head: false,
-      cat_id: "",
-      channel: {},
-      typeObj: {},
-      keyword: "",
-      banner: {},
-      radio: 0
+      channel: {}, // 当前频道
+      typeObj: {}, // 当前平台
+      keyword: "", // 搜索关键字
+      banner: {}, // 顶部背景图
+      ratio: 0, // 赠送佣金比例
+      chabao_ratio: 0, // 赠送茶宝比例
+      catObj: {
+        cat_id: 0,
+        cat_name: "",
+      }, //选中的分类
     };
   },
   async onShow() {
-    uni.setNavigationBarTitle({
-      title: "拼多多购物",
-    });
     page = 1;
     this.goods = [];
     this.duoduoCats();
+    if (this.typeObj.type == 2) {
+      this.taobaoCats();
+    }
     this.goodsDay();
   },
   onLoad(da) {
-    uni.setTabBarStyle({
-      color: "#999",
-      selectedColor: "#E68B1E",
-    });
-    console.log(da);
-
     this.typeObj = da;
-    this.getIcon()
+    this.getIcon();
   },
   onHide() {},
   onPageScroll(e) {
@@ -215,27 +283,45 @@ export default {
       this.sortIndex = index;
       page = 1;
       this.goods = [];
-      this.cat_id = item.cat_id;
+      this.catObj = item;
       this.goodsDay();
     },
+    // 获取平台
     getIcon() {
       post("v1/cashback/getIcon").then((res) => {
         if (res.code === 0) {
           let tabs = res.data;
-          
-          this.radio = tabs[0].ratio
-          console.log(this.radio);
-          
+          let obj = tabs.filter((i) => {
+            return i.type == this.typeObj.type;
+          })[0];
+          this.ratio = obj.ratio;
+          this.chabao_ratio = obj.chabao;
+          console.log(this.ratio);
         } else {
           this.$toast(res.msg);
         }
       });
     },
+    // 获取淘宝平台下的分类
+    taobaoCats() {
+      post("v1/cashback/taobaoCats").then((res) => {
+        if (res.code === 0) {
+          this.sort = res.data.cats;
+          this.catObj = this.sort[0];
+          this.Channels = res.data.channel;
+        } else {
+          this.$toast(res.msg);
+        }
+      });
+    },
+    // 获取拼多多平台下的分类
     duoduoCats() {
       post("v1/cashback/duoduoCats").then((res) => {
         if (res.code === 0) {
-          this.sort = res.data.cats;
-          this.tabs = res.data.channel;
+          if (this.typeObj.type == 1) {
+            this.sort = res.data.cats;
+            this.Channels = res.data.channel;
+          }
           this.banner = res.data.banner[this.typeObj.type];
         } else {
           this.$toast(res.msg);
@@ -245,12 +331,37 @@ export default {
     toPage(url) {
       this.goto(url);
     },
+    // 点击频道事件
     clickPd(e) {
       console.log(e);
       this.channel = e;
+      let _this = this;
+      if (_this.typeObj.type == 1) {
+        _this.$refs.popup.open("center");
+      } else if (_this.typeObj.type == 2) {
+        post("v1/cashback/taobaoTpwd", {
+          material_id: _this.channel.activity_tags,
+        }).then((res) => {
+          if (res.code === 0) {
+            let data = JSON.parse(res.data).tbk_tpwd_create_response.data.model;
 
-      this.$refs.popup.open("center");
+            console.log(data);
+            uniCopy({
+              content: data,
+              success: (res) => {
+                uni.showToast({
+                  title: "商品链接已复制,请转到淘宝APP查看",
+                  icon: "none",
+                  duration: 2000,
+                });
+              },
+              error: (e) => {},
+            });
+          }
+        });
+      }
     },
+    // 拼多多复制链接
     copy() {
       let _this = this;
       post("v1/cashback/duoduoGs", {
@@ -298,6 +409,7 @@ export default {
         }
       });
     },
+    // 拼多多去下单
     toPdd() {
       let _this = this;
       post("v1/cashback/duoduoGs", {
@@ -351,19 +463,30 @@ export default {
     goodsDay() {
       uni.showLoading();
       let that = this;
-      let data = { p: page, cat_id: this.cat_id, keyword: this.keyword };
-      post("v1/cashback/duoduoList", data)
-        .then((res) => {
-          uni.hideLoading();
-          if (res.code === 0) {
-            let obj = JSON.parse(res.data).goods_search_response.goods_list;
-            console.log(obj);
-
-            if (page <= 1) that.goods = [];
-            if (obj.length > 0) {
-              obj.forEach((e) => {
-                that.goods.push(e);
-              });
+      let data = {};
+      if (this.typeObj.type == 1) {
+        data = { p: page, cat_id: this.catObj.cat_id, keyword: this.keyword };
+        post("v1/cashback/duoduoList", data)
+          .then((res) => {
+            uni.hideLoading();
+            if (res.code === 0) {
+              let obj = JSON.parse(res.data).goods_search_response.goods_list;
+              console.log(obj);
+
+              if (page <= 1) that.goods = [];
+              if (obj.length > 0) {
+                obj.forEach((e) => {
+                  that.goods.push(e);
+                });
+              } else {
+                if (page == 1) {
+                  that.haveGoods = true;
+                  page = -1;
+                } else {
+                  page = -1;
+                  this.$toast("暂无更多");
+                }
+              }
             } else {
               if (page == 1) {
                 that.haveGoods = true;
@@ -373,29 +496,105 @@ export default {
                 this.$toast("暂无更多");
               }
             }
-          } else {
-            if (page == 1) {
-              that.haveGoods = true;
-              page = -1;
+          })
+          .catch((e) => {
+            uni.hideLoading();
+          });
+      } else if (this.typeObj.type == 2) {
+        this.catObj.cat_name
+          ? (data = {
+              p: page,
+              cat: this.catObj.cat_name,
+              keyword: this.keyword,
+            })
+          : (data = { p: page, keyword: this.keyword });
+
+        post("v1/cashback/taobaoList", data)
+          .then((res) => {
+            uni.hideLoading();
+            if (res.code === 0) {
+              let obj = JSON.parse(res.data)
+                .tbk_dg_material_optional_upgrade_response.result_list.map_data;
+              console.log(obj);
+
+              obj.map((i) => {
+                let arr =
+                  i.price_promotion_info?.final_promotion_path_list
+                    ?.final_promotion_path_map_data || [];
+
+                if (arr.length > 0) {
+                  for (let ii = 0; ii < arr.length; ii++) {
+                    if (arr[ii].promotion_title == "商品券") {
+                      i.coupon_discount = arr[ii].promotion_fee;
+                      i.promotion_start_time = arr[ii].promotion_start_time;
+                      i.promotion_end_time = arr[ii].promotion_end_time;
+                    }
+                  }
+                } else {
+                  i.coupon_discount = 0;
+                  i.promotion_start_time = 0;
+                  i.promotion_end_time = 0;
+                }
+                return i;
+              });
+              if (page <= 1) that.goods = [];
+              if (obj.length > 0) {
+                obj.forEach((e) => {
+                  that.goods.push(e);
+                });
+              } else {
+                if (page == 1) {
+                  that.haveGoods = true;
+                  page = -1;
+                } else {
+                  page = -1;
+                  this.$toast("暂无更多");
+                }
+              }
             } else {
-              page = -1;
-              this.$toast("暂无更多");
+              if (page == 1) {
+                that.haveGoods = true;
+                page = -1;
+              } else {
+                page = -1;
+                this.$toast("暂无更多");
+              }
             }
-          }
-        })
-        .catch((e) => {
-          uni.hideLoading();
-        });
+          })
+          .catch((e) => {
+            uni.hideLoading();
+          });
+      }
     },
     onBack() {
       uni.navigateBack();
     },
     // 跳转到商品详情页
-    NavToGoodsDetail(goods_sign) {
-      this.goto("/pagesC/shoppingMallType/p_details", {
-        goods_sign,
-        type: this.typeObj.type,
-      });
+    NavToGoodsDetail(item) {
+      if (this.typeObj.type == 1) {
+        this.goto("/pagesC/shoppingMallType/p_details", {
+          goods_sign: item.goods_sign,
+          type: this.typeObj.type,
+        });
+      } else if (this.typeObj.type == 2) {
+        this.goto("/pagesC/shoppingMallType/p_details", {
+          item_id: item.item_id,
+          type: this.typeObj.type,
+          annual_vol: item.item_basic_info.annual_vol,
+          yj_price:
+            Math.floor(
+              ((item.price_promotion_info.final_promotion_price *
+                item.publish_info.income_rate) /
+                100) *
+                this.ratio *
+                100
+            ) / 100 || 0,
+          goods_price: item.price_promotion_info.final_promotion_price,
+          coupon_discount: item.coupon_discount,
+          promotion_start_time: item.promotion_start_time,
+          promotion_end_time: item.promotion_end_time,
+        });
+      }
     },
   },
   //页面上拉触底事件的处理函数
@@ -469,7 +668,9 @@ page {
   }
 
   .content-view {
+    width: calc(100% - 29vw);
     padding: 0 16rpx;
+    box-sizing: border-box;
   }
 
   .product-title {
@@ -524,6 +725,7 @@ page {
       border-radius: 8rpx;
       border: 1rpx solid rgba($color: #e90406, $alpha: 0.3);
       margin-right: 10rpx;
+      margin-top: 6rpx;
 
       .pl {
         padding-right: 10rpx;
@@ -680,7 +882,7 @@ page {
   margin: -50rpx 0 0;
   padding: 20rpx 20rpx 0;
   border-radius: 20rpx;
-  flex-wrap: wrap;
+  // flex-wrap: wrap;
   background-color: #f5f6f8;
 
   .item {

+ 233 - 120
src/pagesC/shoppingMallType/p_details.vue

@@ -14,7 +14,7 @@
     ></swiper-banner>
     <!-- 轮播图-end -->
     <!-- 价格信息栏 -->
-    <view class="price_info flex_r flex_ac flex_jb">
+    <view class="price_info flex_r flex_ac flex_jb" v-if="type == 1">
       <view class="price flex_c flex_jb">
         <view class="text1"> 到手价 </view>
         <view class="bottom">
@@ -25,7 +25,7 @@
         </view>
       </view>
       <view class="price flex_c flex_jb">
-        <view class="text4">预估下单</view>
+        <view class="text4">预估下单</view>
         <view class="text5 bottom">
           {{ yj_price }}
         </view>
@@ -35,10 +35,34 @@
         <view class="text7 bottom">{{ detail.sales_tip }}</view>
       </view>
     </view>
+    <view class="price_info flex_r flex_ac flex_jb" v-else-if="type == 2">
+      <view class="price flex_c flex_jb">
+        <view class="text1"> 到手价 </view>
+        <view class="bottom">
+          <span class="text2">
+            {{ goods_price }}
+          </span>
+          <text class="text3">¥{{ detail.reserve_price }}</text>
+        </view>
+      </view>
+      <view class="price flex_c flex_jb">
+        <view class="text4">预估下单获</view>
+        <view class="text5 bottom">
+          {{ yj_price }}
+        </view>
+      </view>
+      <view class="price flex_c flex_jb">
+        <view class="text6">销量</view>
+        <view class="text7 bottom">{{ decodeURIComponent(annual_vol) }}</view>
+      </view>
+    </view>
+    <view class="chabao">
+      预估下单获得茶宝:{{ Math.floor(goods_price * chabao_ratio * 100) / 100 }}
+    </view>
     <!-- 价格信息栏-end -->
     <!-- 标题信息栏 -->
     <view class="title_info">
-      <view class="goods_name">
+      <view class="goods_name" v-if="type == 1">
         <span class="product-type">
           {{
             tabs.filter((t) => {
@@ -48,7 +72,20 @@
         </span>
         {{ detail.goods_name }}
       </view>
-      <view class="quan flex_r flex_ac flex_jb" v-if="detail.has_coupon">
+      <view class="goods_name" v-else-if="type == 2">
+        <span class="product-type">
+          {{
+            tabs.filter((t) => {
+              return type == t.type;
+            })[0].name
+          }}
+        </span>
+        {{ detail.title }}
+      </view>
+      <view
+        class="quan flex_r flex_ac flex_jb"
+        v-if="type == 1 && detail.has_coupon"
+      >
         <view class="left flex_r flex_ac">
           <view class="quan_price">{{ detail.coupon_discount / 100 }}</view>
           <view class="flex_c time">
@@ -63,6 +100,24 @@
         <view class="split"></view>
         <view class="right" @click="buttonClick"> 立即领券 </view>
       </view>
+      <view
+        class="quan flex_r flex_ac flex_jb"
+        v-if="type == 2 && coupon_discount"
+      >
+        <view class="left flex_r flex_ac">
+          <view class="quan_price">{{ coupon_discount }}</view>
+          <view class="flex_c time">
+            <span>专属优惠券</span>
+            <span>
+              {{ $day(promotion_start_time/1000 *1000).format("YYYY.MM.DD") }}
+              -
+              {{ $day(promotion_end_time/1000 *1000).format("YYYY.MM.DD") }}
+            </span>
+          </view>
+        </view>
+        <view class="split"></view>
+        <view class="right" @click="buttonClick"> 立即领券 </view>
+      </view>
     </view>
     <view class="mall flex_r flex_ac">
       <img
@@ -70,7 +125,8 @@
         alt=""
         class="mall_img"
       />
-      <view class="text7 bottom">{{ detail.mall_name }}</view>
+      <view class="text7 bottom" v-if="type == 1">{{ detail.mall_name }}</view>
+      <view class="text7 bottom" v-else-if="type == 2">{{ detail.nick }}</view>
     </view>
     <!-- 标题信息栏-end -->
     <!-- 产品简介 -->
@@ -109,6 +165,7 @@ import swiperBanner from "@/components/swiperBanner/index.vue";
 import uniGoodsNav from "@/components/uni-goods-nav/uni-goods-nav.vue";
 import uniNumberBox from "@/components/uni-number-box/uni-number-box.vue";
 import authorizeModule from "@/components/authorize-module/index";
+import uniCopy from "@/utils/copy";
 export default {
   components: {
     mpHtml,
@@ -134,42 +191,42 @@ export default {
           color: "#fff",
         },
       ],
-      btnIndex: 0, // 用户点击按钮事件判断 0:加入购物车;1:立即购买
-      type: null, // 商品类型,1零售 2批发 3精品 4今日值买
-      goodsId: "", // 商品ID
+      type: null, // 平台类型,1拼多多 2淘宝 3京东 4抖音
       id: "", //合伙人套餐ID
       detail: {
         goods: {},
         goods_spec_list: [],
       }, // 商品详情
-      checked: false, //是否选中协议
-      buyNum: 1, //购买数量
-      pfway: "1", // 批发
-      qhway: "0", //提货方式
       shopInfo: {}, // 商铺信息
       // showAuth: false,
-
       userinfo: {},
       goodsDa: {},
       unid: "",
-      goodsSpecIndex: 0,
-      goodsAttrIndex: 0,
-      specId: "0",
-      attrId: "0",
-      afterSpecPrice: 0, // 规格选择后显示价格
       goods_price: 0, //到手价
       yj_price: 0, // 返利金额
       tabs: [],
       radio: 0, // 返利比例
+      annual_vol: "", //淘宝销量
+      chabao_ratio: 0, // 茶宝比例
+      coupon_discount: 0, //淘宝商品券
+      promotion_start_time: 0, // 淘宝商品券开始时间
+      promotion_end_time: 0, // 淘宝商品券到期时间
     };
   },
-  onLoad: function (e) {
+  onLoad(e) {
     console.log(e);
-    
     this.userinfo = uni.getStorageSync("userinfo");
     let token = uni.getStorageSync("token");
     this.type = e.type;
     this.goodsDa = e;
+    if (this.type == 2) {
+      this.yj_price = e.yj_price || 0;
+      this.goods_price = e.goods_price || 0;
+      this.annual_vol = e.annual_vol || 0;
+      this.coupon_discount = e.coupon_discount || 0;
+      this.promotion_start_time = e.promotion_start_time;
+      this.promotion_end_time = e.promotion_end_time;
+    }
     this.getIcon();
     this.loadData(e);
 
@@ -182,97 +239,149 @@ export default {
       post("v1/cashback/getIcon").then((res) => {
         if (res.code === 0) {
           this.tabs = res.data;
-          this.radio = this.tabs[0].ratio
+          let obj = this.tabs.filter((i) => {
+            return i.type == this.type;
+          })[0];
+          this.radio = obj.ratio;
+          this.chabao_ratio = obj.chabao;
         }
       });
     },
     // 商品详情信息
     loadData(da) {
-      post("v1/cashback/duoduoInfo", da).then((res) => {
-        if (res.code === 0) {
-          this.detail = JSON.parse(
-            res.data
-          ).goods_detail_response.goods_details[0];
-          this.detail.goods_img = this.detail.goods_gallery_urls;
-          this.goods_price =
-            Math.floor(
-              (this.detail.min_group_price / 100 -
-                this.detail.coupon_discount / 100) *
-                100
-            ) / 100;
-
-          this.yj_price =
-            Math.floor(
-              (this.detail.min_group_price / 100) *
-                (this.detail.promotion_rate / 1000) * this.radio*
-                100
-            ) / 100;
-
-          this.buttonGroup[1].text =
-            "下单省\n¥" + (this.yj_price + this.detail.coupon_discount / 100);
-        } else {
-          uni.showModal({
-            title: "提示",
-            content: res.msg,
-            showCancel: false,
-            success: function (res) {
-              if (res) {
-                uni.navigateBack({
-                  delta: 1,
-                });
-              }
-            },
-          });
-        }
-      });
+      if (this.type == 1) {
+        post("v1/cashback/duoduoInfo", da).then((res) => {
+          if (res.code === 0) {
+            this.detail = JSON.parse(
+              res.data
+            ).goods_detail_response.goods_details[0];
+            this.detail.goods_img = this.detail.goods_gallery_urls;
+
+            this.goods_price =
+              Math.floor(
+                (this.detail.min_group_price / 100 -
+                  this.detail.coupon_discount / 100) *
+                  100
+              ) / 100;
+
+            this.yj_price =
+              Math.floor(
+                (this.detail.min_group_price / 100) *
+                  (this.detail.promotion_rate / 1000) *
+                  this.radio *
+                  100
+              ) / 100;
+
+            this.buttonGroup[1].text =
+              "下单省\n¥" +
+              (this.yj_price + this.detail.coupon_discount / 100);
+          } else {
+            uni.showModal({
+              title: "提示",
+              content: res.msg,
+              showCancel: false,
+              success: function (res) {
+                if (res) {
+                  uni.navigateBack({
+                    delta: 1,
+                  });
+                }
+              },
+            });
+          }
+        });
+      } else if (this.type == 2) {
+        post("v1/cashback/taobaoInfo", da).then((res) => {
+          if (res.code === 0) {
+            this.detail = JSON.parse(
+              res.data
+            ).tbk_item_info_get_response.results.n_tbk_item[0];
+            console.log(this.detail, "----");
+
+            this.detail.goods_img = this.detail?.small_images?.string || [
+              this.detail.pict_url,
+            ];
+            console.log(
+              Number(this.detail.reserve_price),
+              Number(this.goods_price),
+              Number(this.yj_price)
+            );
+
+            this.buttonGroup[1].text =
+              "下单省\n¥" +
+              (Number(this.detail.reserve_price) -
+                Number(this.goods_price) +
+                Number(this.yj_price));
+          } else {
+            uni.showModal({
+              title: "提示",
+              content: res.msg,
+              showCancel: false,
+              success: function (res) {
+                if (res) {
+                  uni.navigateBack({
+                    delta: 1,
+                  });
+                }
+              },
+            });
+          }
+        });
+      }
     },
-    // 去购买
-    ToPayPage: function () {},
     // 点击底部主页购物车等按钮
     onClick(e) {
       console.log(e, "onClick");
     },
     // 点击立即购买或加入购物车
     buttonClick: function (e) {
+      let _this = this;
       if (e.index === 0) {
-        // console.log(111);
-        //   uni.share({
-        //     provider: "weixin",
-        //     scene: "WXSceneSession",
-        //     type: 5,
-        //     imageUrl: _this.detail.goods_image_url,
-        //     title: _this.detail.goods_name,
-        //     miniProgram: {
-        //       id: "gh_e871cdeb44e1",
-        //       path: "pagesC/shoppingMallType/p_details",
-        //       type: 1,
-        //       webUrl: "",
-        //     },
-        //     success: (ret) => {
-        //       console.log(JSON.stringify(ret));
-        //     },
-        //   });
       } else {
-        let _this = this;
-        post("v1/cashback/duoduoZs", {
-          goods_sign: _this.detail.goods_sign,
-        }).then((res) => {
-          if (res.code === 0) {
-            let data = JSON.parse(res.data)
-              .goods_promotion_url_generate_response
-              .goods_promotion_url_list[0];
-            console.log(data);
-            wx.navigateToMiniProgram({
-              shortLink: data.weixin_short_link, //上图找到目标小程序的链接
-              //develop开发版;trial体验版;release正式版
-              envVersion: "release",
-              success(res1) {
-                // 打开成功
-                console.log("跳转小程序成功!", res1);
-              },
-            });
-          }
-        });
+        if (this.type == 1) {
+          post("v1/cashback/duoduoZs", {
+            goods_sign: _this.detail.goods_sign,
+          }).then((res) => {
+            if (res.code === 0) {
+              let data = JSON.parse(res.data)
+                .goods_promotion_url_generate_response
+                .goods_promotion_url_list[0];
+              console.log(data);
+              wx.navigateToMiniProgram({
+                shortLink: data.weixin_short_link, //上图找到目标小程序的链接
+                //develop开发版;trial体验版;release正式版
+                envVersion: "release",
+                success(res1) {
+                  // 打开成功
+                  console.log("跳转小程序成功!", res1);
+                },
+              });
+            }
+          });
+        } else if (this.type == 2) {
+          post("v1/cashback/taobaoUrl", {
+            item_id: _this.detail.input_num_iid,
+          }).then((res) => {
+            if (res.code === 0) {
+              let data = JSON.parse(res.data)
+                .tbk_dg_general_link_convert_response.data.item_url_list
+                .item_url_list[0].link_info_dto.coupon_full_tpwd;
+
+              console.log(data);
+              uniCopy({
+                content: data,
+                success: (res) => {
+                  uni.showToast({
+                    title: "商品链接已复制,请转到淘宝APP查看",
+                    icon: "none",
+                    duration: 2000,
+                  });
+                },
+                error: (e) => {},
+              });
+            }
+          });
+        }
       }
     },
 
@@ -303,33 +412,33 @@ export default {
       });
       // #endif
     },
-    // onauthGetTelSuccess(da) {
-    //     this.SoHAuth();
-    //     post("v1/getMobile", {
-    //         unid: this.unid,
-    //         ...da.detail,
-    //     }).then((res) => {
-    //         if (res.code === 0) {
-    //             uni.setStorageSync("token", res.data.token);
-    //             this.getuserInfo();
-    //         }
-    //     });
-    // },
     async getuserInfo() {
       this.userinfo = await uni.userfun();
     },
   },
   onShareAppMessage() {
     // let userinfo = uni.getStorageSync("userinfo");
-    var path = `pagesC/shoppingMallType/p_details?goods_sign=${this.detail.goods_sign}&type=${this.type}`;
-    var title = this.detail.goods_name;
-    console.log(this.detail.goods_name);
-
-    return {
-      title: title,
-      path: path,
-      imageUrl: this.detail.goods_image_url,
-    };
+    if (this.type == 1) {
+      var path = `pagesC/shoppingMallType/p_details?goods_sign=${this.detail.goods_sign}&type=${this.type}`;
+      var title = this.detail.goods_name;
+      console.log(this.detail.goods_name);
+
+      return {
+        title: title,
+        path: path,
+        imageUrl: this.detail.goods_image_url,
+      };
+    } else if (this.type == 2) {
+      var path = `pagesC/shoppingMallType/p_details?item_id=${this.detail.input_num_iid}&type=${this.type}&goods_price=${this.goods_price}&yj_price=${this.yj_price}&annual_vol=${this.annual_vol}&coupon_discount=${this.coupon_discount}&promotion_start_time=${this.promotion_start_time}&promotion_end_time=${this.promotion_end_time}`;
+      var title = this.detail.title;
+      console.log(this.detail.goods_name);
+
+      return {
+        title: title,
+        path: path,
+        imageUrl: this.detail.pict_url,
+      };
+    }
   },
 };
 </script>
@@ -424,7 +533,7 @@ page {
     width: 70%;
     height: 150rpx;
     box-sizing: border-box;
-    padding: 0 40rpx;
+    padding: 0 20rpx;
     border-radius: 15rpx;
     background-color: #ffeff0;
 
@@ -707,7 +816,11 @@ page {
     padding: 0 16rpx;
   }
 }
-
+.chabao {
+  font-size: 24rpx;
+  color: #999;
+  padding: 0 20rpx 20rpx;
+}
 // 商品规格样式-start
 .goods_spec {
   font-size: 28rpx;