Quellcode durchsuchen

feat: 调整数据接口

xiansin vor 2 Jahren
Ursprung
Commit
d6f32ec2d7

+ 1 - 1
mini/api/user/episode.js

xqd
@@ -7,7 +7,7 @@ const request = uni.$u.http
 export function record(params) {
   return request.get(
     'user/watch/record',
-    params
+    { params }
   )
 }
 export function deleteRecord(id) {

+ 3 - 0
mini/api/user/index.js

xqd
@@ -30,6 +30,9 @@ export async function login() {
         // #ifdef  MP-TOUTIAO
         const url = '/auth/bytedance'
         // #endif
+        // #ifdef  MP-WEIXIN
+        const url = '/auth/wechat'
+        // #endif
 
         return request.post(
           url,

+ 3 - 1
mini/components/Episode/index.vue

xqd xqd
@@ -4,7 +4,7 @@
       <view v-if="rank" class="rank" :class="{first: rank === 1}">
         <text>{{ rank }}</text>
       </view>
-      <image :src="episode.cover_img" mode="aspectFill" :style="[imageStyle]" />
+      <image :src="episode.cover_img" :style="[imageStyle]" />
       <view v-if="recent" class="special">最近播放 </view>
       <view v-if="guess" class="special guess">猜你喜欢 </view>
     </view>
@@ -112,6 +112,8 @@ export default {
           bottom: 0;
           width: 100%;
           font-size: 26rpx;
+          border-bottom-left-radius: 20rpx;
+          border-bottom-right-radius: 20rpx;
           &.guess{
             background: rgba(124, 78, 112, 0.65);
           }

+ 1 - 0
mini/components/SwiperBox/index.vue

xqd
@@ -20,6 +20,7 @@
       :show-title="true"
       indicator-mode="dot"
       :indicator-style="{bottom: '24rpx'}"
+      img-mode=""
       @click="handleClick"
       @change="handleChange"
     >

+ 14 - 2
mini/pages/my/consume.vue

xqd xqd
@@ -44,6 +44,9 @@
 export default {
   data() {
     return {
+      limit: 10,
+      page: 1,
+      isMore: true,
       consume: [],
       datePicker: {
         date: uni.$u.timeFormat(Number(new Date()), 'yyyy-mm'),
@@ -75,14 +78,23 @@ export default {
     },
     getConsume() {
       this.$loading()
-      this.$api.user.consume.record({ date: this.datePicker.date }).then(res => {
+      this.$api.user.consume.record({ date: this.datePicker.date, limit: this.limit, page: this.page }).then(res => {
         this.$hideLoading()
-        this.consume = res.data
+        if (res.data.length) {
+          this.consume = this.consume.concat(res.data)
+        } else {
+          this.isMore = false
+        }
       })
     }
   },
   onLoad() {
     this.getConsume()
+  },
+  onReachBottom(e) {
+    if (!this.isMore) return
+    this.page += 1
+    this.getConsume()
   }
 }
 </script>

+ 14 - 2
mini/pages/my/history.vue

xqd xqd
@@ -38,6 +38,9 @@ export default {
   components: { UModal },
   data() {
     return {
+      limit: 10,
+      page: 1,
+      isMore: true,
       history: [],
       modal: {
         show: false,
@@ -72,14 +75,23 @@ export default {
     },
     getHistory() {
       this.$loading()
-      this.$api.user.episode.record().then(res => {
+      this.$api.user.episode.record({ limit: this.limit, page: this.page }).then(res => {
         this.$hideLoading()
-        this.history = res.data
+        if (res.data.length) {
+          this.history = this.history.concat(res.data)
+        } else {
+          this.isMore = false
+        }
       })
     }
   },
   onLoad() {
     this.getHistory()
+  },
+  onReachBottom(e) {
+    if (!this.isMore) return
+    this.page += 1
+    this.getHistory()
   }
 }
 </script>

+ 2 - 2
mini/pages/my/index.vue

xqd xqd
@@ -99,7 +99,7 @@ export default {
   },
   methods: {
     getHistory() {
-      this.$api.user.episode.record().then(res => {
+      this.$api.user.episode.record({ limit: 3 }).then(res => {
         this.history = res.data
       })
     },
@@ -179,7 +179,7 @@ export default {
       })
     }
   },
-  onLoad() {
+  onShow() {
     this.getHistory()
   }
 }

+ 14 - 2
mini/pages/my/recharge.vue

xqd xqd
@@ -51,6 +51,9 @@
 export default {
   data() {
     return {
+      limit: 10,
+      page: 1,
+      isMore: true,
       recharge: [],
       datePicker: {
         date: uni.$u.timeFormat(Number(new Date()), 'yyyy-mm'),
@@ -73,14 +76,23 @@ export default {
     },
     getRecharge() {
       this.$loading()
-      this.$api.user.recharge.record({ date: this.datePicker.date }).then(res => {
+      this.$api.user.recharge.record({ date: this.datePicker.date, limit: this.limit, page: this.page }).then(res => {
         this.$hideLoading()
-        this.recharge = res.data
+        if (res.data.length) {
+          this.recharge = this.recharge.concat(res.data)
+        } else {
+          this.isMore = false
+        }
       })
     }
   },
   onLoad() {
     this.getRecharge()
+  },
+  onReachBottom(e) {
+    if (!this.isMore) return
+    this.page += 1
+    this.getConsume()
   }
 }
 </script>

+ 2 - 2
mini/setting.js

xqd
@@ -7,7 +7,7 @@ module.exports = {
   // 版本
   VERSION: '0.0.1',
   // API 接口URL
-  BASE_URL: IS_DEV ? 'http://www.zsy.me/api' : 'https://t3.9026.com/api',
+  BASE_URL: IS_DEV ? 'http://www.zsy.me/api' : 'https://zhangsiye.9026.com/api',
   // API 接口URL
-  IMAGE_URL: IS_DEV ? 'http://www.zsy.me/static/image' : 'https://t3.9026.com/static/image'
+  IMAGE_URL: IS_DEV ? 'http://www.zsy.me/static/image' : 'https://zhangsiye.9026.com/static/image'
 }

+ 7 - 1
server/app/Http/Controllers/V1/User/ConsumeController.php

xqd xqd
@@ -13,6 +13,9 @@ class ConsumeController extends Controller
 {
     public function record(Request $request)
     {
+        $limit = $request->input('limit', 10);
+        $page = $request->input('page', 1);
+        $offset = ($page - 1) * 10;
         $date = $request->input('date');
         $date= $date??Carbon::now()->format('Y-m');
         $lists  = UserEpisodesRecord::filterUser()
@@ -21,7 +24,10 @@ class ConsumeController extends Controller
                 return $query->where('created_at', 'like', "$date%");
             })
             ->with(['detail.episode'])
-            ->orderByDesc('id')->get();
+            ->orderByDesc('id')
+            ->limit($limit)
+            ->offset($offset)
+            ->get();
 
         foreach ($lists as $list){
             $count = $list->detail->episode->withCount('lists')->first()->toArray();

+ 5 - 0
server/app/Http/Controllers/V1/User/RechargeController.php

xqd xqd
@@ -19,6 +19,9 @@ class RechargeController extends Controller
 {
     public function record(Request $request)
     {
+        $limit = $request->input('limit', 10);
+        $page = $request->input('page', 1);
+        $offset = ($page - 1) * 10;
         $date = $request->input('date');
         $date= $date??Carbon::now()->format('Y-m');
         $lists  = UserRechargeRecord::filterUser()
@@ -28,6 +31,8 @@ class RechargeController extends Controller
             })
             ->where('status', 1)
             ->orderByDesc('id')
+            ->limit($limit)
+            ->offset($offset)
             ->get();