test.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <view class="content">
  3. <ad-rewarded-video adpid="1372912966" :loadnext="true" v-slot:default="{loading, error}" @load="onadload" @close="onadclose" @error="onaderror"
  4. :url-callback="callbackData">
  5. <button :disabled="loading" :loading="loading">显示广告</button>
  6. <view v-if="error">{{error}}</view>
  7. </ad-rewarded-video>
  8. </view>
  9. </template>
  10. <script>
  11. import {
  12. mapState
  13. } from "vuex"
  14. export default {
  15. data() {
  16. return {
  17. callbackData:{
  18. 'userId':"",
  19. 'extra':{}
  20. }
  21. }
  22. },
  23. onLoad(){
  24. console.log(this.userInfo);
  25. this.callbackData.userId = this.userInfo.sysUser.id;
  26. },
  27. computed: {
  28. ...mapState(['userInfo', 'userCheckInfo']),
  29. },
  30. methods: {
  31. onadload(e) {
  32. },
  33. onCreateAd(){
  34. },
  35. onadclose(e) {
  36. const detail = e.detail
  37. // 用户点击了【关闭广告】按钮
  38. if (detail && detail.isEnded) {
  39. } else {
  40. // 播放中途退出
  41. console.log("onadclose " + detail.isEnded);
  42. }
  43. },
  44. onaderror(e) {
  45. // 广告加载失败
  46. this.$refs.uToast.show({
  47. title: '广告加载失败',
  48. type: 'default',
  49. })
  50. console.log("onaderror: ", e.detail);
  51. }
  52. }
  53. }
  54. </script>