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.

register-step1.vue 4.3KB

2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <!-- 注册第1步 -->
  2. <template>
  3. <view class="register-main">
  4. <view class="title">注册账户</view>
  5. <view class="hint">请输入手机号</view>
  6. <view class="form-input">
  7. <view> +86</view>
  8. <image :src="`${$imgUrl}common/arror_down_black.png`" class="arror" />
  9. <input class="input" v-model="state.phone" focus placeholder="请输入手机号" placeholder-class="form-placeholder"
  10. type="number" maxlength="11" />
  11. </view>
  12. <view class="agreement">
  13. <checkbox-group @change="checkboxChange" class="group">
  14. <checkbox :checked="state.checked" color="#00B38B" style="transform:scale(0.85)">
  15. </checkbox>
  16. <label>我已阅读并同意</label>
  17. </checkbox-group>
  18. <!-- <view class="txt-grey">我已阅读并同意</view> -->
  19. <view class="txt-green" @click="toRead">《平台用户服务隐私协议》</view>
  20. </view>
  21. </view>
  22. <view class="btn">
  23. <submit-button title="同意协议并获取验证码" @submit="mobileIsRepeat"></submit-button>
  24. </view>
  25. </template>
  26. <script setup lang="ts">
  27. // import uCheckBox from "@/uni_modules/vk-uview-ui/components/u-checkbox/u-checkbox.vue";
  28. import { reactive } from "vue";
  29. import { checkStr, msg, navTo } from "@/utils/utils";
  30. import { sendCode, regist, mobileIsRepeatApi } from "@/utils/network/api.js";
  31. import { request } from "@/utils/network/request.js";
  32. import { stringToJson } from "@/utils/network/encryption";
  33. const state = reactive({
  34. phone: "", //电话
  35. checked: false, //是否勾选阅读协议
  36. });
  37. const checkboxChange = (e) => {
  38. console.log(e);
  39. state.checked = !state.checked;
  40. };
  41. // 去协议页面
  42. const toRead = () => {
  43. navTo("/login/agreement")
  44. }
  45. /* 下一步 */
  46. const nextStep = () => {
  47. if (!state.phone) {
  48. msg("请输入手机号!");
  49. return;
  50. }
  51. if (!checkStr(state.phone, "mobile")) {
  52. msg("请输入正确的手机号!");
  53. return;
  54. }
  55. if (!state.checked) {
  56. msg("请勾选我已阅读并同意《平台用户服务隐私协议》");
  57. return;
  58. }
  59. const options = {
  60. type: 2,
  61. data: { mobile: state.phone },
  62. method: "POST",
  63. showLoading: true,
  64. };
  65. request(sendCode, options)
  66. .then((res) => {
  67. msg("验证码发送成功!");
  68. // #ifdef MP-WEIXIN
  69. navTo(`/login/register-step2?phone=${state.phone}`);
  70. // #endif
  71. // #ifdef MP-ALIPAY
  72. navTo(`/login/register-step2-ali?phone=${state.phone}`);
  73. // #endif
  74. })
  75. .catch((err) => {
  76. console.log(err);
  77. });
  78. };
  79. const mobileIsRepeat = () => {
  80. if (!state.phone) {
  81. msg("请输入手机号!");
  82. return;
  83. }
  84. if (!checkStr(state.phone, "mobile")) {
  85. msg("请输入正确的手机号!");
  86. return;
  87. }
  88. if (!state.checked) {
  89. msg("请勾选我已阅读并同意《平台用户服务隐私协议》");
  90. return;
  91. }
  92. const options = {
  93. type: 2,
  94. data: { mobile: state.phone },
  95. method: "POST",
  96. showLoading: true,
  97. };
  98. request(mobileIsRepeatApi, options)
  99. .then((res) => {
  100. const result = stringToJson(res.bizContent);
  101. console.log("个人账号重复注册校验", result.canRegister)
  102. if (result.canRegister) {
  103. nextStep();
  104. } else {
  105. msg("该手机号已注册!");
  106. }
  107. })
  108. .catch((err) => {
  109. console.log(err);
  110. });
  111. };
  112. </script>
  113. <style lang="scss" scoped>
  114. .group {
  115. display: flex;
  116. align-items: center;
  117. }
  118. .register-main {
  119. border-top: 1rpx solid #dcdcdc;
  120. padding: 78rpx 30rpx 50rpx;
  121. .title {
  122. font-size: 32rpx;
  123. color: #333333;
  124. font-weight: 600;
  125. }
  126. .hint {
  127. font-size: 24rpx;
  128. color: #999999;
  129. margin-top: 20rpx;
  130. }
  131. .form-input {
  132. margin-top: 80rpx;
  133. display: flex;
  134. flex-direction: row;
  135. align-items: center;
  136. height: 90rpx;
  137. border-bottom: 1rpx solid #dcdcdc;
  138. padding: 0rpx 12rpx;
  139. font-size: 28rpx;
  140. color: #333333;
  141. &:last-child {
  142. margin-top: 50rpx;
  143. }
  144. .input {
  145. flex: 1;
  146. padding-right: 48rpx;
  147. background: transparent;
  148. }
  149. .arror {
  150. width: 28rpx;
  151. height: 25rpx;
  152. margin-left: 16rpx;
  153. margin-right: 40rpx;
  154. }
  155. .eye {
  156. width: 48rpx;
  157. height: 48rpx;
  158. }
  159. }
  160. .form-placeholder {
  161. color: #999999;
  162. }
  163. .agreement {
  164. font-size: 24rpx;
  165. display: flex;
  166. align-items: center;
  167. margin-top: 60rpx;
  168. .txt-grey {
  169. color: #666666;
  170. }
  171. .txt-green {
  172. color: #00b38b;
  173. }
  174. :deep(.u-checkbox) {
  175. margin-right: -20rpx;
  176. }
  177. }
  178. }
  179. .btn {
  180. margin: 200rpx 40rpx 0px;
  181. }
  182. </style>