Просмотр исходного кода

Merge branch 'dev-ryan' of gitee.com:beijing_hongye_huicheng/lilishop-uniapp into dev-ryan

Chopper 5 лет назад
Родитель
Сommit
5c67c608bc
4 измененных файлов с 140 добавлено и 36 удалено
  1. 2 1
      api/promotions.js
  2. 2 2
      config/api.js
  3. 2 2
      manifest.json
  4. 134 31
      pages/promotion/lives.vue

+ 2 - 1
api/promotions.js

@@ -9,10 +9,11 @@ import { http, Method } from "@/utils/request.js";
  * @param {*}
  * @param {*}
  * @returns
  * @returns
  */
  */
-export function getLiveList() {
+export function getLiveList(params) {
   return http.request({
   return http.request({
     url: `broadcast/studio`,
     url: `broadcast/studio`,
     method: Method.GET,
     method: Method.GET,
+    params
   });
   });
 }
 }
 
 

+ 2 - 2
config/api.js

@@ -4,8 +4,8 @@
  */
  */
 // 开发环境
 // 开发环境
 const dev = {
 const dev = {
-  common: 'http://192.168.0.100:8890',
-  buyer: 'http://192.168.0.100:8888',
+  common: "http://192.168.0.100:8890",
+  buyer: "http://192.168.0.100:8888",
   // common: "https://common-api.pickmall.cn",
   // common: "https://common-api.pickmall.cn",
   // buyer: "https://buyer-api.pickmall.cn",
   // buyer: "https://buyer-api.pickmall.cn",
 };
 };

+ 2 - 2
manifest.json

@@ -185,7 +185,7 @@
         "setting" : {
         "setting" : {
             "urlCheck" : false,
             "urlCheck" : false,
             "minified" : true,
             "minified" : true,
-            "postcss" : true,
+            "postcss" : false,
             "es6" : true
             "es6" : true
         },
         },
         "permission" : {
         "permission" : {
@@ -221,6 +221,6 @@
             }
             }
         },
         },
         "title" : "lilishop",
         "title" : "lilishop",
-        "template" : "/pages/passport/appleLogin.html"
+        "template" : ""
     }
     }
 }
 }

+ 134 - 31
pages/promotion/lives.vue

@@ -2,14 +2,14 @@
   <div class="box">
   <div class="box">
     <u-navbar class="navbar">
     <u-navbar class="navbar">
       <view class="slot-wrap">
       <view class="slot-wrap">
-        <u-search placeholder="搜索直播间" v-model="keyword"></u-search>
+        <u-search placeholder="搜索直播间" @custom="searchLive" @clear="clear" @search="searchLive" v-model="keyword"></u-search>
       </view>
       </view>
     </u-navbar>
     </u-navbar>
     <!-- 轮播图 -->
     <!-- 轮播图 -->
-    <u-swiper class="swiper" :effect3d="true" :list="swiperImg">
+    <u-swiper @click="clickSwiper" class="swiper" :effect3d="true" :list="swiperImg">
 
 
     </u-swiper>
     </u-swiper>
-    <u-tabs :is-scroll="false" :active-color="activeColor" inactive-color="#606266" ref="tabs" :list="tabs"></u-tabs>
+    <u-tabs :is-scroll="false" @change="changeTabs" :current="current" :active-color="activeColor" inactive-color="#606266" ref="tabs" :list="tabs"></u-tabs>
 
 
     <div class="wrapper">
     <div class="wrapper">
       <!-- 直播中 全部 直播回放 -->
       <!-- 直播中 全部 直播回放 -->
@@ -29,21 +29,19 @@
             {{item.name}}
             {{item.name}}
           </div>
           </div>
           <div class="live-store">
           <div class="live-store">
-
             <span class="wes">lilishop</span>
             <span class="wes">lilishop</span>
           </div>
           </div>
-        
           <div class="live-goods-list">
           <div class="live-goods-list">
             <div class="live-goods-item">
             <div class="live-goods-item">
-              <u-image border-radius="20" :src="item.roomGoodsList.length !=0 ? item.roomGoodsList[0] : ''" height="140"></u-image>
+              <u-image border-radius="20" :src="item.roomGoodsList ? item.roomGoodsList[0] : ''" height="140"></u-image>
             </div>
             </div>
             <div class="live-goods-item">
             <div class="live-goods-item">
-              <u-image border-radius="20" :src="item.roomGoodsList.length !=0 ? item.roomGoodsList[1] : ''" height="140"></u-image>
+              <u-image border-radius="20" :src="item.roomGoodsList ? item.roomGoodsList[1] : ''" height="140"></u-image>
             </div>
             </div>
-
           </div>
           </div>
         </div>
         </div>
       </div>
       </div>
+      <u-loadmore bg-color="transparent" :status="status" />
     </div>
     </div>
   </div>
   </div>
 </template>
 </template>
@@ -53,8 +51,10 @@ import { getLiveList } from "@/api/promotions.js";
 export default {
 export default {
   data() {
   data() {
     return {
     return {
+      status: "loadmore",
       activeColor: this.$lightColor,
       activeColor: this.$lightColor,
-      keyword: "",
+      current: 0, // 当前tabs索引
+      keyword: "", //搜索直播间
       // 标签栏
       // 标签栏
       tabs: [
       tabs: [
         {
         {
@@ -63,27 +63,36 @@ export default {
         {
         {
           name: "全部",
           name: "全部",
         },
         },
-
-        {
-          name: "回放",
-        },
       ],
       ],
       // 导航栏的配置
       // 导航栏的配置
       background: {
       background: {
         background: "#ff9f28",
         background: "#ff9f28",
       },
       },
-      // 直播间列表
-      liveList: "",
-      //轮播图滚动的图片
-      swiperImg: [
+      // 直播间params
+      params: [
         {
         {
-          image:
-            "https://lilishop-oss.oss-cn-beijing.aliyuncs.com/8e33ab68ef734558bdc158d6b1b1451f.png",
+          pageNumber: 1,
+          pageSize: 10,
+          status: "START",
         },
         },
         {
         {
-          image:
-            "https://lilishop-oss.oss-cn-beijing.aliyuncs.com/5ec999c942374e849d085071b4d20a19.jpeg",
+          pageNumber: 1,
+          pageSize: 4,
         },
         },
+      ],
+      // 推荐直播间Params
+      recommendParams: {
+        pageNumber: 1,
+        pageSize: 3,
+        recommend: 0,
+      },
+      // 直播间列表
+      liveList: [],
+      // 推荐直播间列表
+      recommendLiveList: [],
+
+      //轮播图滚动的图片
+      swiperImg: [
         {
         {
           image:
           image:
             "https://lilishop-oss.oss-cn-beijing.aliyuncs.com/48d789cb9c864b7b87c1c0f70996c3e8.jpeg",
             "https://lilishop-oss.oss-cn-beijing.aliyuncs.com/48d789cb9c864b7b87c1c0f70996c3e8.jpeg",
@@ -91,29 +100,123 @@ export default {
       ],
       ],
     };
     };
   },
   },
-  mounted() {
+  onShow() {
+    this.getLives();
+    this.getRecommendLives();
+  },
+  onReachBottom() {
+    this.params[this.current].pageNumber++;
     this.getLives();
     this.getLives();
   },
   },
   methods: {
   methods: {
     /**
     /**
-     *
+     * 点击标签栏切换
+     */
+    changeTabs(index) {
+      this.current = index;
+      this.init();
+    },
+
+    /**
+     * 初始化直播间
+     */
+    init() {
+      this.liveList = [];
+      this.status = "loadmore";
+      this.getLives();
+    },
+
+    /**
+     * 清除搜索内容
+     */
+    clear() {
+      delete this.params[this.current].name;
+      this.init();
+    },
+    /**
+     * 点击顶部推荐直播间
+     */
+    clickSwiper(val) {
+      console.log(this.swiperImg[val])
+      this.handleLivePlayer(this.swiperImg[val]);
+    },
+
+    /**
+     * 搜索直播间
+     */
+    searchLive(val) {
+      this.params[this.current].name = val;
+      this.init();
+    },
+    /**
+     * 获取推荐直播间
+     */
+    async getRecommendLives() {
+      this.status = "loading";
+      let recommendLives = await getLiveList(this.recommendParams);
+      if (recommendLives.data.success) {
+        // 推荐直播间
+        if (recommendLives.data.result.records.length != 0) {
+          this.status = "loadmore";
+          this.recommendLives = recommendLives.data.result.records;
+        } else {
+          this.status = "noMore";
+        }
+
+        /**
+         * 如果推荐直播间没有的情况下
+         * 1.获取直播间第一个图片
+         * 2.如果没有直播间设置一个默认图片
+         */
+
+        if (this.recommendLives.length == 0) {
+          if (this.liveList[0].shareImg) {
+            this.$set(this, "swiperImg", [
+              {
+                image: this.liveList[0].shareImg,
+                roomId: this.liveList[0].roomId,
+              },
+            ]);
+          }
+        } else {
+          this.recommendLives.forEach((item) => {
+            this.$set(this, "swiperImg", [
+              { image: item.shareImg, roomId: item.roomId },
+            ]);
+          });
+        }
+      }
+    },
+
+    /**
+     * 获取直播间
      */
      */
     async getLives() {
     async getLives() {
-      let res = await getLiveList();
+      this.status = "loading";
+      let res = await getLiveList(this.params[this.current]);
+      // 直播间
       if (res.data.success) {
       if (res.data.success) {
-        this.liveList = res.data.result.records;
+        if (res.data.result.records.length != 0) {
+          this.status = "loadmore";
+          this.liveList.push(...res.data.result.records);
+        } else {
+          this.status = "noMore";
+        }
+        res.data.result.total >
+        this.params[this.current].pageNumber *
+          this.params[this.current].pageSize
+          ? (this.status = "loadmore")
+          : (this.status = "noMore");
 
 
+        console.log(this.status);
         this.liveList.forEach((item) => {
         this.liveList.forEach((item) => {
-          console.log();
+          if (item.roomGoodsList) {
+            item.roomGoodsList = JSON.parse(item.roomGoodsList);
+          }
         });
         });
       }
       }
     },
     },
 
 
-    /**
-     * 推荐直播间
-     */
-    async getStarLive() {},
-
     /**
     /**
      * 进入直播间
      * 进入直播间
      */
      */