account.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view class="container">
  3. <view class="input-box">
  4. <view class="icon" />
  5. <input class="input" type="text" :value="account.account" placeholder="请输入账号" data-name='account'
  6. @input="onInput">
  7. </view>
  8. <view class="input-box" style="margin-top:15px;">
  9. <view class="icon" />
  10. <input class="input" type="password" :value="account.password" placeholder="请输入密码" data-name='password'
  11. @input="onInput">
  12. </view>
  13. <view class="assist">
  14. <label @click="memory = memory == '1' ? '0' : '1'">
  15. <checkbox :checked="memory == 1" :class="memory == 1 ? 'checked blue' : 'blue'" />记住密码
  16. </label>
  17. <navigator url="#">忘记密码?</navigator>
  18. </view>
  19. <u-button :customStyle="butSty" :disabled="account.account == '' || account.password == ''" :loading="loading"
  20. loadingText='登陆中...' @click="startLogging">
  21. <text style="font-size: 4.267vw;">
  22. 确 定
  23. </text>
  24. </u-button>
  25. </view>
  26. </template>
  27. <script>
  28. import { hexMD5 } from "./md5";
  29. import { loginMsg } from "./dispose";
  30. export default {
  31. name: "Account",
  32. data() {
  33. return {
  34. memory: 1,//是否记忆密码
  35. loading: false,
  36. account: {
  37. account: "",
  38. password: ""
  39. },
  40. butSty: {
  41. width: "73.333vw",
  42. height: "12.000vw",
  43. background: "#0A3971",
  44. borderRadius: "1.067vw",
  45. opacity: "0.65",
  46. borderWidth: 0,
  47. fontFamily: " PingFang SC - Regular, PingFang SC",
  48. color: " #FFFFFF",
  49. margin: "17.867vw auto 0"
  50. }
  51. };
  52. },
  53. mounted() {
  54. this.account = uni.getStorageSync("account") || {
  55. account: "",
  56. password: ""
  57. };
  58. this.memory = uni.getStorageSync("memory") || 0;
  59. },
  60. methods: {
  61. /* 输入框输入内容 */
  62. onInput(e) {
  63. this.account[e.target.dataset.name] = e.detail.value;
  64. },
  65. /* 开始登录 */
  66. startLogging() {
  67. if (this.loading) return;
  68. this.loading = true;
  69. this.$Http.login({
  70. "accountno": this.account.account,
  71. "password": hexMD5(this.account.password),
  72. "systemclient": "wechat"
  73. }).then(res => {
  74. console.log("账号密码登录", res)
  75. this.loading = false;
  76. if (res.code == 0) {
  77. uni.showToast({
  78. title: res.msg,
  79. duration: 2000,
  80. icon: "none"
  81. });
  82. } else {
  83. //存储是否记住密码 以及登录方式
  84. uni.setStorageSync("memory", this.memory + '');
  85. uni.setStorageSync("loginMethod", 'account')
  86. uni.setStorageSync("account", {
  87. account: this.account.account,
  88. password: this.memory == 1 ? this.account.password : ''
  89. });
  90. loginMsg(res.account_list, this.$Http)
  91. }
  92. })
  93. }
  94. }
  95. }
  96. </script>
  97. <style lang="scss">
  98. .input-box {
  99. display: flex;
  100. align-items: center;
  101. width: 275px;
  102. height: 45px;
  103. background: #FFFFFF;
  104. border-radius: 4px;
  105. opacity: 0.65;
  106. margin: 0 auto 0;
  107. .input {
  108. font-size: 14px;
  109. }
  110. }
  111. .icon {
  112. width: 16px;
  113. height: 16px;
  114. margin: 0 10px;
  115. }
  116. input {
  117. width: 80%;
  118. }
  119. /* 验证码 */
  120. .authcode {
  121. display: flex;
  122. justify-content: space-between;
  123. height: 45px;
  124. width: 275px;
  125. margin: 0 auto 0;
  126. }
  127. .authcode .input-box {
  128. width: 170px;
  129. }
  130. .authcode .cu-btn {
  131. width: 97px;
  132. height: 45px;
  133. background: #0A3971;
  134. border-radius: 4px;
  135. opacity: 0.65;
  136. margin-left: 8px;
  137. font-size: 24px;
  138. font-family: PingFang SC-Regular, PingFang SC;
  139. padding: 0;
  140. }
  141. .icon {
  142. background-color: $my-color-main;
  143. }
  144. /deep/uni-checkbox.blue.checked .uni-checkbox-input {
  145. background-color: #0A3971 !important;
  146. opacity: 0.65;
  147. }
  148. .assist {
  149. display: flex;
  150. justify-content: space-between;
  151. width: 274px;
  152. height: 17px;
  153. font-size: 12px;
  154. font-family: PingFang SC-Regular, PingFang SC;
  155. color: #FFFFFF;
  156. margin: 13px auto 0;
  157. label {
  158. display: flex;
  159. align-items: center;
  160. checkbox {
  161. transform: scale(0.6);
  162. background: #0A3971;
  163. color: #0A3971;
  164. border-radius: 4px;
  165. opacity: 0.65;
  166. border: 1px solid rgba(11, 63, 126, 0.1);
  167. }
  168. }
  169. navigator {
  170. padding-right: 5px;
  171. }
  172. }
  173. </style>