index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view class='app-container'>
  3. <img :src="pic" />
  4. <button class="submit" type="submit" circle @click="getSubmit">立即兑换</button>
  5. <!-- 弹窗 -->
  6. <uni-popup ref="popup" type="center" :is-mask-click="false">
  7. <view class="popup">
  8. <h3>{{ isShow ? '兑换成功' : '抱歉' }}</h3>
  9. <view class="center">{{ content }}</view>
  10. <view class="submit-btn">
  11. <button type="submit" circle @click="getClose">确定</button>
  12. <span>{{ isShow ? '该套餐内容仅可在WIFI/移动数据模式下收听' : '' }}</span>
  13. </view>
  14. </view>
  15. </uni-popup>
  16. </view>
  17. </template>
  18. <script>
  19. import { detail, submit } from '@/api/activity.js'
  20. export default {
  21. data() {
  22. return {
  23. pic: '',
  24. form: {
  25. activityId: '',
  26. clientType: getApp().globalData.userInfo.deviceClientType,
  27. deviceMac: getApp().globalData.userInfo.deviceMac,
  28. type: getApp().globalData.deviceInfo.deviceMode
  29. },
  30. // 弹窗内容
  31. content: '',
  32. // 兑换成功
  33. isShow: false
  34. }
  35. },
  36. onLoad(e) {
  37. this.form.activityId = e.activityId
  38. this.getDetail()
  39. },
  40. methods: {
  41. getDetail() {
  42. detail({
  43. activityId: this.form.activityId
  44. }).then(res => {
  45. if (res.data.code === 0) {
  46. this.pic = res.data.data.pic
  47. } else {
  48. uni.showToast({
  49. title: res.data.message,
  50. icon: 'error',
  51. duration: 2000
  52. })
  53. }
  54. })
  55. },
  56. // 立即领取
  57. getSubmit() {
  58. this.$refs.popup.open()
  59. if (this.form.type == 2 || this.form.type == 4) {
  60. submit(this.form).then(res => {
  61. if (res.data.code === 0) {
  62. this.content = res.data.data
  63. this.isShow = true
  64. } else {
  65. this.content = res.data.message
  66. this.isShow = false
  67. }
  68. })
  69. } else {
  70. this.content = '请在WIFI/4G模式下连接设备'
  71. this.isShow = false
  72. }
  73. },
  74. // 关闭弹窗
  75. getClose() {
  76. this.$refs.popup.close()
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. .app-container {
  83. padding: 0;
  84. overflow: hidden;
  85. position: relative;
  86. }
  87. img {
  88. width: 100%;
  89. height: 100%;
  90. display: block;
  91. }
  92. .submit {
  93. position: absolute;
  94. bottom: 20rpx;
  95. left: 50%;
  96. transform: translate(-50%);
  97. width: calc(100% - 120rpx);
  98. }
  99. .popup {
  100. width: 576rpx;
  101. height: 600rpx;
  102. background: #fff;
  103. border-radius: 32rpx;
  104. color: #000;
  105. font-weight: bold;
  106. text-align: center;
  107. padding: 48rpx 0;
  108. display: flex;
  109. flex-direction: column;
  110. justify-content: space-between;
  111. align-items: center;
  112. .center {
  113. font-size: 32rpx;
  114. }
  115. .submit-btn {
  116. button {
  117. width: 320rpx;
  118. height: 80rpx;
  119. line-height: 80rpx;
  120. font-size: 32rpx;
  121. }
  122. span {
  123. font-size: 24rpx;
  124. }
  125. }
  126. }
  127. </style>