index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view v-if="pic" class="app-container">
  3. <img :src="pic" />
  4. <button class="submit" type="submit" circle @click="getSubmit">
  5. 立即兑换
  6. </button>
  7. <!-- 弹窗 -->
  8. <uni-popup ref="popup" type="center" :is-mask-click="false">
  9. <view class="popup">
  10. <h3>兑换成功</h3>
  11. <view class="center">{{ content }}</view>
  12. <view class="submit-btn">
  13. <button type="submit" circle @click="getClose">确定</button>
  14. <span>该套餐内容仅可在WIFI/移动数据模式下收听</span>
  15. </view>
  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. console.log("gadfadsfqewrqerq====" + JSON.stringify(res));
  48. if (res.code === 0) {
  49. this.pic = res.data.pic;
  50. } else {
  51. uni.showToast({
  52. title: res.data.message,
  53. icon: "error",
  54. duration: 2000,
  55. });
  56. }
  57. });
  58. },
  59. // 立即领取
  60. getSubmit() {
  61. submit(this.form).then((res) => {
  62. if (res.code === 0) {
  63. this.$refs.popup.open();
  64. this.content = res.data;
  65. this.isShow = true;
  66. } else {
  67. uni.showToast({
  68. title: res.data.message,
  69. icon: "none",
  70. mask: true,
  71. duration: 2000,
  72. });
  73. }
  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. overflow: hidden;
  87. position: relative;
  88. }
  89. img {
  90. width: 100%;
  91. height: 100%;
  92. display: block;
  93. }
  94. .submit {
  95. position: absolute;
  96. bottom: 20rpx;
  97. left: 50%;
  98. transform: translate(-50%);
  99. width: calc(100% - 120rpx);
  100. }
  101. .popup {
  102. width: 576rpx;
  103. height: 600rpx;
  104. background: #fff;
  105. border-radius: 32rpx;
  106. color: #000;
  107. font-weight: bold;
  108. text-align: center;
  109. padding: 48rpx 0;
  110. display: flex;
  111. flex-direction: column;
  112. justify-content: space-between;
  113. align-items: center;
  114. .center {
  115. font-size: 32rpx;
  116. }
  117. .submit-btn {
  118. button {
  119. width: 320rpx;
  120. height: 80rpx;
  121. line-height: 80rpx;
  122. font-size: 32rpx;
  123. }
  124. span {
  125. font-size: 24rpx;
  126. }
  127. }
  128. }
  129. </style>