@@ -1,6 +1,6 @@
|
|||||||
web:
|
web:
|
||||||
host: "127.0.0.1"
|
host: "127.0.0.1"
|
||||||
web_port: "8080"
|
port: "8080"
|
||||||
tls: false
|
tls: false
|
||||||
cert_private_path: ""
|
cert_private_path: ""
|
||||||
cert_public_path: ""
|
cert_public_path: ""
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ require (
|
|||||||
github.com/leodido/go-urn v1.4.0 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/ncruces/go-strftime v0.1.9 // indirect
|
github.com/ncruces/go-strftime v0.1.9 // indirect
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHP
|
|||||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
|
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||||
|
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
|||||||
+6
-5
@@ -92,18 +92,19 @@ func main() {
|
|||||||
|
|
||||||
routers.Def_router(r.Group("/")) //分组路由传递到def_routers。go
|
routers.Def_router(r.Group("/")) //分组路由传递到def_routers。go
|
||||||
|
|
||||||
var http_port = models.Wed_configs["host"].(string) + ":" + models.Wed_configs["web_port"].(string)
|
var http_port = models.Wed_configs.Host + ":" + models.Wed_configs.Port
|
||||||
if models.Wed_configs["tls"].(bool) {
|
var gin_port = "0.0.0.0" + ":" + models.Wed_configs.Port
|
||||||
if models.Wed_configs["cert_public_path"] == "" || models.Wed_configs["cert_private_path"] == "" {
|
if models.Wed_configs.Tls {
|
||||||
|
if models.Wed_configs.Cert_public_path == "" || models.Wed_configs.Cert_private_path == "" {
|
||||||
fmt.Printf("需要配置证书路径")
|
fmt.Printf("需要配置证书路径")
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("https://" + http_port)
|
fmt.Println("https://" + http_port)
|
||||||
r.RunTLS(http_port, models.Wed_configs["cert_public_path"].(string), models.Wed_configs["cert_private_path"].(string))
|
r.RunTLS(gin_port, models.Wed_configs.Cert_public_path, models.Wed_configs.Cert_private_path)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("http://" + http_port)
|
fmt.Println("http://" + http_port)
|
||||||
r.Run(http_port)
|
r.Run(gin_port)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/mitchellh/mapstructure"
|
||||||
|
|
||||||
var Configs map[string]interface{}
|
var Configs map[string]interface{}
|
||||||
|
|
||||||
var Wed_configs map[string]interface{}
|
var Wed_configs Wed_configs_t
|
||||||
|
|
||||||
var Database_configs map[string]interface{}
|
var Database_configs map[string]interface{}
|
||||||
|
|
||||||
@@ -25,7 +27,11 @@ func init() {
|
|||||||
|
|
||||||
func All_config_init() {
|
func All_config_init() {
|
||||||
//读取web配置
|
//读取web配置
|
||||||
Wed_configs = Configs["web"].(map[string]interface{})
|
|
||||||
|
err := mapstructure.Decode(Configs["web"].(map[string]interface{}), &Wed_configs)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
//初始化数据库
|
//初始化数据库
|
||||||
Database_init()
|
Database_init()
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
type Wed_configs_t struct {
|
||||||
|
Host string `mapstructure:"host"`
|
||||||
|
Port string `mapstructure:"port"`
|
||||||
|
Tls bool `mapstructure:"tls"`
|
||||||
|
Cert_private_path string `mapstructure:"cert_private_path"`
|
||||||
|
Cert_public_path string `mapstructure:"cert_public_path"`
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package routers
|
package routers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"saas/models"
|
"saas/models"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -64,18 +63,17 @@ func V1_user_api(r *gin.RouterGroup) {
|
|||||||
//返回前端的数据
|
//返回前端的数据
|
||||||
err_msg = "user_api_error"
|
err_msg = "user_api_error"
|
||||||
err_code = Error_code[err_msg]
|
err_code = Error_code[err_msg]
|
||||||
|
|
||||||
//转换传进来的数据
|
//转换传进来的数据
|
||||||
var jsonData map[string]interface{}
|
var jsonData Login_from
|
||||||
if err := ctx.ShouldBindJSON(&jsonData); err != nil {
|
if err := ctx.ShouldBindJSON(&jsonData); err == nil {
|
||||||
fmt.Println("解析JSON ERROR:", err)
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
//转换字段
|
//转换字段
|
||||||
newUser := models.User{
|
newUser := models.User{
|
||||||
Name: jsonData["username"].(string),
|
Name: jsonData.Username,
|
||||||
Pass: jsonData["userpass"].(string), // 实际应替换为哈希值
|
Pass: jsonData.Password, // 实际应替换为哈希值
|
||||||
// Date 字段无需赋值,数据库会自动填充默认值
|
// Date 字段无需赋值,数据库会自动填充默认值
|
||||||
}
|
}
|
||||||
|
|
||||||
//对用户的密码进行哈希替换
|
//对用户的密码进行哈希替换
|
||||||
newUser.Pass = models.Hash_user_pass(newUser.Pass)
|
newUser.Pass = models.Hash_user_pass(newUser.Pass)
|
||||||
|
|
||||||
@@ -91,7 +89,7 @@ func V1_user_api(r *gin.RouterGroup) {
|
|||||||
//发送cookie
|
//发送cookie
|
||||||
//cookie时间
|
//cookie时间
|
||||||
var cookie_time = 0
|
var cookie_time = 0
|
||||||
if jsonData["keep_login"].(bool) {
|
if jsonData.Is_keep_login {
|
||||||
cookie_time = models.User_configs["cookie_timeout"].(int)
|
cookie_time = models.User_configs["cookie_timeout"].(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +98,7 @@ func V1_user_api(r *gin.RouterGroup) {
|
|||||||
//fmt.Println(cookie)
|
//fmt.Println(cookie)
|
||||||
//将cookie写进数据库
|
//将cookie写进数据库
|
||||||
new_cookie := models.Cookie{}
|
new_cookie := models.Cookie{}
|
||||||
new_cookie.Domain = models.Wed_configs["host"].(string)
|
new_cookie.Domain = models.Wed_configs.Host
|
||||||
new_cookie.Name = "user"
|
new_cookie.Name = "user"
|
||||||
new_cookie.Value = cookie
|
new_cookie.Value = cookie
|
||||||
new_cookie.UserID = user.ID
|
new_cookie.UserID = user.ID
|
||||||
@@ -110,8 +108,8 @@ func V1_user_api(r *gin.RouterGroup) {
|
|||||||
new_cookie.UpdatedAt = new_cookie.CreatedAt
|
new_cookie.UpdatedAt = new_cookie.CreatedAt
|
||||||
//计算cookie失效时间
|
//计算cookie失效时间
|
||||||
new_cookie.ExpiresAt = time.Now().Add(time.Duration(models.User_configs["cookie_timeout"].(int)) * time.Second) //计算过期时间
|
new_cookie.ExpiresAt = time.Now().Add(time.Duration(models.User_configs["cookie_timeout"].(int)) * time.Second) //计算过期时间
|
||||||
new_cookie.SecureFlag = models.Wed_configs["tls"].(bool)
|
new_cookie.SecureFlag = models.Wed_configs.Tls
|
||||||
ctx.SetCookie("user", cookie, cookie_time, "/", models.Wed_configs["host"].(string), models.Wed_configs["tls"].(bool), true)
|
ctx.SetCookie("user", cookie, cookie_time, "/", models.Wed_configs.Host, models.Wed_configs.Tls, true)
|
||||||
|
|
||||||
models.DB.Create(&new_cookie) // 传入指针
|
models.DB.Create(&new_cookie) // 传入指针
|
||||||
|
|
||||||
@@ -127,6 +125,11 @@ func V1_user_api(r *gin.RouterGroup) {
|
|||||||
err_code = Error_code[err_msg]
|
err_code = Error_code[err_msg]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
err_msg = "json_error"
|
||||||
|
err_code = Error_code[err_msg]
|
||||||
|
}
|
||||||
|
|
||||||
ctx.JSON(200, map[string]interface{}{
|
ctx.JSON(200, map[string]interface{}{
|
||||||
"api": "ok",
|
"api": "ok",
|
||||||
"err_code": err_code,
|
"err_code": err_code,
|
||||||
@@ -151,7 +154,7 @@ func V1_user_api(r *gin.RouterGroup) {
|
|||||||
cookie.Value = cookie_vel
|
cookie.Value = cookie_vel
|
||||||
models.DB.Where(&cookie).Delete(&cookie)
|
models.DB.Where(&cookie).Delete(&cookie)
|
||||||
//删除前端cookie
|
//删除前端cookie
|
||||||
ctx.SetCookie("user", "", -1, "/", models.Wed_configs["host"].(string), models.Wed_configs["tls"].(bool), true)
|
ctx.SetCookie("user", "", -1, "/", models.Wed_configs.Host, models.Wed_configs.Tls, true)
|
||||||
|
|
||||||
err_msg = "api_ok"
|
err_msg = "api_ok"
|
||||||
err_code = Error_code[err_msg]
|
err_code = Error_code[err_msg]
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package routers
|
||||||
|
|
||||||
|
type Login_from struct {
|
||||||
|
Is_keep_login bool `json:"is_keep_login"`
|
||||||
|
Username string `json:"username"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
}
|
||||||
@@ -68,7 +68,7 @@ func Def_router(r *gin.RouterGroup) {
|
|||||||
} else {
|
} else {
|
||||||
//找不到登录权限?? 可能被封号?
|
//找不到登录权限?? 可能被封号?
|
||||||
//删除前端cookie
|
//删除前端cookie
|
||||||
ctx.SetCookie("user", "", -1, "/", models.Wed_configs["host"].(string), models.Wed_configs["tls"].(bool), true)
|
ctx.SetCookie("user", "", -1, "/", models.Wed_configs.Host, models.Wed_configs.Tls, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -77,12 +77,12 @@ func Def_router(r *gin.RouterGroup) {
|
|||||||
//删除数据库的cookie
|
//删除数据库的cookie
|
||||||
models.DB.Delete(&cookie)
|
models.DB.Delete(&cookie)
|
||||||
//删除前端cookie
|
//删除前端cookie
|
||||||
ctx.SetCookie("user", "", -1, "/", models.Wed_configs["host"].(string), models.Wed_configs["tls"].(bool), true)
|
ctx.SetCookie("user", "", -1, "/", models.Wed_configs.Host, models.Wed_configs.Tls, true)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//找不到cookie,未登录
|
//找不到cookie,未登录
|
||||||
//删除前端cookie
|
//删除前端cookie
|
||||||
ctx.SetCookie("user", "", -1, "/", models.Wed_configs["host"].(string), models.Wed_configs["tls"].(bool), true)
|
ctx.SetCookie("user", "", -1, "/", models.Wed_configs.Host, models.Wed_configs.Tls, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,8 +161,8 @@
|
|||||||
const url = '/api/v1/user/login';
|
const url = '/api/v1/user/login';
|
||||||
const sumt_data = {
|
const sumt_data = {
|
||||||
username: username_dom.value,
|
username: username_dom.value,
|
||||||
userpass: password_dom.value,
|
password: password_dom.value,
|
||||||
keep_login: keep_login_dom.checked
|
is_keep_login: keep_login_dom.checked
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<template>
|
||||||
|
<footer class="footer footer-transparent d-print-none my_footer">
|
||||||
|
<div class="container-xl">
|
||||||
|
<div class="row text-center align-items-center flex-row-reverse">
|
||||||
|
<div class="col-lg-auto ms-lg-auto">
|
||||||
|
<ul class="list-inline list-inline-dots mb-0">
|
||||||
|
<li class="list-inline-item"><a href="https://git.lmve.net/kevin/gin_saas/-/blob/main/readme.md?ref_type=heads" target="_blank"
|
||||||
|
class="link-secondary" rel="noopener">文档</a></li>
|
||||||
|
<li class="list-inline-item"><a href="https://git.lmve.net/kevin/gin_saas/-/blob/main/LICENSE?ref_type=heads" target="_blank" class="link-secondary">开源协议</a>
|
||||||
|
</li>
|
||||||
|
<li class="list-inline-item"><a href="https://git.lmve.net/kevin/gin_saas" target="_blank"
|
||||||
|
class="link-secondary" rel="noopener">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" class="icon text-orange" width="24" height="24"
|
||||||
|
viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
||||||
|
stroke-linejoin="round">
|
||||||
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
|
<path d="M21 14l-9 7l-9 -7l3 -11l3 7h6l3 -7z" />
|
||||||
|
</svg>
|
||||||
|
源码</a></li>
|
||||||
|
<li class="list-inline-item">
|
||||||
|
<a href="https://wnfed.com" target="_blank" class="link-secondary" rel="noopener">
|
||||||
|
<!-- Download SVG icon from http://tabler-icons.io/i/heart -->
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" class="icon text-pink icon-filled icon-inline" width="24"
|
||||||
|
height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
|
||||||
|
stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
|
<path d="M19.5 12.572l-7.5 7.428l-7.5 -7.428a5 5 0 1 1 7.5 -6.566a5 5 0 1 1 7.5 6.572" />
|
||||||
|
</svg>
|
||||||
|
博客
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-lg-auto mt-3 mt-lg-0">
|
||||||
|
<ul class="list-inline list-inline-dots mb-0">
|
||||||
|
<li class="list-inline-item">
|
||||||
|
Copyright © 2025
|
||||||
|
<a href="https://lmve.net" target="_blank" class="link-secondary">Lmve.NET</a>.
|
||||||
|
All rights reserved.
|
||||||
|
</li>
|
||||||
|
<li class="list-inline-item">
|
||||||
|
<a href="https://git.lmve.net/kevin/gin_saas/-/commits/main" target="_blank" class="link-secondary" rel="noopener">
|
||||||
|
v0.0.1
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name:"tabler-footer",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
export const my_network_func = {
|
||||||
|
host: "",
|
||||||
|
port: 0,
|
||||||
|
head_path: "/api/v1",
|
||||||
|
|
||||||
|
post_json(path, json,callback) {
|
||||||
|
var re_data = {}
|
||||||
|
uni.request({
|
||||||
|
header: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
url: this.head_path + path,
|
||||||
|
method: 'POST',
|
||||||
|
data: json,
|
||||||
|
timeout: 10000,
|
||||||
|
success(res) {
|
||||||
|
|
||||||
|
re_data["statusCode"] = res.statusCode
|
||||||
|
re_data["data"] = res.data
|
||||||
|
callback(re_data)
|
||||||
|
|
||||||
|
},
|
||||||
|
fail() {
|
||||||
|
re_data["statusCode"] = -1
|
||||||
|
callback(re_data)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
+21
-4
@@ -1,9 +1,26 @@
|
|||||||
.my-input-field {
|
.my_input_field {
|
||||||
height: 80rpx;
|
height: 70rpx;
|
||||||
padding: 16rpx 1rpx;
|
padding: 16rpx 16rpx;
|
||||||
border-radius: 18rpx;
|
border-radius: 18rpx;
|
||||||
border: 2rpx solid rgba(58, 77, 128, 0.08);
|
border: 2rpx solid #e3e3e3;
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
box-shadow: 0 4rpx 12rpx rgba(58, 77, 128, 0.08);
|
box-shadow: 0 4rpx 12rpx rgba(58, 77, 128, 0.08);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.my_input_placeholder {
|
||||||
|
|
||||||
|
font-size: 30rpx;
|
||||||
|
color: #cfcfcf;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.my_input_placeholder_error {
|
||||||
|
font-size: 30rpx;
|
||||||
|
color: #d48686;
|
||||||
|
}
|
||||||
|
|
||||||
|
.my_footer{
|
||||||
|
margin-top: auto;
|
||||||
|
}
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="d-flex flex-column">
|
<view class="d-flex flex-column ">
|
||||||
<tabler-header ></tabler-header>
|
<div class="page">
|
||||||
<view class="content">
|
<tabler-header></tabler-header>
|
||||||
<image class="logo" src="/static/logo.png"></image>
|
|
||||||
<view class="text-area">
|
<tabler-footer></tabler-footer>
|
||||||
<text class="title">{{title}}</text>
|
</div>
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
+82
-16
@@ -10,8 +10,8 @@
|
|||||||
<div class="col-lg">
|
<div class="col-lg">
|
||||||
<div class="container-tight">
|
<div class="container-tight">
|
||||||
<div class="text-center mb-4">
|
<div class="text-center mb-4">
|
||||||
<div class="navbar-brand navbar-brand-autodark"><img src="/static/logo.svg"
|
<div class="navbar-brand navbar-brand-autodark"><img src="/static/logo.svg" height="36"
|
||||||
height="36" alt=""></div>
|
alt=""></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card card-md">
|
<div class="card card-md">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@@ -19,25 +19,32 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">用户名</label>
|
<label class="form-label mb-0 ms-1">用户名</label>
|
||||||
<input type="text" class="my-input-field" placeholder="输入你的用户名" autocomplete="off" maxlength="25">
|
|
||||||
|
<input type="text" class="my_input_field"
|
||||||
|
:placeholder-class="is_username_err?'my_input_placeholder_error':'my_input_placeholder'"
|
||||||
|
:placeholder="ph_username" autocomplete="off" maxlength="25"
|
||||||
|
v-model="post_data.username">
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<label class="form-label">
|
<label class="form-label mb-0 ms-1">密码</label>
|
||||||
密码
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<input type="password" class="my-input-field" password="true" placeholder="输入你的密码" autocomplete="off" maxlength="100">
|
<input type="password" class="my_input_field"
|
||||||
|
:placeholder-class="is_password_err?'my_input_placeholder_error':'my_input_placeholder'"
|
||||||
|
password="true" :placeholder="ph_password" autocomplete="off"
|
||||||
|
maxlength="100" v-model="post_data.password">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
|
<checkbox-group @change="chack_box_change">
|
||||||
<label class="d-flex">
|
<label class="d-flex">
|
||||||
<checkbox />
|
<checkbox value="keep_login_in" />
|
||||||
<span class="form-check-label">保持登录</span>
|
<span class="form-check-label">保持登录</span>
|
||||||
</label>
|
</label>
|
||||||
|
</checkbox-group>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-footer">
|
<div class="form-footer">
|
||||||
<button class="btn btn-primary w-100">登录</button>
|
<button class="btn btn-primary w-100" @click="submit_data">登录</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -51,6 +58,7 @@
|
|||||||
<a href="./forgot-password.html">忘记密码?</a>
|
<a href="./forgot-password.html">忘记密码?</a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg d-none d-lg-block">
|
<div class="col-lg d-none d-lg-block">
|
||||||
@@ -61,30 +69,89 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<tabler-footer></tabler-footer>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {
|
||||||
|
my_network_func
|
||||||
|
} from '../my_network_func'
|
||||||
|
import {
|
||||||
|
Offcanvas
|
||||||
|
} from 'bootstrap'
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
ph_username: "输入你的用户名",
|
||||||
|
ph_password: "输入你的密码",
|
||||||
|
is_username_err: false,
|
||||||
|
is_password_err: false,
|
||||||
|
post_data: {
|
||||||
|
is_keep_login: false,
|
||||||
|
username: "",
|
||||||
|
password: "",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
|
chack_box_change(val) {
|
||||||
|
//console.log(val.detail.value[0])
|
||||||
|
if (val.detail.value[0] === 'keep_login_in') {
|
||||||
|
this.post_data.is_keep_login = true
|
||||||
|
} else {
|
||||||
|
this.post_data.is_keep_login = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
submit_data() {
|
||||||
|
//提交登录数据,
|
||||||
|
//先验证数据合法性
|
||||||
|
if (this.post_data.username == "") {
|
||||||
|
this.is_username_err = true
|
||||||
|
this.ph_username = "用户名不能为空"
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.is_username_err = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.post_data.password == "") {
|
||||||
|
this.is_password_err = true
|
||||||
|
this.ph_password = "密码不能为空"
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.is_password_err = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.is_username_err === false && this.is_password_err === false) {
|
||||||
|
console.log(this.post_data)
|
||||||
|
my_network_func.post_json("/user/login", this.post_data, (c) => {
|
||||||
|
console.log(c)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.my123{
|
.my123 {
|
||||||
/* 设置边框:宽度、样式、颜色 */
|
/* 设置边框:宽度、样式、颜色 */
|
||||||
border: 1px solid #e3e3e3; /* 2像素宽的红色实线边框 */
|
border: 1px solid #e3e3e3;
|
||||||
|
/* 2像素宽的红色实线边框 */
|
||||||
|
|
||||||
/* 设置圆角,值越大,角越圆 */
|
/* 设置圆角,值越大,角越圆 */
|
||||||
border-radius: 3px; /* 也可以使用百分比,例如50%会变成圆形 */
|
border-radius: 3px;
|
||||||
|
/* 也可以使用百分比,例如50%会变成圆形 */
|
||||||
|
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
|
|
||||||
@@ -94,5 +161,4 @@
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
Reference in New Issue
Block a user