公众号前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

244 line
6.3 KiB

  1. <template>
  2. <div class="app-container">
  3. <div class="title">
  4. <!-- <img style="display: block;
  5. margin: 0 auto;" src="../../static/images/onlineHome/yinnongLogo.jpg" alt=""> -->
  6. </div>
  7. <!-- <van-tabs v-model="active" :swipeable="true" style="margin-top:0.5rem;padding:0 10px;"> -->
  8. <van-form style="margin:50px 0;">
  9. <van-field
  10. v-model="formData.memberName"
  11. name="请输入姓名"
  12. placeholder="请输入姓名"
  13. :rules="[{ required: true, message: '' }]"
  14. />
  15. <van-field
  16. v-model="formData.idcard"
  17. name="请输入身份证号"
  18. style="margin-top: 20px"
  19. placeholder="请输入身份证号"
  20. :rules="[{ required: true, message: '' }]"
  21. />
  22. <van-field
  23. v-model="formData.mobile"
  24. name="请输入手机号"
  25. style="margin-top: 20px"
  26. placeholder="请输入手机号"
  27. :rules="[{ required: true, message: '' }]"
  28. />
  29. <van-field
  30. v-model="formData.code"
  31. center
  32. clearable
  33. label="验证码"
  34. placeholder="图形验证码"
  35. >
  36. <template #button>
  37. <img style="width: 100px" :src="codeUrl" @click="getCode" />
  38. </template>
  39. </van-field>
  40. <van-field
  41. v-model="formData.smsCode"
  42. style="margin-top: 20px"
  43. placeholder="请输入验证码"
  44. :rules="[{ required: true, message: '' }]"
  45. >
  46. <template #button>
  47. <!-- <van-button size="mini" type="info" @click="getRegisterSmsCode" >获取验证码</van-button> -->
  48. <div class="registerSmsBtn" @click="getRegisterSmsCode">{{
  49. computeTime > 0 ? `(${computeTime}s)已发送` : "获取短信码"
  50. }}</div>
  51. </template>
  52. </van-field>
  53. <div style="margin: 50px 16px 16px;">
  54. <van-button block type="info" native-type="submit" @click="registerSubmit">绑定</van-button>
  55. </div>
  56. </van-form>
  57. </div>
  58. </template>
  59. <style scoped>
  60. .app-container{
  61. background: #fff;
  62. height: 100vh;
  63. }
  64. .title{
  65. padding-top: 20%;
  66. width: 88%;
  67. margin: 0 auto;
  68. }
  69. .van-tab--active{
  70. font-size: .6rem;
  71. font-weight: bold;
  72. }
  73. .van-tabs__line{
  74. background:#1D6FE9;
  75. width: 0.15rem;
  76. height: 0.15rem;
  77. border-radius: 0.07rem;
  78. bottom: 0.3rem;
  79. }
  80. .van-tabs__nav{
  81. padding:0
  82. }
  83. .van-tab{
  84. display: inline-block;
  85. flex: inherit;
  86. margin-left: 30px;
  87. line-height: .8rem;
  88. }
  89. .van-tab__text--ellipsis {
  90. overflow: auto;
  91. }
  92. .van-password-input{
  93. width: 50%;
  94. margin: 0 auto;
  95. }
  96. [class*=van-hairline]::after{
  97. border:none;
  98. }
  99. .van-password-input__security li{
  100. margin: 0 10px;
  101. border-bottom: 3px solid black;
  102. }
  103. .registerSmsBtn{
  104. color: rgb(29, 111, 233);
  105. font-size: 0.34rem;
  106. }
  107. </style>
  108. <script>
  109. import { getUUID } from '@/utils'
  110. export default {
  111. data() {
  112. return {
  113. showMessage:false,
  114. smsCodeValue:"",
  115. showKeyboard:false,
  116. formData: {
  117. username: "", //账号
  118. password: "", //密码
  119. code: null, //图片验证码
  120. uuid: null, //识别uuid
  121. mobile: null, //手机号
  122. smsCode: null, //短信验证码
  123. memberName:null, //身份信息
  124. idcard:null, //身份号码
  125. rememberMe:false
  126. },
  127. loading: false,
  128. codeUrl: "", //验证码
  129. isSmsLogin: false, //是否手机验证码
  130. computeTime: 0,
  131. active:1
  132. };
  133. },
  134. created() {
  135. this.getCode();
  136. this.reset();
  137. },
  138. methods: {
  139. reset(){
  140. },
  141. showPopup(){
  142. this.showKeyboard = !this.showKeyboard
  143. },
  144. showMessagePop(){
  145. this.showMessage = !this.showMessage
  146. },
  147. getCode() {
  148. this.formData.uuid = getUUID()
  149. this.codeUrl = this.$http.adornUrl(`/captcha?uuid=${this.formData.uuid}`)
  150. },
  151. getRegisterSmsCode(){
  152. if (!this.computeTime) {
  153. let myreg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
  154. if (!myreg.test(this.formData.mobile)) {
  155. this.$dialog.alert({
  156. message: '手机号格式不正确',
  157. });
  158. return false;
  159. }else if (this.formData.code == "") {
  160. this.$dialog.alert({
  161. message: '图片验证码不能为空',
  162. });
  163. return false;
  164. }
  165. if (this.active==2) {
  166. let formObj = {
  167. code :this.formData.code,
  168. mobile:this.formData.mobile,
  169. uuid:this.formData.uuid
  170. }
  171. getRegisterSmsCode(formObj).then((res) => {
  172. console.log(res)
  173. console.log(res.code == 200)
  174. if(res.code == 200) {
  175. this.$dialog.alert({
  176. message: '验证码已发送',
  177. });
  178. this.formData.uuid = res.uuid;
  179. this.computeTime = 60;
  180. this.timer = setInterval(() => {
  181. this.computeTime--;
  182. if (this.computeTime <= 0) {
  183. clearInterval(this.timer);
  184. }
  185. }, 1000);
  186. }
  187. }).catch((res)=>{
  188. if(res=='Error: 验证码已失效'){
  189. this.getCode()
  190. }
  191. });
  192. }
  193. }
  194. },
  195. registerSubmit(){
  196. //注册
  197. if (this.formData.memberName == "") {
  198. this.$dialog.alert({
  199. message: '姓名不能为空',
  200. });
  201. return false;
  202. } else if (this.formData.idcard == "") {
  203. this.$dialog.alert({
  204. message: '身份证号不能为空',
  205. });
  206. return false;
  207. } else if (this.formData.mobile == "") {
  208. this.$dialog.alert({
  209. message: '手机号码不能为空',
  210. });
  211. return false;
  212. }else if (this.formData.smsCode == "") {
  213. this.$dialog.alert({
  214. message: '短信验证码不能为空',
  215. });
  216. return false;
  217. }
  218. //registerCheck,registerOn
  219. console.log(this.formData)
  220. registerCheck(this.formData).then((res)=>{
  221. if(res.code == 200){
  222. registerOn(this.formData).then((res)=>{
  223. if(res.code == 200){
  224. //
  225. this.$dialog.alert({
  226. message: '您的初始密码:'+res.password,
  227. }).then(() => {
  228. this.$router.push({ path: "/yinnong/workbench" }).catch(() => {});
  229. });
  230. }
  231. })
  232. }
  233. })
  234. }
  235. },
  236. };
  237. </script>