婚礼邀请函小程序项目

这篇具有很好参考价值的文章主要介绍了婚礼邀请函小程序项目。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

一、学习目标

1.掌握小程序常用组件的使用

2.掌握腾讯视频插件的使用

3.掌握背景音乐API、地图API的使用

4.掌握订阅消息的发送

二、开发前准备

  • 项目展示、项目分析、项目初始化

1.项目展示

  • 照片页面

婚礼邀请函小程序项目

  • 美好时光页面

婚礼邀请函小程序项目

  • 宾客信息页面

婚礼邀请函小程序项目文章来源地址https://www.toymoban.com/news/detail-460697.html

三、代码实现

1 项目搭建

  • 在微信开发者工具中创建一个空白项目。创建成功后,新建app.json文件,在该文件中定义本项目中的页面路径、定义项目导航栏样式、定义项目底部标签栏
{
  "pages":[
    "pages/index/index",
    "pages/picture/picture",
    "pages/video/video",
    "pages/map/map",
    "pages/guest/guest",
    "pages/logs/logs"
  ],
  "window":{
    "backgroundTextStyle":"light",
    "navigationBarBackgroundColor": "#fff",
    "navigationBarTitleText": "婚礼邀请函",
    "navigationBarTextStyle":"black"
  },
  "tabBar": {
    "color": "#ccc",
    "selectedColor": "#ff4ccc",
    "borderStyle": "black",
    "backgroundColor": "#ffffff",
    "position": "bottom",
    "list": [
      {
          "pagePath": "pages/index/index",
          "iconPath": "/images/invite.png",
          "selectedIconPath": "/images/invite.png",
          "text": "邀请函"
      },
      {
       "pagePath":"pages/picture/picture",
      "iconPath": "/images/marry.png",
      "selectedIconPath": "/images/marry.png",
      "text": "照片"},
      {
          "pagePath":"pages/video/video",
         "iconPath": "/images/video.png",
         "selectedIconPath": "/images/video.png",
         "text": "美好时光"},
         {
          "pagePath":"pages/map/map",
         "iconPath": "/images/map.png",
         "selectedIconPath": "/images/map.png",
         "text": "婚礼地点"},
         {
          "pagePath":"pages/guest/guest",
         "iconPath": "/images/guest.png",
         "selectedIconPath": "/images/guest.png",
         "text": "宾客信息"}
  ]
},
  "style": "v2",
  "sitemapLocation": "sitemap.json"
}

2 功能实现

2.1 背景音乐功能

  • 在index.wxml设置页面和展示图片,代码如下:
<view class="player player-{{isPlayingMusic ? 'play' : 'pause'}}" 
bindtap="play">
  <image src="/images/music_icon.png" />
  <image src="/images/music_play.png"/>
</view>

  • 在index.wxss中编写播放器的样式
.content{
  /*vw 表示屏幕的宽度,vh 表示屏幕的高度*/
  width: 100vw;
  height: 100vh;
}

.bg{
  width: 100%;
  height: 100%;
}
.play{
  position: fixed;
  top: 20rpx;
  right: 20rpx;
  /*提高堆叠的顺序*/
  z-index: 1;
}
.play>image:first-child{
  width: 80rpx;
  height: 80rpx;
}
.play>image:last-child{
  width: 20rpx;
  height: 80rpx;
  margin-left: -5px;
}
.cont{
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0rpx;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.cont-info-weding{
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.cont-gif{
  width: 19vh;
  height: 18.6vh;
}
.cont-title{
  font-size: 5vh;
  color:#ff4c91;
  font-weight: bold;
  margin-top: 1.5vh;
}
.cont-avatar{
  width: 24vh;
  height: 24vh;
  border-radius: 50%;
  border: 3px solid #ff4c91;
  margin-top: 2.5vh;
}
.cont-info{
  display: flex;
  flex-direction: row;
  align-items: center;
  width: 50vw;
}
.cont-info-wedding{
  width: 60rpx;
  height: 60rpx;
  /*margin-left: 40rpx;
  margin-right: 40rpx;*/
}
.content-name{
  position: relative;
  color: #ff4c91;
  font-weight: bold;
  font-size: 2.7vh;
  
}
.content-name>image{
  height: 30rpx;
  width: 30rpx;
  /*设置电话半圆*/
  border-radius: 50%;
  border: 1px solid #ff4c91;
  position: absolute;
  top: -25rpx;
  right: -35rpx;
}
.cont-address{
  color:#ff4c91;
  font-weight: bold;
  margin-top: 10rpx;
  font-size: 2.9vh;
  align-items: center;
  text-align: center;
  line-height: 4.5vh;/*时间地点的行高度*/
}
.cont-address>view:first-child{
  font-size:3.2vh;
  margin-bottom: 2vh;
}

  • 在index.js中实现音乐播放、暂停功能,并选择音乐源,代码如下:
onReady: function () {
  this.bgm = wx.getBackgroundAudioManager()
  this.bgm.onCanplay(()=> {
    this.bgm.pause()
  })
  this.bgm.src = this.music_url
},

  • 在index.js中实现正在播放功能,代码如下:
play: function (e) {
  if (this.data.isPlayingMusic) {
    this.bgm.pause()
  } else { this.bgm.play() }
  this.setData({
isPlayingMusic:!this.data.isPlayingMusic })
},

  • 在index.wxml中编写页面结构的样式,实现一键拨打电话功能
<view class="content">
    <image class="bg" src="/images/bg_1.png"></image>
    <view class="play">
        <image src="/images/music_icon.png"></image>
        <image src="/images/music_play.png"></image>
      </view>
    <view class="cont">
        <image class="cont-gif" src="/imagesve_the_date.gif"></image>
        <view class="cont-title">邀请函</view>
        <image class="cont-avatar" src="/images/avatar.png" ></image>
        <view class="cont-info">
        <!--新郎的信息-->
            <view class="content-name">
                <image src="/images/tel.png" bindtap="callGroom"></image>
                <view>小张</view>
                <view>新郎</view>
                </view>
                <!--放的喜字信息-->
            <view class="cont-info-weding">
                <image class="cont-info-wedding" src="/images/wedding.png"></image>
              </view>
              <!--新娘的信息-->
            <view class="content-name">
                <image src="/images/tel.png" bindtap="callBride"></image>
                <view>小李</view>
                <view>新娘</view>
                </view>
            </view> 
            <view class="cont-address">
            <view>我们邀请您来参加我们的婚礼</view>
            <view>时间:2022年12月24日</view>
            <view>地点:    </view>
          </view>
        </view>
</view>
/

2.2 照片页面功能

  • 实现纵向轮播图:在picture.js中准备图片路径
Page({

  /**
   * 页面的初始数据
   */
  data: {
     pictures:[
       {
         id:0,
         src:"/images/timg1.jpg"
       },
       {
        id:1,
        src:"/images/timg2.jpg"
      },
      {
        id:2,
        src:"/images/timg3.jpg"
      },
      {
        id:3,
        src:"/images/timg4.jpg"
      }
     ]
  },
  • 在picture.wxml中设置swiper组件的属性
<swiper indicator-dots="true" vertical="ture" indicator-color="white" indicator-active-color="#ff4c91"
autoplay="true" interval="3500" duration="1000">
<swiper-item wx:for="{{pictures}}" wx:key="id">
<image src="{{item.src}}"></image>
</swiper-item>
 <!--
<swiper-item>
<image src="/images/timg1.jpg"></image>
</swiper-item>
<swiper-item>
<image src="/images/timg2.jpg"></image>
</swiper-item>
<swiper-item>
<image src="/images/timg3.jpg"></image>
</swiper-item>
<swiper-item>
<image src="/images/timg4.jpg"></image>
</swiper-item>
-->
</swiper>

  • 在picture.wxss中编写样式
swiper{
  height: 100vh;
}
/*设置图片的大小*/
image{
  height: 100%;
}

2.3 美好时光页面

  • 在video.wxml中使用video组件播放视频,并提供获取视频和发送弹幕的的按钮
<view class="video-list" wx:for="{{vedioList}}" wx:key="title">
<view class="video-list-title">{{item.title}}</view>
<view class="video-list-time">{{item.time}}</view>
<video src="{{item.src}}" object-fit="fill" loop="ture" controls="false" danmu-btn="ture" enable-danmu="ture"></video>
</view>
  • 在video.js中定义弹幕数据和视频资源地址
Page({

  /**
   * 页面的初始数据
   */
  data: {
    danmuList: [{ text: '第 1s 出现的弹幕', color: '#ff0000', time: 1 },
                { text: '第 2s 出现的弹幕', color: '#ff00ff', time: 2 },
                { text: '第 3s 出现的弹幕', color: '#ff00ff', time: 3},
                { text: '第 4s 出现的弹幕', color: '#ff00ff', time: 3}

 ] ,
   vedioList:[
     {title:"海边旅游",
      time:'2022年1月1日',
     src:'http://www.lzy.edu.cn/vedio/lzy2022.mp4'},
     {title:"川西旅游",
      time:'2022年10月1日',
     src:'http://www.lzy.edu.cn/vedio/lzy2022.mp4'},
     {title:"北京旅游",
      time:'2022年5月1日',
     src:'http://www.lzy.edu.cn/vedio/lzy2022.mp4'},
    ]
  },
  play:function(e){
    console.log("播放了")
  },
  pause:function(e){
    console.log("视频暂停")
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },
  • 在video.wxss中编写样式
.video-list{
  margin:10rpx 25rpx;
  padding:20rpx;
  border-radius: 10rpx;
 /* border:1px solid #000000;*/
  background: #ffffff;
  box-shadow:0 8rpx 17rpx 0 rgba(7,17,27,0.1);
}
.video-list-title{
  font-size:35rpx;
  color:#333333; 
}
 .video-list-time{
  font-size:30rpx;
  color:#979797; 
}
.video-list>video{
  width:100%;
  margin-top: 20rpx;
}
  • 在app.json中配置本项目使用的插件
"plugins":{
	"tencentvideo":{
		"version":"1.2.2",
		"provider":"wxa75efa648b60994b"
		}
}
  • 在video.json中将腾讯视频插件添加到自定义组件,将组件名称命名为txv_video
{
  "usingComponents": {
    "txv-video":"plugin://tencentvideo/video"
  }
}

2.4 婚礼地点页面

  • 在map.wxml中编写页面结构

<map class="pg" latitude="28.915616" longitude="105.410766" markers="{{markers}}" scale="16" polyline="{{polyLine}}" circles="{{circles}}"
show-location="ture" bindmarkertap="markertap"
bindregionchange="regionchange" bindtap="tap" bindupdated="updated"
></map>

  • 在map.wxss中编写页面样式
.pg{
  width: 100vh;
  height: 100vh;
}

  • 在map.js中编写data数据和markertap()函数
// pages/map/map.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    markers: [
      {
        id: 0,
        longitude: 105.410766,
        latitude: 28.915616,
        title: "婚礼地点",
        iconPath: "/images/navi.png",
        width: 30, 
        height: 30
      },
      {
        id: 1,
        longitude: 105.410766,
        latitude: 28.916616,
        title: "停车场",
        iconPath: "/images/navi.png",
        width: 30, 
        height: 30
      },
      {
        id: 2,
        longitude: 105.413886,
        latitude: 28.917616,
        title: "停车场",
        iconPath: "/images/navi.png",
        width: 30, 
        height: 30
      }
    ],
    polyLine:[{
      points:[
      {latitude: 28.917616, longitude: 105.413886},
      {latitude:28.916616,longitude:105.410766},
        {latitude:28.915616,longitude:105.410766}],
         color:"#ffffffAA",
         width:3,
       dottedLine:true
      },
      //{
      //  points:[
      //  {latitude: 28.917616, longitude: 105.413586},
      //  {latitude:28.916616,longitude:105.415766},
       //   {latitude:28.915616,longitude:105.415766}],
       //    color:"#ffffffAA",
       //    width:3,
       //  dottedLine:true
     //   }
    ],
    circles:[{
      latitude:28.915616,
      longitude:105.410566,
      radius:200,
      color:"#ff4c91AA",
      strokeWidth:3,
      fillColor:"#ff4c910A"
    },
    {
      latitude:28.915616,
      longitude:105.410566,
      radius:300,
      color:"#000000AA",
      strokeWidth:3,
      fillColor:"#ff4c910A",
    }
  ]
  },
  markertap:function(e){
    //点击标记处位触发,后面给地图导航的逻辑
    console.log(e)
    var onemarker=this.data.markers[e.markerId]
    wx.openLocation({
      latitude: onemarker.latitude,
      longitude: onemarker.longitude,
      name:onemarker.title,
      address:""
    })
  },
  regionchange:function(e){
    console.log(e);
  },
  tap:function(e){
    console.log(e);
  },
  updated:function(e){
    console.log(e);
  },

2.5 宾客信息页面

  • 在index.wxml中实现邀请函首页展现新人信息、婚礼信息功能,代码如下:
<form bindsubmit="formsubmit">
    <view class="container">
    <view class="container-info">
        <input name="name" placeholder="请输入您的名字" placeholder-class="phclass" />
    </view>
    <view class="container-info">
        <input name="phone" placeholder="请输入您的手机号码" placeholder-class="phclass" />
      </view>

    <view class="container-info">
        <picker name="num" range="{{picker.array}}" value="{{picker.index}}" bindchange="pickerchange">
            <view>参加婚礼的人数:{{picker.array[picker.index]}}</view>
        </picker>
      </view>
    <view class="container-info">
        <input name="wish" placeholder="请输入您的祝福语" placeholder-class="phclass" />
      </view>
        <button form-type="submit" style="width: 550rpx;">提交</button>
        </view>
</form>

<image src="/images/bj_2.png" class="bg"></image>

  • 在guest.wxml中实现邀请函首页展现新人信息、婚礼信息功能
<form bindsubmit="formsubmit">
    <view class="container">
    <view class="container-info">
        <input name="name" placeholder="请输入您的名字" placeholder-class="phclass" />
    </view>
    <view class="container-info">
        <input name="phone" placeholder="请输入您的手机号码" placeholder-class="phclass" />
      </view>

    <view class="container-info">
        <picker name="num" range="{{picker.array}}" value="{{picker.index}}" bindchange="pickerchange">
            <view>参加婚礼的人数:{{picker.array[picker.index]}}</view>
        </picker>
      </view>
    <view class="container-info">
        <input name="wish" placeholder="请输入您的祝福语" placeholder-class="phclass" />
      </view>
        <button form-type="submit" style="width: 550rpx;">提交</button>
        </view>
</form>

<image src="/images/bj_2.png" class="bg"></image>
  • 在guest.js中编写data数据和pickerChange()函数、事件处理函数、实现表单验证,在page()函数的后面编写server对象,用于模拟服务器,与微信接口进行交互。
// pages/guest/guest.js
Page({

  /**
 * 页面的初始数据
   */
  data: {
    picker:{
      array:['1','2','3','4','5'],
      index:0
    }

  },
  pickerchange:function(e){
    console.log(e);
    this.setData({
      'picker.index':e.detail.value
    })
  },
 formsubmit:function(e){
   console.log(e);
   var name = e.detail.value.name;
   var phone=e.detail.value.phone;
   var num = e.detail.value.num;
   var wish =e.detail.value.wish;
   //1'判断姓名是否由中英文组成
   this.checkName(name)
   //2.判断电话号码是否符合规范
   this.checkPhone(phone)
 },
 checkPhone:function(data){
   var reg = /^1[3456789][0-9]{9}$/
   if(!reg.test(data)){
     wx.showToast({
       title: '号码格式错误',
       icon:"none",
       duration:1500
     })
   }
 },
 checkName:function(data){
   //正则表达式 中英文
   var reg = /^[a-zA-Z\u4e00-\u9fa5]+$/
   if(!reg.test(data)){
     wx.showToast({
       title: '姓名输入错误',
       icon:"none",
       duration:1500
     })
   }
 },

到了这里,关于婚礼邀请函小程序项目的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 微信小程序案例2-3:婚礼邀请函

    “婚礼邀请函” 微信小程序 由4个页面组成,分别是“邀请函”页面、“照片”页面、“美好时光”页面和“宾客信息”页面。每个页面顶部的导航栏和底部的标签栏是公共部分,在每个页面中都会出现;页面中间的部分是页面内容,每个页面的内容都不同。 \\\"邀请函\\\"页面

    2024年02月06日
    浏览(29)
  • “婚礼邀请函”小程序开发过程

    要求该小程序有以下功能: 1.邀请函页面:新郎和新娘的电话、婚礼时间、婚礼地点 2.照片页面:新郎和新娘的幸福照 3.美好时光页面:采用视频的方式记录新人的相历程 4.地图页面:通导航查看婚礼地点的路线图 5.宾客信息页面:参加婚礼的宾客填写个人信息,送给一些祝

    2024年02月10日
    浏览(25)
  • 杭州-区块链前瞻性论坛邀请函​

    2023密码与安全前瞻性论坛邀请函

    2024年02月04日
    浏览(34)
  • html5实现好看的年会邀请函源码模板

    作者:xcLeigh 文章地址:https://blog.csdn.net/weixin_43151418/article/details/135720875 html5实现好看的年会邀请函源码模板 ,十个界面效果,邀请函、诚挚邀请、关于我们、董事长致词、公司合作方、活动流程、加盟支持、加盟流程、加盟申请、活动信息等。界面展示图文时支持自己设置

    2024年01月21日
    浏览(30)
  • 邀请函 | 区块链如何助力公益?腾讯、深大、微众专家齐聚ESG系列研讨会

    9月5日是我国第七个“中华慈善日”。作为全球最大的公益节日之一,2022年腾讯99公益日也已正式启动。其中,腾讯公益基于腾讯安全区块链,联合企业、行业协会、监管部门打造了公益信用联盟链,由微众区块链提供开源技术支持。 对于公益事业而言,善款去向、信息透明

    2024年02月12日
    浏览(40)
  • 师承AI世界新星|7天获新加坡南洋理工大学访学邀请函

    能够拜师在“人工智能 10 大新星”名下,必定可以学习到前沿技术,受益良多,本案例中的 C 老师无疑就是这个幸运儿。我们只用了 7 天时间就取得了这位 AI 新星导师的邀请函,最终 C 老师顺利获批 CSC ,如愿出国。 C 老师背景: 申请类型: CSC访学 工作背景: 高校老师 教

    2024年02月16日
    浏览(35)
  • 从零开始制作婚礼策划展示小程序

    随着移动互联网的发展,小程序已经成为各行各业展示和推广自己的重要工具之一。对于婚礼策划行业来说,制作一个专属的婚礼策划展示小程序,不仅能提升服务的专业性和便利性,还能吸引更多的客户。下面将介绍从零开始制作婚礼策划展示小程序的步骤。 第一步是进入

    2024年02月16日
    浏览(31)
  • 竞赛项目 深度学习的视频多目标跟踪实现

    🔥 优质竞赛项目系列,今天要分享的是 基于深度学习的视频多目标跟踪实现 该项目较为新颖,适合作为竞赛课题方向,学长非常推荐! 🧿 更多资料, 项目分享: https://gitee.com/dancheng-senior/postgraduate 基于初始化帧的跟踪,在视频第一帧中选择你的目标,之后交给跟踪算法去

    2024年02月13日
    浏览(25)
  • 深度学习图像分类、目标检测、图像分割源码小项目

    ​demo仓库和视频演示: 到此一游7758258的个人空间_哔哩哔哩_bilibili 卷积网路CNN分类的模型一般使用包括alexnet、DenseNet、DLA、GoogleNet、Mobilenet、ResNet、ResNeXt、ShuffleNet、VGG、EfficientNet和Swin transformer等10多种模型 目标检测包括yolov3、yolov4、yolov5、yolox、faster rcnn、SDD等 图像分割包

    2024年02月09日
    浏览(35)
  • 首个AI程序员诞生!已通过公司面试,掌握全栈技能,可独自开发完整项目

    3 月 13 日,由华人团队创立的 Cognition Labs 推出了第一个 AI 软件工程师 Devin,从目前公布的信息来看,说它是目前最强的 AI 软件工程师似乎一点也不过分,今天直接在 X 上刷屏。 在 SWE-Bench 基础测试中,无需人类协助,Devin 就可以解决 13.86% 的问题。而目前的 SOTA 模型,在没

    2024年04月11日
    浏览(41)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包