get-right-now.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <view class="get-right-now">
  3. <view class="card dir-top-nowrap main-between cross-center">
  4. <view class="jump-card background-image" @click="receiveGift">
  5. <image class="card-image" @load="is_text = true" :src="background.bg_pic"></image>
  6. <image class="avatar" :src="avatar"></image>
  7. <view class="avatar audio" @click.stop="play" v-if="bless_music">
  8. <image :src="music_play ? '../../image/play-big.png' : '../../image/stop-big.png'"></image>
  9. </view>
  10. <view class="font" v-show="is_text" :style="{color: background.color, top: `${Number(background.top)}px`, left: `${Number(background.left)}px`}">
  11. <view class="nickname">{{nickname}}</view>
  12. <view>送你一份礼物,快来领取吧</view>
  13. <view class="bless-word">{{bless_word}}</view>
  14. </view>
  15. </view>
  16. <image class="icon-close" src="./../../image/gift-close.png" @click="setGift"></image>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. name: 'figure-rule',
  23. data() {
  24. return {
  25. is_text: false,
  26. }
  27. },
  28. props: [`theme`, `gift_id`, `turn_no`, `background`, `bless_word`, `nickname`, `avatar`, `type`, `template_message`, `bless_music`, `music_play`],
  29. methods: {
  30. setGift() {
  31. this.$emit('setGift', false);
  32. },
  33. async submit() {
  34. uni.showLoading({
  35. title: '获取中'
  36. });
  37. if (this.turn_no) {
  38. const res = await this.$request({
  39. url: this.$api.gift.get_turn,
  40. method: 'get',
  41. data: {
  42. turn_no: this.turn_no,
  43. }
  44. });
  45. if (res.code === 0) {
  46. let _this = this;
  47. uni.navigateTo({
  48. url: `/plugins/gift/receive/receive?gift_id=${this.gift_id}&status=1`,
  49. success() {
  50. _this.setGift();
  51. }
  52. })
  53. } else {
  54. uni.showModal({
  55. title: '提示',
  56. content: res.msg,
  57. });
  58. this.setGift();
  59. }
  60. uni.hideLoading();
  61. } else {
  62. const res = await this.$request({
  63. url: this.$api.gift.join,
  64. method: 'get',
  65. data: {
  66. gift_id: this.gift_id
  67. }
  68. });
  69. if (res.code === 0) {
  70. this.loopAcquisition(res.data);
  71. } else {
  72. uni.showModal({
  73. title: '提示',
  74. content: res.msg,
  75. });
  76. this.setGift();
  77. }
  78. }
  79. },
  80. async receiveGift() {
  81. if (this.type !== 'direct_open') {
  82. this.$subscribe(this.template_message).then(() => {
  83. this.submit();
  84. }).catch(() => {
  85. this.submit();
  86. });
  87. } else {
  88. this.submit();
  89. }
  90. },
  91. loopAcquisition(data) {
  92. this.$request({
  93. url: this.$api.gift.join_status,
  94. data: {
  95. ...data,
  96. gift_id: this.gift_id,
  97. },
  98. method: 'get',
  99. }).then(res => {
  100. if (res.code === 0) {
  101. if (res.data.hasOwnProperty('list')) {
  102. uni.hideLoading();
  103. let _this = this;
  104. uni.navigateTo({
  105. url: `/plugins/gift/receive/receive?gift_id=${this.gift_id}&status=1`,
  106. success() {
  107. _this.setGift();
  108. }
  109. });
  110. return res.data;
  111. } else {
  112. setTimeout(() => {
  113. this.loopAcquisition(data);
  114. }, 1000);
  115. }
  116. } else if (res.code === 1) {
  117. uni.hideLoading();
  118. let status = 2;
  119. if (this.type === 'direct_open') {
  120. status = 2;
  121. } else {
  122. status = 3;
  123. }
  124. uni.navigateTo({
  125. url: `/plugins/gift/receive/receive?gift_id=${this.gift_id}&status=${status}`
  126. });
  127. this.setGift();
  128. }
  129. });
  130. },
  131. play() {
  132. if (this.music_play) {
  133. this.$emit('music', false);
  134. } else {
  135. this.$emit('music', true, this.bless_music);
  136. }
  137. }
  138. }
  139. }
  140. </script>
  141. <style scoped lang="scss">
  142. @import '../../css/gift.scss';
  143. /* 广告图 规则 */
  144. .get-right-now {
  145. position: fixed;
  146. top: 0;
  147. left: 0;
  148. width: 100%;
  149. height: 100%;
  150. z-index: 1500;
  151. background-color: rgba(0,0,0,.3);
  152. .card {
  153. position: absolute;
  154. left: 50%;
  155. top: 50%;
  156. transform: translate(-50%, -50%);
  157. width: #{600upx};
  158. height: #{900upx};
  159. .card-image {
  160. width: #{600upx};
  161. height: #{800upx};
  162. position: absolute;
  163. top: 0;
  164. left: 0;
  165. }
  166. .icon-close {
  167. width: #{42upx};
  168. height: #{42upx};
  169. padding: #{8upx};
  170. margin-top: #{48upx};
  171. }
  172. .jump-card {
  173. width: #{600upx};
  174. height: #{800upx};
  175. position: relative;
  176. .avatar {
  177. width: #{128upx};
  178. height: #{128upx};
  179. position: absolute;
  180. top: #{126upx};
  181. left: 50%;
  182. transform: translateX(-50%);
  183. border-radius: 50%;
  184. }
  185. .audio {
  186. z-index: 1000;
  187. >image {
  188. width: 100%;
  189. height: 100%;
  190. }
  191. }
  192. .font {
  193. position: absolute;
  194. text-align: center;
  195. /*文字*/
  196. view {
  197. font-size: #{30upx};
  198. line-height: 1;
  199. white-space: nowrap;
  200. }
  201. /*用户名*/
  202. .nickname {
  203. margin-bottom: #{14upx};
  204. }
  205. /*祝福语*/
  206. .bless-word {
  207. margin-top: #{52upx};
  208. }
  209. }
  210. }
  211. }
  212. }
  213. </style>