|
@@ -0,0 +1,404 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <XHeader :left-options="{backText: ''}"
|
|
|
+ style="border-bottom: 2px solid #dddddd;background:#fff;z-index:3;">兑换专区</XHeader>
|
|
|
+ <div class="bg_transparent"></div>
|
|
|
+ <scroller style="">
|
|
|
+ <!-- <div class="header">
|
|
|
+ <span @click='back'>返回</span>兑换专区
|
|
|
+ </div> -->
|
|
|
+ <div class="box">
|
|
|
+ <!-- name -->
|
|
|
+ <div class="weui-cell">
|
|
|
+ <div class="weui-cell__hd">
|
|
|
+ <label class="weui-label">
|
|
|
+ <span>姓</span>
|
|
|
+ <span class="white">白</span>
|
|
|
+ <span>名</span>
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
+ <div class="weui-cell__bd">
|
|
|
+ <input v-model="user.name"
|
|
|
+ class="weui-input"
|
|
|
+ type="text"
|
|
|
+ required=""
|
|
|
+ maxlength="15"
|
|
|
+ placeholder="输入你的姓名">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- mobile -->
|
|
|
+ <div class="weui-cell">
|
|
|
+ <div class="weui-cell__hd">
|
|
|
+ <label class="weui-label">
|
|
|
+ <span>手</span>
|
|
|
+ <span class="white">白</span>
|
|
|
+ <span>机</span>
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
+ <div class="weui-cell__bd"><input v-model="user.mobile"
|
|
|
+ class="weui-input"
|
|
|
+ type="text"
|
|
|
+ required=""
|
|
|
+ maxlength="15"
|
|
|
+ placeholder="输入你的手机">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- 验证码 -->
|
|
|
+ <div class="weui-cell">
|
|
|
+ <div class="weui-cell__hd">
|
|
|
+ <label class="weui-label">
|
|
|
+ <span>识别码</span>
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
+ <div class="weui-cell__bd"><input v-model="Vcode.enter"
|
|
|
+ class="weui-input"
|
|
|
+ type="text"
|
|
|
+ required=""
|
|
|
+ maxlength="15"
|
|
|
+ placeholder="输入识别码">
|
|
|
+ </div>
|
|
|
+ <input type="button"
|
|
|
+ @click='getCreateCode'
|
|
|
+ v-model="Vcode.create"
|
|
|
+ class="v-code">
|
|
|
+ </div>
|
|
|
+ <div class="weui-cell">
|
|
|
+ <div class="weui-cell__hd">
|
|
|
+ <label class="weui-label">
|
|
|
+ <span>短信码</span>
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
+ <div class="weui-cell__bd"><input v-model="Vcode.sms.enter"
|
|
|
+ class="weui-input"
|
|
|
+ type="text"
|
|
|
+ required=""
|
|
|
+ maxlength="15"
|
|
|
+ placeholder="输入短信验证码">
|
|
|
+ </div>
|
|
|
+ <div class="weui-btn weui-btn_mini weui-btn_plain-default"
|
|
|
+ @click=getSMS>
|
|
|
+ 获取
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- address -->
|
|
|
+ <div class="weui-cell">
|
|
|
+ <div class="weui-cell__hd">
|
|
|
+ <label class="weui-label">
|
|
|
+ <span>地</span>
|
|
|
+ <span class="white">白</span>
|
|
|
+ <span>址</span>
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
+ <div class="weui-cell__bd">
|
|
|
+ <input v-model="user.address"
|
|
|
+ class="weui-input"
|
|
|
+ type="text"
|
|
|
+ required=""
|
|
|
+ maxlength="15"
|
|
|
+ placeholder="如:上海市徐汇区天平路245号">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- code.pwd -->
|
|
|
+ <div class="weui-cell">
|
|
|
+ <div class="weui-cell__hd">
|
|
|
+ <label class="weui-label">
|
|
|
+ <span>兑换码</span>
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
+ <div class="weui-cell__bd"><input v-model="code.pwd"
|
|
|
+ class="weui-input"
|
|
|
+ type="text"
|
|
|
+ required=""
|
|
|
+ maxlength="15"
|
|
|
+ placeholder="输入你的兑换码密码">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- code.num -->
|
|
|
+ <div class="weui-cell">
|
|
|
+ <div class="weui-cell__hd">
|
|
|
+ <label class="weui-label">
|
|
|
+ <span>验证码</span>
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
+ <div class="weui-cell__bd">
|
|
|
+ <input v-model="code.num"
|
|
|
+ class="weui-input"
|
|
|
+ placeholder="输入你的验证码">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- 提交 -->
|
|
|
+ <div class="submit" @click="exchange()">兑换</div>
|
|
|
+ </div>
|
|
|
+ </scroller>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import axios from 'axios';
|
|
|
+import qs from 'qs';
|
|
|
+import _ from '@/config';
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ user: {
|
|
|
+ name: null,
|
|
|
+ mobile: null,
|
|
|
+ address: null,
|
|
|
+ },
|
|
|
+ Vcode: {
|
|
|
+ create: this.createCode(),
|
|
|
+ enter: null,
|
|
|
+ sms: {
|
|
|
+ create: null,
|
|
|
+ enter: null,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ code: {
|
|
|
+ num: null,
|
|
|
+ pwd: null,
|
|
|
+ time: '',
|
|
|
+ },
|
|
|
+ exchangeBtn: true,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ exchange() {
|
|
|
+ let self = this;
|
|
|
+ if (!self.exchangeBtn) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 验证姓名
|
|
|
+ if (self.user.name == null) {
|
|
|
+ weui.alert('请重新输入姓名!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证手机
|
|
|
+ if (self.Vcode.sms.create != self.Vcode.sms.enter) {
|
|
|
+ weui.alert('手机验证失败,因为短信码填写错误,请重新验证!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 验证地址
|
|
|
+ if (self.user.address == null) {
|
|
|
+ weui.alert('地址不能为空!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 验证兑换码
|
|
|
+ if (self.code.pwd == null) {
|
|
|
+ weui.alert('请输入兑换券上的兑换码!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 兑换码编号不为空
|
|
|
+ if (self.code.num == null) {
|
|
|
+ weui.alert('请输入兑换券上的验证码!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 验证兑换码编号
|
|
|
+ if (isNaN(self.code.num)) {
|
|
|
+ weui.alert('您输入的编号有误,请重新输入!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ self.exchangeBtn = false;
|
|
|
+ axios
|
|
|
+ .get(
|
|
|
+ `${_.apiPath}/j/JRecord/Record&user_id=${_.userId}&name=${
|
|
|
+ self.user.name
|
|
|
+ }&mobile=${self.user.mobile}&address=${self.user.address}&pwd=${
|
|
|
+ self.code.pwd
|
|
|
+ }&coding_num=${self.code.num}`,
|
|
|
+ )
|
|
|
+ .then((data) => {
|
|
|
+ if (!data.data.success) {
|
|
|
+ console.log(data.data);
|
|
|
+ weui.alert(data.data.message);
|
|
|
+ self.exchangeBtn = true;
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ self.exchangeBtn = false;
|
|
|
+ console.log(data.data);
|
|
|
+ let tips = '客服人员将在一个工作日内联系您,请保持手机畅通。';
|
|
|
+ let addressName = '服务';
|
|
|
+ if (tips) {
|
|
|
+ tips = '如有疑问请拨打电话400-8800-365';
|
|
|
+ }
|
|
|
+ if (addressName) {
|
|
|
+ addressName = '收货';
|
|
|
+ }
|
|
|
+ weui.alert(
|
|
|
+ `礼包名称:${
|
|
|
+ data.data.data.gift.title
|
|
|
+ }。<br/>${addressName}地址:${self.user.address}。<br/>${tips}`,
|
|
|
+ function() {
|
|
|
+ self.$router.push('/');
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '兑换成功',
|
|
|
+ className: 's-weui-dialog__bd',
|
|
|
+ },
|
|
|
+ );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * data.data.gift.desc
|
|
|
+ */
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 验证码
|
|
|
+ getCreateCode() {
|
|
|
+ this.Vcode.create = this.createCode();
|
|
|
+ },
|
|
|
+ //sms
|
|
|
+ getSMS() {
|
|
|
+ let self = this;
|
|
|
+ let newTime = Date.parse(new Date()) / 1000;
|
|
|
+ if (self.code.time !== '' && self.code.time + 60 > newTime) {
|
|
|
+ weui.alert('请您60秒后重试');
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ self.code.time = '';
|
|
|
+ }
|
|
|
+ // console.log(self.code.time);
|
|
|
+ // 检验手机号码
|
|
|
+ if (!/^1[34578]\d{9}$/.test(self.user.mobile) || self.user.mobile === 0) {
|
|
|
+ weui.alert('输入的手机号码有误,请重新输入');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 验证码检测
|
|
|
+ if (self.Vcode.enter == null || self.Vcode.enter != self.Vcode.create) {
|
|
|
+ weui.alert('您输入验证码有误,请重新输入');
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ if (self.code.time === '') {
|
|
|
+ self.code.time = Date.parse(new Date()) / 1000;
|
|
|
+ }
|
|
|
+ axios
|
|
|
+ .get(
|
|
|
+ `${_.apiPath}/moonclub/reserve/code&type=2&mobile=${
|
|
|
+ self.user.mobile
|
|
|
+ }`,
|
|
|
+ )
|
|
|
+ .then((data) => {
|
|
|
+ weui.alert('短信已发送,请留意查收!');
|
|
|
+ self.Vcode.sms.create = data.data.data.code;
|
|
|
+ // console.log(data.data.data.code);
|
|
|
+ return;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ createCode() {
|
|
|
+ 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值赋给验证码
|
|
|
+ },
|
|
|
+ back() {
|
|
|
+ // console.log(170);
|
|
|
+ this.$router.push('/');
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+.header {
|
|
|
+ color: white;
|
|
|
+ // background-color: #ffb433;
|
|
|
+ padding: 0 5px;
|
|
|
+ line-height: 2.5;
|
|
|
+ text-align: center;
|
|
|
+ font-weight: 600;
|
|
|
+ position: fixed;
|
|
|
+ top: 0;
|
|
|
+ right: 0;
|
|
|
+ left: 0;
|
|
|
+ margin-bottom: 15px;
|
|
|
+ span {
|
|
|
+ font-weight: 100;
|
|
|
+ position: absolute;
|
|
|
+ left: 15px;
|
|
|
+ top: 5px;
|
|
|
+ font-size: 15px;
|
|
|
+ }
|
|
|
+}
|
|
|
+.box {
|
|
|
+ // margin-top: 60px;
|
|
|
+ padding-top: 60px;
|
|
|
+ // padding: 15px;
|
|
|
+ .v-code {
|
|
|
+ font-size: 16px;
|
|
|
+ font-family: Arial;
|
|
|
+ font-style: italic;
|
|
|
+ font-weight: 700;
|
|
|
+ border: 0;
|
|
|
+ height: 35px;
|
|
|
+ letter-spacing: 3px;
|
|
|
+ color: blue;
|
|
|
+ padding: 0 10px;
|
|
|
+ margin-top: 5px;
|
|
|
+ text-align: center;
|
|
|
+ &:active {
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+.weui-label {
|
|
|
+ font-size: 0;
|
|
|
+ span {
|
|
|
+ font-size: 18px;
|
|
|
+ }
|
|
|
+}
|
|
|
+.submit {
|
|
|
+ background: #ffb433;
|
|
|
+ color: rgb(255, 255, 255);
|
|
|
+ border: 0;
|
|
|
+ padding: 10px 0;
|
|
|
+ font-size: 22px;
|
|
|
+ line-height: 30px;
|
|
|
+ height: 30px;
|
|
|
+ width: calc(100% - 15px);
|
|
|
+ margin: 15px auto;
|
|
|
+ display: block;
|
|
|
+ text-align: center;
|
|
|
+ transition: all 0.1s;
|
|
|
+ &:active {
|
|
|
+ font-size: 20px;
|
|
|
+ background: rgba(47, 0, 78, 0.81);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+::-webkit-input-placeholder {
|
|
|
+ /* WebKit browsers */
|
|
|
+ color: #c8c8cd;
|
|
|
+ font-size: 16px;
|
|
|
+}
|
|
|
+:-moz-placeholder {
|
|
|
+ /* Mozilla Firefox 4 to 18 */
|
|
|
+ color: #c8c8cd;
|
|
|
+ font-size: 16px;
|
|
|
+}
|
|
|
+::-moz-placeholder {
|
|
|
+ /* Mozilla Firefox 19+ */
|
|
|
+ color: #c8c8cd;
|
|
|
+ font-size: 16px;
|
|
|
+}
|
|
|
+:-ms-input-placeholder {
|
|
|
+ /* Internet Explorer 10+ */
|
|
|
+ color: #c8c8cd;
|
|
|
+ font-size: 16px;
|
|
|
+}
|
|
|
+.white {
|
|
|
+ color: transparent;
|
|
|
+}
|
|
|
+.bg_transparent {
|
|
|
+ position: fixed;
|
|
|
+ z-index: -1;
|
|
|
+ top: 0;
|
|
|
+ bottom: 0;
|
|
|
+ right: 0;
|
|
|
+ left: 0;
|
|
|
+ background-color: #fff;
|
|
|
+}
|
|
|
+</style>
|