JXDS18FUJT 1 жил өмнө
parent
commit
3ec127bc43

+ 118 - 8
src/otherPages/forecastHistory/index.vue

@@ -5,7 +5,8 @@
                 <view class="content">
                     <view v-for="(item, index) in list" :key="index" class="item">
                         <view>
-                           <text @click="goForecast(item)">{{ item.name }} {{ item.sex == '1' ? '男' : '女' }} {{ item.birthday }}</text> 
+                            <text @click="goForecast(item)">{{ item.name }} {{ item.sex == '1' ? '男' : '女' }} {{
+                                item.birthday }}</text>
                             <image v-if="item.isPay == 2" class="item-vip" mode="widthFix"
                                 src="/static/icon/gold_vip@2x.png">
                             </image>
@@ -34,7 +35,7 @@
                     </view> -->
                 </view>
             </view>
-            <view class="buttons">
+            <view class="bottom">
                 <view @click="getPrePage()" class="pre">
                     上一页
                 </view>
@@ -45,7 +46,24 @@
                     下一页
                 </view>
             </view>
+
         </view>
+        <van-popup round close-on-click-overlay safe-area-tab-bar :show="wxadWatchTip">
+            <view class="wxad">
+                <image style="width: 100%;" src="https://ndata.zzxcx.net/ctjk/mp-wx/future/wxad_bg@2x.png" mode="widthFix">
+                </image>
+                <view class="buttons">
+                    <view @click="watchWxAd()" class="button1">
+                        <van-icon custom-style="margin-right:10rpx;" color="#A21D0F" name="video-o" /><text>看广告免费领取</text>
+                    </view>
+                    <view @click="() => {
+                        wxadWatchTip = false
+                    }" class="button2">
+                        <van-icon custom-style="margin-right:10rpx;" color="#B35B23" name="close" />取消
+                    </view>
+                </view>
+            </view>
+        </van-popup>
     </view>
 </template>
 
@@ -57,6 +75,10 @@ export default {
             list: [],
             total: 1,
             pageNum: 1,
+            wxadWatchTip: false,
+            currentItem:{
+
+            }
 
 
         }
@@ -67,15 +89,62 @@ export default {
         }
     },
     methods: {
-        goForecast(item){
-           uni.navigateTo({
-            url:`/pages/forecast/index?birthday=${item.birthday}&sex=${item.sex}&username=${item.name}`,
+        watchWxAd() {
+            let that = this
+            let videoAd = null;
+            if (wx.createRewardedVideoAd) {
+                videoAd = wx.createRewardedVideoAd({
+                    adUnitId: "adunit-f0e94618f34d4baf",
+                });
+                videoAd.onLoad(() => {
+
+                });
+                videoAd.onError((err) => {
+                    console.log(err)
+                });
+                videoAd.offClose();
+                videoAd.onClose((res) => {
+
+                    if (!res.isEnded) {
+                        return
+                    }
+                    that.wxadWatchTip = false
+                    uni.navigateTo({
+                        url: `/pages/forecast/index?birthday=${that.currentItem.birthday}&sex=${that.currentItem.sex}&username=${that.currentItem.name}`,
+
+                    })
+                });
+                videoAd.show().catch(() => {
+                    // 失败重试
+                    videoAd
+                        .load()
+                        .then(() => videoAd.show())
+                        .catch((err) => {
+                            console.log("激励视频 广告显示失败");
+                        });
+                });
+            } else if (res.cancel) {
+                console.log('用户点击取消')
+            }
+        },
+        goForecast(item) {
+            let that = this
+            let videoAd = null;
+            that.currentItem = item
+            if (item.isPay == 0) {
+                that.wxadWatchTip = true
+                return
+
+            }
 
-           })
+            uni.navigateTo({
+                url: `/pages/forecast/index?birthday=${item.birthday}&sex=${item.sex}&username=${item.name}`,
+
+            })
 
         },
         delSingleHistory(id) {
-            let that =this
+            let that = this
             uni.showModal({
                 title: '提示',
                 content: '是否删除该记录',
@@ -140,6 +209,47 @@ export default {
     padding-bottom: 90rpx;
 }
 
+.wxad {
+    width: 580rpx;
+    position: relative;
+
+    .buttons {
+        position: absolute;
+        top: 478rpx;
+        display: flex;
+        justify-content: center;
+        height: 202rpx;
+        width: 100%;
+        flex-wrap: wrap;
+
+        .button1 {
+            width: 412rpx;
+            background-image: url('https://ndata.zzxcx.net/ctjk/mp-wx/future/wxad_button1_bg@2x.png');
+            height: 80rpx;
+            background-size: 100% 100%;
+            line-height: 80rpx;
+            font-size: 34rpx;
+            text-align: center;
+            color: #A21D0F;
+            font-weight: bold;
+            border-radius: 20rpx;
+        }
+
+        .button2 {
+            width: 412rpx;
+            height: 80rpx;
+            background-color: #F8D5BA;
+            color: #B35B23;
+            font-size: 34rpx;
+            font-weight: bold;
+            line-height: 80rpx;
+            text-align: center;
+            border-radius: 20rpx;
+
+        }
+    }
+}
+
 .list {
     padding: 0 30rpx;
     padding-top: 50rpx;
@@ -183,7 +293,7 @@ export default {
 
 }
 
-.buttons {
+.bottom {
     width: 690rpx;
     margin: 0 auto;
     border: 4rpx solid #FDE575;