美业医疗美容院小程序,预约会员管理养生馆诊所肌护肤理疗系统,附源码交付

预约会员小程序代码示例

前端页面代码 (WXML)

html 复制代码
<view class="container">
  <picker mode="selector" range="{{services}}" range-key="name" bindchange="selectService">
    <view class="picker">选择服务:{{selectedService.name || '请选择'}}</view>
  </picker>

  <picker mode="date" start="{{today}}" end="{{maxDate}}" bindchange="selectDate">
    <view class="picker">选择日期:{{selectedDate || '请选择'}}</view>
  </picker>

  <picker mode="time" start="09:00" end="21:00" bindchange="selectTime">
    <view class="picker">选择时间:{{selectedTime || '请选择'}}</view>
  </picker>

  <input type="text" placeholder="请输入姓名" bindinput="inputName"/>
  <input type="number" placeholder="请输入手机号" bindinput="inputPhone"/>

  <button type="primary" bindtap="submitReservation" disabled="{{!formValid}}">提交预约</button>
</view>

逻辑层代码 (JS)

javascript 复制代码
Page({
  data: {
    services: [
      { id: 1, name: '基础护理' },
      { id: 2, name: '深度清洁' },
      { id: 3, name: '专业理疗' }
    ],
    selectedService: {},
    today: new Date().toISOString().split('T')[0],
    maxDate: new Date(Date.now() + 30*24*60*60*1000).toISOString().split('T')[0],
    selectedDate: '',
    selectedTime: '',
    name: '',
    phone: '',
    formValid: false
  },

  selectService(e) {
    const index = e.detail.value
    this.setData({
      selectedService: this.data.services[index]
    })
    this.checkForm()
  },

  selectDate(e) {
    this.setData({
      selectedDate: e.detail.value
    })
    this.checkForm()
  },

  selectTime(e) {
    this.setData({
      selectedTime: e.detail.value
    })
    this.checkForm()
  },

  inputName(e) {
    this.setData({
      name: e.detail.value
    })
    this.checkForm()
  },

  inputPhone(e) {
    this.setData({
      phone: e.detail.value
    })
    this.checkForm()
  },

  checkForm() {
    const valid = this.data.selectedService.id && 
                 this.data.selectedDate && 
                 this.data.selectedTime && 
                 this.data.name && 
                 /^1[3-9]\d{9}$/.test(this.data.phone)
    this.setData({
      formValid: valid
    })
  },

  submitReservation() {
    wx.request({
      url: 'https://your-api-domain.com/reservations',
      method: 'POST',
      data: {
        serviceId: this.data.selectedService.id,
        date: this.data.selectedDate,
        time: this.data.selectedTime,
        name: this.data.name,
        phone: this.data.phone
      },
      success(res) {
        wx.showToast({
          title: '预约成功',
          icon: 'success'
        })
      },
      fail() {
        wx.showToast({
          title: '预约失败',
          icon: 'none'
        })
      }
    })
  }
})

样式代码 (WXSS)

css 复制代码
.container {
  padding: 20px;
}

.picker {
  margin: 15px 0;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

input {
  margin: 15px 0;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

button {
  margin-top: 20px;
}

功能说明

  1. 服务选择:通过picker组件提供可选择的会员服务列表
  2. 时间选择:限制可预约日期范围为当天至30天后,时间限制在9:00-21:00
  3. 表单验证:实时检查表单完整性,包括手机号格式验证
  4. 数据提交:通过wx.request将预约信息提交至后端API

后端接口建议

需要配套的后端接口支持,建议包含以下功能:

  • 接收预约请求并存储到数据库
  • 检查时间冲突
  • 发送预约确认通知
  • 会员积分管理

代码可根据实际需求进行调整,如增加会员等级判断、优惠券使用等功能。

相关推荐
码农客栈1 小时前
小程序学习(十一)之uni-app和原生小程序开发区别
学习·小程序·uni-app
说私域2 小时前
基于AI客服链动2+1模式商城小程序的社群运营策略研究——以千人社群活跃度提升为例
人工智能·微信·小程序·私域运营
mqjFKmYf2 小时前
VSC整流系统定功率控制系统的MATLAB仿真模型(支持MATLAB 2014a及以上版本)
小程序
Json____3 小时前
使用uni-app开发抖音小程序遇到previewImage方法图片加载不出来解决方案
小程序·uni-app
毕设源码-钟学长4 小时前
【开题答辩全过程】以 基于微信小程序教学评价平台的设计与实现为例,包含答辩的问题和答案
微信小程序·小程序
说私域4 小时前
基于AI智能名片链动2+1模式S2B2C商城小程序的流量运营策略研究
人工智能·微信·小程序·产品运营·流量运营
阿巴资源站4 小时前
小程序原生授权手机号
小程序·apache
UI设计兰亭妙微5 小时前
兰亭妙微:以交互设计与UI设计赋能文旅小程序,重塑用户体验界面设计优化新标杆
小程序·ui设计外包
咖啡の猫18 小时前
微信小程序WXSS 模板样式
微信小程序·小程序
AALoveTouch1 天前
分享演唱会攻略-抢票利器
小程序·自动化