Skip to content

Commit

Permalink
2组 user_id信息错误显示问题、用户持有卡片不显示问题(靠添加刷新按钮额外解决)、退出按钮、登录注册界面排版问题、修改密码部分的密码…
Browse files Browse the repository at this point in the history
…隐藏问题
  • Loading branch information
LeChatelier-Lenz committed Jun 14, 2024
1 parent 9bc426c commit 76a50ec
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 152 deletions.
1 change: 1 addition & 0 deletions backend/bank_site/bank_app/user_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
path('sign_in/', user_views.user_log_in),
path('change_password/', user_views.user_change_password),
path('list_cards/', user_views.list_cards),
path('bind_cards/', user_views.bind_cards),
path('card_lost/', user_views.card_lost),
path('user_info/', user_views.get_user_info),
path('money_transfer/', user_views.user_account_transfer),
Expand Down
36 changes: 19 additions & 17 deletions backend/bank_site/bank_app/user_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,25 @@ def list_cards(request):
return JsonResponse({"error": "Method not allowed"}, status=405)


# @csrf_exempt
# def bind_cards(request):
# if request.method == 'POST':
# data = json.loads(request.body.decode('utf-8'))
# print(f'获取到的post数据为:{data}')
# filter_accounts = account.objects.filter(identity_card=data.get('identity_card'), phone_num=data.get('phone_num'))
# filter_users = online_user.objects.filter(identity_card=data.get('identity_card'), phone_num=data.get('phone_num'))
# if filter_accounts.exists() and filter_users.exists():
# filter_accounts.update(user_id=filter_users[0].user_id)
# return_data = {"success": "The auto-binding is successful", 'state': True}
# return JsonResponse(return_data, status=200)
# else:
# return JsonResponse({"success": "No accounts now for this user", 'state': False}, status=200)
# elif request.method == 'OPTION':
# return JsonResponse({"success": "OPTION operation"}, status=200)
# else:
# return JsonResponse({"error": "Method not allowed", 'state': True}, status=405)
@csrf_exempt
def bind_cards(request):
if request.method == 'POST':
data = json.loads(request.body.decode('utf-8'))
print(f'获取到的post数据为:{data}')
filter_users = online_user.objects.filter(user_id=data.get('user_id'))
if not filter_users.exists():
return JsonResponse({"error": "User not found"}, status=404)
filter_accounts = account.objects.filter(identity_card=filter_users[0].identity_card, phone_num=filter_users[0].phone_num)
if filter_accounts.exists() and filter_users.exists():
filter_accounts.update(user_id=filter_users[0].user_id)
return_data = {"success": "The binding is successfully refreshed", 'state': True}
return JsonResponse(return_data, status=200)
else:
return JsonResponse({"success": "No accounts now for this user", 'state': False}, status=200)
elif request.method == 'OPTION':
return JsonResponse({"success": "OPTION operation"}, status=200)
else:
return JsonResponse({"error": "Method not allowed", 'state': True}, status=405)


@csrf_exempt
Expand Down
73 changes: 35 additions & 38 deletions frontend/src/login/components/signup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,39 @@
<div style="width:45%;margin:0 auto; padding-top:5vh;">
<div class="loginBox">
<!-- 卡片标题 -->
<div style="font-size: 25px; font-weight: bold;"></div>




<!-- 卡片内容 -->
<div style="margin-left: 10px; text-align: start; font-size: 16px;">
<div style="height: 70px">
<div style = "margin-left: 7vw; font-weight: bold; font-size: 1.5rem; margin-top: 5px;">
用户注册
</div>
</div>
<div style = "margin-left: 3vw; font-weight: bold; font-size: 1rem; margin-top: 5px;">
账户名:
<el-input v-model="account" style="width: 12.5vw; margin-left: 1rem" maxlength="18" clearable/>
<div style="margin-left: 10px; height: 180px ;text-align: start; font-size: 16px;">
<div style=" height: 40px;margin: auto;display: flex;align-items: center;justify-content: center">
<div style ="font-size: 1.5rem;font-weight: bolder; margin-top: 20px;text-align: center">
用 户 注 册
</div>
</div>
<div style="height: 25px"></div>
<div style = "margin-left: 4.3vw; font-weight: bold; font-size: 1rem; margin-top: 5px;">
密码:
<el-input v-model="password" style="width: 12.5vw; margin-left: 1rem" type="password" maxlength="20" clearable/>
</div>
<div style = "margin-left: 3vw; font-weight: bold; font-size: 1rem; margin-top: 5px;">
电话号:
<el-input v-model="phone" style="width: 12.5vw; margin-left: 1rem" maxlength="18" clearable/>
</div>
<div style="height: 25px"></div>
<div style = "margin-left: 4.3vw; font-weight: bold; font-size: 1rem; margin-top: 5px;">
身份证号:
<el-input v-model="IDCard" style="width: 12.5vw; margin-left: 1rem" type="password" maxlength="20" clearable/>
</div>
<div style="height: 40px"></div>
</div>
<!-- 卡片操作 -->
<div style="margin-top: 10px; display:flex; margin-left: 5rem;">
<el-button type="primary" @click="handle">
注册
</el-button>
<el-link :icon="Edit" href = "user" style="margin-left: 3rem;">
已有帐户,进行登录
</el-link>
<el-divider/>
<el-form label-position="right" label-width="100px" style=" font-weight: bolder; font-size: 10px">
<el-form-item label="用户名" style = "margin-top: 5px;">
<el-input v-model="account" style="width: 12.5vw; margin-left: 1rem" maxlength="18" clearable/>
</el-form-item>
<el-form-item label="密码" style = "margin-top: 5px;">
<el-input v-model="password" style="width: 12.5vw; margin-left: 1rem" type="password" maxlength="20" clearable/>
</el-form-item>
<el-form-item label="电话号码" style = "margin-top: 5px;">
<el-input v-model="phone" style="width: 12.5vw; margin-left: 1rem" maxlength="18" clearable/>
</el-form-item>
<el-form-item label="身份证号" style = "margin-top: 5px;">
<el-input v-model="IDCard" style="width: 12.5vw; margin-left: 1rem" type="password" maxlength="20" clearable/>
</el-form-item>

<!-- 卡片操作 -->
<div style="margin-top: 30px; display:flex;justify-content: center">
<el-button type="primary" @click="handle()">
注册
</el-button>
<el-button :icon="Edit" @click = "login">
返回
</el-button>
</div>
</el-form>
</div>
</div>
</div>
Expand All @@ -64,6 +58,9 @@
}
},
methods: {
login(){
window.location.href = "/login/user";
},
handle (){
axios.post('http:https://127.0.0.1:8000/user/sign_up/',{
user_name: this.account,
Expand All @@ -86,7 +83,7 @@

<style scoped>
.loginBox {
height: 300px;
height: 400px;
width: 400px;
margin-top: 40px;
margin-left: 27.5px;
Expand Down
47 changes: 26 additions & 21 deletions frontend/src/login/components/user.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,33 @@
<div style="width:45%;margin:0 auto; padding-top:5vh;">
<div class="loginBox">
<!-- 卡片标题 -->
<div style="font-size: 25px; font-weight: bold;"></div>



<!-- 卡片内容 -->
<div style="margin-left: 10px; text-align: start; font-size: 16px;">
<div style="height: 70px">
<div style = "margin-left: 7vw; font-weight: bold; font-size: 1.5rem; margin-top: 5px;">
用户登录
</div>
</div>
<div style = "margin-left: 3vw; font-weight: bold; font-size: 1rem; margin-top: 5px;">
账户名:
<el-input v-model="account" style="width: 12.5vw; margin-left: 1rem" maxlength="18" clearable/>
</div>
<div style="height: 25px"></div>
<div style = "margin-left: 4.3vw; font-weight: bold; font-size: 1rem; margin-top: 5px;">
密码:
<el-input v-model="password" style="width: 12.5vw; margin-left: 1rem" type="password" maxlength="20" clearable/>
<div style=" height: 40px;margin: auto;display: flex;align-items: center;justify-content: center">
<div style ="font-size: 1.5rem;font-weight: bolder; margin-top: 20px;text-align: center">
用 户 登 录
</div>
</div>
<div style="height: 40px"></div>
<el-divider/>
<el-form label-position="right" label-width="100px" style=" font-weight: bolder; font-size: 10px">
<el-form-item label="用户名" style = "margin-top: 5px;">
<el-input v-model="account" style="width: 12.5vw; margin-left: 1rem" maxlength="18" clearable/>
</el-form-item>
<el-form-item label="密码" style = "margin-top: 5px;">
<el-input v-model="password" style="width: 12.5vw; margin-left: 1rem" type="password" maxlength="20" clearable/>
</el-form-item>
</el-form>
</div>
<!-- 卡片操作 -->
<div style="margin-top: 10px; display:flex; margin-left: 5rem;">
<div style="margin-top: 30px; display:flex;justify-content: center">
<el-button type="primary" @click="handle()">
登录
</el-button>

<el-link :icon="Edit" href = "signup" style="margin-left: 3rem;">
没有账户,进行注册
</el-link>
<el-button :icon="Edit" @click = "signup">
注册新用户
</el-button>
</div>
</div>
</div>
Expand All @@ -46,7 +42,13 @@
<script>
import axios from "axios";
import { ElMessage } from 'element-plus'
import {Edit} from "@element-plus/icons-vue";
export default{
computed: {
Edit() {
return Edit
}
},
data(){
return{
account: "", // 用户登录,还不知道用什么
Expand All @@ -57,6 +59,9 @@ export default{
}
},
methods: {
signup(){
window.location.href = "/login/signup";
},
handle (){
// console.log( "文豪说看看这个6666")
axios.post('http:https://127.0.0.1:8000/user/sign_in/',{
Expand Down
29 changes: 25 additions & 4 deletions frontend/src/online_user/components/account.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@
<p style="font-weight: bold;font-size: larger;margin: 10px" >电话号码 : {{user_info.phone_num}}</p>
</div>

<div style="margin-top: 40px; margin-left: 40px; font-size: 1.5em; font-weight: bold;">
账户列表/卡包
<div style="display: flex;flex-direction: row">
<div style="margin-top: 40px; margin-left: 40px; font-size: 1.5em; font-weight: bold;">
账户列表/卡包
</div>
<el-button @click="RefreshCards" style="margin-top: 40px; margin-left: 15px;border-radius: 50%;width: 40px;height: 40px">
<el-icon>
<RefreshLeft />
</el-icon>
</el-button>
</div>
<div style="display: flex;flex-wrap: wrap; justify-content: start;">
<!-- 借书证卡片 -->
Expand Down Expand Up @@ -111,7 +118,7 @@

<script>
import axios from 'axios';
import {Delete, DocumentChecked, DocumentDelete, Edit, Plus, Search} from '@element-plus/icons-vue'
import {Delete, DocumentChecked, DocumentDelete, Edit, Plus, RefreshLeft, Search} from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import { ref } from 'vue'
Expand All @@ -120,7 +127,7 @@ const TimeDepositVisible = ref(false)
const TotalDepositVisible = ref(false)
export default{
components: {Plus},
components: {RefreshLeft, Plus},
computed: {
DocumentChecked() {
return DocumentChecked
Expand Down Expand Up @@ -175,6 +182,19 @@ export default{
}
},
methods: {
RefreshCards(){
axios.post("http:https://127.0.0.1:8000/user/bind_cards/",
{ // 请求体
user_id: this.user_id,
})
.then(response => {
ElMessage.success(response.data.success) // 显示消息提醒
this.QueryCards() // 重新查询借书证以刷新页面
}).catch(error=>{
ElMessage.error(error.response.data.error);
})
this.QueryCards()
},
/*ConfirmNewCard(){
// 发出POST请求
axios.post("http:https://127.0.0.1:8000/user/bind_card",
Expand Down Expand Up @@ -230,6 +250,7 @@ export default{
let response = axios.get('http:https://127.0.0.1:8000/user/user_info',
{params:{user_id: this.user_id}})
.then(response=> {
this.user_info.user_id = this.$route.query.user_id;
this.user_info.user_name = response.data.user_name;
this.user_info.phone_num = response.data.phone_num;
}).catch(error=>{
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/online_user/components/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<el-input style="width: 200px" v-model="toTransferInfo.account_out_id">
</el-input>
</el-form-item >
<el-form-item label="密码" >
<el-form-item label="密码" type="password">
<el-input style="width: 200px" v-model="toTransferInfo.password" >
</el-input>
</el-form-item>
Expand Down
Loading

0 comments on commit 76a50ec

Please sign in to comment.