Browse Source

开发,并抽离广告部分组件

sunxf 2 years ago
parent
commit
d4a3b82fb0

+ 5 - 1
api/user.js

@@ -4,5 +4,9 @@ import {
 
 module.exports = {
     //获取用户信息
-    getUserInfo: data => request('/user/my', 'get', data),
+    getUserInfo: data => request('/v3/user/my', 'get', data),
+    //获取自己朗读的作品
+    getSelfRead: data => request('/userRead/my', 'get', data),
+    //获取用户朗读的作品
+    getUserRead: data => request('/userRead', 'get', data),
 }

+ 1 - 0
app.json

@@ -1,6 +1,7 @@
 {
     "pages": [
         "pages/my/index",
+        "pages/userWorks/index",
         "pages/index/index",
         "pages/login/login",
         "pages/reading/reading",

+ 57 - 0
component/rewardedVideo/index.js

@@ -0,0 +1,57 @@
+var videoAd = null;
+Component({
+    /**
+     * 组件的属性列表
+     */
+    properties: {
+
+    },
+    lifetimes: {
+        attached() {
+            if (wx.createRewardedVideoAd) {
+                // 加载激励视频广告
+                videoAd = wx.createRewardedVideoAd({
+                    adUnitId: 'adunit-77f46b2dc73da123'
+                })
+                //捕捉错误
+                videoAd.onError(err => {
+                    console.log(err);
+                })
+                // 监听关闭
+                videoAd.onClose((status) => {
+                    if (status && status.isEnded || status === undefined) {
+                        // 正常播放结束,下发奖励
+                        // continue you code
+                    } else {
+                        // 播放中途退出,进行提示
+                        wx.showToast({
+                            icon: 'none',
+                            title: '取消观看',
+                        })
+                    }
+                })
+            }
+        }
+    },
+    /**
+     * 组件的初始数据
+     */
+    data: {
+
+    },
+
+    /**
+     * 组件的方法列表
+     */
+    methods: {
+        rewardedVideo() {
+            if (videoAd) {
+                videoAd.show().catch(err => {
+                    // 失败重试
+                    videoAd.load()
+                        .then(() => videoAd.show())
+                })
+            }
+        }
+    }
+})

+ 4 - 0
component/rewardedVideo/index.json

@@ -0,0 +1,4 @@
+{
+    "component": true,
+    "usingComponents": {}
+}

+ 1 - 0
component/rewardedVideo/index.wxml

@@ -0,0 +1 @@
+<view></view>

+ 1 - 0
component/rewardedVideo/index.wxss

@@ -0,0 +1 @@
+/* component/rewardedVideo/index.wxss */

+ 171 - 176
component/video-swiper/index.wxml

@@ -1,182 +1,177 @@
 <view class="swiper_container">
-  <swiper wx:if="{{isSwiper}}" class="video-swiper" circular="{{circular}}" easing-function="{{easingFunction}}" vertical current="0" duration="{{duration}}" next-margin="{{nextMargin}}" bindanimationfinish="animationfinish">
-    <!-- curQueue 循环会导致video重新插入,objectFit 不可变更 -->
-    <swiper-item class="swiper_item" wx:for="{{curQueue}}" data-id="{{item.id}}" wx:key="id">
-      <view class="head_box">
-        <image class="tag_icon" wx:if="{{item.hasTag}}" src="{{item.tagUrl}}" />
-        <view class="user_box" catchtap="{{ifHeadTap ? 'headTap' : null}}" data-uid="{{item.uid}}">
-          <image class="avatar" lazy-load="true" src="{{item.avatar}}" />
-          <image class="avatar_fans" src="../../static/index/add_follow.png" />
-          <view class="user_right">
-            <view class="nickname">{{item.nickName}}</view>
-            <image class="efun_tag" src="../../static/index/efun_tag.png" wx:if="{{item.isEfun}}"></image>
-          </view>
+    <swiper wx:if="{{isSwiper}}" class="video-swiper" circular="{{circular}}" easing-function="{{easingFunction}}"
+        vertical current="0" duration="{{duration}}" next-margin="{{nextMargin}}" bindanimationfinish="animationfinish">
+        <!-- curQueue 循环会导致video重新插入,objectFit 不可变更 -->
+        <swiper-item class="swiper_item" wx:for="{{curQueue}}" data-id="{{item.id}}" wx:key="id">
+            <view class="head_box">
+                <image class="tag_icon" wx:if="{{item.hasTag}}" src="{{item.tagUrl}}" />
+                <view class="user_box" catchtap="{{ifHeadTap ? 'headTap' : null}}" data-uid="{{item.uid}}">
+                    <image class="avatar" lazy-load="true" src="{{item.avatar}}" />
+                    <image class="avatar_fans" src="../../static/index/add_follow.png" />
+                    <view class="user_right">
+                        <view class="nickname">{{item.nickName}}</view>
+                        <image class="efun_tag" src="../../static/index/efun_tag.png" wx:if="{{item.isEfun}}"></image>
+                    </view>
+                </view>
+                <view wx:if="{{!item.showMyBtn}}" class="time">
+                    <text>发布时间:{{item.time}}</text>
+                </view>
+                <view wx:if="{{item.showMyBtn}}" class="my_btn">
+                    <view catchtap="delete" data-id="{{item.id}}">
+                        <image src="../../static/index/delete.png" />
+                        <text>删除</text>
+                    </view>
+                    <view catchtap="hide" data-status="{{item.status}}" data-id="{{item.id}}">
+                        <image
+                            src="{{item.status==='NORMAL'? '../../static/index/show_icon.png': '../../static/index/hide_icon.png'}}" />
+                        <text>{{item.status==='NORMAL'? '隐藏': '展示'}}</text>
+                    </view>
+                </view>
+            </view>
+            <video id="video_{{index}}" class="video_item" loop="{{loop}}" enable-play-gesture enable-progress-gesture
+                show-center-play-btn="{{false}}" controls="{{true}}" src="{{item.url}}" object-fit="contain"
+                data-index="{{index}}" data-id="{{item.id}}" bindplay="onPlay" bindended="onEnded">
+            </video>
+            <view class="video_title">
+                <text>{{item.title}}</text>
+            </view>
+            <view class="foot_box">
+                <view class="foot_left">
+                    <view class="video_btn collect_btn" catchtap="collectTap" data-index="{{index}}"
+                        data-id="{{item.id}}" data-type="{{item.type}}">
+                        <image class="collect_btn_icon"
+                            src="{{item.isFavorite ? '../../static/index/star_colored.png' : '../../static/index/star.png'}}" />
+                        <text>收藏</text>
+                    </view>
+                    <view class="video_btn share_btn" bindtap="openShare" data-index="{{index}}" data-id="{{item.id}}"
+                        data-avatar="{{item.avatar}}" data-author="{{item.nickName}}" data-uid="{{item.uid}}"
+                        data-img="{{item.img}}" data-title="{{item.title}}" data-type="{{item.type}}"
+                        ata-activity="{{item.activity}}">
+                        <image class="share_btn_icon" src="../../static/index/share.png" lazy-load="true" />
+                        <text>分享</text>
+                    </view>
+                </view>
+                <view class="foot_right">
+                    <view class="video_btn flower_btn" catchtap="{{item.isLike ?  null : 'likeTap'}}"
+                        data-index="{{index}}" data-id="{{item.id}}" data-islike="{{item.isLike}}">
+                        <image class="flower_btn_icon"
+                            src="{{item.isLike ? '../../static/index/heart_colored.png' : '../../static/index/heart.png'}}" />
+                        <text>{{item.likes}}</text>
+                    </view>
+                    <view class="video_btn comment_btn" catchtap="openComment" data-id="{{item.id}}">
+                        <image class="comment_btn_icon" src="../../static/index/comment.png" lazy-load="true" />
+                        <text>{{item.commentAmount}}</text>
+                    </view>
+                </view>
+            </view>
+            <view class="btn_wrapper" catchtap="goToReading" data-id="{{item.classId}}">
+                <view class="reading_btn">
+                    <image src="../../static/index/microphone.png" />
+                    <text>我要配音</text>
+                </view>
+            </view>
+        </swiper-item>
+    </swiper>
+    <!-- // 非swiper -->
+    <view wx:if="{{!isSwiper}}" class="swiper_item no_swiper" wx:for="{{sonVideoList}}" data-id="{{item.id}}"
+        wx:key="id">
+        <view class="head_box">
+            <image class="tag_icon" wx:if="{{item.hasTag}}" src="{{item.tagUrl}}" />
+            <view class="user_box" catchtap="{{ifHeadTap ? 'headTap' : null}}" data-uid="{{item.uid}}">
+                <image class="avatar" lazy-load="true" src="{{item.avatar}}" />
+                <image class="avatar_fans" wx:if="{{!item.isFans}}" src="../../static/index/add_follow.png" />
+                <view class="user_right">
+                    <view class="nickname">{{item.nickName}}</view>
+                    <image class="efun_tag" src="../../static/index/efun_tag.png" wx:if="{{item.isEfun}}"></image>
+                </view>
+            </view>
+            <view wx:if="{{!item.showMyBtn && item.type != 'EXAMPLE'}}" class="time">
+                <text>发布时间:{{item.time}}</text>
+            </view>
+            <view wx:if="{{item.showMyBtn && !item.ifCheck}}" class="my_btn">
+                <view class="delete" catchtap="download" data-url="{{item.markPath ? item.markPath : '' }}"
+                    data-id="{{item.id}}">
+                    <image class="download_image" src="../../static/index/down.png" />
+                    <text class="delete_text">下载</text>
+                </view>
+                <view class="delete" catchtap="delete" data-id="{{item.id}}">
+                    <image class="delete_image" src="../../static/index/delete.png" />
+                    <text class="delete_text">删除</text>
+                </view>
+                <view class="hide" catchtap="hide" wx:if="{{!item.activity}}" data-status="{{item.status}}"
+                    data-id="{{item.id}}">
+                    <!-- <image class="hide_image" src="{{item.status==='NORMAL'? '../../static/index/hide_icon.png': '../../static/index/show_icon.png'}}" /> -->
+                    <image class="hide_image"
+                        src="{{item.status==='NORMAL'? '../../static/index/unlock.png': '../../static/index/lock.png'}}" />
+                    <text class="hide_text">{{item.status==='NORMAL'? '公开': '私密'}}</text>
+                </view>
+            </view>
+        </view>
+        <view class="video_place" wx:if="{{!item.videoShow}}" catchtap="{{item.ifCheck ? null : 'showVideo'}}"
+            data-index="{{index}}">
+            <image class="place_img" src="{{item.coverImg}}" />
+            <image class="play_btn" src="../../static/image/play-btn.png" />
+            <image class="activity_tigs" wx:if="{{item.activity && item.type != 'EXAMPLE'}}"
+                src="http://reader-wx.ai160.com/images/reader/activity/activity1.png" />
+            <view class="video_item_dialog" wx:if="{{item.ifCheck}}">
+                <image class="video_item_dialog_img" src="../../static/index/checking.png"
+                    mode="aspectFit|aspectFill|widthFix" />
+            </view>
+        </view>
+        <video wx:if="{{item.videoShow}}" id="video_{{index}}" class="video_item" loop="{{loop}}"
+            show-center-play-btn="{{!item.ifCheck ? true : false}}" controls="{{!item.ifCheck ? true : false}}"
+            src="{{item.url ? item.url : '' }}" autoplay="{{true}}" object-fit="contain" data-index="{{index}}"
+            data-id="{{item.id}}" bindplay="onPlayList" bindended="onEndedList" binderror="onError">
+        </video>
+        <view class="video_title">
+            <text>{{item.title}}</text>
+        </view>
+        <view class="foot_box" wx:if="{{!item.ifCheck}}">
+            <view class="foot_left">
+                <view class="video_btn collect_btn" catchtap="collectTap" data-index="{{index}}" data-id="{{item.id}}"
+                    data-type="{{item.type}}">
+                    <image class="collect_btn_icon"
+                        src="{{item.isFavorite ? '../../static/index/star_colored.png' : '../../static/index/star.png'}}" />
+                    <text>{{item.favoritesAmount === 0 ? '收藏' : item.favoritesAmount}}</text>
+                </view>
+                <view class="video_btn share_btn" bindtap="openShare" data-author="{{item.nickName}}"
+                    data-index="{{index}}" data-id="{{item.id}}" data-avatar="{{item.avatar}}" data-uid="{{item.uid}}"
+                    data-img="{{item.img}}" data-title="{{item.title}}" data-shareimg="{{item.shareImg}}"
+                    data-grade="{{item.grade}}" data-type="{{item.type}}" data-activity="{{item.activity}}">
+                    <image class="share_btn_icon" src="../../static/index/share.png" />
+                    <text>{{item.shareAmount === 0 ? '分享' : item.shareAmount}}</text>
+                </view>
+            </view>
+            <view class="foot_right">
+                <view class="video_btn flower_btn" catchtap="{{item.isLike ?  null : 'likeTap'}}" data-index="{{index}}"
+                    data-id="{{item.id}}" data-islike="{{item.isLike}}">
+                    <view class="animation-flower {{addComeOut === index ? 'add-one-come-out' : ''}}">
+                        <image class="animation-flower-icon"
+                            src="{{item.activity ? '../../static/activity/popularity1.png' : '../../static/image/flower_small.png'}}" />
+                        <text>+1</text>
+                    </view>
+                    <image class="flower_btn_icon"
+                        src="{{item.isLike ? '../../static/index/heart_colored.png' : '../../static/index/heart.png'}}" />
+                    <text>{{item.likes === 0 ? '点赞' : item.likes}}</text>
+                </view>
+                <view class="video_btn comment_btn" catchtap="openComment" data-id="{{item.id}}" data-index="{{index}}">
+                    <image class="comment_btn_icon" src="../../static/index/comment.png" lazy-load="true" />
+                    <text>{{item.commentAmount === 0 ?'评论' : item.commentAmount}}</text>
+                </view>
+            </view>
+        </view>
+        <view class="btn_wrapper" wx:if="{{!item.noReading && !item.ifCheck}}" catchtap="goToReading"
+            data-id="{{item.classId}}">
+            <view class="reading_btn">
+                <image src="../../static/index/microphone.png" />
+                <text>我要配音</text>
+            </view>
         </view>
-        <view wx:if="{{!item.showMyBtn}}" class="time">
-          <text>发布时间:{{item.time}}</text>
-        </view>
-        <view wx:if="{{item.showMyBtn}}" class="my_btn">
-          <view catchtap="delete" data-id="{{item.id}}">
-            <image src="../../static/index/delete.png" />
-            <text>删除</text>
-          </view>
-          <view catchtap="hide" data-status="{{item.status}}" data-id="{{item.id}}">
-            <image src="{{item.status==='NORMAL'? '../../static/index/show_icon.png': '../../static/index/hide_icon.png'}}" />
-            <text>{{item.status==='NORMAL'? '隐藏': '展示'}}</text>
-          </view>
-        </view>
-      </view>
-      <video id="video_{{index}}" class="video_item" loop="{{loop}}" enable-play-gesture enable-progress-gesture show-center-play-btn="{{false}}" controls="{{true}}" src="{{item.url}}" object-fit="contain" data-index="{{index}}" data-id="{{item.id}}" bindplay="onPlay" bindended="onEnded">
-        <!-- bindplay="onPlay"
-        bindpause="onPause"
-        bindended="onEnded"
-        binderror="onError"
-        bindtimeupdate="onTimeUpdate"
-        bindwaiting="onWaiting"
-        bindprogress="onProgress"
-        bindloadedmetadata="onLoadedMetaData" -->
-      </video>
-      <view class="video_title">
-        <text>{{item.title}}</text>
-      </view>
-      <view class="foot_box">
-        <view class="foot_left">
-          <view class="video_btn collect_btn" catchtap="collectTap" data-index="{{index}}" data-id="{{item.id}}" data-type="{{item.type}}">
-            <image class="collect_btn_icon" src="{{item.isFavorite ? '../../static/index/star_colored.png' : '../../static/index/star.png'}}" />
-            <text>收藏</text>
-          </view>
-          <view class="video_btn share_btn" bindtap="openShare" data-index="{{index}}" data-id="{{item.id}}" data-avatar="{{item.avatar}}" data-author="{{item.nickName}}" data-uid="{{item.uid}}" data-img="{{item.img}}" data-title="{{item.title}}" data-type="{{item.type}}" ata-activity="{{item.activity}}">
-            <image class="share_btn_icon" src="../../static/index/share.png" lazy-load="true" />
-            <text>分享</text>
-          </view>
-        </view>
-        <view class="foot_right">
-          <view class="video_btn flower_btn" catchtap="{{item.isLike ?  null : 'likeTap'}}" data-index="{{index}}" data-id="{{item.id}}" data-islike="{{item.isLike}}">
-            <image class="flower_btn_icon" src="{{item.isLike ? '../../static/index/heart_colored.png' : '../../static/index/heart.png'}}" />
-            <text>{{item.likes}}</text>
-          </view>
-          <view class="video_btn comment_btn" catchtap="openComment" data-id="{{item.id}}">
-            <image class="comment_btn_icon" src="../../static/index/comment.png" lazy-load="true" />
-            <text>{{item.commentAmount}}</text>
-          </view>
-        </view>
-      </view>
-      <view class="btn_wrapper" catchtap="goToReading" data-id="{{item.classId}}">
-        <view class="reading_btn">
-          <image src="../../static/index/microphone.png" />
-          <text>我要配音</text>
-        </view>
-      </view>
-    </swiper-item>
-  </swiper>
-  <!-- // 非swiper -->
-  <view wx:if="{{!isSwiper}}" class="swiper_item no_swiper" wx:for="{{sonVideoList}}" data-id="{{item.id}}" wx:key="id">
-    <view class="head_box">
-      <image class="tag_icon" wx:if="{{item.hasTag}}" src="{{item.tagUrl}}" />
-      <view class="user_box" catchtap="{{ifHeadTap ? 'headTap' : null}}" data-uid="{{item.uid}}">
-        <image class="avatar" lazy-load="true" src="{{item.avatar}}" />
-        <image class="avatar_fans" wx:if="{{!item.isFans}}" src="../../static/index/add_follow.png" />
-        <view class="user_right">
-          <view class="nickname">{{item.nickName}}</view>
-          <image class="efun_tag" src="../../static/index/efun_tag.png" wx:if="{{item.isEfun}}"></image>
-        </view>
-      </view>
-      <!-- <view wx:if="{{!item.showMyBtn}}" class="time">
-        <text>发布时间:{{item.time}}</text>
-      </view> -->
-      <view wx:if="{{!item.showMyBtn && item.type != 'EXAMPLE'}}" class="time">
-        <text>发布时间:{{item.time}}</text>
-      </view>
-      <view wx:if="{{item.showMyBtn && !item.ifCheck}}" class="my_btn">
-        <view class="delete" catchtap="download" data-url="{{item.markPath ? item.markPath : '' }}" data-id="{{item.id}}">
-          <image class="download_image" src="../../static/index/down.png" />
-          <text class="delete_text">下载</text>
-        </view>
-        <view class="delete" catchtap="delete" data-id="{{item.id}}">
-          <image class="delete_image" src="../../static/index/delete.png" />
-          <text class="delete_text">删除</text>
-        </view>
-        <view class="hide" catchtap="hide" wx:if="{{!item.activity}}" data-status="{{item.status}}" data-id="{{item.id}}">
-          <!-- <image class="hide_image" src="{{item.status==='NORMAL'? '../../static/index/hide_icon.png': '../../static/index/show_icon.png'}}" /> -->
-          <image class="hide_image" src="{{item.status==='NORMAL'? '../../static/index/unlock.png': '../../static/index/lock.png'}}" />
-          <text class="hide_text">{{item.status==='NORMAL'? '公开': '私密'}}</text>
-        </view>
-      </view>
-      <!-- <view wx:if="{{item.showMyBtn && !item.ifCheck}}" class="my_btn">
-        <view class="delete" catchtap="delete" data-id="{{item.id}}">
-          <image class="delete_image" src="../../static/index/delete.png" />
-          <text class="delete_text">删除</text>
-        </view>
-        <view class="hide" catchtap="hide" data-status="{{item.status}}" data-id="{{item.id}}">
-          <image class="hide_image" src="{{item.status==='NORMAL'? '../../static/index/unlock.png': '../../static/index/lock.png'}}" />
-          <text class="hide_text">{{item.status==='NORMAL'? '公开': '仅自己可见'}}</text>
-        </view>
-      </view> -->
-    </view>
-    <view class="video_place" wx:if="{{!item.videoShow}}" catchtap="{{item.ifCheck ? null : 'showVideo'}}" data-index="{{index}}">
-      <image class="place_img" src="{{item.coverImg}}" />
-      <image class="play_btn" src="../../static/image/play-btn.png" />
-      <image class="activity_tigs" wx:if="{{item.activity && item.type != 'EXAMPLE'}}" src="http://reader-wx.ai160.com/images/reader/activity/activity1.png" />
-      <view class="video_item_dialog" wx:if="{{item.ifCheck}}">
-        <image class="video_item_dialog_img" src="../../static/index/checking.png" mode="aspectFit|aspectFill|widthFix" />
-      </view>
-    </view>
-    <video wx:if="{{item.videoShow}}" id="video_{{index}}" class="video_item" loop="{{loop}}" show-center-play-btn="{{!item.ifCheck ? true : false}}" controls="{{!item.ifCheck ? true : false}}" src="{{item.url ? item.url : '' }}" autoplay="{{true}}" object-fit="contain" data-index="{{index}}" data-id="{{item.id}}" bindplay="onPlayList" bindended="onEndedList" binderror="onError">
-      <!-- show-center-play-btn="{{!item.ifCheck ? true : false}}" -->
-      <!-- show-center-play-btn="{{!item.ifCheck ? true : false}}" -->
-      <!-- show-center-play-btn="{{!item.ifCheck ? true : false}}" -->
-      <!-- bindplay="onPlay"
-        bindpause="onPause"
-        bindended="onEnded"
-        binderror="onError"
-        bindtimeupdate="onTimeUpdate"
-        bindwaiting="onWaiting"
-        bindprogress="onProgress"
-        bindloadedmetadata="onLoadedMetaData" -->
-    </video>
-    <view class="video_title">
-      <text>{{item.title}}</text>
-    </view>
-    <view class="foot_box" wx:if="{{!item.ifCheck}}">
-      <view class="foot_left">
-        <view class="video_btn collect_btn" catchtap="collectTap" data-index="{{index}}" data-id="{{item.id}}" data-type="{{item.type}}">
-          <image class="collect_btn_icon" src="{{item.isFavorite ? '../../static/index/star_colored.png' : '../../static/index/star.png'}}" />
-          <text>{{item.favoritesAmount === 0 ? '收藏' : item.favoritesAmount}}</text>
-        </view>
-        <view class="video_btn share_btn" bindtap="openShare" data-author="{{item.nickName}}" data-index="{{index}}" data-id="{{item.id}}" data-avatar="{{item.avatar}}" data-uid="{{item.uid}}" data-img="{{item.img}}" data-title="{{item.title}}" data-shareimg="{{item.shareImg}}" data-grade="{{item.grade}}" data-type="{{item.type}}" data-activity="{{item.activity}}">
-          <image class="share_btn_icon" src="../../static/index/share.png" />
-          <text>{{item.shareAmount === 0 ? '分享' : item.shareAmount}}</text>
-        </view>
-        <!-- <button class="video_btn share_btn" open-type="share" bindtap="openShare" data-author="{{item.nickName}}" data-index="{{index}}" data-id="{{item.id}}" data-avatar="{{item.avatar}}" data-uid="{{item.uid}}" data-img="{{item.img}}" data-title="{{item.title}}" data-shareimg="{{item.shareImg}}" data-grade="{{item.grade}}" data-type="{{item.type}}">
-   <image class="share_btn_icon" src="../../static/index/share.png"></image>
-   <text>分享</text>
- </button> -->
-      </view>
-      <view class="foot_right">
-        <view class="video_btn flower_btn" catchtap="{{item.isLike ?  null : 'likeTap'}}" data-index="{{index}}" data-id="{{item.id}}" data-islike="{{item.isLike}}">
-          <view class="animation-flower {{addComeOut === index ? 'add-one-come-out' : ''}}">
-            <image class="animation-flower-icon" src="{{item.activity ? '../../static/activity/popularity1.png' : '../../static/image/flower_small.png'}}" />
-            <text>+1</text>
-          </view>
-          <image class="flower_btn_icon" src="{{item.isLike ? '../../static/index/heart_colored.png' : '../../static/index/heart.png'}}" />
-          <text>{{item.likes === 0 ? '点赞' : item.likes}}</text>
-        </view>
-        <view class="video_btn comment_btn" catchtap="openComment" data-id="{{item.id}}" data-index="{{index}}">
-          <image class="comment_btn_icon" src="../../static/index/comment.png" lazy-load="true" />
-          <text>{{item.commentAmount === 0 ?'评论' : item.commentAmount}}</text>
-        </view>
-      </view>
     </view>
-    <view class="btn_wrapper" wx:if="{{!item.noReading && !item.ifCheck}}" catchtap="goToReading" data-id="{{item.classId}}">
-      <view class="reading_btn">
-        <image src="../../static/index/microphone.png" />
-        <text>我要配音</text>
-      </view>
+    <view class="no_work" wx:if="{{!isSwiper && noMoreWork}}">
+        <text class="no_work_text">已经到底啦!</text>
     </view>
-  </view>
-  <view class="no_work" wx:if="{{!isSwiper && noMoreWork}}">
-    <text class="no_work_text">已经到底啦!</text>
-  </view>
 </view>
 <flowerBox id="flower-toast" flowerNum="{{flowerNum}}" />
-<shareDialog id="share-dialog" shareType='works' bindShareDialogClose="shareDialogClose" bindaddShareAmount="addShareAmount" shareId="{{id}}" />
+<shareDialog id="share-dialog" shareType='works' bindShareDialogClose="shareDialogClose"
+    bindaddShareAmount="addShareAmount" shareId="{{id}}" />

+ 90 - 90
pages/index/index.js

@@ -93,12 +93,12 @@ Page({
         isVip: null,
         isIos: null
     },
-    jurisdiction: function() {
+    jurisdiction: function () {
         //隐藏弹框
         this.setData({
-                hide: !this.data.hide
-            })
-            //登录页信息
+            hide: !this.data.hide
+        })
+        //登录页信息
         this.updateData(0)
     },
     // 隐藏升级弹窗
@@ -113,14 +113,14 @@ Page({
         });
     },
     //tab点击
-    switcher: function({
+    switcher: function ({
         currentTarget
     }) {
         if (currentTarget.dataset.index === this.data.myIndex) return;
         this.updateData(currentTarget.dataset.index);
     },
     // 根据index 更新template
-    updateData: function(index) {
+    updateData: function (index) {
         let myIndex = parseInt(index);
         this.setData({
             myIndex,
@@ -142,7 +142,7 @@ Page({
         }
 
         /* 关注和我的需要登陆后查看 */
-
+        console.log(this.data.isLogin,'zzzzzzzzz');
         if (!this.data.isLogin) {
             wx.navigateTo({
                 url: `../../pages/login/login?index=${myIndex}`
@@ -151,7 +151,7 @@ Page({
         }
 
         console.log('继续')
-            // 刷新关注列表
+        // 刷新关注列表
         if (myIndex == 1) {
             this.setData({
                 videoList: [],
@@ -190,7 +190,7 @@ Page({
 
 
     },
-    showPage: function() {
+    showPage: function () {
         let options = this.data.options;
         console.log('this.data.workId', this.data.workId)
         if (this.data.workId) {
@@ -264,7 +264,7 @@ Page({
             }
         }, 2800)
     },
-    onLoad: function(options) {
+    onLoad: function (options) {
         this.setData({
             isIos: app.globalData.isIOS
         })
@@ -310,20 +310,20 @@ Page({
         })
         getOpenidNoLogin((res) => {
             console.log('getOpenidNoLogin', res)
-                /**获取权限和订单信息 */
-                // 获取商品信息
+            /**获取权限和订单信息 */
+            // 获取商品信息
             httpRequestApi.getProductActivity().success(res => {
-                    wx.setStorageSync('price', res.data.data.price / 100)
-                    wx.setStorageSync('productId', res.data.data.id)
-                    if (options.type && options.type === 'iphone') {
-                        this.setData({
-                            payPrice: res.data.data.price / 100
-                        })
-                    }
-                }).fail(error => {
-                    console.log(error)
-                })
-                // 获取用户权限
+                wx.setStorageSync('price', res.data.data.price / 100)
+                wx.setStorageSync('productId', res.data.data.id)
+                if (options.type && options.type === 'iphone') {
+                    this.setData({
+                        payPrice: res.data.data.price / 100
+                    })
+                }
+            }).fail(error => {
+                console.log(error)
+            })
+            // 获取用户权限
             this.getHelpAuth()
             if (!res.data.data.grade) {
                 // 没有年级的老用户
@@ -386,7 +386,7 @@ Page({
                 console.log('nextMargin', res.pixelRatio)
                 console.log('windowHeight', res.windowHeight)
                 console.log('windowWidth', res.windowWidth)
-                    // let ratio = res.pixelRatio;
+                // let ratio = res.pixelRatio;
                 let ratio = (res.screenHeight / res.screenWidth) * 1.1;
                 console.log('比例系数', ratio)
                 let winH = res.windowHeight * ratio;
@@ -434,7 +434,7 @@ Page({
             })
         }
     },
-    onShow: function() {
+    onShow: function () {
         let grade = wx.getStorageSync('grade');
         this.setData({
             gradeActivity: grade
@@ -474,7 +474,7 @@ Page({
         })
     },
 
-    onHide: function() {
+    onHide: function () {
         const str = 'hotData.inputFocus'
         this.setData({
             [str]: false
@@ -483,7 +483,7 @@ Page({
     /* 两个接口维护同一个数组,手动的结束后添加算法的 */
     // 推荐页信息 获取消息和手动推荐内容
     // 获取热门作品 算法出来的
-    getHotRecommend: function() {
+    getHotRecommend: function () {
         let grade = wx.getStorageSync('grade')
         let pageNo = this.data.recommendPageNo;
         let pageSize = this.data.recommendPageSize;
@@ -552,15 +552,15 @@ Page({
             // tempList.push(temp);
         });
         console.log('当前list', this.data.videoList)
-            // if (!notSet) {
+        // if (!notSet) {
         this.setData({
-                videoList: this.data.videoList
-            })
-            // }
+            videoList: this.data.videoList
+        })
+        // }
 
     },
     // 获取用户信息
-    getUserWorksInfo: function(flag) {
+    getUserWorksInfo: function (flag) {
         if (flag) {
             httpRequestApi.getUserWorksInfo().success(res => {
                 const userInfo = this.formatGrade(res.data.data.user);
@@ -614,7 +614,7 @@ Page({
         }
         return userInfo;
     },
-    videoChange: function(e) {
+    videoChange: function (e) {
         if (e.detail.activeId === this.data.updateId) {
             console.log('应该刷新')
             if (this.data.myIndex === 1) {
@@ -637,7 +637,7 @@ Page({
 
     },
     // 触底加载
-    onReachBottom: function() {
+    onReachBottom: function () {
         if (this.data.myIndex === 2) {
             this.setData({
                 coursePageNo: this.data.coursePageNo + 1
@@ -677,17 +677,17 @@ Page({
         // }
 
     },
-    onPullDownRefresh: function() {
+    onPullDownRefresh: function () {
         //当前在团购页下拉加载
         this.updateData(this.data.myIndex)
         wx.showNavigationBarLoading() //在标题栏中显示加载
-            //模拟加载
-        setTimeout(function() {
+        //模拟加载
+        setTimeout(function () {
             wx.hideNavigationBarLoading() //完成停止加载
             wx.stopPullDownRefresh() //停止下拉刷新
         }, 1000);
     },
-    goToMessage: function() {
+    goToMessage: function () {
         wx.navigateTo({
             url: `../../pages/social/insideMessage/insideMessage`
         });
@@ -697,10 +697,10 @@ Page({
             [str]: 0
         })
     },
-    goToService: function() {
+    goToService: function () {
         httpRequestApi.userEvent('SERVICE');
     },
-    toMyCollage: function(e) {
+    toMyCollage: function (e) {
         if (app.globalData.isIOS) {
             wx.navigateTo({
                 url: `../../pages/groupPage/my-group/my-group?title=我的助力`
@@ -712,19 +712,19 @@ Page({
         }
 
     },
-    toMyCourse: function() {
+    toMyCourse: function () {
         wx.navigateTo({
             url: `../../pages/user/mycourse/mycourse?title=我的课程`
         });
     },
-    goToFlower: function() {
+    goToFlower: function () {
         wx.navigateTo({
             url: `../../pages/social/littleFlower/littleFlower`
         });
         httpRequestApi.userEvent('INTEGRAL');
 
     },
-    signInBtn: function(e) {
+    signInBtn: function (e) {
         this.setData({
             indexSignDialog: false
         })
@@ -734,13 +734,13 @@ Page({
         })
         this.goToFlower();
     },
-    missionBtn: function() {
+    missionBtn: function () {
         this.setData({
             indexMissionDialog: false
         })
         this.goToFlower();
     },
-    getUserAuth: function() {
+    getUserAuth: function () {
         httpRequestApi.getUserAuth().success(res => {
             console.log(res)
             const str = 'myData.isVIP'
@@ -755,11 +755,11 @@ Page({
             }
         })
     },
-    delHideMyWork: function() {
+    delHideMyWork: function () {
         this.getMyRead()
     },
     // 获取我的朗读
-    getMyRead: function() {
+    getMyRead: function () {
         httpRequestApi.myRead().success(res => {
             console.log(123123, res)
             console.log('mydata', this.data.myData)
@@ -817,7 +817,7 @@ Page({
         })
     },
     // 评论区点击
-    commentTap: function(e) {
+    commentTap: function (e) {
         console.log('点击评论区', e)
         if (e.target.dataset.type === 'blank') {
             if (this.data.commentShow && this.data.commentId) {
@@ -834,11 +834,11 @@ Page({
             })
         }
     },
-    touchMove: function(e) {
+    touchMove: function (e) {
         return
     },
     // 打开评论
-    openComment: function(e) {
+    openComment: function (e) {
         //
         console.log('id', e.detail.activeId)
         console.log('id', e)
@@ -846,17 +846,17 @@ Page({
             commentShow: !this.data.commentShow,
             commentId: e.detail.activeId,
             commentIndex: e.detail.activeIndex
-                // commentList: []
+            // commentList: []
         });
         // this.getReply(e.detail.activeId);
     },
     // 获取评论信息
-    getReply: function(columnId) {
+    getReply: function (columnId) {
         debugger
         // let columnId = this.data.id;
         console.log(123123123, columnId)
-            // let pageNo = this.data.pageNo;
-            // let pageSize = this.data.pageSize;
+        // let pageNo = this.data.pageNo;
+        // let pageSize = this.data.pageSize;
         httpRequestApi.getReply(this.uid, columnId, 1, 10).success((res) => {
             console.log('reply', res)
             const commentList = res.data.data.list;
@@ -883,7 +883,7 @@ Page({
         });
     },
     // 发布回复
-    sendReply: function(e) {
+    sendReply: function (e) {
         console.log('triger', e.detail.content);
         let data = {
             columnId: this.data.commentId,
@@ -901,13 +901,13 @@ Page({
             })
         });
     },
-    gradeTap: function() {
+    gradeTap: function () {
         // console.log("组件回调,返回上一页");
         this.setData({
             isGradeShow: true
         })
     },
-    onShareAppMessage: function(res) {
+    onShareAppMessage: function (res) {
         console.log('onShareAppMessage>>>>>>>>>>>>')
         console.log('this.data', this.data)
         if (res.from === 'button') {
@@ -923,7 +923,7 @@ Page({
             }
         }
     },
-    openShare: function(e) {
+    openShare: function (e) {
         console.log('点击分享', e)
         this.setData({
             shareTitle: e.detail.currentTarget.dataset.title,
@@ -934,7 +934,7 @@ Page({
         })
     },
     // 修改年级
-    changeGrade: function(e) {
+    changeGrade: function (e) {
         const grade = e.target.dataset.code;
 
         wx.setStorageSync('grade', grade)
@@ -953,7 +953,7 @@ Page({
         };
         getOpenidNoLogin((res) => {
             console.log('getOpenidNoLogin', res)
-                // 登录或注册完成 展示页面
+            // 登录或注册完成 展示页面
             if (res.data.data.wechatName) {
                 this.setData({
                     isLogin: true
@@ -973,7 +973,7 @@ Page({
         }, grade);
     },
 
-    getFollowData: function() {
+    getFollowData: function () {
         httpRequestApi.getFollowWorks(this.data.followPageNo, this.data.followPageSize).success(res => {
             if (res.data.data.totalSize === 0) {
                 this.setData({
@@ -996,7 +996,7 @@ Page({
         httpRequestApi.userEvent('SUBSCRIBE');
     },
     // 点击用户头像区域
-    headTapHandler: function(e) {
+    headTapHandler: function (e) {
         console.log('点击头像', e)
         let tapId = e.detail.activeId;
         // 点击头像既关注 测试
@@ -1004,7 +1004,7 @@ Page({
             console.log(res)
         })
     },
-    getCoursesList: function() {
+    getCoursesList: function () {
         const grade = wx.getStorageSync('grade');
         const data = {
             pageNo: this.data.coursePageNo,
@@ -1024,7 +1024,7 @@ Page({
         })
         httpRequestApi.userEvent('RESOURCES');
     },
-    goToReading: function(e) {
+    goToReading: function (e) {
         console.log('去朗读', e)
         const id = e.detail.activeId ? e.detail.activeId : e.currentTarget.dataset.id;
         const index = e.currentTarget.dataset.index;
@@ -1085,16 +1085,16 @@ Page({
         if (1) {
             this.shareDialog = this.selectComponent("#share-dialog");
             const data = {
-                    avatar: obj.avatar,
-                    author: obj.author,
-                    iconImg: obj.iconImg,
-                    title: obj.title,
-                    path: `pages/index/index`,
-                    scene: obj.id,
-                    productId: 1
-                        // tip: this.data.tip,
-                }
-                // console.log(data)
+                avatar: obj.avatar,
+                author: obj.author,
+                iconImg: obj.iconImg,
+                title: obj.title,
+                path: `pages/index/index`,
+                scene: obj.id,
+                productId: 1
+                // tip: this.data.tip,
+            }
+            // console.log(data)
             this.setData({
                 noScroll: 'noScroll',
                 shareTitle: obj.title,
@@ -1104,7 +1104,7 @@ Page({
             this.shareDialog.share(data);
         }
     },
-    collectTap: function(e) {
+    collectTap: function (e) {
         const index = e.detail.index;
         let str = `videoList[${index}].isFavorite`;
         let str2 = `videoList[${index}].favoritesAmount`;
@@ -1114,23 +1114,23 @@ Page({
             [str2]: favoritesAmount
         })
     },
-    likeTap: function(e) {
+    likeTap: function (e) {
         console.log('点赞', e)
         const index = e.detail.index;
         let likeStr = `videoList[${index}].isLike`;
         let likeNumStr = `videoList[${index}].likes`;
         this.setData({
-                [likeStr]: true,
-                [likeNumStr]: this.data.videoList[index].likes + 1
-            })
-            // this.flowerAnimationHandler()
+            [likeStr]: true,
+            [likeNumStr]: this.data.videoList[index].likes + 1
+        })
+        // this.flowerAnimationHandler()
     },
-    flowerAnimationHandler: function() {
+    flowerAnimationHandler: function () {
         this.flowerBox = this.selectComponent("#flower-box");
         console.log('this.flower', this.flowerBox)
         this.flowerBox.comeOut();
     },
-    addShareAmount: function(e) {
+    addShareAmount: function (e) {
         console.log('+++++1', e)
         let str = `videoList[${e.detail.index}].shareAmount`;
         this.setData({
@@ -1142,12 +1142,12 @@ Page({
      */
     goToActivity() {
         httpRequestApi.postActEvent('BANNER').success(res => {
-                console.log('活动banner', res)
-            })
-            // wx.navigateTo({
-            //   url: `../activity/index/index`
-            //   // url: `../activity/rule/rule`
-            // });
+            console.log('活动banner', res)
+        })
+        // wx.navigateTo({
+        //   url: `../activity/index/index`
+        //   // url: `../activity/rule/rule`
+        // });
         wx.navigateTo({
             url: `../activity/goodList/goodList`
         });
@@ -1179,11 +1179,11 @@ Page({
                     console.log(res)
                     if (res['KJ0YtcAacJNSXDBsE27JXqoaFrcJ1-N6Jcu85yTtQuY'] === 'reject') {
                         console.log('用户不同意订阅')
-                            // 用户不同意订阅
+                        // 用户不同意订阅
                         wx.setStorageSync('message', false)
                     } else if (res['KJ0YtcAacJNSXDBsE27JXqoaFrcJ1-N6Jcu85yTtQuY'] === 'accept') {
                         console.log('订阅成功')
-                            // 用户点击统一订阅
+                        // 用户点击统一订阅
                         wx.setStorageSync('message', true)
                     }
                     wx.navigateTo({

+ 17 - 28
pages/index/index.wxml

@@ -56,19 +56,18 @@
         <image src="http://reader-wx.ai160.com/images/reader/pay/vip_icon.png"></image>
     </view>
     <!-- 调用组件 -->
-    <template is="{{templates}}" wx:if="{{myIndex === 3 || myIndex === 2}}" data="{{myData: myData,coursesData:coursesData,noMoreWork:noMoreWork}}"></template>
-    <VideoSwiper wx:if="{{videoList.length > 0}}" class="video-swiper" video-list="{{videoList}}" nextMargin="{{nextMargin}}" isSwiper="{{isSwiper}}" noMoreWork="{{noMoreWork}}" ifHeadTap="{{true}}" bindopenShare="openShare" bindopenComment="openComment" bindheadTap="headTapHandler" bindgoToReading="goToReading" bindcollectTap="collectTap" bindlikeTap="likeTap" binddelHideMyWork="delHideMyWork" bindaddShareAmount="addShareAmount" bindchange="videoChange">
-        <!-- bindplay="onPlay"
-  bindpause="onPause"
-  bindtimeupdate="onTimeUpdate"
-  bindended="onEnded"
-  binderror="onError"
-  bindwaiting="onWaiting"
-  bindprogress="onProgress"
-  bindloadedmetadata="onLoadedMetaData" -->
+    <template is="{{templates}}" wx:if="{{myIndex === 3 || myIndex === 2}}"
+        data="{{myData: myData,coursesData:coursesData,noMoreWork:noMoreWork}}"></template>
+    <VideoSwiper wx:if="{{videoList.length > 0}}" class="video-swiper" video-list="{{videoList}}"
+        nextMargin="{{nextMargin}}" isSwiper="{{isSwiper}}" noMoreWork="{{noMoreWork}}" ifHeadTap="{{true}}"
+        bindopenShare="openShare" bindopenComment="openComment" bindheadTap="headTapHandler"
+        bindgoToReading="goToReading" bindcollectTap="collectTap" bindlikeTap="likeTap"
+        binddelHideMyWork="delHideMyWork" bindaddShareAmount="addShareAmount" bindchange="videoChange">
     </VideoSwiper>
-    <view class="comment_section" catchtouchmove="touchMove" catchtap="commentTap" data-type="blank" wx:if="{{commentShow}}">
-        <Comment data-type="list" commentId="{{commentId}}" commentNum="{{commentNum}}" inputValue="{{inputValue}}" bindsendReply="sendReply" />
+    <view class="comment_section" catchtouchmove="touchMove" catchtap="commentTap" data-type="blank"
+        wx:if="{{commentShow}}">
+        <Comment data-type="list" commentId="{{commentId}}" commentNum="{{commentNum}}" inputValue="{{inputValue}}"
+            bindsendReply="sendReply" />
     </view>
     <view class="no_follow" wx:if="{{myIndex === 1 && videoList.length <= 0 && noFollow}}">
         <image class="no_follow_icon" src="../../static/index/no_follow.png" />
@@ -94,22 +93,12 @@
 <!-- <view class="upgrade" hidden="{{gradeActivity === 'PRIMARY_SENIOR_GRADE' || gradeActivity === 'PRESCHOOL' || upgradeHide}}"> -->
 <view class="upgrade" hidden="{{upgradeHide}}" bindtap="hideUpgrade">
     <view class="upgrade-main">
-        <image class="upgrade-icon" src="http://reader-wx.ai160.com/images/reader/activity/activity_dialog.png" catchtap="goToActivity"></image>
+        <image class="upgrade-icon" src="http://reader-wx.ai160.com/images/reader/activity/activity_dialog.png"
+            catchtap="goToActivity"></image>
         <image class="close" catchtap="hideUpgrade" src="../../static/image/close.png"></image>
     </view>
 </view>
-<shareDialog id="share-dialog" shareType='works' bindaddShareAmount="addShareAmount" bindShareDialogClose="shareDialogClose" shareId="{{id}}" />
-<canvas canvas-id="myCanvas" style="width:300px; height: 525px; position: absolute; left: -999rpx; top: -9999rpx;"></canvas>
-<!-- <view class="index-dialog" wx:if="{{indexSignDialog}}">
-  <form bindsubmit="signInBtn" report-submit="{{true}}" class="index-dialog-wrapper" >
-    <view class="index-dialog-text">签到领取小红花哦</view>
-    <view class="index-dialog-btn" >去签到</view>
-    <button class="index-dialog-btn-hide" form-type="submit"></button>
-  </form>
-</view> -->
-<!-- <view class="index-dialog" wx:if="{{indexMissionDialog}}">
-  <view class="index-dialog-wrapper" bindtap="missionBtn" >
-    <view class="index-dialog-text">还有<text class="red-text">{{unfinishedCount}}</text>个小红花任务哦</view>
-    <view class="index-dialog-btn" >查看任务</view>
-  </view>
-</view> -->
+<shareDialog id="share-dialog" shareType='works' bindaddShareAmount="addShareAmount"
+    bindShareDialogClose="shareDialogClose" shareId="{{id}}" />
+<canvas canvas-id="myCanvas"
+    style="width:300px; height: 525px; position: absolute; left: -999rpx; top: -9999rpx;"></canvas>

+ 188 - 189
pages/login/login.js

@@ -1,6 +1,6 @@
 // pages/login/login.js
 import {
-  getOpenidSessionKey
+    getOpenidSessionKey
 } from '../../utils/httpUtil';
 import url from '../../utils/const';
 import request from '../../utils/WXHttpRequest';
@@ -9,213 +9,212 @@ const HOST = url.baseApi;
 
 
 function getAPIUrl(action) {
-  return HOST + action;
+    return HOST + action;
 }
 Page({
 
-  /**
-   * 页面的初始数据
-   */
-  data: {
-    index: 0,
-    canIUseGetUserProfile: false
-  },
-
-  /**
-   * 生命周期函数--监听页面加载
-   */
-
-  onLoad: function (options) {
-    if (options.index) {
-      this.setData({
-        index: options.index
-      })
-    }
-    if (wx.getUserProfile) {
-      this.setData({
-        canIUseGetUserProfile: true
-      })
-    }
-  },
-  userLoginRecord: function (uid) {
-    if (wx.getStorageSync('uid')) {
-      console.log('调用方法')
-      let url = getAPIUrl('wx/loginLog');
-      return request.getInstance().header({
-        uid: wx.getStorageSync('uid')
-      }).method('POST').url(url).send().success(() => {}).fail(() => {});
-    }
-  },
-  getUserProfile: function (e) {
-    wx.getUserProfile({
-      desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
-      success: (userProfile) => {
-        console.log('getUserProfile', userProfile);
-        const userInfo = userProfile.userInfo;
-        this.getOpenId((openidData) => {
-          console.log('openid', openidData)
-          let url = getAPIUrl('wx/user');
-          const userData = {
-            openId: openidData.data.data.openid,
-            unionId: openidData.data.data.unionid,
-            wechatName: userInfo.nickName,
-            gender: userInfo.gender,
-            avatar: userInfo.avatarUrl
-          }
-          request.getInstance().url(url).header({}).data(userData).method('POST').send().success(res => {
-            console.log('登陆成功', res)
-            wx.hideToast()
-            wx.showToast({
-              title: '登录成功',
-              icon: 'success',
-              duration: 1500,
-              mask: true
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        index: 0,
+        canIUseGetUserProfile: false
+    },
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+
+    onLoad: function (options) {
+        if (options.index) {
+            this.setData({
+                index: options.index
             })
-            wx.setStorageSync('uid', res.data.data.data.uid)
-            wx.setStorageSync('user', res.data.data.data)
-            this.userLoginRecord();
-            const pages = getCurrentPages();
-            const prevPage = pages[pages.length - 2];
-            console.log(222222, prevPage)
-            prevPage.setData({
-              fromLoginIndex: this.data.index, // 有id就塞到第一位
-            }, () => {
-              wx.navigateBack({
-                delta: 1
-              })
-            })
-          });
-        })
-        // getOpenidSessionKey((res) => {
-        //   console.log('getUserProfilegetUserProfile', res)
-        //   wx.showToast({
-        //     title: '登录成功',
-        //     icon: 'fail',
-        //     duration: 1000,
-        //     success: () => {
-        //       const pages = getCurrentPages();
-        //       const prevPage = pages[pages.length - 2];
-        //       prevPage.setData({
-        //         fromLoginIndex: this.data.index, // 有id就塞到第一位
-        //       }, () => {
-        //         wx.navigateBack({
-        //           delta: 1
-        //         })
-        //       })
-        //     }
-        //   })
-        // }, (error) => {
-        //   wx.showToast({
-        //     title: '登录失败',
-        //     icon: 'fail',
-        //     duration: 1000,
-        //     success: () => {
-        //       wx.navigateBack()
-        //     }
-        //   })
-        // });
-      }
-    })
-  },
-  getOpenId: function (successcallback, failcallback) {
-    wx.login({
-      success: function (res) {
-        if (res.code) {
-          // 获取openid
-          console.log('openId', res.code)
-          let url = getAPIUrl('wx/user/openId')
-          let data = {
-            code: res.code
-          }
-          return request.getInstance().url(url).data(data).send().success(successcallback).fail(failcallback);
-        } else {
-          console.log('获取用户登录态失败!' + res.errMsg)
         }
-      }
-    })
-  },
-  impower: function (e) {
-    console.log(e)
-    var myEventDetail = {} // detail对象,提供给事件监听函数
-    var myEventOption = {} // 触发事件的选项
-    getOpenidSessionKey((res) => {
-      console.log(res)
-      wx.showToast({
-        title: '登录成功',
-        icon: 'fail',
-        duration: 1000,
-        success: () => {
-          const pages = getCurrentPages();
-          const prevPage = pages[pages.length - 2];
-          prevPage.setData({
-            fromLoginIndex: this.data.index, // 有id就塞到第一位
-          }, () => {
-            wx.navigateBack({
-              delta: 1
+        if (wx.getUserProfile) {
+            this.setData({
+                canIUseGetUserProfile: true
             })
-          })
         }
-      })
-    }, (error) => {
-      wx.showToast({
-        title: '登录失败',
-        icon: 'fail',
-        duration: 1000,
-        success: () => {
-          wx.navigateBack()
+    },
+    userLoginRecord: function (uid) {
+        if (wx.getStorageSync('uid')) {
+            console.log('调用方法')
+            let url = getAPIUrl('wx/loginLog');
+            return request.getInstance().header({
+                uid: wx.getStorageSync('uid')
+            }).method('POST').url(url).send().success(() => {}).fail(() => {});
         }
-      })
-    });
-  },
-  touchMove: function () {
-    return false
-  },
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady: function () {
+    },
+    getUserProfile: function (e) {
+        wx.getUserProfile({
+            desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
+            success: (userProfile) => {
+                console.log('getUserProfile', userProfile);
+                const userInfo = userProfile.userInfo;
+                this.getOpenId((openidData) => {
+                    console.log('openid', openidData)
+                    let url = getAPIUrl('wx/user');
+                    const userData = {
+                        openId: openidData.data.data.openid,
+                        unionId: openidData.data.data.unionid,
+                        wechatName: userInfo.nickName,
+                        gender: userInfo.gender,
+                        avatar: userInfo.avatarUrl
+                    }
+                    request.getInstance().url(url).header({}).data(userData).method('POST').send().success(res => {
+                        console.log('登陆成功', res)
+                        wx.hideToast()
+                        wx.showToast({
+                            title: '登录成功',
+                            icon: 'success',
+                            duration: 1500,
+                            mask: true
+                        })
+                        wx.setStorageSync('uid', res.data.data.data.uid)
+                        wx.setStorageSync('user', res.data.data.data)
+                        this.userLoginRecord();
+                        const pages = getCurrentPages();
+                        const prevPage = pages[pages.length - 2];
+                        prevPage.setData({
+                            fromLoginIndex: this.data.index, // 有id就塞到第一位
+                        }, () => {
+                            wx.navigateBack({
+                                delta: 1
+                            })
+                        })
+                    });
+                })
+                // getOpenidSessionKey((res) => {
+                //   console.log('getUserProfilegetUserProfile', res)
+                //   wx.showToast({
+                //     title: '登录成功',
+                //     icon: 'fail',
+                //     duration: 1000,
+                //     success: () => {
+                //       const pages = getCurrentPages();
+                //       const prevPage = pages[pages.length - 2];
+                //       prevPage.setData({
+                //         fromLoginIndex: this.data.index, // 有id就塞到第一位
+                //       }, () => {
+                //         wx.navigateBack({
+                //           delta: 1
+                //         })
+                //       })
+                //     }
+                //   })
+                // }, (error) => {
+                //   wx.showToast({
+                //     title: '登录失败',
+                //     icon: 'fail',
+                //     duration: 1000,
+                //     success: () => {
+                //       wx.navigateBack()
+                //     }
+                //   })
+                // });
+            }
+        })
+    },
+    getOpenId: function (successcallback, failcallback) {
+        wx.login({
+            success: function (res) {
+                if (res.code) {
+                    // 获取openid
+                    console.log('openId', res.code)
+                    let url = getAPIUrl('wx/user/openId')
+                    let data = {
+                        code: res.code
+                    }
+                    return request.getInstance().url(url).data(data).send().success(successcallback).fail(failcallback);
+                } else {
+                    console.log('获取用户登录态失败!' + res.errMsg)
+                }
+            }
+        })
+    },
+    impower: function (e) {
+        console.log(e)
+        var myEventDetail = {} // detail对象,提供给事件监听函数
+        var myEventOption = {} // 触发事件的选项
+        getOpenidSessionKey((res) => {
+            console.log(res)
+            wx.showToast({
+                title: '登录成功',
+                icon: 'fail',
+                duration: 1000,
+                success: () => {
+                    const pages = getCurrentPages();
+                    const prevPage = pages[pages.length - 2];
+                    prevPage.setData({
+                        fromLoginIndex: this.data.index, // 有id就塞到第一位
+                    }, () => {
+                        wx.navigateBack({
+                            delta: 1
+                        })
+                    })
+                }
+            })
+        }, (error) => {
+            wx.showToast({
+                title: '登录失败',
+                icon: 'fail',
+                duration: 1000,
+                success: () => {
+                    wx.navigateBack()
+                }
+            })
+        });
+    },
+    touchMove: function () {
+        return false
+    },
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () {
 
-  },
+    },
 
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow: function () {
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
 
-  },
+    },
 
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide: function () {
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
 
-  },
+    },
 
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload: function () {
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
 
-  },
+    },
 
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh: function () {
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
 
-  },
+    },
 
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom: function () {
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom: function () {
 
-  },
+    },
 
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
 
-  }
+    }
 })

+ 3 - 8
pages/login/login.wxml

@@ -1,13 +1,8 @@
 <!--pages/login/login.wxml-->
 <view class="dialog" catchtouchmove="touchMove">
     <view class="dialog-contain">
-        <!-- <view class="title">微信授权</view> -->
-        <!-- <image class="head-bg" src="../../static/image/reader_logo.jpg" style="background: red;"></image> -->
         <view class="text">使用您的微信登录</view>
-        <!-- <view class="shuoming">获得你的公开信息(昵称、头像等)</view> -->
-
-        <button class="btn"  wx:if="{{canIUseGetUserProfile}}" bindtap="getUserProfile">登录</button>
-        <button class="btn"  wx:else open-type="getUserInfo" bindgetuserinfo="impower">登录</button>
-        <!-- <button class="btn"  open-type="getUserInfo" bindgetuserinfo="impower" bindtap="getUserProfile">登录</button> -->
+        <button class="btn" wx:if="{{canIUseGetUserProfile}}" bindtap="getUserProfile">登录</button>
+        <button class="btn" wx:else open-type="getUserInfo" bindgetuserinfo="impower">登录</button>
     </view>
-</view>
+</view>

+ 18 - 53
pages/my/index.js

@@ -6,61 +6,35 @@ import {
 } from '~/utils/httpUtilNoLogin';
 import httpRequestApi from '~/utils/APIClient';
 let app = getApp()
-var videoAd = null;
-
 Page({
-
-    /**
-     * 页面的初始数据
-     */
     data: {
         userInfo: {},
         isIos: false
         // isIos: app.globalData.isIOS
     },
-    onLoad() {
-        if (wx.createRewardedVideoAd) {
-            // 加载激励视频广告
-            videoAd = wx.createRewardedVideoAd({
-                adUnitId: 'adunit-77f46b2dc73da123'
-            })
-            //捕捉错误
-            videoAd.onError(err => {
-                console.log(err);
-            })
-            // 监听关闭
-            videoAd.onClose((status) => {
-                console.log(status);
-                if (status && status.isEnded || status === undefined) {
-                    // 正常播放结束,下发奖励
-                    // continue you code
-                } else {
-                    // 播放中途退出,进行提示
-                    wx.showToast({
-                        icon: 'none',
-                        title: '取消观看',
-                    })
-                }
-            })
-        }
-    },
+    onLoad() {},
     async onShow() {
         let uid = wx.getStorageSync('uid') || ''
         // 没登陆先走静默登录,登录后直接获取用户信息
         if (!uid) {
-            return getOpenidNoLogin(async () => {
-                let userInfo = await getUserInfo()
-                console.log(userInfo);
-                this.setData({
-                    userInfo
-                })
+            getOpenidNoLogin(async () => {
+                this.setUserInfo()
             })
         } else {
-            let userInfo = await getUserInfo()
-            console.log(userInfo);
-            this.setData({
-                userInfo
-            })
+            this.setUserInfo()
+        }
+    },
+    async setUserInfo() {
+        let userInfo = await getUserInfo()
+        this.setData({
+            userInfo
+        })
+        console.log(userInfo);
+        // 如果用户没有头像及昵称的话就提醒获取
+        if (!userInfo.user.avatar && !userInfo.user.wechatName) {
+            wx.navigateTo({
+                url: `/pages/login/login`
+            });
         }
     },
     jump({
@@ -82,15 +56,6 @@ Page({
         });
     },
     rewardedVideo() {
-        // button 点击事件
-        console.log('打开激励视频');
-        // 在合适的位置打开广告
-        if (videoAd) {
-            videoAd.show().catch(err => {
-                // 失败重试
-                videoAd.load()
-                    .then(() => videoAd.show())
-            })
-        }
+        this.selectComponent('#advert').rewardedVideo();
     }
 })

+ 3 - 2
pages/my/index.json

@@ -1,5 +1,6 @@
 {
-    "usingComponents": {},
+    "usingComponents": {
+        "rewardedVideo": "../../component/rewardedVideo/index"
+    },
     "enablePullDownRefresh": false
-
 }

+ 7 - 6
pages/my/index.wxml

@@ -32,13 +32,13 @@
             </view>
             <view class="uRBtm">
                 <view class="count countFirst">
-                    作品<text class="countNum textOver">{{userInfo.user.readAmount || 0}}</text>
+                    作品<text class="countNum textOver">{{userInfo.readAmount || 0}}</text>
                 </view>
                 <view class="count">
-                    粉丝<text class="countNum textOver">{{userInfo.user.fansAmount || 0}}</text>
+                    粉丝<text class="countNum textOver">{{userInfo.fansAmount || 0}}</text>
                 </view>
                 <view class="count countEnd">
-                    播放<text class="countNum textOver">{{userInfo.user.playAmount || 0}}</text>
+                    播放<text class="countNum textOver">{{userInfo.playAmount || 0}}</text>
                 </view>
             </view>
         </view>
@@ -49,7 +49,7 @@
     </view>
     <!-- 跳转菜单 -->
     <view class="sectionBoxs">
-        <view class="sBox" bindtap='jump' data-url="/pages/myworks/myworks">
+        <view class="sBox" bindtap='jump' data-url="/pages/userWorks/index">
             <image class="img" src="/static/image/work.png" mode="" />
             <text class="title">我的作品</text>
         </view>
@@ -102,7 +102,7 @@
     <!-- 剩余使用次数 -->
     <view class="surplus">
         <view class="title">剩余使用次数:</view>
-        <view class="num">0次</view>
+        <view class="num">{{userInfo.experienceAmount}}次</view>
     </view>
     <!-- 任务活动 -->
     <view class="taskBox">
@@ -149,4 +149,5 @@
             </view>
         </view>
     </view>
-</view>
+</view>
+<rewardedVideo id='advert'></rewardedVideo>

+ 2 - 2
pages/reading/reading.js

@@ -516,7 +516,7 @@ Page({
         } else {
             const recordSource = this.data.recordSource
             wx.uploadFile({
-                url: 'https://reader-api.ai160.com/file/upload',
+                url: 'https://reader-api.efunbox.cn/file/upload',
                 filePath: recordSource,
                 name: '朗读录音',
                 header: {
@@ -589,7 +589,7 @@ Page({
         })
         const recordSource = this.data.recordSource;
         wx.uploadFile({
-            // url: 'https://reader-api.ai160.com/file/upload',
+            // url: 'https://reader-api.efunbox.cn/file/upload',
             url: 'https://reader-api.efunbox.cn//file/upload',
             filePath: recordSource,
             name: '朗读录音',

+ 1 - 1
pages/user/myEdit/myEdit.js

@@ -79,7 +79,7 @@ Page({
         // tempFilePath可以作为img标签的src属性显示图片
         const localImage = res.tempFilePaths[0];
         wx.uploadFile({
-          url: 'https://reader-api.ai160.com/file/upload',
+          url: 'https://reader-api.efunbox.cn/file/upload',
           filePath: localImage,
           name: '头像',
           header: {

+ 58 - 0
pages/userWorks/index.js

@@ -0,0 +1,58 @@
+import {
+    getSelfRead
+} from '~/api/user'
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        list: []
+    },
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad(options) {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady() {
+        this.getSelfRead()
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow() {
+
+    },
+    async getSelfRead() {
+        let params = {
+            uid: wx.getStorageSync('uid'),
+            pageNo: 1,
+            pageSize: 99
+        }
+        let list = await getSelfRead(params)
+        this.setData({
+            list
+        })
+        console.log(list[0]);
+    },
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom() {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage() {
+
+    }
+})

+ 3 - 0
pages/userWorks/index.json

@@ -0,0 +1,3 @@
+{
+    "usingComponents": {}
+}

+ 69 - 0
pages/userWorks/index.less

@@ -0,0 +1,69 @@
+.worksBox {
+    .work {
+        background-color: white;
+
+        .workHead {
+            display: flex;
+            justify-content: space-between;
+            align-items: center;
+            padding: 16rpx 20rpx;
+
+            .wH-left {
+                display: flex;
+                justify-content: space-between;
+                align-items: center;
+
+                .avatar {
+                    width: 80rpx;
+                    height: 80rpx;
+                    border-radius: 50%;
+                    overflow: hidden;
+                }
+
+                .wH-left-user {
+                    margin-left: 18rpx;
+
+                    .nickname {
+                        max-width: 320rpx;
+                        font-size: 30rpx;
+                        font-weight: bold;
+                        color: #000;
+                    }
+
+                    .time {
+                        margin-top: 4rpx;
+                        font-size: 26rpx;
+                        color: rgba(0, 0, 0, 0.6);
+                    }
+                }
+            }
+
+            .wH-right {
+                display: flex;
+                align-items: center;
+
+                .wH-right-btn {
+                    text-align: center;
+                    margin-right: 30rpx;
+
+                    .img {
+                        width: 27rpx;
+                        height: 32rpx;
+                    }
+
+                    .text {
+                        font-size: 26rpx;
+                        color: rgba(0, 0, 0, 0.74);
+                    }
+                }
+            }
+        }
+
+        .workContent {
+            .video {
+                width: 100%;
+                height: 422rpx;
+            }
+        }
+    }
+}

+ 41 - 0
pages/userWorks/index.wxml

@@ -0,0 +1,41 @@
+<view class="worksBox">
+    <!-- 作品列表 -->
+    <view class="works">
+        <view class="work" wx:for="{{list}}" wx:key="index">
+            <view class="workHead">
+                <view class="wH-left">
+                    <image src="{{item.user.avatar}}" class="avatar" mode="" />
+                    <view class="wH-left-user">
+                        <view class="nickname textOver">{{item.user.nickName}}</view>
+                        <view class="time">发布时间:{{item.userRead.day}}</view>
+                    </view>
+                </view>
+                <view class="wH-right">
+                    <view class="wH-right-btn">
+                        <image class="img" src="/static/index/down.png" mode="" />
+                        <view class="text">下载</view>
+                    </view>
+                    <view class="wH-right-btn">
+                        <image class="img" style="width:24rpx" src="/static/index/delete.png" mode="" />
+                        <view class="text">删除</view>
+                    </view>
+                    <view class="wH-right-btn">
+                        <image class="img" style="width:30rpx"
+                            src="{{item.userRead.status==='NORMAL'? '/static/index/unlock.png': '/static/index/lock.png'}}" />
+                        <view class="text">
+                            {{item.userRead.status==='NORMAL'? '公开': '私密'}}
+                        </view>
+                    </view>
+                </view>
+            </view>
+            <view class="workContent">
+                <!-- <view>
+                    <image class="video_item_dialog_img" src="../../static/index/checking.png"
+                        mode="aspectFit|aspectFill|widthFix" />
+                </view> -->
+                <!--  <video class="video" src="{{item.userRead.videoPath}}" autoplay="{{false}}" object-fit="contain">
+                </video> -->
+            </view>
+        </view>
+    </view>
+</view>

+ 54 - 0
pages/userWorks/index.wxss

@@ -0,0 +1,54 @@
+.worksBox .work {
+  background-color: white;
+}
+.worksBox .work .workHead {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  padding: 16rpx 20rpx;
+}
+.worksBox .work .workHead .wH-left {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+}
+.worksBox .work .workHead .wH-left .avatar {
+  width: 80rpx;
+  height: 80rpx;
+  border-radius: 50%;
+  overflow: hidden;
+}
+.worksBox .work .workHead .wH-left .wH-left-user {
+  margin-left: 18rpx;
+}
+.worksBox .work .workHead .wH-left .wH-left-user .nickname {
+  max-width: 320rpx;
+  font-size: 30rpx;
+  font-weight: bold;
+  color: #000;
+}
+.worksBox .work .workHead .wH-left .wH-left-user .time {
+  margin-top: 4rpx;
+  font-size: 26rpx;
+  color: rgba(0, 0, 0, 0.6);
+}
+.worksBox .work .workHead .wH-right {
+  display: flex;
+  align-items: center;
+}
+.worksBox .work .workHead .wH-right .wH-right-btn {
+  text-align: center;
+  margin-right: 30rpx;
+}
+.worksBox .work .workHead .wH-right .wH-right-btn .img {
+  width: 27rpx;
+  height: 32rpx;
+}
+.worksBox .work .workHead .wH-right .wH-right-btn .text {
+  font-size: 26rpx;
+  color: rgba(0, 0, 0, 0.74);
+}
+.worksBox .work .workContent .video {
+  width: 100%;
+  height: 422rpx;
+}

+ 1 - 1
utils/const.js

@@ -5,6 +5,6 @@ module.exports = {
   productApi:  'https://reader-test.efunbox.cn/readerProduct/',
   // baseApi: 'https://reader.lingjiao.cn/readerBase/'
   // baseApi: 'https://readertest.lingjiao.cn:442/readerBase/'
-  baseApi: 'https://reader-api.ai160.com/'
+  baseApi: 'https://reader-api.efunbox.cn/'
   // baseApi: 'https://reader-api.efunbox.cn/'
 }

+ 3 - 0
utils/filter.wxs

@@ -15,6 +15,9 @@ var formatDate = function (datetime) {
 }
 
 function gradeFilter(grade) {
+    if (!grade) {
+        return '暂无'
+    }
     var gradeObj = {
         "PRIMARY_FIRST_GRADE": "一年级",
         "PRIMARY_SECOND_GRADE": "二年级",

+ 4 - 7
utils/httpUtilNoLogin.js

@@ -13,7 +13,7 @@ function genAPIUrl(action) {
 // 登录
 function wxLogin(successcallback, failcallback) {
     wx.login({
-        success: function(res) {
+        success: function (res) {
             if (res.code) {
                 // 获取openid
                 console.log('登录登录登录登录code', res.code)
@@ -33,13 +33,9 @@ function wxLogin(successcallback, failcallback) {
 /* 新增参数grade 需要给游客添加grade参数 */
 function getOpenidNoLogin(successcallback, failcallback, grade) {
 
-    wxLogin(function(res) {
-        console.log('wx.login', res)
+    wxLogin(function (res) {
         if (res.data.code == 200) {
-            let sessionKey = res.data.data.session_key;
             let openId = res.data.data.openid;
-            // successcallback()
-            // wx.setStorageSync('uid', '111')
             let url = genAPIUrl('wx/user/register');
             request.getInstance().method('POST').url(url).header({
                 'content-type': 'application/json'
@@ -51,12 +47,13 @@ function getOpenidNoLogin(successcallback, failcallback, grade) {
                     wx.setStorageSync('uid', res.data.data.uid)
                     wx.setStorageSync('grade', res.data.data.grade)
                     wx.setStorageSync('user', res.data.data)
+                    console.log('wx.login', res)
                     successcallback(res)
                 }
             }).fail(() => {});
         }
 
-    }, function(res) {
+    }, function (res) {
         failcallback(res);
     })
 }

+ 2 - 1
utils/request.js

@@ -1,4 +1,5 @@
-let baseUrl = 'https://reader-api.ai160.com/wx'
+// let baseUrl = 'https://reader-api.efunbox.cn/wx'
+let baseUrl = 'https://reader-api.efunbox.cn/wx'
 
 
 function request(url, method, data, abort = false) {

+ 43 - 0
utils/rewardVideo.js

@@ -0,0 +1,43 @@
+export default function (adUnitId) {
+    this.Ad = false;
+
+    if (wx.createInterstitialAd) {
+        this.Ad = wx.createInterstitialAd({
+            adUnitId: adUnitId
+        })
+    }
+
+    this.show = function (opt) {
+        var defaul_opt = {
+            show_suc: function () {
+                console.log('interstitial ad show suc');
+            },
+            show_fail: function (err) {
+                console.log('interstitial ad show fail', err);
+            },
+            close: function () {
+                console.log('interstitial ad close');
+            }
+        }
+
+        opt = {
+            ...defaul_opt,
+            ...opt
+        };
+        if (!this.Ad) {
+            opt.show_fail('this ad is false');
+            return false;
+        }
+        this.Ad.show().then(function () {
+            opt.show_suc();
+        }).catch(function (err) {
+            opt.show_fail(err);
+        });
+
+        //on close
+        this.Ad.offClose();
+        this.Ad.onClose(function () {
+            opt.close();
+        })
+    }
+}