zcx 1 year ago
parent 9350aac4d9
commit 7d34478c1d

@ -1,122 +0,0 @@
<template>
<div class="chat-container">
<div class="chat">
<h2 class="title">聊天室</h2>
<div class="chat-box">
<div v-for="(message, index) in messages" :key="index" class="message">
<span class="sender">{{ message.sender }}</span>
<span class="content">{{ message.content }}</span>
</div>
</div>
<div class="input">
<input type="text" v-model="newMessage" @keyup.enter="sendMessage" placeholder="输入消息...">
<button @click="sendMessage"></button>
</div>
</div>
</div>
</template>
<script>
import axios from 'axios';
export default {
data() {
return {
messages: [],
newMessage: '',
};
},
methods: {
async fetchMessages() {
try {
const response = await axios.get('http://example.com/messages');
this.messages = response.data;
} catch (error) {
console.error('Error fetching messages:', error);
}
},
async sendMessage() {
try {
await axios.post('http://example.com/messages', {
content: this.newMessage,
sender: 'Me', // You can replace 'Me' with the sender's name
});
this.newMessage = ''; // Clear the input field after sending
// You might want to fetch messages again here to update the UI with the latest messages
} catch (error) {
console.error('Error sending message:', error);
}
},
// WebSocket logic to receive messages
setupWebSocket() {
const ws = new WebSocket('ws://example.com/socket');
ws.onmessage = (event) => {
const message = JSON.parse(event.data);
this.messages.push(message);
};
},
},
created() {
this.fetchMessages(); // Fetch messages when the component is created
this.setupWebSocket(); // Setup WebSocket connection
},
};
</script>
<style>
.chat-container {
max-width: 600px;
margin: 0 auto;
}
.chat {
border: 2px solid #ccc;
border-radius: 10px;
padding: 20px;
display: flex;
flex-direction: column;
height: 100%; /* Ensure the chat box takes up the entire height */
}
.title {
margin-top: 0;
}
.chat-box {
flex: 1; /* Allow the chat box to grow and take up remaining space */
max-height: 300px;
overflow-y: auto;
}
.message {
margin-bottom: 10px;
}
.input {
display: flex;
margin-top: 10px;
}
.input input {
flex: 1;
padding: 8px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
}
.input button {
padding: 8px 15px;
border: none;
border-radius: 5px;
background-color: #007bff;
color: #fff;
font-size: 16px;
cursor: pointer;
margin-left: 10px;
}
.input button:hover {
background-color: #0056b3;
}
</style>

@ -1,41 +0,0 @@
<template>
<div>
<h1>任务列表</h1>
<div v-for="task in tasks" :key="task.id" class="task-item">
<div>{{ task.title }}</div>
<div>{{ task.description }}</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
tasks: []
};
},
mounted() {
this.fetchTasks();
},
methods: {
async fetchTasks() {
try {
const response = await fetch('http://localhost:3000/tasks');
const data = await response.json();
this.tasks = data;
} catch (error) {
console.error(error);
}
}
}
};
</script>
<style>
.task-item {
border: 1px solid #ccc;
padding: 10px;
margin: 10px 0;
}
</style>

@ -1,95 +0,0 @@
<template>
<div class="user-feedback">
<!-- 输入评价 -->
<div class="feedback-input">
<h2>写下你的评价吧</h2>
<form @submit.prevent="submitFeedback">
<textarea id="feedback" v-model.trim="feedback" rows="4" cols="50" placeholder="在这里输入您的评价"></textarea>
<button type="submit">发布评价</button>
</form>
</div>
<!-- 已发布评价 -->
<div class="submitted-feedback" v-if="submittedFeedback">
<h2>已发布评价</h2>
<div class="feedback-item">
<p>{{ submittedFeedback }}</p>
</div>
</div>
</div>
</template>
<script>
import axios from 'axios';
export default {
data() {
return {
feedback: '',
submittedFeedback: ''
};
},
methods: {
submitFeedback() {
if (!this.feedback.trim()) {
return;
}
axios.post('/api/feedback', { feedback: this.feedback.trim() })
.then(response => {
this.submittedFeedback = response.data.feedback;
this.feedback = ''; //
})
.catch(error => {
console.error('Error submitting feedback:', error);
});
}
}
};
</script>
<style scoped>
.user-feedback {
max-width: 600px;
margin: 0 auto;
}
.feedback-input {
margin-bottom: 20px;
}
textarea {
width: 100%;
padding: 8px;
font-size: 16px;
border: 1px solid #28a7a3;
border-radius: 4px;
margin-bottom: 10px;
}
button {
padding: 8px 16px;
font-size: 16px;
border: none;
border-radius: 4px;
background-color: #007bff;
color: #003f3f;
cursor: pointer;
}
.submitted-feedback {
border-top: 1px solid #a6cfee;
padding-top: 20px;
}
.feedback-item {
background-color: #abd4ee;
border: 1px solid #c2f1fb;
border-radius: 4px;
padding: 10px;
}
.feedback-item p {
margin: 0;
}
</style>

@ -1,110 +0,0 @@
<template>
<div class="login-container">
<h1>登录</h1>
<form @submit.prevent="login" class="login-form">
<label for="phone">手机号</label>
<input type="text" id="phone" v-model="phone" class="input-field">
<br>
<label for="password">密码</label>
<input type="password" id="password" v-model="password" class="input-field">
<br>
<button type="submit" class="submit-button">登录</button>
<button @click="goToRegister" class="register-button">注册</button>
</form>
</div>
</template>
<style scoped>
.login-container {
max-width: 400px;
margin: 0 auto;
padding: 20px;
border: 1px solid #28a7a3;
border-radius: 5px;
text-align: center;
}
.input-field {
margin: 10px 0;
padding: 5px;
width: 100%;
}
.submit-button {
padding: 10px 20px;
background-color: #007bff;
color: #003f3f;
border: none;
border-radius: 5px;
cursor: pointer;
}
.register-button {
padding: 10px 20px;
background-color: #ff6347;
color: #003f3f;
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
<script>
import { login } from '../api/auth'
import axios from "axios";
export default {
data() {
return {
phone: '',
password: ''
}
},
methods: {
login() {
console.log("手机号:", this.phone);
console.log("密码:", this.password);
axios.post('http://106.52.218.118:12607/Login/login', {
//
phone: this.phone,
password: this.password
}, {
// cookie
withCredentials: true,
// JSON
headers: {
'Content-Type': 'application/json'
}
})
.then(response => {
if (response.data == 1) {
sessionStorage.setItem('phone', this.phone);
//
this.$router.push('/home');
}
else if (response.data == 2) {
alert('登录失败:账号或密码错误' );
}
else if(response.data == 3){
alert('登录失败:账号未注册');
}
else if(response.data == 0) {
alert('登录失败:未知原因');
}
else {
alert('登录失败:未知原因');
}
})
.catch(error => {
console.error(error);
//
alert('登录失败:网络错误或服务器错误');
});
},
goToRegister() {
this.$router.push('/register'); //
}
}
}
</script>

@ -1,113 +0,0 @@
<template>
<div class="payment">
<h2>支付订单</h2>
<div class="order-summary">
<p>订单金额: {{ orderAmount }} </p>
</div>
<div class="payment-form">
<label for="cardNumber">银行卡号</label>
<input type="text" id="cardNumber" v-model.trim="cardNumber" placeholder="请输入银行卡号">
<label for="expiry">到期日期</label>
<input type="text" id="expiry" v-model.trim="expiry" placeholder="MM/YY">
<label for="cvv">CVV</label>
<input type="text" id="cvv" v-model.trim="cvv" placeholder="请输入CVV">
<button @click="submitPayment" :disabled="loading">支付</button>
<p v-if="error" class="error-message">{{ error }}</p>
</div>
</div>
</template>
<script>
export default {
data() {
return {
orderAmount: 100, // 100
cardNumber: '',
expiry: '',
cvv: '',
loading: false,
error: ''
};
},
methods: {
submitPayment() {
//
this.loading = true;
const paymentData = {
cardNumber: this.cardNumber,
expiry: this.expiry,
cvv: this.cvv,
amount: this.orderAmount
};
// '/api/payment'
fetch('/api/payment', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(paymentData)
})
.then(response => {
if (!response.ok) {
throw new Error('支付失败,请稍后重试。');
}
return response.json();
})
.then(data => {
//
console.log('支付成功:', data);
this.error = '';
})
.catch(error => {
//
console.error('支付失败:', error.message);
this.error = error.message;
})
.finally(() => {
this.loading = false;
});
}
}
};
</script>
<style scoped>
.payment {
max-width: 600px;
margin: 0 auto;
}
.order-summary {
margin-bottom: 20px;
}
label {
font-weight: bold;
}
input {
padding: 8px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
padding: 8px 16px;
font-size: 16px;
border: none;
border-radius: 4px;
background-color: #007bff;
color: #fff;
cursor: pointer;
}
button:disabled {
background-color: #ccc;
cursor: not-allowed;
}
.error-message {
color: #dc3545;
}
</style>

@ -1,118 +0,0 @@
<template>
<div class="register-container">
<h1>注册</h1>
<form @submit.prevent="register" class="register-form">
<label for="phone">手机号</label>
<input type="phone" id="phone" v-model="phone" class="input-field">
<br>
<label for="password">密码</label>
<input type="password" id="password" v-model="password" class="input-field">
<br>
<label for="name">姓名</label>
<input type="name" id="name" v-model="name" class="input-field">
<br>
<label for="IDcard">身份证号</label>
<input type="IDcard" id="IDcard" v-model="IDcard" class="input-field">
<br>
<label for="nickname">昵称</label>
<input type="nickname" id="nickname" v-model="nickname" class="input-field">
<br>
<button type="submit" class="submit-button">注册</button>
<button class="return-button" @click="gotoLogin()"></button>
</form>
</div>
</template>
<style scoped>
.register-container {
max-width: 400px;
margin: 0 auto;
padding: 30px;
border: 1px solid #cccc7b;
border-radius: 5px;
text-align: center;
}
.input-field {
margin: 10px 0;
padding: 5px;
width: 100%;
}
.submit-button {
padding: 10px 20px;
background-color: #28a7a3;
color: #abd4ee;
border: none;
border-radius: 5px;
cursor: pointer;
}
.return-button {
padding: 10px 20px;
background-color: #ff6347; /* 例如,设置为红色 */
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
margin-top: 10px; /* 可以添加一些上边距来分隔按钮 */
}
</style>
<script>
import { register } from '../api/auth'
import axios from "axios";
export default {
data() {
return {
phone: '',
password: '',
name:'',
nickname:'',
IDcard:''
}
},
methods: {
register() {
console.log("", this.phone);
console.log("密码:", this.password);
console.log("姓名:",this.name);
console.log("身份证号:",this.IDcard);
console.log("昵称:",this.nickname);
axios.post('http://106.52.218.118:12607/Login/register', {
//
phone: this.phone,
password: this.password,
name:this.name,
IDCard:this.IDcard,
nickname:this.nickname
}, {
// cookie
withCredentials: true,
// JSON
headers: {
'Content-Type': 'application/json'
}
})
.then(response => {
console.log(response.data)
//
alert("注册成功");
})
.catch(error => {
console.error(error)
//
alert("已注册");
})
},
gotoLogin(){
this.$router.push('/login');
},
}
}
</script>

@ -1,116 +0,0 @@
<template>
<div class="security-verification">
<h2>安全验证</h2>
<!-- 身份证号验证 -->
<div class="verification-item">
<label for="idCard">身份证号</label>
<input type="text" id="idCard" v-model.trim="idCard" placeholder="请输入身份证号">
<button @click="verifyIdCard" :disabled="loading">验证</button>
<p v-if="idCardValid" class="valid-message"></p>
<p v-else-if="idCard !== ''" class="invalid-message">请输入有效的身份证号</p>
</div>
<!-- 银行卡号验证 -->
<div class="verification-item">
<label for="bankCard">银行卡号</label>
<input type="text" id="bankCard" v-model.trim="bankCard" placeholder="请输入银行卡号">
<button @click="verifyBankCard" :disabled="loading">验证</button>
<p v-if="bankCardValid" class="valid-message"></p>
<p v-else-if="bankCard !== ''" class="invalid-message">请输入有效的银行卡号</p>
</div>
<p v-if="error" class="error-message">{{ error }}</p>
</div>
</template>
<script>
export default {
data() {
return {
idCard: '',
idCardValid: false,
bankCard: '',
bankCardValid: false,
loading: false,
error: ''
};
},
methods: {
verifyIdCard() {
this.loading = true;
//
setTimeout(() => {
if (/^\d{17}[\dXx]$/.test(this.idCard)) {
this.idCardValid = true;
this.error = '';
} else {
this.idCardValid = false;
this.error = '请输入有效的身份证号!';
}
this.loading = false;
}, 1000); // 1
},
verifyBankCard() {
this.loading = true;
//
setTimeout(() => {
if (/^\d{16,19}$/.test(this.bankCard)) {
this.bankCardValid = true;
this.error = '';
} else {
this.bankCardValid = false;
this.error = '请输入有效的银行卡号!';
}
this.loading = false;
}, 1000); // 1
}
}
};
</script>
<style scoped>
.security-verification {
max-width: 600px;
margin: 0 auto;
}
.verification-item {
margin-bottom: 20px;
}
label {
font-weight: bold;
}
input {
padding: 8px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
padding: 8px 16px;
font-size: 16px;
border: none;
border-radius: 4px;
background-color: #007bff;
color: #fff;
cursor: pointer;
}
button:disabled {
background-color: #ccc;
cursor: not-allowed;
}
.valid-message {
color: #28a745;
}
.invalid-message {
color: #dc3545;
}
.error-message {
color: #dc3545;
}
</style>

@ -1,190 +0,0 @@
<template>
<div class="profile">
<h2>个人主页</h2>
<div v-if="showNicknameInput">
<label for="nickname">昵称</label>
<input type="nickname" id="nickname" v-model="nickname" class="input-field">
<button @click="updateNickname"></button>
</div>
<div v-else>
<p>昵称{{ user.nickname }}</p>
<button @click="toggleNicknameInput"></button>
</div>
<div v-if="showEmailInput">
<label for="email">邮箱</label>
<input type="email" id="email" v-model="email" class="input-field">
<button @click="updateEmail"></button>
</div>
<div v-else>
<p>邮箱{{ user.email }}</p>
<button @click="toggleEmailInput"></button>
</div>
<div v-if="showPhoneInput">
<label for="PhoneNumber">手机号</label>
<input type="phone" id="phone" v-model="phone" class="input-field">
<button @click="updatePhone"></button>
</div>
<div v-else>
<p>手机号{{ user.phone }}</p>
<button @click="togglePhoneInput"></button>
</div>
<div class="footer-nav">
<button @click="gotohome()"></button>
<button @click="gotomessage()"></button>
<button>我的</button>
</div>
</div>
</template>
<style scoped>
/* 在这里添加样式 */
.profile {
max-width: 400px;
margin: 0 auto;
padding: 20px;
}
.input-field {
margin-bottom: 10px;
}
button {
margin-top: 10px;
}
.home-container {
/* 添加你的样式 */
text-align: center;
padding: 20px;
/* 可能需要为内容添加一些底部空间以容纳底部导航 */
padding-bottom: 50px;
}
.footer-nav {
/* 定义底部导航的样式 */
position: fixed;
bottom: 0;
left: 0;
right: 0;
display: flex;
justify-content: space-around;
padding: 10px;
background-color: #f5f5f5; /* 示例背景色 */
}
.footer-nav button {
/* 定义按钮的样式 */
flex: 1;
border: none;
padding: 10px;
background-color: #ccc;
color: #333;
cursor: pointer;
}
.footer-nav button:hover {
/* 按钮点击时的样式 */
background-color: #bbb;
}
</style>
<script>
import axios from 'axios';
export default {
data() {
return {
user: {},
nickname:'',
showNicknameInput: false,
email: '',
showEmailInput: false,
phone:sessionStorage.getItem('phone') || '',
showPhoneInput: false,
IDCard: '',
createtime: '',
status: 0,
};
},
/*computed: {
...mapGetters(['getPhone'])
},*/
created() {
this.fetchUser(this.phone);
},
methods: {
fetchUser(phone) {
// API
axios.get(`http://106.52.218.118:12607/users/getByPhone?phone=${phone}`)
.then(response => {
this.user = response.data;
})
.catch(error => {
console.error('Error fetching user:', error);
});
},
toggleNicknameInput(){
this.showNicknameInput = !this.showNicknameInput;
this.nickname = this.user.nickname;
},
updateNickname(){
this.user.nickname = this.nickname;
axios.post(`http://106.52.218.118:12607/users/pupdate`,{user:this.user})
.then(response => {
this.user.nickname = this.nickname;
this.toggleNicknameInput(); //
})
.catch(error => {
console.error('Error updating nickname:', error);
});
},
toggleEmailInput() {
this.showEmailInput = !this.showEmailInput;
this.email = this.user.email;//
},
updateEmail() {
//
this.user.email = this.email;
axios.post(`http://106.52.218.118:12607/users/pupdate`,{user:this.user})
.then(response => {
this.user.email = this.email;
this.toggleEmailInput(); //
})
.catch(error => {
console.error('Error updating email:', error);
});
},
togglePhoneInput(){
this.showPhoneInput = !this.showPhoneInput;
this.phone = this.user.phone;
},
updatePhone(){
this.user.phone = this.phone;
axios.post(`http://106.52.218.118:12607/users/pupdate`,{user:this.user})
.then(response => {
sessionStorage.setItem('phone', this.phone);
this.user.phone = this.phone;
this.togglePhoneInput(); //
})
.catch(error => {
console.error('Error updating phone:', error);
});
},
gotohome() {
this.$router.push('/home');
},
gotomessage() {
this.$router.push('/message');
},
}
};
</script>
Loading…
Cancel
Save