account.vue 3.7 KB

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