当前位置:   article > 正文

微信小程序——婚礼邀请函页面_微信小程序婚礼邀请函代码

微信小程序婚礼邀请函代码

1、主体页面和导航栏样式app.json

 

  1. "pages": [
  2. "pages/index/index",
  3. "pages/picture/picture",
  4. "pages/video/video",
  5. "pages/map/map",
  6. "pages/guest/guest"
  7. ],
  8. "requiredBackgroundModes": ["audio"],
  9. "window": {
  10. "navigationBarBackgroundColor": "#ff4c91",
  11. "navigationBarTextStyle": "white",
  12. "backgroundTextStyle": "light",
  13. "enablePullDownRefresh": false
  14. },

其中"requiredBackgroundModes": ["audio"]为音乐播放配置

2、底部标签栏

tabBar用于实现页面底部的标签栏,主要属性如下,其中list是一个数组,数组中的每一个元素都是一个标签按钮对象,设置对应的属性时,可以跳转到对应的标签页。

属性说明
color未选择时,底部导航栏颜色
selectedColor选中时,底部导航栏颜色
borderStyle底部导航边框颜色
backgroundColor底部导航背景色
list导航配置数组
pagePath页面访问地址
iconPath未选择时图片路径
selectedIconPath选中时图片路径
text导航图标下方文字

3、在app.json中添加如下代码,完成标签栏的配置

  1. "tabBar": {
  2. "color": "black",
  3. "selectedColor": "#ff4c91",
  4. "borderStyle": "white",
  5. "backgroundColor": "#ffffff",
  6. "list": [
  7. {
  8. "pagePath": "pages/index/index",
  9. "iconPath": "images/invite.png",
  10. "selectedIconPath": "images/invite.png",
  11. "text": "邀请函"
  12. },
  13. {
  14. "pagePath": "pages/picture/picture",
  15. "iconPath": "images/marry.png",
  16. "selectedIconPath": "images/marry.png",
  17. "text": "照片"
  18. },
  19. {
  20. "pagePath": "pages/video/video",
  21. "iconPath": "images/video.png",
  22. "selectedIconPath": "images/video.png",
  23. "text": "美好时光"
  24. },
  25. {
  26. "pagePath": "pages/map/map",
  27. "iconPath": "images/map.png",
  28. "selectedIconPath": "images/map.png",
  29. "text": "婚礼地点"
  30. },
  31. {
  32. "pagePath": "pages/guest/guest",
  33. "iconPath": "images/guest.png",
  34. "selectedIconPath": "images/guest.png",
  35. "text": "宾客信息"
  36. }
  37. ]
  38. },

4、页面的公共样式app.wxss

  1. page{
  2. font-family: Helvetica Neue,Arial, Helvetica, sans-serif ;
  3. display: flex;
  4. flex-direction: column;
  5. justify-content: space-between;
  6. box-sizing: border-box;
  7. }

 justify-content: space-between;使各项周围都留有空白

5、邀请函的内部结构index.wxss

  1. <!-- 显示歌曲播放暂停的小图标 -->
  2. <view class="player player-{{isPlayingMusic ? 'play':'pause'}}" bindtap="play">
  3. <image src="/images/music_icon.jpg"></image>
  4. <image src="/images/music_play.png"></image>
  5. </view>
  6. <!-- 背景图片 -->
  7. <image class="bg" src="/images/bg_1.png"></image>
  8. <!-- 内容区域 -->
  9. <view class="content">
  10. <!-- 顶部图片区域 -->
  11. <image class="content-gif" src="/images/save_the_date.gif"></image>
  12. <!-- 标题 -->
  13. <view class="content-title">邀请函</view>
  14. <!-- 新郎和新娘合照 -->
  15. <view class="content-avatar">
  16. <image src="/images/avatar.png"></image>
  17. </view>
  18. <!-- 新郎和新娘的名字 -->
  19. <view class="content-info">
  20. <view class="content-name" bindtap="callGroom">
  21. <image src="/images/tel.png"></image>
  22. <view>王小名</view>
  23. <view>新郎</view>
  24. </view>
  25. <view class="content-wedding">
  26. <image src="/images/wedding.png"></image>
  27. </view>
  28. <view class="content-name" bindtap="callBride">
  29. <image src="/images/tel.png"></image>
  30. <view>张小红</view>
  31. <view>新娘</view>
  32. </view>
  33. </view>
  34. <!-- 婚礼信息 -->
  35. <view class="content-address">
  36. <view>我们曾邀你来参加我们的婚礼</view>
  37. <view>时间:20211011</view>
  38. <view>地点:河南省周口市曦皇大酒店</view>
  39. </view>
  40. </view>

6、样式控制

  1. /* 显示歌曲播放暂停的小图标 */
  2. .player{
  3. position: fixed;
  4. top:20rpx;
  5. right:20rpx;
  6. /* 元素的堆叠顺序,防止被content中的内容覆盖在下面 */
  7. z-index: 1;
  8. }
  9. .player>image:first-child{
  10. width: 80rpx;
  11. height: 80rpx;
  12. border: 1rpx solid #ffffff;
  13. border-radius: 50%;
  14. /* 将动画与div绑定,musicRotate只是起的一个名字 */
  15. animation: musicRotate 3s linear infinite;
  16. }
  17. /* 对唱胶动画设置 */
  18. @keyframes musicRotate{
  19. from{
  20. transform: rotate(0deg);
  21. }
  22. to{
  23. transform: rotate(360deg);
  24. }
  25. }
  26. .player>image:last-child{
  27. width: 28rpx;
  28. height:80rpx;
  29. margin-left: -5px;
  30. }
  31. /* 对唱胶图标设置旋转和暂停以及唱臂的移入和移出 */
  32. .player-play>image:first-child{
  33. animation-play-state: running;
  34. }
  35. .player-pause>image:last-child{
  36. animation: musicStart 0.2s linear forwards;
  37. }
  38. .player-pause>image:first-child{
  39. animation-play-state: paused;
  40. }
  41. .player-pause>image:last-child{
  42. animation: musicStop 0.2 linear forwards;
  43. }
  44. @keyframes musicStart{
  45. from{
  46. transform: rotate(0deg);
  47. }
  48. to{
  49. transform: rotate(20deg);
  50. }
  51. }
  52. @keyframes musicStop{
  53. from{
  54. transform: rotate(20deg);
  55. }
  56. to{
  57. transform: rotate(0deg);
  58. }
  59. }
  60. /* 背景图片 */
  61. .bg{
  62. width: 100vw;
  63. height: 100vh;
  64. }
  65. .content{
  66. width: 100vw;
  67. height: 100vh;
  68. /* 绝对定位元素,相对于浏览器 */
  69. position: fixed;
  70. display: flex;
  71. flex-direction: column;
  72. align-items: center;
  73. }
  74. .content-gif{
  75. width: 19vh;
  76. height: 18.6vh;
  77. margin-bottom: 1.5vh;
  78. }
  79. .content-title{
  80. font-size: 5vh;
  81. color: #ff4c91;
  82. text-align: center;
  83. margin-bottom: 2.5vh;
  84. }
  85. /* 新郎新娘合照 */
  86. .content-avatar image{
  87. width: 24vh;
  88. height: 24vh;
  89. border: 3rpx solid #ff4c91;
  90. border-radius: 50%;
  91. }
  92. /* 新郎新郎电话区 */
  93. .content-info{
  94. width:45vh;
  95. text-align: center;
  96. margin-top: 4vh;
  97. display: flex;
  98. align-items: center;
  99. }
  100. .content-wedding{
  101. flex: 1;
  102. }
  103. .content-wedding>image{
  104. width:5.5vh;
  105. height:5.5vh;
  106. margin-left: 20rpx;
  107. }
  108. .content-name{
  109. color: #ff4c91;
  110. font-size: 2.7vh;
  111. line-height: 4.5vh;
  112. font-weight: bold;
  113. position: relative;
  114. }
  115. .content-name>image{
  116. width: 2.6vh;
  117. height: 2.6vh;
  118. border: 1px solid #ff4c91;
  119. border-radius: 50%;
  120. position: absolute;
  121. top:-1vh;
  122. right:-3.6vh;
  123. }
  124. .content-address{
  125. margin-top: 5vh;
  126. color: #ec5f89;
  127. font-size: 2.5vh;
  128. font-weight: bold;
  129. text-align: center;
  130. line-height: 4.5vh;
  131. }
  132. .content-address view:first-child{
  133. font-size: 3vh;
  134. padding-bottom: 2vh;
  135. }

 7、在index.js中编写背景音频播放的代码

  1. bgm:null,
  2. music_url:'http://localhost:3000/1.mp3',
  3. music_coverImgUrl:"http://localhost:3000/cover.jpg",
  4. onReady:function () {
  5. //用于播放背景音频
  6. this.bgm=wx.getBackgroundAudioManager()
  7. this.bgm.title="marry me"
  8. this.bgm.epname="wedding"
  9. this.bgm.singer="singer"
  10. this.bgm.coverImgUrl=this.music_coverImgUrl
  11. this.bgm.onCanplay(()=>{
  12. this.bgm.pause()
  13. })
  14. this.bgm.src=this.music_url
  15. },

8、实现单击播放器实现音乐的播放与暂停,在index.js中添加如下代码

  1. play:function(e){
  2. if(this.data.isPlayingMusic){
  3. this.bgm.pause()
  4. }else{
  5. this.bgm.play()
  6. }
  7. this.setData({
  8. isPlayingMusic: !this.data.isPlayingMusic
  9. })
  10. },

9、实现一键拨打电话的功能

  1. callGroom:function(){
  2. wx.makePhoneCall({
  3. phoneNumber: '15138726924',
  4. })
  5. },
  6. callBride:function(){
  7. wx.makePhoneCall({
  8. phoneNumber: '18236347304',
  9. })
  10. }

10、页面最终运行效果如图

婚礼邀请函图片获取资源

链接: https://pan.baidu.com/s/1OcI_KBEXx-WYJv9srXlWAw 提取码: jwwg 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/398360
推荐阅读
相关标签
  

闽ICP备14008679号