donaSuccess.vue 5.5 KB

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