donaSuccess.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <view class="content">
  3. <view class="bgimg">
  4. <image src="../../static/img/thanks.png" mode=""></image>
  5. </view>
  6. <view class="box">
  7. <view class="music">
  8. <view class="player playing" :class="playing?'none':'keepgo'" @click.stop="play">
  9. <image src="../../static/img/music.png" style="width: 68rpx;height: 68rpx;" :animation="animationData"></image>
  10. <!-- <view class="">
  11. <image src="../../static/img/forbid.png" mode="" style="width: 52rpx;height: 52rpx;"></image>
  12. </view> -->
  13. </view>
  14. <!-- <view class="page-section page-section-gap" style="text-align: center;"> -->
  15. <!-- <audio style="text-align: left" :src="current.src"
  16. :action="audioAction" controls></audio> -->
  17. <!-- </view> -->
  18. </view>
  19. <view class="title">
  20. 感谢信
  21. </view>
  22. <view class="main">
  23. <view class="box-2">
  24. 感谢您积极参与井武汉市江夏区红十字会志愿服务各项活动,关爱他人、无私付出,为有需要的人送去温暖,用实际行动诠释了“人道、博爱、奉献”的红十字精神。
  25. </view>
  26. <view class="box-2">
  27. 祝您及您的家人新年吉祥!身体健康!万事顺意!
  28. </view>
  29. </view>
  30. <view class="footer" @click="demo">
  31. <view class="box-1">
  32. 此致
  33. </view>
  34. <view class="box-1">
  35. 谨表谢意
  36. </view>
  37. <view class="box-1">
  38. 武汉市江夏区红十字会
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. export default {
  46. data() {
  47. return {
  48. playing: false,
  49. current: {
  50. src: '../../static/audio/xx.mp3',
  51. },
  52. rotateIndex: '',
  53. animation: {},
  54. animationData: {},
  55. audioAction: {
  56. method: 'pause'
  57. },
  58. ran: -1,
  59. isStop: true,
  60. demo: 0
  61. }
  62. },
  63. onShow() {
  64. var animation = uni.createAnimation()
  65. this.animation = animation
  66. if (this.isStop) {
  67. // 使用动画
  68. this.scaleAndScale()
  69. this.timer = setInterval(()=>{ //创建定时器,3秒执行异一次
  70. this.scaleAndScale()
  71. console.log('每三秒执行一次 , 达到往复运动的效果')
  72. },1000)
  73. } else {
  74. this.noscaleAndScale()
  75. }
  76. },
  77. onLoad() {
  78. console.log(223)
  79. this.ScanAudio()
  80. // app.audioMusic.src = '../../static/audio/xx.png';
  81. // const innerAudioContext = uni.createInnerAudioContext();
  82. // innerAudioContext.autoplay = true;
  83. // innerAudioContext.src = '../../static/audio/xx.png';
  84. // console.log(1123);
  85. // innerAudioContext.onPlay(() => {
  86. // console.log('开始播放');
  87. // });
  88. // innerAudioContext.onError((res) => {
  89. // console.log('出错了');
  90. // console.log(res);
  91. // // console.log(res);
  92. // });
  93. },
  94. onHide() { //在页面隐藏时也要清除定时器
  95. if(this.timer){
  96. console.log('清除定时器-' + this.timer)
  97. clearInterval(this.timer)
  98. }
  99. },
  100. onUnload(){ //在页面卸载时清除定时器 避免出现多个定时器连续创建动画
  101. if(this.timer){
  102. console.log('清除定时器-' + this.timer)
  103. clearInterval(this.timer)
  104. }
  105. },
  106. methods: {
  107. musicClick() {
  108. // if (this.isRoate) {
  109. // this.isRoate = false
  110. // this.stopScanAudio()
  111. // } else {
  112. // this.isRoate = true
  113. // this.ScanAudio()
  114. // }
  115. },
  116. play() {
  117. var music = uni.createInnerAudioContext();
  118. music.src= "../../static/audio/xx.mp3"; //选择播放的音频
  119. music.onPause(); //暂停播放
  120. console.log('暂停播放')
  121. // console.log('dianjizanting')
  122. // this.stopAudio()
  123. // this.playing = !this.playing; //背景音乐点击,暂停或继续
  124. },
  125. // 定义动画内容
  126. scaleAndScale() {
  127. // 定义动画内容
  128. // this.animation.scale(1.2, 1.2).step() //先放大1,2倍
  129. // this.animation.scale(1, 1).step() //缩小至原来的大小
  130. // 导出动画数据传递给data层
  131. // this.animationData = this.animation.export(); //每次执行导出动画时 会覆盖之前的动画
  132. this.animation.rotate(this.demo).step({
  133. duration: 1000
  134. })
  135. this.animationData = this.animation.export()
  136. this.demo += 360;
  137. },
  138. noscaleAndScale() {
  139. this.animation.scale(1, 1).step()
  140. this.animationData = this.animation.export()
  141. },
  142. }
  143. }
  144. </script>
  145. <style lang="scss">
  146. page {
  147. width: 100%;
  148. height: 100%;
  149. }
  150. .content {
  151. // background-color: pink;
  152. width: 100%;
  153. height: 100%;
  154. position: relative;
  155. .bgimg {
  156. width: 100%;
  157. height: 100%;
  158. // background-color: pink;
  159. image {
  160. width: 100%;
  161. height: 100%;
  162. }
  163. }
  164. .box {
  165. position: absolute;
  166. left: 0;
  167. top: 0;
  168. // background-color: pink;
  169. width: 100%;
  170. height: 100%;
  171. display: flex;
  172. flex-direction: column;
  173. align-items: center;
  174. color: #FFFFFF;
  175. padding: 0rpx 32rpx 0 32rpx;
  176. .music {
  177. // width: 55rpx;
  178. // height: 55rpx;
  179. border-radius: 28rpx;
  180. // background-color: pink;
  181. position: absolute;
  182. left: 12rpx;
  183. top: 250rpx;
  184. }
  185. .title {
  186. margin-top: 234rpx;
  187. font-size: 54rpx;
  188. }
  189. .main {
  190. margin-top: 20rpx;
  191. font-size: 32rpx;
  192. .box-2 {
  193. text-indent: 68rpx;
  194. margin-top: 12rpx;
  195. }
  196. }
  197. .footer {
  198. margin-top: 32rpx;
  199. // background-color: pink;
  200. width: 100%;
  201. .box-1 {
  202. display: flex;
  203. justify-content: flex-end;
  204. font-size: 28rpx;
  205. // padding-right: 14rpx;
  206. }
  207. }
  208. }
  209. // .playing {
  210. // animation: run 10s linear 0s infinite;
  211. // }
  212. // .player {
  213. // width: 65rpx;
  214. // height: 65rpx;
  215. // border-radius: 50%;
  216. // background-color: rgba(0, 0, 0, 0.1);
  217. // z-index: 999999;
  218. // }
  219. .keepgo {
  220. animation-play-state: paused;
  221. }
  222. }
  223. </style>