瑶都万能墙
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
2.9 KiB

11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
11 months ago
10 months ago
11 months ago
11 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
11 months ago
10 months ago
11 months ago
  1. <template>
  2. <view class="phone" v-if="phone" @click.stop="callPhone">
  3. <image src="/static/image/home/phone.png" mode="widthFix"></image>
  4. {{ title || '联系' + ta[sexName] }}
  5. </view>
  6. </template>
  7. <script>
  8. import mixinsSex from '@/mixins/sex.js'
  9. import rewardedVideoAdMixin from '@/mixins/rewardedVideoAd.js'
  10. import { mapState } from 'vuex'
  11. export default {
  12. mixins: [mixinsSex, rewardedVideoAdMixin],
  13. props: ['phone', 'title', 'sexName', 'type', 'phoneTitle', 'pid'],
  14. data() {
  15. return {
  16. // 视频广告相关数据已移至混入中
  17. }
  18. },
  19. computed : {
  20. ...mapState(['priceMap']),
  21. },
  22. // mounted钩子已在混入中处理
  23. methods: {
  24. // 广告观看完成回调
  25. onAdWatchComplete() {
  26. console.log('用户看完广告,开始拨打电话')
  27. this.performCall()
  28. },
  29. // 广告观看取消回调
  30. onAdWatchCancel() {
  31. uni.showToast({
  32. title: '请观看完整广告才能拨打电话',
  33. icon: 'none'
  34. })
  35. },
  36. callPhone(){
  37. let data = {
  38. title : this.phoneTitle,
  39. type : this.type,
  40. id : this.pid
  41. }
  42. console.log(data);
  43. if(!data.id || !data.title){
  44. return uni.showToast({
  45. title: '缺少参数',
  46. icon: 'none'
  47. })
  48. }
  49. // 注释积分消耗逻辑,改为观看视频
  50. // uni.showModal({
  51. // title: `确定消耗${this.priceMap.phone}积分呼叫吗?`,
  52. // success : (r) => {
  53. // if(r.confirm){
  54. // this.$api('checkGivePhone', data, res => {
  55. // if(res.code == 200){
  56. // uni.makePhoneCall({
  57. // phoneNumber: this.phone
  58. // })
  59. // }
  60. // })
  61. // }
  62. // }
  63. // })
  64. // 改为观看视频后拨打电话
  65. uni.showModal({
  66. title: '观看广告后拨打电话',
  67. content: '观看完整视频广告后即可免费拨打电话',
  68. success : (r) => {
  69. if(r.confirm){
  70. // 使用混入的方法显示广告
  71. this.showRewardedVideoAd({
  72. onSuccess: this.onAdWatchComplete,
  73. onCancel: this.onAdWatchCancel,
  74. fallbackTitle: '广告加载失败',
  75. fallbackContent: '无法加载广告,是否直接拨打电话?'
  76. })
  77. }
  78. }
  79. })
  80. },
  81. // 执行拨打电话(观看广告后调用)
  82. performCall() {
  83. let data = {
  84. title : this.phoneTitle,
  85. type : this.type,
  86. id : this.pid
  87. }
  88. // 注释原有的积分检查接口调用
  89. // this.$api('checkGivePhone', data, res => {
  90. // if(res.code == 200){
  91. // uni.makePhoneCall({
  92. // phoneNumber: this.phone
  93. // })
  94. // }
  95. // })
  96. // 直接拨打电话,不再检查积分
  97. uni.makePhoneCall({
  98. phoneNumber: this.phone
  99. })
  100. }
  101. }
  102. }
  103. </script>
  104. <style scoped lang="scss">
  105. .phone {
  106. background-color: rgba($uni-color, 0.2);
  107. color: $uni-color;
  108. padding: 8rpx 16rpx;
  109. border-radius: 10rpx;
  110. margin-left: auto;
  111. font-size: 26rpx;
  112. image {
  113. width: 20rpx;
  114. height: 20rpx;
  115. }
  116. }
  117. </style>