├── php-api/ # 改造后的PHP接口层 ├── java-ad-service/ # 若依框架微服务(广告+VIP+分账) ├── uniapp-reader/ # UniApp前端项目 │ ├── pages/ # 各端页面 │ └──
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.

login.vue 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. async handleLogin() {
  106. if (this.loginForm.username === "") {
  107. this.$modal.msgError("请输入账号")
  108. } else if (this.loginForm.password === "") {
  109. this.$modal.msgError("请输入密码")
  110. } else if (this.loginForm.code === "" && this.captchaEnabled) {
  111. this.$modal.msgError("请输入验证码")
  112. } else {
  113. this.$modal.loading("登录中,请耐心等待...")
  114. this.pwdLogin()
  115. }
  116. },
  117. // 密码登录
  118. async pwdLogin() {
  119. this.$store.dispatch('Login', this.loginForm).then(() => {
  120. this.$modal.closeLoading()
  121. this.loginSuccess()
  122. }).catch(() => {
  123. if (this.captchaEnabled) {
  124. this.getCode()
  125. }
  126. })
  127. },
  128. // 登录成功后,处理函数
  129. loginSuccess(result) {
  130. // 设置用户信息
  131. this.$store.dispatch('GetInfo').then(res => {
  132. this.$tab.reLaunch('/pages/index')
  133. })
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. page {
  140. background-color: #ffffff;
  141. }
  142. .reading-tips {
  143. margin-top: 40rpx;
  144. padding: 20rpx;
  145. background-color: #f9f9f9;
  146. border-radius: 10rpx;
  147. }
  148. .tip-text {
  149. font-size: 32rpx;
  150. font-weight: bold;
  151. display: block;
  152. margin-bottom: 20rpx;
  153. }
  154. .benefits text {
  155. display: block;
  156. font-size: 28rpx;
  157. margin: 10rpx 0;
  158. color: #2c3e50;
  159. }
  160. .normal-login-container {
  161. width: 100%;
  162. .logo-content {
  163. width: 100%;
  164. font-size: 21px;
  165. text-align: center;
  166. padding-top: 15%;
  167. image {
  168. border-radius: 4px;
  169. }
  170. .title {
  171. margin-left: 10px;
  172. }
  173. }
  174. .login-form-content {
  175. text-align: center;
  176. margin: 20px auto;
  177. margin-top: 15%;
  178. width: 80%;
  179. .input-item {
  180. margin: 20px auto;
  181. background-color: #f5f6f7;
  182. height: 45px;
  183. border-radius: 20px;
  184. .icon {
  185. font-size: 38rpx;
  186. margin-left: 10px;
  187. color: #999;
  188. }
  189. .input {
  190. width: 100%;
  191. font-size: 14px;
  192. line-height: 20px;
  193. text-align: left;
  194. padding-left: 15px;
  195. }
  196. }
  197. .login-btn {
  198. margin-top: 40px;
  199. height: 45px;
  200. }
  201. .reg {
  202. margin-top: 15px;
  203. }
  204. .xieyi {
  205. color: #333;
  206. margin-top: 20px;
  207. }
  208. .login-code {
  209. height: 38px;
  210. float: right;
  211. .login-code-img {
  212. height: 38px;
  213. position: absolute;
  214. margin-left: 10px;
  215. width: 200rpx;
  216. }
  217. }
  218. }
  219. }
  220. </style>