feat: add contact management and various bug fixes

- Add contact API methods in athlete.js
- Add contact list display in common-info.vue
- Update add-contact.vue for contact creation
- Create edit-contact page for contact editing
- Fix event-register.vue with contact picker modal
- Fix home.vue registration status display
- Fix my-registration.vue cert modal display

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
DevOps
2026-01-05 15:12:04 +08:00
co-authored by factory-droid[bot]
parent 4eddc5a194
commit 13eb311575
8 changed files with 720 additions and 489 deletions
+45 -143
View File
@@ -13,82 +13,46 @@
<view class="form-item">
<view class="form-label">姓名</view>
<view class="form-value">
<input
class="form-input"
v-model="formData.name"
placeholder="请输入姓名"
placeholder-class="placeholder"
/>
<input class="form-input" v-model="formData.name" placeholder="请输入姓名" placeholder-class="placeholder" />
</view>
</view>
<view class="form-item">
<view class="form-label">证件号码</view>
<view class="form-value">
<input
class="form-input"
v-model="formData.idCard"
placeholder="请输入身份证号码"
placeholder-class="placeholder"
/>
<input class="form-input" v-model="formData.idCard" placeholder="请输入身份证号码" placeholder-class="placeholder" />
</view>
</view>
<view class="form-item">
<view class="form-label">手机号码</view>
<view class="form-value">
<input
class="form-input"
v-model="formData.phone"
placeholder="请输入手机号码"
placeholder-class="placeholder"
type="number"
/>
<input class="form-input" v-model="formData.phone" placeholder="请输入手机号码" placeholder-class="placeholder" type="number" />
</view>
</view>
<view class="form-item">
<view class="form-label">邮箱</view>
<view class="form-value">
<input
class="form-input"
v-model="formData.email"
placeholder="请输入邮箱"
placeholder-class="placeholder"
/>
<input class="form-input" v-model="formData.email" placeholder="请输入邮箱" placeholder-class="placeholder" />
</view>
</view>
<view class="form-item">
<view class="form-label">地址</view>
<view class="form-value">
<input
class="form-input"
v-model="formData.address"
placeholder="请输入地址"
placeholder-class="placeholder"
/>
<input class="form-input" v-model="formData.address" placeholder="请输入地址" placeholder-class="placeholder" />
</view>
</view>
<view class="form-item switch-item">
<view class="form-label">设置为默认联系人</view>
<view class="form-value">
<switch
:checked="formData.isDefault"
@change="handleSwitchChange"
color="#C93639"
/>
<switch :checked="formData.isDefault" @change="handleSwitchChange" color="#C93639" />
</view>
</view>
</view>
<!-- 提示信息 -->
<view class="hint-message" v-if="showHint">
<text class="hint-icon"></text>
<text class="hint-text">{{ hintText }}</text>
</view>
<!-- Toast提示 -->
<view class="toast-message" v-if="showToast">
<text class="toast-text">{{ toastMessage }}</text>
@@ -96,13 +60,16 @@
<!-- 按钮 -->
<view class="btn-wrapper">
<view class="btn save-btn disabled" v-if="!isFormValid">保存</view>
<view class="btn save-btn" v-else @click="handleSave">保存</view>
<view class="btn save-btn" :class="{ disabled: !isFormValid || saving }" @click="handleSave">
{{ saving ? '保存中...' : '保存' }}
</view>
</view>
</view>
</template>
<script>
import athleteAPI from '@/api/athlete.js';
export default {
data() {
return {
@@ -115,27 +82,20 @@ export default {
address: '',
isDefault: false
},
showHint: false,
hintText: '',
showToast: false,
toastMessage: '',
showIdTypePicker: false
saving: false
};
},
computed: {
isFormValid() {
return (
this.formData.name &&
this.formData.idCard &&
this.formData.phone &&
this.validateIdCard(this.formData.idCard) &&
this.validatePhone(this.formData.phone)
);
return this.formData.name && this.formData.idCard && this.formData.phone &&
this.validateIdCard(this.formData.idCard) && this.validatePhone(this.formData.phone);
}
},
methods: {
validateIdCard(idCard) {
return /^\d{18}$/.test(idCard);
return /^\d{17}[\dXx]$/.test(idCard);
},
validatePhone(phone) {
return /^1\d{10}$/.test(phone);
@@ -143,38 +103,34 @@ export default {
handleSwitchChange(e) {
this.formData.isDefault = e.detail.value;
},
handleSave() {
if (!this.isFormValid) {
if (this.formData.phone && !this.validatePhone(this.formData.phone)) {
this.toastMessage = '手机号码格式不正确';
this.showToast = true;
setTimeout(() => {
this.showToast = false;
}, 2000);
} else if (this.formData.idCard && !this.validateIdCard(this.formData.idCard)) {
this.toastMessage = '身份证号码格式不正确';
this.showToast = true;
setTimeout(() => {
this.showToast = false;
}, 2000);
} else {
this.hintText = '请完善信息';
this.showHint = true;
setTimeout(() => {
this.showHint = false;
}, 2000);
}
showToastMsg(msg) {
this.toastMessage = msg;
this.showToast = true;
setTimeout(() => { this.showToast = false; }, 2000);
},
async handleSave() {
if (!this.isFormValid || this.saving) return;
if (!this.validatePhone(this.formData.phone)) {
this.showToastMsg('手机号码格式不正确');
return;
}
if (!this.validateIdCard(this.formData.idCard)) {
this.showToastMsg('身份证号码格式不正确');
return;
}
// 实际保存逻辑
uni.showToast({
title: '保存成功',
icon: 'success'
});
setTimeout(() => {
uni.navigateBack();
}, 1500);
this.saving = true;
try {
await athleteAPI.saveContact(this.formData);
uni.showToast({ title: '保存成功', icon: 'success' });
setTimeout(() => { uni.navigateBack(); }, 1500);
} catch (err) {
console.error('保存联系人失败:', err);
this.showToastMsg('保存失败,请重试');
} finally {
this.saving = false;
}
}
}
};
@@ -201,13 +157,8 @@ export default {
border-bottom: 1rpx solid #f5f5f5;
}
.form-item:last-child {
border-bottom: none;
}
.switch-item {
padding: 30rpx;
}
.form-item:last-child { border-bottom: none; }
.switch-item { padding: 30rpx; }
.form-label {
width: 180rpx;
@@ -228,38 +179,8 @@ export default {
color: #333333;
}
.placeholder {
color: #cccccc;
}
.arrow {
font-size: 40rpx;
color: #cccccc;
margin-left: 10rpx;
}
.hint-message {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(0, 0, 0, 0.7);
color: #fff;
padding: 30rpx 50rpx;
border-radius: 16rpx;
display: flex;
align-items: center;
gap: 15rpx;
z-index: 9999;
}
.hint-icon {
font-size: 40rpx;
}
.hint-text {
font-size: 28rpx;
}
.placeholder { color: #cccccc; }
.arrow { font-size: 40rpx; color: #cccccc; margin-left: 10rpx; }
.toast-message {
position: fixed;
@@ -273,26 +194,7 @@ export default {
z-index: 9999;
}
.toast-text {
font-size: 28rpx;
}
.info-text {
margin: 20rpx 30rpx;
text-align: center;
}
.info-hint {
font-size: 24rpx;
color: #C93639;
}
.warning-text {
margin: 20rpx 30rpx;
text-align: center;
font-size: 24rpx;
color: #C93639;
}
.toast-text { font-size: 28rpx; }
.btn-wrapper {
position: fixed;