瀏覽代碼

新增三力测试广告

JXDS18FUJT 1 年之前
父節點
當前提交
2462cb4611
共有 2 個文件被更改,包括 63 次插入11 次删除
  1. 53 3
      src/otherPages/beforeThreeExam/index.vue
  2. 10 8
      src/otherPages/threeExam/index.vue

+ 53 - 3
src/otherPages/beforeThreeExam/index.vue

@@ -41,9 +41,9 @@
         </view>
       </view>
       <view class="mid1-submit">
-        <navigator url="/otherPages/threeExam/index?showSubmit=1">
-          <view class="mid1-submit-begin"> 开始考试</view>
-        </navigator>
+       
+          <view @click="watchAdTobegin" class="mid1-submit-begin"> 开始考试</view>
+       
         <navigator url="/otherPages/threeExam/index?showSubmit=0">
           <view class="mid1-submit-continue">继续练习</view>
         </navigator>
@@ -73,6 +73,56 @@ export default {
     return {};
   },
   methods: {
+    watchAdTobegin(){
+      let that = this
+			let videoAd = null;
+      uni.showModal({
+        title:'观看激励广告',
+        content:'广告结束后开始考试',
+        success(res){
+          if(res.confirm){
+            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:"/otherPages/threeExam/index?showSubmit=1"
+      })
+				});
+				videoAd.show().catch(() => {
+					// 失败重试
+					videoAd
+						.load()
+						.then(() => videoAd.show())
+						.catch((err) => {
+							console.log("激励视频 广告显示失败");
+						});
+				});
+			} else if (res.cancel) {
+				console.log('用户点击取消')
+			}
+          }
+          
+        }
+
+      })
+		
+    
+
+    },
     back() {
       uni.navigateBack();
     },

+ 10 - 8
src/otherPages/threeExam/index.vue

@@ -1,8 +1,8 @@
 <template>
   <view class="threeExam">
-    <view class="topad">
+    <!-- <view class="topad">
       <ad class="wxad" :ad-intervals="100" unit-id="adunit-f9ac1a546be5b3f0"></ad>
-    </view>
+    </view> -->
     <view class="problem">
       <!-- <text class="problem-type"> 判断题 </text> -->
       <!-- <text class="problem-issue"
@@ -15,6 +15,13 @@
         '、' +
         problemList[problemListIndex].question
         "></rich-text>
+
+<view class="problem-media">
+        <image mode="widthFix" v-if="getFileType(problemList[problemListIndex].mediaUrl) == 'image'"
+          :src="problemList[problemListIndex].mediaUrl"></image>
+        <video :controls="false" autoplay loop v-if="getFileType(problemList[problemListIndex].mediaUrl) == 'video'"
+          :src="problemList[problemListIndex].mediaUrl"></video>
+      </view>
       <view class="problem-radio">
         <van-radio-group v-if="!problemList[problemListIndex].isComplete" @change="changeUserAnswer"
           :value="problemList[problemListIndex].userAnswer">
@@ -182,12 +189,7 @@
           </view>
         </van-radio-group>
       </view>
-      <view class="problem-media">
-        <image mode="widthFix" v-if="getFileType(problemList[problemListIndex].mediaUrl) == 'image'"
-          :src="problemList[problemListIndex].mediaUrl"></image>
-        <video :controls="false" autoplay loop v-if="getFileType(problemList[problemListIndex].mediaUrl) == 'video'"
-          :src="problemList[problemListIndex].mediaUrl"></video>
-      </view>
+  
     </view>
     <view class="bottom">
       <view class="switch">