register.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view id="register-container">
  3. <view class="top-area" v-if="proxy.$common.isVisible()">
  4. <u-icon name="arrow-left" size="17px" color="#000" :bold="true" @click="navigateTo"></u-icon>
  5. </view>
  6. <view class="content-area" v-if="proxy.$common.isVisible()">
  7. <text class="content-area-title">注册</text>
  8. </view>
  9. <view class="bottom-area">
  10. <u-input v-model="phone" prefixIcon="phone" placeholder="手机号(必填)" border="none" />
  11. <u-input v-model="verify" prefixIcon="email" placeholder="验证码(必填)" border="none" :maxlength="6">
  12. <template #suffix>
  13. <button class="verify" @click="getVerifyCode">{{ !useStore.codeTime ? "获取验证码" : useStore.codeTime + "s" }}</button>
  14. </template>
  15. </u-input>
  16. <u-input v-model="nickName" prefixIcon="account" placeholder="昵称(必填)" border="none" />
  17. <u-input v-model="newPassword" prefixIcon="lock" placeholder="密码(必填)" border="none" :password="newPasswordBool">
  18. <template #suffix>
  19. <text :class="!newPasswordBool ? 'iconfont oaIcon-eye' : 'iconfont oaIcon-eye-close'" @click="newPasswordBool = !newPasswordBool"></text>
  20. </template>
  21. </u-input>
  22. <u-input v-model="confirmPassword" prefixIcon="lock" placeholder="再次输入密码(必填)" border="none" :password="confirmPasswordBool">
  23. <template #suffix>
  24. <text :class="!confirmPasswordBool ? 'iconfont oaIcon-eye' : 'iconfont oaIcon-eye-close'" @click="confirmPasswordBool = !confirmPasswordBool"></text>
  25. </template>
  26. </u-input>
  27. <u-button
  28. type="primary"
  29. shape="circle"
  30. :customStyle="{
  31. display: 'block',
  32. width: '100%',
  33. height: '45px',
  34. lineHeight: '45px',
  35. fontSize: '17px',
  36. }"
  37. @click="handleSubmit()"
  38. >
  39. 注 册
  40. </u-button>
  41. </view>
  42. </view>
  43. </template>
  44. <script setup>
  45. import config from "@/config";
  46. import { onLoad, onShow, onHide, onLaunch } from "@dcloudio/uni-app";
  47. import { ref, onMounted, inject, shallowRef, reactive, toRefs, getCurrentInstance } from "vue";
  48. import { useStores, commonStores } from "@/store/modules/index";
  49. import { getToken, setToken, removeToken } from "@/utils/auth";
  50. const useStore = useStores();
  51. const { proxy } = getCurrentInstance();
  52. const dataList = reactive({
  53. nickName: undefined,
  54. phone: undefined,
  55. verify: undefined,
  56. newPassword: undefined,
  57. newPasswordBool: true,
  58. confirmPassword: undefined,
  59. confirmPasswordBool: true,
  60. });
  61. const { nickName, phone, verify, newPassword, newPasswordBool, confirmPassword, confirmPasswordBool } = toRefs(dataList);
  62. /**
  63. * @点击发送验证码
  64. */
  65. function getVerifyCode() {
  66. verify.value = undefined;
  67. useStore.GetCodeImg({
  68. phone: phone.value,
  69. success: (res) => {
  70. proxy.$modal.msgSuccess("发送成功");
  71. },
  72. });
  73. }
  74. /**
  75. * @注册
  76. * @按钮点击事件
  77. */
  78. function handleSubmit() {
  79. useStore.PhoneVerify({
  80. data: {
  81. phone: phone.value,
  82. verify: verify.value,
  83. },
  84. success: (res) => {
  85. useStore.UserAdd({
  86. data: {
  87. nickName: nickName.value,
  88. phone: phone.value,
  89. verify: verify.value,
  90. newPassword: newPassword.value,
  91. confirmPassword: confirmPassword.value,
  92. },
  93. success: (res) => {
  94. proxy.$modal.msgSuccess("注册成功");
  95. setTimeout(() => {
  96. proxy.$modal.loading("登录中,请耐心等待...");
  97. useStore
  98. .Login({
  99. username: phone.value,
  100. password: newPassword.value,
  101. tenantId: useStore.tenantId,
  102. })
  103. .then(() => {
  104. /** 获取用户信息 */
  105. proxy.$modal.closeLoading();
  106. useStore.GetInfo().then((res) => {
  107. proxy.$tab.reLaunch("/pages/index");
  108. });
  109. });
  110. }, 1000);
  111. },
  112. });
  113. },
  114. error: (res) => {
  115. return false;
  116. },
  117. });
  118. }
  119. /**
  120. * @跳转登录
  121. */
  122. function navigateTo() {
  123. proxy.$tab.navigateBack(1);
  124. }
  125. onLoad((options) => {});
  126. </script>
  127. <style lang="scss" scoped>
  128. #register-container {
  129. position: fixed;
  130. top: 0;
  131. left: 0;
  132. right: 0;
  133. bottom: 0;
  134. z-index: 1;
  135. width: 100%;
  136. margin: auto;
  137. padding: 0 30px;
  138. padding-top: 20%;
  139. //#ifdef MP-WEIXIN
  140. padding-top: 30%;
  141. //#endif
  142. background-color: #ffffff;
  143. .top-area {
  144. }
  145. .content-area {
  146. display: flex;
  147. margin: 30px 0;
  148. &-title {
  149. margin: auto auto auto 0;
  150. color: #000;
  151. font-size: 18px;
  152. }
  153. }
  154. .bottom-area {
  155. :deep(.u-input) {
  156. height: 45px;
  157. border-radius: 8px;
  158. padding: 5px 12px !important;
  159. border: 0 !important;
  160. background-color: #f5f6fa !important;
  161. margin-bottom: 15px;
  162. }
  163. :deep(.u-icon__icon) {
  164. font-size: 24px !important;
  165. line-height: 24px !important;
  166. color: gray !important;
  167. }
  168. :deep(.iconfont) {
  169. color: gray !important;
  170. }
  171. :deep(.input-placeholder) {
  172. color: #c0c4cc !important;
  173. }
  174. :deep(.uni-input-wrapper) {
  175. font-size: 16px;
  176. }
  177. :deep(.u-line) {
  178. display: none !important;
  179. }
  180. }
  181. }
  182. </style>