gift-content.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <view class="gift-content">
  3. <view class="avatar" :style="{backgroundImage: `url(${avatar})`}" >
  4. <view class="ripple" v-if="bless_music" :animation="animationData1"></view>
  5. <view class="ripple" v-if="bless_music" :animation="animationData2"></view>
  6. </view>
  7. <image class="avatar" @click="play" v-if="bless_music" :src="is_play ? './../../image/play-big.png' : './../../image/stop-big.png'"></image>
  8. <view class="sender dir-left-nowrap main-center">
  9. <text class="who">{{nickname}}</text>
  10. </view>
  11. <view class="greetings">{{bless_word}}</view>
  12. <view class="goods" :class="[`${theme}-border`]">
  13. <image class="pic" :src=" is_big_gift === 0 ? cover_pic : big_gift_pic"></image>
  14. <view class="name" v-if="is_big_gift === 0">{{name}}</view>
  15. </view>
  16. <view class="automatic-refund">{{refund_time}}天内无人领取将自动退款</view>
  17. <view class="button dir-left-nowrap main-center">
  18. <navigator
  19. url="/plugins/gift/index/index"
  20. open-type="redirect"
  21. :class="[`item`,` again`,`${theme}-border`, `${theme}-color`, `${theme}-shadow`]"
  22. >
  23. 再送一份
  24. </navigator>
  25. <button @click="share" :class="[`item`, `send`, `${theme}-background`, `${theme}-shadow`]">
  26. 送给朋友
  27. </button>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. name: 'gift-content',
  34. props: [
  35. `theme`, `avatar`, `nickname`,
  36. `bless_word`, `is_big_gift`,
  37. `cover_pic`, `name`, `refund_time`,
  38. `big_gift_pic`, `bless_music`, `is_play`
  39. ],
  40. data() {
  41. return {
  42. animationData1: '',
  43. animationData2: '',
  44. animationStatus: false
  45. }
  46. },
  47. methods: {
  48. share() {
  49. this.$emit('share');
  50. },
  51. animationFun:function(animationData){
  52. if(!this.animationStatus){
  53. return;
  54. }
  55. let animation = uni.createAnimation({
  56. duration: 1000
  57. })
  58. animation.opacity(0).scale(1.5,1.5).step();
  59. this[animationData] = animation.export();
  60. },
  61. animationEnd: function (animationData) {
  62. let animation = uni.createAnimation({
  63. duration: 0
  64. })
  65. animation.opacity(1).scale(1, 1).step();
  66. this[animationData] = animation.export()
  67. },
  68. recodeEnd: function() {
  69. //动画1结束
  70. let animation1 = uni.createAnimation({
  71. duration: 0
  72. })
  73. animation1.opacity(1).scale(1, 1).step();
  74. //动画2结束
  75. let animation2 = uni.createAnimation({
  76. duration: 0
  77. })
  78. animation2.opacity(1).scale(1, 1).step();
  79. this.animationData1 = animation1.export();
  80. this.animationData2 = animation2.export();
  81. this.animationStatus = false;
  82. },
  83. recodeClick: function() {
  84. this.animationStatus = true;
  85. this.animationFun('animationData1');
  86. setTimeout(()=>{
  87. this.animationFun('animationData2');
  88. },500);
  89. setTimeout(() => {
  90. this.animationRest();
  91. }, 1000);
  92. },
  93. animationRest: function() {
  94. this.animationEnd('animationData1');
  95. setTimeout(()=>{
  96. this.animationEnd('animationData2');
  97. },500);
  98. setTimeout(() => {
  99. if (this.animationStatus) {
  100. this.recodeClick();
  101. }
  102. }, 100);
  103. },
  104. start() {
  105. this.recodeClick();
  106. },
  107. end() {
  108. this.recodeEnd();
  109. },
  110. play() {
  111. if (this.is_play) {
  112. this.$emit('play', false);
  113. } else {
  114. this.start();
  115. this.$emit('play', true, this.bless_music);
  116. }
  117. },
  118. },
  119. watch: {
  120. is_play: {
  121. handler(data) {
  122. if (!data) {
  123. this.end();
  124. }
  125. }
  126. }
  127. }
  128. }
  129. </script>
  130. <style scoped lang="scss">
  131. @import "../../css/gift.scss";
  132. /*礼物内容*/
  133. .gift-content {
  134. width: calc(100% - #{48upx});
  135. height: 101%;
  136. background-color: #ffffff;
  137. border-radius: #{16upx};
  138. margin: #{0 24upx};
  139. position: relative;
  140. padding-top: #{80upx};
  141. }
  142. /*头像*/
  143. .avatar {
  144. width: #{96upx};
  145. height: #{96upx};
  146. border-radius: #{48upx};
  147. position: absolute;
  148. left: 50%;
  149. background-repeat: no-repeat;
  150. background-size: 100% 100%;
  151. transform: translate(-50%, #{-128upx});
  152. }
  153. /*送礼物者*/
  154. .sender {
  155. font-size: #{28upx};
  156. color: #353535;
  157. line-height: 1;
  158. margin: #{0 0 28upx 0};
  159. text.who {
  160. max-width: #{336upx};
  161. word-break: break-all;
  162. text-overflow: ellipsis;
  163. display: -webkit-box;
  164. -webkit-box-orient: vertical;
  165. -webkit-line-clamp: 1;
  166. overflow: hidden;
  167. white-space: normal !important;
  168. }
  169. }
  170. /*祝福语*/
  171. .greetings {
  172. font-size: #{32upx};
  173. color: #353535;
  174. text-align: center;
  175. line-height: 1;
  176. margin-bottom: #{64upx};
  177. }
  178. /*礼物*/
  179. .goods {
  180. width: #{400upx};
  181. padding: #{50upx 50upx 20upx 50upx};
  182. margin: #{64upx 151upx 32upx 151upx};
  183. border-width: #{1upx};
  184. border-style: solid;
  185. border-radius: #{16upx};
  186. /*图片*/
  187. .pic {
  188. width: #{300upx};
  189. height: #{300upx};
  190. margin-bottom: #{30upx};
  191. }
  192. /*名字*/
  193. .name {
  194. width: #{300upx};
  195. margin-bottom: #{22upx};
  196. font-size: #{28upx};
  197. color: #353535;
  198. word-break: break-all;
  199. text-overflow: ellipsis;
  200. display: -webkit-box;
  201. -webkit-box-orient: vertical;
  202. -webkit-line-clamp: 1;
  203. overflow: hidden;
  204. white-space: normal;
  205. }
  206. }
  207. /*自动退款*/
  208. .automatic-refund {
  209. font-size: #{24upx};
  210. line-height: 1;
  211. margin-top: #{32upx};
  212. color: #999999;
  213. text-align: center;
  214. }
  215. /*按钮*/
  216. .button {
  217. margin-top: #{72upx};
  218. height: #{100upx};
  219. width: 100%;
  220. .item {
  221. width: #{280upx};
  222. padding: 0;
  223. margin: 0;
  224. border-radius: #{58upx};
  225. text-align: center;
  226. font-size: #{32upx};
  227. height: #{100upx};
  228. line-height: #{100upx};
  229. }
  230. /*送给朋友*/
  231. .send {
  232. color: #ffffff;
  233. margin-left: #{24upx};
  234. }
  235. /*再送一份*/
  236. .again {
  237. border-width: #{1upx};
  238. border-style: solid;
  239. margin-right: #{24upx};
  240. background-color: #ffffff;
  241. }
  242. }
  243. .ripple{
  244. position: absolute;
  245. top:0;
  246. left:0;
  247. right:0;
  248. bottom:0;
  249. border-radius: 50%;
  250. border: #{2upx} solid #ffffff;
  251. }
  252. </style>