|
@@ -0,0 +1,237 @@
|
|
|
+<template>
|
|
|
+ <div class="user-info">
|
|
|
+ <scroller>
|
|
|
+ <h2 class="title">预约</h2>
|
|
|
+ <!--输入框-->
|
|
|
+ <div class="weui-cells weui-cells_form">
|
|
|
+ <!--姓名-->
|
|
|
+ <div class="weui-cell">
|
|
|
+ <div class="weui-cell__hd"><label class="weui-label">姓名</label></div>
|
|
|
+ <div class="weui-cell__bd"><input v-model="userName" class="weui-input" type="text" required="" maxlength="11"
|
|
|
+ placeholder="输入你的姓名">
|
|
|
+ </div>
|
|
|
+ <div class="weui-cell__ft"><i class="weui-icon-warn"></i></div>
|
|
|
+ </div>
|
|
|
+ <!--预产期-->
|
|
|
+ <div class="weui-cell">
|
|
|
+ <div class="weui-cell__hd"><label class="weui-label">预产期</label></div>
|
|
|
+ <div class="weui-cell__bd" @click='btn()'>
|
|
|
+ <input class="weui-input select-time" type="button" required=""
|
|
|
+ :value="time">
|
|
|
+ </div>
|
|
|
+ <div class="weui-cell__ft"><i class="weui-icon-warn"></i></div>
|
|
|
+ </div>
|
|
|
+ <!--手机验证-->
|
|
|
+ <div class="weui-cell">
|
|
|
+ <div class="weui-cell__hd"><label class="weui-label">手机</label></div>
|
|
|
+ <div class="weui-cell__bd"><input class="weui-input" type="tel" v-model="number" required="" pattern="^\d{11}$"
|
|
|
+ maxlength="11"
|
|
|
+ placeholder="输入你现在的手机号" emptytips="请输入手机号" notmatchtips="请输入正确的手机号"></div>
|
|
|
+ <div class="weui-cell__ft"><i class="weui-icon-warn"></i></div>
|
|
|
+ </div>
|
|
|
+ <div class="weui-cell weui-cell_vcode">
|
|
|
+ <div class="weui-cell__hd"><label class="weui-label">验证码</label></div>
|
|
|
+ <div class="weui-cell__bd"><input v-model="iCreateCode" class="weui-input" maxlength="4" type="text" required=""
|
|
|
+ pattern="REG_VCODE"
|
|
|
+ placeholder="点击验证码更换" tips="请输入验证码"></div>
|
|
|
+ <div class="weui-cell__ft"><i class="weui-icon-warn"></i>
|
|
|
+ <input type="button" class="code checkCode checkCodeBtn" @click='getCreateCode()' :value="createCode">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="weui-cell weui-cell_vcode">
|
|
|
+ <div class="weui-cell_hd"><label class="weui-label">短信验证</label></div>
|
|
|
+ <div class="weui-cell_hd"><input v-model="iCode" type="text" class="weui-input" maxlength="4"
|
|
|
+ placeholder="输入短信验证码"></div>
|
|
|
+ <div class="weui-cell__ft"><i class="weui-icon-warn"></i>
|
|
|
+ <input @click="getCode()" type="button" class="getCreateCode" value="获取">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!--提交-->
|
|
|
+ <div class="submit" @click="submit()">提交</div>
|
|
|
+ </scroller>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+ import axios from 'axios'
|
|
|
+ import config from '@/config'
|
|
|
+ export default {
|
|
|
+ name: 'userInfo',
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ msg: 'this is userInfo',
|
|
|
+ userName: '',
|
|
|
+ number: '',
|
|
|
+ time: '选择你的预产期', // 展示已选择时间
|
|
|
+ resTime: '', // 已选择时间集合
|
|
|
+ createCode: '', // 验证码
|
|
|
+ iCreateCode: '', // 用户输入的验证码
|
|
|
+ Code: '', // 短信验证码
|
|
|
+ iCode: '', // 用户输入的短信验证码
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.createCode = createCode()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ btn() {
|
|
|
+ let that = this;
|
|
|
+ let currentDate = new Date() // Sat Jun 24 2017 10:09:18 GMT+0800 (中国标准时间)
|
|
|
+ let currentYear = currentDate.getFullYear() // 当前年 2017
|
|
|
+ let currentMonth = currentDate.getMonth() + 1 // 当前月 6
|
|
|
+ let currentDay = currentDate.getDate() // 当前日 24
|
|
|
+ weui.datePicker({
|
|
|
+ start: new Date(), // 从今天开始
|
|
|
+ end: currentYear + 20,
|
|
|
+ defaultValue: [currentYear, currentMonth, currentDay],
|
|
|
+ onChange: function (result) {
|
|
|
+// console.log(result);
|
|
|
+ },
|
|
|
+ onConfirm: function (result) {
|
|
|
+ that.time = result[0].label + result[1].label + result[2].label
|
|
|
+ that.resTime = result
|
|
|
+ },
|
|
|
+ id: 'datePicker'
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getCreateCode() {
|
|
|
+ this.createCode = createCode()
|
|
|
+ },
|
|
|
+ // 获取短信验证码
|
|
|
+ getCode() {
|
|
|
+ // 检验手机号码
|
|
|
+ if (!(/^1[34578]\d{9}$/.test(this.number)) || this.number === 0) {
|
|
|
+ weui.alert('输入的手机号码有误,请重新输入');
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.iCreateCode === this.createCode) {
|
|
|
+ axios.get(config.apiPath + '/moonclub/reserve/code&number=' + this.number).then(res => {
|
|
|
+ // 短信发送成功
|
|
|
+ if (res.data.success) {
|
|
|
+ weui.alert('短信已发送,请留意查收!');
|
|
|
+ // 绑定短信验证码
|
|
|
+ this.code = res.data.data.code;
|
|
|
+ // this.iCode = this.code // 系统调试时开启
|
|
|
+ this.iCreateCode = '';// 清空已输入验证码
|
|
|
+ this.createCode = createCode(); // 重置验证码
|
|
|
+ } else {
|
|
|
+ weui.alert('短信发送发送失败,请稍后再试!');
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ weui.alert('您输入验证码有误,请重新输入');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 表单提交
|
|
|
+ submit() {
|
|
|
+ let that = this;
|
|
|
+ // 用户来源
|
|
|
+ let lest = window.location.href;
|
|
|
+ // 判断用户来源
|
|
|
+ let source = 0;
|
|
|
+ if(lest.indexOf('source')> -1) {
|
|
|
+ // source
|
|
|
+ let w = lest.indexOf('source');
|
|
|
+ source = lest.slice(w+7,w+8); // 1 2
|
|
|
+ }
|
|
|
+// 用户名判断
|
|
|
+ if (!this.userName) {
|
|
|
+ weui.alert('请重新输入你的姓名');
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 短信验证码判断
|
|
|
+ if (Number.parseInt(this.iCode) !== this.code) {
|
|
|
+ weui.alert('输入的短信验证码有误,请重新输入');
|
|
|
+ return
|
|
|
+ }
|
|
|
+ axios.post(config.apiPath + 'moonclub/Reserve/Month1&user_id=' + config.user_id + '&user_name=' + this.userName + '&homeType=1&num='+this.time+'&mobile='+this.number+'&source='+source).then(res=>{
|
|
|
+ // console.log(res)
|
|
|
+ if (res.data.success) {
|
|
|
+ /*
|
|
|
+ 提交失败,刷新界面,
|
|
|
+ 重复提交或提交成功都返回首页
|
|
|
+ */
|
|
|
+ if (res.data.message === '您已经提交过信息') {
|
|
|
+ weui.alert(res.data.message,function () {
|
|
|
+ that.$router.push({path: '/'})
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ weui.alert('提交成功',function () {
|
|
|
+ that.$router.push({path: '/'})
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ weui.alert('提交失败,请稍后再试!',function () {
|
|
|
+ that.$router.push({path: '/userInfo'})
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function createCode(Number) {
|
|
|
+ let code = ''
|
|
|
+ let random = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] // 随机数
|
|
|
+ for (let i = 0; i < 4; i++) { // 循环操作
|
|
|
+ let charIndex = Math.floor(Math.random() * random.length) // 取得随机数的索引
|
|
|
+ code += random[charIndex] // 根据索引取得随机数加到code上
|
|
|
+ }
|
|
|
+ return code // 把code值赋给验证码
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped lang="less">
|
|
|
+ .user-info {
|
|
|
+ .select-time {
|
|
|
+ text-align: left;
|
|
|
+ color: #848484;
|
|
|
+ }
|
|
|
+ input {
|
|
|
+ font-size: 16px;
|
|
|
+ }
|
|
|
+ .title {
|
|
|
+ text-align: center;
|
|
|
+ font-weight: 500;
|
|
|
+ }
|
|
|
+ .checkCodeBtn {
|
|
|
+ font-family: Arial;
|
|
|
+ font-style: italic;
|
|
|
+ font-weight: bold;
|
|
|
+ border: 0;
|
|
|
+ height: 35px;
|
|
|
+ letter-spacing: 3px;
|
|
|
+ color: blue;
|
|
|
+ padding: 0px 10px;
|
|
|
+ margin-top: 5px;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+ .getCreateCode {
|
|
|
+ border: 0;
|
|
|
+ height: 35px;
|
|
|
+ padding: 0 18px;
|
|
|
+ margin-top: 5px;
|
|
|
+ }
|
|
|
+ .submit {
|
|
|
+ background: #61904a;
|
|
|
+ color: rgb(255, 255, 255);
|
|
|
+ border: 0;
|
|
|
+ padding: 4px 0;
|
|
|
+ font-size: 22px;
|
|
|
+ line-height: 30px;
|
|
|
+ height: 30px;
|
|
|
+ width: calc(100% - 15px);
|
|
|
+ margin: 15px auto;
|
|
|
+ display: block;
|
|
|
+ text-align: center;
|
|
|
+ transition: all .1s;
|
|
|
+ &:active {
|
|
|
+ font-size: 20px;
|
|
|
+ background: rgba(47, 0, 78, 0.81);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+</style>
|