index.vue 3.1 KB

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