瑶都万能墙
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.

243 lines
5.2 KiB

1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
  1. <template>
  2. <view>
  3. <!-- 普通模式 -->
  4. <view v-if="!showModel" class="phone" v-show="phone" @click.stop="callPhone">
  5. <image src="/static/image/home/phone.png" mode="widthFix"></image>
  6. {{ title || '联系' + ta[sexName] }}
  7. </view>
  8. <!-- 悬浮窗模式 -->
  9. <view v-else v-show="phone" class="phone-modal" @click.stop="callPhone">
  10. <view class="phone-modal-content">
  11. <image src="/static/image/home/phone.png" mode="widthFix"></image>
  12. <text class="phone-modal-text">{{ title || '联系' + ta[sexName] }}</text>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import mixinsSex from '@/mixins/sex.js'
  19. import rewardedVideoAdMixin from '@/mixins/rewardedVideoAd.js'
  20. import { mapState } from 'vuex'
  21. export default {
  22. mixins: [mixinsSex, rewardedVideoAdMixin],
  23. props: {
  24. phone: {
  25. type: String,
  26. default: ''
  27. },
  28. title: {
  29. type: String,
  30. default: ''
  31. },
  32. sexName: {
  33. type: String,
  34. default: ''
  35. },
  36. type: {
  37. type: String,
  38. default: ''
  39. },
  40. phoneTitle: {
  41. type: String,
  42. default: ''
  43. },
  44. pid: {
  45. type: [String, Number],
  46. default: ''
  47. },
  48. // 显示模式:false-普通模式,true-悬浮窗模式
  49. showModel: {
  50. type: Boolean,
  51. default: false
  52. }
  53. },
  54. data() {
  55. return {
  56. // 视频广告相关数据已移至混入中
  57. }
  58. },
  59. computed : {
  60. ...mapState(['priceMap']),
  61. },
  62. // mounted钩子已在混入中处理
  63. methods: {
  64. // 广告观看完成回调
  65. onAdWatchComplete() {
  66. console.log('用户看完广告,开始拨打电话')
  67. this.performCall()
  68. },
  69. // 广告观看取消回调
  70. onAdWatchCancel() {
  71. uni.showToast({
  72. title: '请观看完整广告才能拨打电话',
  73. icon: 'none'
  74. })
  75. },
  76. callPhone(){
  77. let data = {
  78. title : this.phoneTitle,
  79. type : this.type,
  80. id : this.pid
  81. }
  82. this.rewardedRecordConfig.type = this.type //
  83. this.rewardedRecordConfig.formId = this.pid //
  84. console.log(data);
  85. if(!data.id || !data.title){
  86. return uni.showToast({
  87. title: '缺少参数',
  88. icon: 'none'
  89. })
  90. }
  91. // 注释积分消耗逻辑,改为观看视频
  92. // uni.showModal({
  93. // title: `确定消耗${this.priceMap.phone}积分呼叫吗?`,
  94. // success : (r) => {
  95. // if(r.confirm){
  96. // this.$api('checkGivePhone', data, res => {
  97. // if(res.code == 200){
  98. // uni.makePhoneCall({
  99. // phoneNumber: this.phone
  100. // })
  101. // }
  102. // })
  103. // }
  104. // }
  105. // })
  106. // 改为观看视频后拨打电话
  107. uni.showModal({
  108. title: '观看广告后拨打电话',
  109. content: '观看完整视频广告后即可免费拨打电话',
  110. success : (r) => {
  111. if(r.confirm){
  112. // 使用混入的方法显示广告
  113. this.showRewardedVideoAd({
  114. onSuccess: this.onAdWatchComplete,
  115. onCancel: this.onAdWatchCancel,
  116. fallbackTitle: '广告加载失败',
  117. fallbackContent: '无法加载广告,是否直接拨打电话?'
  118. })
  119. }
  120. }
  121. })
  122. },
  123. // 执行拨打电话(观看广告后调用)
  124. performCall() {
  125. let data = {
  126. title : this.phoneTitle,
  127. type : this.type,
  128. id : this.pid
  129. }
  130. // 注释原有的积分检查接口调用
  131. // this.$api('checkGivePhone', data, res => {
  132. // if(res.code == 200){
  133. // uni.makePhoneCall({
  134. // phoneNumber: this.phone
  135. // })
  136. // }
  137. // })
  138. // 直接拨打电话,不再检查积分
  139. uni.makePhoneCall({
  140. phoneNumber: this.phone
  141. })
  142. }
  143. }
  144. }
  145. </script>
  146. <style scoped lang="scss">
  147. // 普通模式样式
  148. .phone {
  149. background-color: rgba($uni-color, 0.2);
  150. color: $uni-color;
  151. padding: 8rpx 16rpx;
  152. border-radius: 10rpx;
  153. margin-left: auto;
  154. font-size: 26rpx;
  155. image {
  156. width: 20rpx;
  157. height: 20rpx;
  158. }
  159. }
  160. // 悬浮窗模式样式
  161. .phone-modal {
  162. position: fixed;
  163. bottom: calc(140rpx + env(safe-area-inset-bottom));
  164. right: 30rpx;
  165. z-index: 999;
  166. .phone-modal-content {
  167. background: linear-gradient(135deg, $uni-color 0%, rgba($uni-color, 0.8) 100%);
  168. color: #ffffff;
  169. padding: 20rpx 30rpx;
  170. border-radius: 50rpx;
  171. box-shadow: 0 8rpx 24rpx rgba($uni-color, 0.3);
  172. display: flex;
  173. align-items: center;
  174. justify-content: center;
  175. min-width: 160rpx;
  176. transition: all 0.3s ease;
  177. &:active {
  178. transform: scale(0.95);
  179. box-shadow: 0 4rpx 12rpx rgba($uni-color, 0.4);
  180. }
  181. image {
  182. width: 28rpx;
  183. height: 28rpx;
  184. margin-right: 12rpx;
  185. filter: brightness(0) invert(1); // 将图标变为白色
  186. }
  187. .phone-modal-text {
  188. font-size: 28rpx;
  189. font-weight: 500;
  190. white-space: nowrap;
  191. }
  192. }
  193. // 悬浮窗呼吸动画效果
  194. &::before {
  195. content: '';
  196. position: absolute;
  197. top: -10rpx;
  198. left: -10rpx;
  199. right: -10rpx;
  200. bottom: -10rpx;
  201. background: rgba($uni-color, 0.2);
  202. border-radius: 60rpx;
  203. animation: pulse 2s infinite;
  204. z-index: -1;
  205. }
  206. }
  207. // 呼吸动画
  208. @keyframes pulse {
  209. 0% {
  210. transform: scale(1);
  211. opacity: 0.7;
  212. }
  213. 50% {
  214. transform: scale(1.1);
  215. opacity: 0.3;
  216. }
  217. 100% {
  218. transform: scale(1);
  219. opacity: 0.7;
  220. }
  221. }
  222. </style>