Showing
4 changed files
with
232 additions
and
3 deletions
| ... | @@ -1302,7 +1302,6 @@ | ... | @@ -1302,7 +1302,6 @@ |
| 1302 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz", | 1302 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz", |
| 1303 | "integrity": "sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ==", | 1303 | "integrity": "sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ==", |
| 1304 | "dev": true, | 1304 | "dev": true, |
| 1305 | - "license": "BSD-3-Clause", | ||
| 1306 | "dependencies": { | 1305 | "dependencies": { |
| 1307 | "side-channel": "^1.0.4" | 1306 | "side-channel": "^1.0.4" |
| 1308 | }, | 1307 | }, | ... | ... |
| ... | @@ -109,6 +109,14 @@ export default [{ | ... | @@ -109,6 +109,14 @@ export default [{ |
| 109 | }, | 109 | }, |
| 110 | children: [] | 110 | children: [] |
| 111 | }, { | 111 | }, { |
| 112 | + path: '/me/verifyUser', | ||
| 113 | + name: '实名认证', | ||
| 114 | + component: () => import('./views/me/verifyUser.vue'), | ||
| 115 | + meta: { | ||
| 116 | + title: '实名认证' | ||
| 117 | + }, | ||
| 118 | + children: [] | ||
| 119 | +}, { | ||
| 112 | path: '/image', | 120 | path: '/image', |
| 113 | name: 'html转图片', | 121 | name: 'html转图片', |
| 114 | component: () => import('./views/html2canvas.vue'), | 122 | component: () => import('./views/html2canvas.vue'), | ... | ... |
| ... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
| 10 | <van-col class="text-wrapper" span="18"> | 10 | <van-col class="text-wrapper" span="18"> |
| 11 | <div> | 11 | <div> |
| 12 | <div class="username">瑟日古娜</div> | 12 | <div class="username">瑟日古娜</div> |
| 13 | - <div class="toggle-user">切换儿童</div> | 13 | + <div class="toggle-user" @click="toggleUser">切换儿童</div> |
| 14 | </div> | 14 | </div> |
| 15 | <div class="address">呼和浩特市新城区蒙古族幼儿园</div> | 15 | <div class="address">呼和浩特市新城区蒙古族幼儿园</div> |
| 16 | </van-col> | 16 | </van-col> |
| ... | @@ -44,7 +44,7 @@ | ... | @@ -44,7 +44,7 @@ |
| 44 | 44 | ||
| 45 | <div class="van-hairline--bottom sub-handle"> | 45 | <div class="van-hairline--bottom sub-handle"> |
| 46 | <div> | 46 | <div> |
| 47 | - <my-button type="custom" :custom-style="styleObject1" @on-click="">实名认证</my-button> | 47 | + <my-button type="custom" :custom-style="styleObject1" @on-click="goTo('/me/verifyUser')">实名认证</my-button> |
| 48 | </div> | 48 | </div> |
| 49 | <div> | 49 | <div> |
| 50 | <my-button type="custom" :custom-style="styleObject2" @on-click="">新增儿童</my-button> | 50 | <my-button type="custom" :custom-style="styleObject2" @on-click="">新增儿童</my-button> |
| ... | @@ -76,6 +76,17 @@ import { Toast } from 'vant'; | ... | @@ -76,6 +76,17 @@ import { Toast } from 'vant'; |
| 76 | const $route = useRoute(); | 76 | const $route = useRoute(); |
| 77 | const $router = useRouter(); | 77 | const $router = useRouter(); |
| 78 | 78 | ||
| 79 | +// 切换用户功能 | ||
| 80 | +const toggleUser = () => { | ||
| 81 | + console.warn('切换儿童'); | ||
| 82 | +} | ||
| 83 | +// 跳转相关页面 | ||
| 84 | +const goTo = (path) => { | ||
| 85 | + $router.push({ | ||
| 86 | + path: path | ||
| 87 | + }) | ||
| 88 | +} | ||
| 89 | + | ||
| 79 | // 自定义按钮颜色样式 | 90 | // 自定义按钮颜色样式 |
| 80 | const styleObject1 = reactive({ | 91 | const styleObject1 = reactive({ |
| 81 | backgroundColor: '#FFFFFF', | 92 | backgroundColor: '#FFFFFF', | ... | ... |
src/views/me/verifyUser.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div class="verify-user-page"> | ||
| 3 | + <p style="color: #713610; font-size: 1.25rem; padding: 1rem; text-align: center; font-weight: bold;">请录入真实的信息</p> | ||
| 4 | + <div style="padding: 1rem;"> | ||
| 5 | + <van-config-provider :theme-vars="themeVars"> | ||
| 6 | + <van-form ref="form" @submit="onSubmit"> | ||
| 7 | + <div class="van-hairline--bottom"> | ||
| 8 | + <van-field v-model="parent" label="家长姓名" placeholder="请输入你真实的姓名" :rules="[{ required: true, message: '请填写家长姓名' }]" /> | ||
| 9 | + </div> | ||
| 10 | + <div class="van-hairline--bottom"> | ||
| 11 | + <van-field v-if="use_widget" v-model="phone" name="phone" label="手机号" placeholder="手机号" readonly clickable @touchstart.stop="showKeyboard" /> | ||
| 12 | + <van-field v-else v-model="phone" name="phone" label="手机号" placeholder="手机号" :rules="[{ validator, message: '请输入正确手机号' }]" /> | ||
| 13 | + </div> | ||
| 14 | + <div class="van-hairline--bottom"> | ||
| 15 | + <van-field v-model="code" center clearable name="code" label="短信验证码" placeholder="请输入短信验证码" :formatter="formatter" :rules="[{ required: true, message: '请填写验证码' }]" > | ||
| 16 | + <template #button> | ||
| 17 | + <van-button @click="sendCode" size="small" type="primary" :disabled="disabled"> | ||
| 18 | + <span v-if="countDown === 60">发送验证码</span> | ||
| 19 | + <span v-else>{{ countDown }} 秒重新发送</span> | ||
| 20 | + </van-button> | ||
| 21 | + </template> | ||
| 22 | + </van-field> | ||
| 23 | + </div> | ||
| 24 | + </van-form> | ||
| 25 | + </van-config-provider> | ||
| 26 | + </div> | ||
| 27 | + </div> | ||
| 28 | + | ||
| 29 | + <div style="padding: 2rem;"> | ||
| 30 | + <my-button @on-click="submit" type="primary">保存</my-button> | ||
| 31 | + </div> | ||
| 32 | + | ||
| 33 | + <van-number-keyboard | ||
| 34 | + v-model="phone" | ||
| 35 | + :show="keyboard_show" | ||
| 36 | + :maxlength="11" | ||
| 37 | + @blur="onBlur" | ||
| 38 | + /> | ||
| 39 | +</template> | ||
| 40 | + | ||
| 41 | +<script setup> | ||
| 42 | +import MyButton from '@/components/MyButton/index.vue' | ||
| 43 | +import { wxInfo } from '@/utils/tools'; | ||
| 44 | +import qs from 'Qs' | ||
| 45 | +import { ref, reactive, onMounted } from 'vue' | ||
| 46 | +import { useRoute, useRouter } from 'vue-router' | ||
| 47 | +import axios from '@/utils/axios'; | ||
| 48 | +import $ from 'jquery' | ||
| 49 | +import { Toast } from 'vant'; | ||
| 50 | +const $route = useRoute(); | ||
| 51 | +const $router = useRouter(); | ||
| 52 | + | ||
| 53 | +const themeVars = { | ||
| 54 | + buttonPrimaryBackground: '#F9D95C', | ||
| 55 | + buttonPrimaryBorderColor: '#F9D95C', | ||
| 56 | + buttonPrimaryColor: '#713610', | ||
| 57 | +}; | ||
| 58 | + | ||
| 59 | +const parent = ref('') | ||
| 60 | + | ||
| 61 | +// 判断是否显示控件 | ||
| 62 | +let use_widget = ref(true); | ||
| 63 | +/** | ||
| 64 | + * 手机号码校验 | ||
| 65 | + * 函数返回 true 表示校验通过,false 表示不通过 | ||
| 66 | + * @param {*} val | ||
| 67 | + */ | ||
| 68 | +const validator = (val) => { | ||
| 69 | + let flag = false; | ||
| 70 | + // 简单判断手机号位数 | ||
| 71 | + if (/1\d{10}/.test(val) && phone.value.length === 11) { | ||
| 72 | + disabled.value = false; | ||
| 73 | + flag = true; | ||
| 74 | + } else { | ||
| 75 | + disabled.value = true; | ||
| 76 | + flag = false; | ||
| 77 | + } | ||
| 78 | + return flag | ||
| 79 | +}; | ||
| 80 | + | ||
| 81 | + onMounted(() => { | ||
| 82 | + /** | ||
| 83 | + * 判断微信环境看是否弹出控件框 | ||
| 84 | + * 桌面微信直接输入 | ||
| 85 | + * 其他环境弹出输入框 | ||
| 86 | + */ | ||
| 87 | + if (wxInfo().isiOS || wxInfo().isAndroid) { | ||
| 88 | + use_widget.value = true; | ||
| 89 | + } else { | ||
| 90 | + use_widget.value = false; | ||
| 91 | + } | ||
| 92 | + }) | ||
| 93 | + | ||
| 94 | +// 手机号输入控件控制 | ||
| 95 | +const keyboard_show = ref(false); | ||
| 96 | +const showKeyboard = () => { // 弹出数字弹框 | ||
| 97 | + keyboard_show.value = true; | ||
| 98 | +}; | ||
| 99 | +const onBlur = () => { // 数字键盘失焦回调 | ||
| 100 | + keyboard_show.value = false; | ||
| 101 | + if (phone.value.length === 11) { | ||
| 102 | + disabled.value = false; | ||
| 103 | + } | ||
| 104 | +}; | ||
| 105 | + | ||
| 106 | +// 设置发送短信倒计时 | ||
| 107 | +const countDown = ref(60); | ||
| 108 | +const countDownHandle = () => { | ||
| 109 | + // 倒计时 | ||
| 110 | + if (countDown.value === 0) { | ||
| 111 | + countDown.value = 60; | ||
| 112 | + } else { | ||
| 113 | + countDown.value--; | ||
| 114 | + setTimeout(() => { | ||
| 115 | + countDownHandle() | ||
| 116 | + }, 1000) | ||
| 117 | + } | ||
| 118 | +} | ||
| 119 | +const sendCode = () => { // 发送验证码 | ||
| 120 | + if (countDown.value === 60) { | ||
| 121 | + axios.post('/srv/?f=shzl_comment&a=bind_phone&t=get_code', | ||
| 122 | + qs.stringify({ | ||
| 123 | + phone: phone.value | ||
| 124 | + })) | ||
| 125 | + .then(res => { | ||
| 126 | + if (res.data.code === 1) { | ||
| 127 | + Toast.success('发送成功'); | ||
| 128 | + countDownHandle() | ||
| 129 | + } else { | ||
| 130 | + console.warn(res.data); | ||
| 131 | + Toast({ | ||
| 132 | + message: res.data.msg, | ||
| 133 | + icon: 'close', | ||
| 134 | + }); | ||
| 135 | + } | ||
| 136 | + }) | ||
| 137 | + .catch(err => { | ||
| 138 | + console.error(err); | ||
| 139 | + }) | ||
| 140 | + } | ||
| 141 | +}; | ||
| 142 | + | ||
| 143 | +const phone = ref(''); | ||
| 144 | +const code = ref(''); | ||
| 145 | +const disabled = ref(true); | ||
| 146 | +// 过滤输入的数字 只能四位 | ||
| 147 | +const formatter = (value) => value.substring(0, 4); | ||
| 148 | + | ||
| 149 | +// 保存用户信息 | ||
| 150 | +const onSubmit = (values) => { | ||
| 151 | + axios.post('/srv/?f=shzl_comment&a=bind_phone&t=bind', | ||
| 152 | + qs.stringify({ | ||
| 153 | + phone: values.phone, | ||
| 154 | + code: values.code, | ||
| 155 | + })) | ||
| 156 | + .then(res => { | ||
| 157 | + if (res.data.code === 1) { | ||
| 158 | + $router.push({ | ||
| 159 | + path: '/' | ||
| 160 | + }); | ||
| 161 | + } else { | ||
| 162 | + console.warn(res.data); | ||
| 163 | + Toast({ | ||
| 164 | + message: res.data.msg, | ||
| 165 | + icon: 'close', | ||
| 166 | + }); | ||
| 167 | + } | ||
| 168 | + }) | ||
| 169 | + .catch(err => { | ||
| 170 | + console.error(err); | ||
| 171 | + }) | ||
| 172 | +}; | ||
| 173 | +</script> | ||
| 174 | + | ||
| 175 | +<script> | ||
| 176 | +import mixin from 'common/mixin'; | ||
| 177 | + | ||
| 178 | +export default { | ||
| 179 | + mixins: [mixin.init], | ||
| 180 | + data () { | ||
| 181 | + return { | ||
| 182 | + | ||
| 183 | + } | ||
| 184 | + }, | ||
| 185 | + mounted () { | ||
| 186 | + | ||
| 187 | + }, | ||
| 188 | + methods: { | ||
| 189 | + submit () { | ||
| 190 | + let valid = this.$refs.form.validate(); | ||
| 191 | + valid | ||
| 192 | + .then(() => { | ||
| 193 | + this.$refs.form.submit(); | ||
| 194 | + }) | ||
| 195 | + .catch(error => { | ||
| 196 | + console.error(error); | ||
| 197 | + this.$toast({ | ||
| 198 | + message: '请检查后再次提交', | ||
| 199 | + icon: 'cross', | ||
| 200 | + }); | ||
| 201 | + }) | ||
| 202 | + } | ||
| 203 | + } | ||
| 204 | +} | ||
| 205 | +</script> | ||
| 206 | + | ||
| 207 | +<style lang="less" scoped> | ||
| 208 | +.verify-user-page { | ||
| 209 | + padding: 1rem; | ||
| 210 | +} | ||
| 211 | +</style> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment