account.vue 4.0 KB

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