├── php-api/ # 改造后的PHP接口层 ├── java-ad-service/ # 若依框架微服务(广告+VIP+分账) ├── uniapp-reader/ # UniApp前端项目 │ ├── pages/ # 各端页面 │ └──
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

login.vue 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <view class="normal-login-container">
  3. <view class="logo-content align-center justify-center flex">
  4. <!-- <image :src="globalConfig.appInfo.logo" class="logo" /> -->
  5. <text class="title">哎呀免费小说登录</text>
  6. </view>
  7. <view class="login-form-content">
  8. <view class="input-item flex align-center">
  9. <view class="iconfont icon-user icon"></view>
  10. <input v-model="loginForm.username" class="input" type="text" placeholder="请输入账号" maxlength="30" />
  11. </view>
  12. <view class="input-item flex align-center">
  13. <view class="iconfont icon-password icon"></view>
  14. <input v-model="loginForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" />
  15. </view>
  16. <view class="input-item flex align-center" style="width: 60%;margin: 0px;" v-if="captchaEnabled">
  17. <view class="iconfont icon-code icon"></view>
  18. <input v-model="loginForm.code" type="number" class="input" placeholder="请输入验证码" maxlength="4" />
  19. <view class="login-code">
  20. <image :src="codeUrl" @click="getCode" class="login-code-img"></image>
  21. </view>
  22. </view>
  23. <view class="action-btn">
  24. <button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button>
  25. </view>
  26. <view class="reg text-center" v-if="register">
  27. <text class="text-grey1">没有账号?</text>
  28. <text @click="handleUserRegister" class="text-blue">立即注册</text>
  29. </view>
  30. <view class="xieyi text-center">
  31. <text class="text-grey1">登录即代表同意</text>
  32. <text @click="handleUserAgrement" class="text-blue">《用户协议》</text>
  33. <text @click="handlePrivacy" class="text-blue">《隐私协议》</text>
  34. </view>
  35. </view>
  36. <view class="reading-tips">
  37. <text class="tip-text">登录后即可:</text>
  38. <view class="benefits">
  39. <text>✓ 继续阅读精彩章节</text>
  40. <text>✓ 加入书架保存进度</text>
  41. <text>✓ 获得每日阅读奖励</text>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. import { getCodeImg } from '@/api/login'
  48. import { getToken } from '@/utils/auth'
  49. export default {
  50. data() {
  51. return {
  52. codeUrl: "",
  53. captchaEnabled: true,
  54. // 用户注册开关
  55. register: false,
  56. globalConfig: getApp().globalData.config,
  57. loginForm: {
  58. username: "admin",
  59. password: "admin123",
  60. code: "",
  61. uuid: ""
  62. }
  63. }
  64. },
  65. created() {
  66. this.getCode()
  67. },
  68. onLoad() {
  69. // 如果全局配置已设置,则使用全局配置
  70. if (this.$config) {
  71. this.globalConfig = this.$config
  72. }
  73. //#ifdef H5
  74. if (getToken()) {
  75. this.$tab.reLaunch('/pages/index')
  76. }
  77. //#endif
  78. },
  79. methods: {
  80. // 用户注册
  81. handleUserRegister() {
  82. this.$tab.redirectTo(`/pages/register`)
  83. },
  84. // 隐私协议
  85. // handlePrivacy() {
  86. // let site = this.globalConfig.appInfo.agreements[0]
  87. // this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
  88. // },
  89. // 用户协议
  90. // handleUserAgrement() {
  91. // let site = this.globalConfig.appInfo.agreements[1]
  92. // this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
  93. // },
  94. // 获取图形验证码
  95. // getCode() {
  96. // getCodeImg().then(res => {
  97. // this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
  98. // if (this.captchaEnabled) {
  99. // this.codeUrl = 'data:image/gif;base64,' + res.img
  100. // this.loginForm.uuid = res.uuid
  101. // }
  102. // })
  103. // },
  104. // 获取验证码
  105. getCode() {
  106. this.$axios.get('/captchaImage').then(res => {
  107. this.codeUrl = 'data:image/png;base64,' + res.data.img;
  108. this.loginForm.uuid = res.data.uuid;
  109. }).catch(() => {
  110. this.$message.error("验证码获取失败");
  111. });
  112. },
  113. // 登录方法
  114. async handleLogin() {
  115. if (this.loginForm.username === "") {
  116. this.$modal.msgError("请输入账号")
  117. } else if (this.loginForm.password === "") {
  118. this.$modal.msgError("请输入密码")
  119. } else if (this.loginForm.code === "" && this.captchaEnabled) {
  120. this.$modal.msgError("请输入验证码")
  121. } else {
  122. this.$modal.loading("登录中,请耐心等待...")
  123. this.pwdLogin()
  124. }
  125. },
  126. // 密码登录
  127. async pwdLogin() {
  128. this.$store.dispatch('Login', this.loginForm).then(() => {
  129. this.$modal.closeLoading()
  130. this.loginSuccess()
  131. }).catch(() => {
  132. if (this.captchaEnabled) {
  133. this.getCode()
  134. }
  135. })
  136. },
  137. // 登录成功后,处理函数
  138. loginSuccess(result) {
  139. // 设置用户信息
  140. this.$store.dispatch('GetInfo').then(res => {
  141. this.$tab.reLaunch('/pages/index')
  142. })
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss" scoped>
  148. page {
  149. background-color: #ffffff;
  150. }
  151. .reading-tips {
  152. margin-top: 40rpx;
  153. padding: 20rpx;
  154. background-color: #f9f9f9;
  155. border-radius: 10rpx;
  156. }
  157. .tip-text {
  158. font-size: 32rpx;
  159. font-weight: bold;
  160. display: block;
  161. margin-bottom: 20rpx;
  162. }
  163. .benefits text {
  164. display: block;
  165. font-size: 28rpx;
  166. margin: 10rpx 0;
  167. color: #2c3e50;
  168. }
  169. .normal-login-container {
  170. width: 100%;
  171. .logo-content {
  172. width: 100%;
  173. font-size: 21px;
  174. text-align: center;
  175. padding-top: 15%;
  176. image {
  177. border-radius: 4px;
  178. }
  179. .title {
  180. margin-left: 10px;
  181. }
  182. }
  183. .login-form-content {
  184. text-align: center;
  185. margin: 20px auto;
  186. margin-top: 15%;
  187. width: 80%;
  188. .input-item {
  189. margin: 20px auto;
  190. background-color: #f5f6f7;
  191. height: 45px;
  192. border-radius: 20px;
  193. .icon {
  194. font-size: 38rpx;
  195. margin-left: 10px;
  196. color: #999;
  197. }
  198. .input {
  199. width: 100%;
  200. font-size: 14px;
  201. line-height: 20px;
  202. text-align: left;
  203. padding-left: 15px;
  204. }
  205. }
  206. .login-btn {
  207. margin-top: 40px;
  208. height: 45px;
  209. }
  210. .reg {
  211. margin-top: 15px;
  212. }
  213. .xieyi {
  214. color: #333;
  215. margin-top: 20px;
  216. }
  217. .login-code {
  218. height: 38px;
  219. float: right;
  220. .login-code-img {
  221. height: 38px;
  222. position: absolute;
  223. margin-left: 10px;
  224. width: 200rpx;
  225. }
  226. }
  227. }
  228. }
  229. </style>