爱简收旧衣按件回收前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

311 lines
7.1 KiB

1 year ago
  1. <template>
  2. <view class="login-container">
  3. <!-- Logo和标题区域 -->
  4. <image class="logo" src="/static/logo.png" mode="aspectFit"></image>
  5. <text class="app-title">瀚海回收</text>
  6. <!-- 登录表单 -->
  7. <view class="login-form">
  8. <text class="form-title">管理员登录</text>
  9. <!-- 账号输入框 -->
  10. <view class="input-group">
  11. <text class="label">账号</text>
  12. <input
  13. type="text"
  14. v-model="formData.username"
  15. placeholder="请输入"
  16. placeholder-class="placeholder"
  17. />
  18. </view>
  19. <!-- 密码输入框 -->
  20. <view class="input-group">
  21. <text class="label">密码</text>
  22. <view class="password-input">
  23. <input
  24. :type="showPassword ? 'text' : 'password'"
  25. v-model="formData.password"
  26. placeholder="请输入"
  27. placeholder-class="placeholder"
  28. />
  29. <view class="eye-icon" @tap="togglePasswordVisibility">
  30. <uni-icons :type="showPassword ? 'eye' : 'eye-slash'" size="20" color="#666"></uni-icons>
  31. </view>
  32. </view>
  33. </view>
  34. <!-- 登录按钮 -->
  35. <button
  36. class="login-btn"
  37. :class="{'login-btn-active': isFormValid}"
  38. @tap="handleLogin"
  39. >登录</button>
  40. <!-- 取消登录按钮 -->
  41. <button
  42. class="cancel-btn"
  43. @tap="handleCancel"
  44. >取消登录</button>
  45. <!-- 协议勾选 -->
  46. <view class="agreement">
  47. <view class="checkbox" @tap="toggleAgreement">
  48. <view v-if="formData.agreement" class="checkbox-checked">
  49. <text class="checkmark"></text>
  50. </view>
  51. <view v-else class="checkbox-empty"></view>
  52. </view>
  53. <text class="agreement-text">
  54. 我已阅读并同意
  55. <text class="link" @tap="openServiceAgreement">服务协议</text>
  56. <text class="link" @tap="openPrivacyPolicy">隐私政策</text>
  57. </text>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. export default {
  64. data() {
  65. return {
  66. formData: {
  67. username: '',
  68. password: '',
  69. agreement: false
  70. },
  71. showPassword: false
  72. }
  73. },
  74. computed: {
  75. isFormValid() {
  76. return this.formData.username &&
  77. this.formData.password &&
  78. this.formData.agreement
  79. }
  80. },
  81. methods: {
  82. togglePasswordVisibility() {
  83. this.showPassword = !this.showPassword
  84. },
  85. toggleAgreement() {
  86. this.formData.agreement = !this.formData.agreement
  87. },
  88. handleLogin() {
  89. if (!this.isFormValid) {
  90. uni.showToast({
  91. title: '请完善登录信息',
  92. icon: 'none'
  93. })
  94. return
  95. }
  96. // 这里添加登录逻辑
  97. console.log('登录信息:',JSON.parse(JSON.stringify(this.formData) ) )
  98. if( JSON.parse(JSON.stringify(this.formData)).username == 'admin' && JSON.parse(JSON.stringify(this.formData) ).password == '123' ){
  99. console.log(1)
  100. uni.setStorageSync('userInfo', { role: 'admin' })
  101. uni.reLaunch({
  102. url: '/pages/component/admin_home'
  103. })
  104. }
  105. },
  106. handleCancel() {
  107. uni.navigateBack()
  108. },
  109. openServiceAgreement() {
  110. // 打开服务协议页面
  111. uni.navigateTo({
  112. url: '/pages/agreement/service'
  113. })
  114. },
  115. openPrivacyPolicy() {
  116. // 打开隐私政策页面
  117. uni.navigateTo({
  118. url: '/pages/agreement/privacy'
  119. })
  120. }
  121. }
  122. }
  123. </script>
  124. <style lang="scss" scoped>
  125. .login-container {
  126. min-height: 100vh;
  127. background-color: #00C853;
  128. padding: 0 40rpx;
  129. box-sizing: border-box;
  130. display: flex;
  131. flex-direction: column;
  132. align-items: center;
  133. padding-top: 15vh;
  134. .logo {
  135. width: 160rpx;
  136. height: 160rpx;
  137. margin-bottom: 20rpx;
  138. }
  139. .app-title {
  140. font-size: 44rpx;
  141. color: #fff;
  142. font-weight: 600;
  143. margin-bottom: 60rpx;
  144. }
  145. .login-form {
  146. width: 100%;
  147. background: rgba(255, 255, 255, 0.95);
  148. border-radius: 20rpx;
  149. padding: 40rpx;
  150. box-sizing: border-box;
  151. .form-title {
  152. font-family: PingFang SC;
  153. font-weight: 500;
  154. font-size: 32rpx;
  155. line-height: 140%;
  156. letter-spacing: 0%;
  157. color: #333;
  158. font-weight: 500;
  159. margin-bottom: 40rpx;
  160. }
  161. .input-group {
  162. margin-bottom: 30rpx;
  163. position: relative;
  164. .label {
  165. font-family: PingFang SC;
  166. font-weight: 400;
  167. font-size: 13px;
  168. line-height: 140%;
  169. letter-spacing: 0%;
  170. color: #333;
  171. margin-bottom: 8rpx;
  172. display: block;
  173. }
  174. .password-input {
  175. position: relative;
  176. width: 100%;
  177. padding: 0;
  178. input {
  179. width: 100%;
  180. height: 90rpx;
  181. background: transparent;
  182. font-size: 28rpx;
  183. color: #333;
  184. border-bottom: 1px solid #E5E5E5;
  185. padding: 0;
  186. padding-right: 60rpx;
  187. box-sizing: border-box;
  188. }
  189. .eye-icon {
  190. position: absolute;
  191. right: -10rpx;
  192. top: 50%;
  193. transform: translateY(-50%);
  194. padding: 20rpx;
  195. display: flex;
  196. align-items: center;
  197. justify-content: center;
  198. }
  199. }
  200. input {
  201. width: 100%;
  202. height: 90rpx;
  203. background: transparent;
  204. font-size: 28rpx;
  205. color: #333;
  206. border-bottom: 1px solid #E5E5E5;
  207. padding: 0;
  208. box-sizing: border-box;
  209. }
  210. }
  211. .placeholder {
  212. color: #999;
  213. font-size: 28rpx;
  214. }
  215. .login-btn {
  216. width: 100%;
  217. height: 90rpx;
  218. background: #00C853;
  219. color: #fff;
  220. font-size: 32rpx;
  221. border-radius: 45rpx;
  222. margin: 40rpx 0 20rpx;
  223. display: flex;
  224. align-items: center;
  225. justify-content: center;
  226. border: none;
  227. }
  228. .cancel-btn {
  229. width: 100%;
  230. height: 90rpx;
  231. background: transparent;
  232. color: #00C853;
  233. font-size: 32rpx;
  234. border-radius: 45rpx;
  235. margin-bottom: 30rpx;
  236. display: flex;
  237. align-items: center;
  238. justify-content: center;
  239. border: 1px solid #00C853;
  240. }
  241. .agreement {
  242. display: flex;
  243. align-items: center;
  244. padding: 0;
  245. .checkbox {
  246. width: 32rpx;
  247. height: 32rpx;
  248. margin-right: 12rpx;
  249. .checkbox-empty {
  250. width: 30rpx;
  251. height: 30rpx;
  252. border: 1px solid #00C853;
  253. border-radius: 50%;
  254. }
  255. .checkbox-checked {
  256. width: 32rpx;
  257. height: 32rpx;
  258. background: #00C853;
  259. border-radius: 50%;
  260. display: flex;
  261. align-items: center;
  262. justify-content: center;
  263. border: 1px solid #00C853;
  264. .checkmark {
  265. color: #fff;
  266. font-size: 20rpx;
  267. line-height: 1;
  268. transform: translateY(-1rpx);
  269. }
  270. }
  271. }
  272. .agreement-text {
  273. font-size: 24rpx;
  274. color: #666;
  275. .link {
  276. color: #00C853;
  277. }
  278. }
  279. }
  280. }
  281. }
  282. </style>