index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view class="red_packet" catchtouchmove="true">
  3. <image src="https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/icon/red_packet_background.jpg" class="read_packet_background" />
  4. <view class="rule" @click="showRule">活动规则</view>
  5. <view class="get_content" v-if="!showReward">
  6. <view class="custom_button" :class="{ disabled: packetItem.status !== 0 }" @click="showRectangle"> 立即领取 </view>
  7. <text>{{ packetItem.status !== 0 ? "红包已领取或已失效" : "点击领取后,红包将自动到账余额" }}</text>
  8. </view>
  9. <uni-popup ref="lotteryRule" type="center">
  10. <view class="lottery_rule_box">
  11. <view class="lottery_rule_title">
  12. <text>活动规则</text>
  13. <view class="close_btn" @click="closeRule"> X </view>
  14. </view>
  15. <scroll-view class="lottery_rule_info" scroll-y="true">
  16. <rich-text :nodes="packetItem.active_rule" class="rich_text"></rich-text>
  17. </scroll-view>
  18. </view>
  19. </uni-popup>
  20. <div :class="['rectangle', { show: showReward }]">
  21. <image src="https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/icon/red_packet_bottom.png" class="read_packet_background" />
  22. <view class="text_content">
  23. <view>
  24. <text style="font-size: 50rpx; font-weight: bold">{{ packetItem.money }} </text>元
  25. </view>
  26. <view style="margin-top: 20rpx; color: #02a7f0" @click="_goWithdraw">已存入余额,去提现</view>
  27. </view>
  28. </div>
  29. </view>
  30. </template>
  31. <script setup>
  32. import { ref } from "vue";
  33. import { onLoad } from "@dcloudio/uni-app";
  34. import common from "@/utils/common";
  35. import http from "@/utils/request";
  36. const lotteryRule = ref();
  37. const showReward = ref(false);
  38. const packetItem = ref({});
  39. onLoad((options) => {
  40. // 获取传递的参数
  41. _getPacketlist(options.packet_id);
  42. });
  43. const closeRule = () => {
  44. lotteryRule.value.close();
  45. };
  46. const showRule = () => {
  47. lotteryRule.value.open("center");
  48. };
  49. const showRectangle = common.debounce(() => {
  50. if (!packetItem.value.custom_redpacket_id) return;
  51. http.request("/api/redpacket/get_redpacket", { custom_redpacket_id: packetItem.value.custom_redpacket_id }).then((callback) => {
  52. if (callback.code == "success") {
  53. showReward.value = true;
  54. }
  55. });
  56. }, 1000);
  57. const _goWithdraw = () => {
  58. uni.redirectTo({
  59. url: "/pages/user/withdraw",
  60. });
  61. };
  62. const _getPacketlist = (packet_id) => {
  63. http.request("api/redpacket/get_info", { custom_redpacket_id: packet_id }, "POST").then((callback) => {
  64. if (callback.code == "success") {
  65. packetItem.value = callback.data;
  66. }
  67. });
  68. };
  69. </script>
  70. <style lang="less" scoped>
  71. .red_packet {
  72. width: 100vw;
  73. height: 100vh;
  74. position: relative;
  75. .read_packet_background {
  76. width: 100%;
  77. height: 100%;
  78. }
  79. .rule {
  80. position: absolute;
  81. right: 0;
  82. top: 26%;
  83. color: #846100;
  84. padding: 15rpx 35rpx;
  85. background-color: #ffedad;
  86. border-radius: 60rpx;
  87. text-align: center;
  88. font-size: 28rpx;
  89. }
  90. .get_content {
  91. position: absolute;
  92. bottom: 18%;
  93. width: 100%;
  94. display: flex;
  95. flex-direction: column;
  96. align-items: center;
  97. justify-content: center;
  98. > text {
  99. color: #fff;
  100. font-size: 26rpx;
  101. margin-top: 20rpx;
  102. }
  103. }
  104. .custom_button {
  105. display: inline-block;
  106. background-color: #fbe6a0;
  107. color: #9c6c11;
  108. font-size: 18px;
  109. padding: 6px 30px;
  110. border-radius: 8px;
  111. text-align: center;
  112. box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
  113. border: 2px solid transparent;
  114. text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
  115. position: relative;
  116. &.disabled {
  117. background-color: #ccc;
  118. color: #666;
  119. &:before,
  120. &:after {
  121. background-color: #ccc;
  122. border-color: #ccc;
  123. }
  124. }
  125. &:before,
  126. &:after {
  127. content: "";
  128. position: absolute;
  129. width: 24px;
  130. height: 24px;
  131. background-color: #fbe6a0;
  132. border: 2px solid #fbe6a0;
  133. border-radius: 10rpx;
  134. top: 50%;
  135. transform: translateY(-50%);
  136. }
  137. &:before {
  138. left: -6px;
  139. }
  140. &:after {
  141. right: -6px;
  142. }
  143. }
  144. .lottery_rule_box {
  145. width: 500rpx;
  146. display: block;
  147. overflow: hidden;
  148. background-color: #fc335f;
  149. font-size: 26rpx;
  150. margin: 0 auto;
  151. line-height: 50rpx;
  152. border-radius: 10rpx;
  153. padding: 20rpx 25rpx 20rpx;
  154. .lottery_rule_title {
  155. color: #ffffff;
  156. height: 60rpx;
  157. font-size: 32rpx;
  158. line-height: 60rpx;
  159. text-align: center;
  160. margin-bottom: 10rpx;
  161. .close_btn {
  162. float: right;
  163. width: 40rpx;
  164. height: 40rpx;
  165. font-size: 24rpx;
  166. margin-top: 9rpx;
  167. line-height: 40rpx;
  168. border-radius: 50%;
  169. border: 1rpx solid #ffffff;
  170. }
  171. }
  172. .lottery_rule_info {
  173. display: block;
  174. height: 500rpx;
  175. font-size: 24rpx;
  176. line-height: 40rpx;
  177. border-radius: 10rpx;
  178. padding: 20rpx;
  179. box-sizing: border-box;
  180. background-color: #ffffff;
  181. .rich_text {
  182. white-space: break-spaces;
  183. }
  184. }
  185. }
  186. .rectangle {
  187. width: 100%;
  188. height: 250px;
  189. position: absolute;
  190. bottom: -250px; /* 初始位置在视图之外 */
  191. left: 0;
  192. transition: bottom 1s ease; /* 添加过渡效果 */
  193. &.show {
  194. bottom: 0; /* 目标位置 */
  195. }
  196. .text_content {
  197. position: absolute;
  198. top: 50%;
  199. left: 50%;
  200. transform: translate(-50%, -35%);
  201. text-align: center;
  202. }
  203. }
  204. }
  205. </style>