選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

login.vue 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <!-- 密码登录 -->
  2. <template>
  3. <view class="login-main as-gravity-center as-layout-vertical">
  4. <image :src="`${$imgUrl}login/logo.png`" class="logo"></image>
  5. <view class="form">
  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.username" focus placeholder="请输入手机号"
  10. placeholder-class="form-placeholder" type="number" maxlength="11" />
  11. </view>
  12. <view class="form-input" v-if="state.loginType === 'pwd'">
  13. <input class="input" v-model="state.password" type="text" placeholder="请输入密码"
  14. placeholder-class="form-placeholder" :password="state.isPwdType ? true : false" />
  15. <image :src="`${$imgUrl}login/${
  16. state.isPwdType ? 'icon_eye_close' : 'icon_eye_open'
  17. }.png`" class="eye" @click="state.isPwdType = !state.isPwdType"></image>
  18. </view>
  19. <view class="form-input" v-if="state.loginType === 'code'">
  20. <input class="input" v-model="state.code" placeholder="请输入验证码" placeholder-class="form-placeholder"
  21. maxlength="6" type="number" />
  22. <verification-code :bg="false" :mobile="state.username"></verification-code>
  23. </view>
  24. </view>
  25. <view class="btn">
  26. <submit-button title="登录" @submit="doLogin"></submit-button>
  27. </view>
  28. </view>
  29. </template>
  30. <script setup lang="ts">
  31. import {
  32. reactive
  33. } from "vue";
  34. import {
  35. checkStr,
  36. msg,
  37. navTo
  38. } from "@/utils/utils";
  39. import {
  40. onLoad,
  41. onUnload
  42. } from "@dcloudio/uni-app";
  43. import {
  44. login
  45. } from "@/utils/network/api.js";
  46. import {
  47. request
  48. } from "@/utils/network/request.js";
  49. import {
  50. stringToJson
  51. } from "@/utils/network/encryption";
  52. const tools = require("../static/etcUtil/tools.js");
  53. import {
  54. setItem
  55. } from "@/utils/storage";
  56. const state = reactive({
  57. checked: false, //是否勾选协议
  58. isPwdType: true, //是不是密码类型
  59. loginType: "pwd", //pwd-密码登录 code-验证码登录
  60. username: "", //用户名
  61. password: "", //密码
  62. code: "", //验证码
  63. });
  64. onLoad(() => {
  65. });
  66. onUnload(() => {
  67. });
  68. /* 登录 */
  69. const doLogin = () => {
  70. if (!state.username) {
  71. msg("请输入手机号!");
  72. return;
  73. }
  74. if (state.loginType === "pwd" && !state.password) {
  75. msg("请输入密码!");
  76. return;
  77. }
  78. if (!checkStr(state.username, "mobile")) {
  79. msg("请输入正确的手机号!");
  80. return;
  81. }
  82. let reg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,}$/;
  83. if (!reg.test(state.password)) {
  84. msg("密码长度至少为8位,由数字和字母组成");
  85. return;
  86. }
  87. console.log(state);
  88. const options = {
  89. type: 2,
  90. data: {
  91. mobile: state.username,
  92. password: tools.md5Str(state.password),
  93. },
  94. method: "POST",
  95. showLoading: true,
  96. };
  97. request(login, options).then((res) => {
  98. console.log(res);
  99. let result = stringToJson(res.bizcontnent)
  100. })
  101. };
  102. </script>
  103. <style lang="scss" scoped>
  104. .login-main {
  105. border-top: 1rpx solid #dcdcdc;
  106. padding: 22rpx 30rpx 140rpx;
  107. .logo {
  108. width: 260rpx;
  109. height: 160rpx;
  110. }
  111. .title {
  112. font-size: 46rpx;
  113. color: #333333;
  114. margin-top: 30rpx;
  115. font-weight: 600;
  116. }
  117. .form {
  118. width: 100%;
  119. margin-top: 100rpx;
  120. .form-input {
  121. display: flex;
  122. flex-direction: row;
  123. align-items: center;
  124. height: 90rpx;
  125. border-bottom: 1rpx solid #dcdcdc;
  126. padding: 0rpx 12rpx;
  127. color: #333333;
  128. &:last-child {
  129. margin-top: 50rpx;
  130. }
  131. .input {
  132. flex: 1;
  133. padding-right: 48rpx;
  134. font-size: 28rpx;
  135. font-family: Microsoft YaHei;
  136. }
  137. .arror {
  138. width: 28rpx;
  139. height: 25rpx;
  140. margin-left: 16rpx;
  141. margin-right: 40rpx;
  142. }
  143. .eye {
  144. width: 48rpx;
  145. height: 48rpx;
  146. }
  147. }
  148. .form-placeholder {
  149. color: #999999;
  150. }
  151. }
  152. .btn {
  153. width: 100%;
  154. margin: 120rpx 40rpx 50rpx;
  155. }
  156. .agreement {
  157. font-size: 24rpx;
  158. display: flex;
  159. align-items: center;
  160. .txt-grey {
  161. color: #666666;
  162. }
  163. .txt-green {
  164. color: #00b38b;
  165. }
  166. :deep(.u-checkbox) {
  167. margin-right: -20rpx;
  168. }
  169. }
  170. .btns {
  171. width: 100%;
  172. margin-top: 125rpx;
  173. justify-content: space-around;
  174. padding: 0px 8rpx;
  175. .bg {
  176. width: 80rpx;
  177. height: 80rpx;
  178. border-radius: 50%;
  179. .img {
  180. width: 48rpx;
  181. height: 48rpx;
  182. }
  183. }
  184. .blue {
  185. background-color: #1d9cff;
  186. }
  187. .orange {
  188. background-color: #feb654;
  189. }
  190. .purple {
  191. background-color: #8060ff;
  192. }
  193. .label {
  194. font-size: 26rpx;
  195. color: #333333;
  196. margin-top: 30rpx;
  197. }
  198. }
  199. }
  200. </style>