feat: 宠物加性格/过敏/备注字段 + 身份卡照护信息 + 微信取手机号
- Pet 增 personality/allergy/notes;建档表单加「性格标签(多选)/过敏/备注」 - IDCard 增 color/personality/owner/phone(脱敏)/allergy/notes/疫苗驱虫状态/发证机构 - 微信取手机号:POST /api/user/phone 用 getPhoneNumber 的 code 换手机号存库 (BindPhoneByCode 走 getuserphonenumber,复用 access_token) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,8 @@ const upload = require('../../utils/upload.js');
|
||||
const { toastErr } = require('../../utils/ui.js');
|
||||
|
||||
const GENDERS = ['男孩', '女孩', '不确定'];
|
||||
// 性格标签预设,多选,存成逗号分隔串
|
||||
const PERSONA_TAGS = ['活泼', '亲人', '粘人', '高冷', '贪吃', '胆小', '好奇', '温顺'];
|
||||
// 阶段列表和划分标准都从后端来。原来这里写死 4 个,后端细分成 5 段
|
||||
// (而且狗还按体型走不同阈值)之后就对不上了 —— 而且不会报错,只是少两个选项。
|
||||
// 「刚到家 0-30 天」在后端列表的第一个,它和年龄正交,是叠加层
|
||||
@@ -54,10 +56,13 @@ Page({
|
||||
species: 'cat', breed: '',
|
||||
gender: '不确定', birthday: '', arrived_at: '',
|
||||
weight: '', color: '', stage: '',
|
||||
personality: '', allergy: '', notes: '',
|
||||
// 第四步挑的方案。'' 是「先空着自己排」,不是「没选」——
|
||||
// 所以初始值给 null,用来区分「还没走到第四步」
|
||||
template_id: null,
|
||||
},
|
||||
personaTags: PERSONA_TAGS,
|
||||
personaSel: {}, // 性格标签选中态 map
|
||||
tplOptions: [],
|
||||
breedShow: false,
|
||||
breedGroups: [],
|
||||
@@ -88,8 +93,12 @@ Page({
|
||||
arrived_at: p.arrived_at ? String(p.arrived_at).slice(0, 10) : '',
|
||||
weight: (p.weight || '').replace('kg', ''),
|
||||
color: p.color || '',
|
||||
personality: p.personality || '',
|
||||
allergy: p.allergy || '',
|
||||
notes: p.notes || '',
|
||||
stage: p.stage || '',
|
||||
},
|
||||
personaSel: (p.personality || '').split(',').filter(Boolean).reduce((m, t) => ((m[t] = true), m), {}),
|
||||
});
|
||||
})
|
||||
.catch((e) => toastErr(e));
|
||||
@@ -170,6 +179,21 @@ Page({
|
||||
onColor(e) {
|
||||
this.setData({ 'form.color': e.detail.value });
|
||||
},
|
||||
onAllergy(e) {
|
||||
this.setData({ 'form.allergy': e.detail.value });
|
||||
},
|
||||
onNotes(e) {
|
||||
this.setData({ 'form.notes': e.detail.value });
|
||||
},
|
||||
// 性格标签多选:切换选中态,再拼回逗号串存进 form.personality
|
||||
togglePersona(e) {
|
||||
const tag = e.currentTarget.dataset.v;
|
||||
const sel = Object.assign({}, this.data.personaSel);
|
||||
if (sel[tag]) delete sel[tag];
|
||||
else sel[tag] = true;
|
||||
const personality = this.data.personaTags.filter((t) => sel[t]).join(',');
|
||||
this.setData({ personaSel: sel, 'form.personality': personality });
|
||||
},
|
||||
|
||||
// ── 品种选择器 ──
|
||||
openBreed() {
|
||||
@@ -258,6 +282,9 @@ Page({
|
||||
weight: f.weight,
|
||||
color: f.color.trim(),
|
||||
breed: f.breed,
|
||||
personality: f.personality,
|
||||
allergy: f.allergy.trim(),
|
||||
notes: f.notes.trim(),
|
||||
stage: f.stage || stageFromBirthday(f.birthday) || '成年期',
|
||||
age: ageLabel(f.birthday),
|
||||
};
|
||||
|
||||
@@ -74,6 +74,16 @@
|
||||
<view class="field"><label>毛色</label>
|
||||
<input class="input" placeholder="例如:橘白 / 奶牛 / 黑" placeholder-class="placeholder"
|
||||
value="{{form.color}}" maxlength="16" bindinput="onColor"/></view>
|
||||
<view class="field"><label>性格标签</label><view class="mini-options">
|
||||
<view wx:for="{{personaTags}}" wx:key="*this" class="option {{personaSel[item] ? 'selected' : ''}}"
|
||||
data-v="{{item}}" bindtap="togglePersona">{{item}}</view>
|
||||
</view></view>
|
||||
<view class="field"><label>过敏情况</label>
|
||||
<input class="input" placeholder="没有就填「无」" placeholder-class="placeholder"
|
||||
value="{{form.allergy}}" maxlength="32" bindinput="onAllergy"/></view>
|
||||
<view class="field"><label>备注(身份卡背面显示)</label>
|
||||
<textarea class="textarea" placeholder="如:肠胃敏感,请勿喂陌生食物" placeholder-class="placeholder"
|
||||
value="{{form.notes}}" maxlength="80" bindinput="onNotes"></textarea></view>
|
||||
<view class="field"><label>当前阶段</label><view class="mini-options">
|
||||
<view wx:for="{{stages}}" wx:key="*this" class="option {{form.stage === item ? 'selected' : ''}}"
|
||||
data-v="{{item}}" bindtap="pickStage">{{item}}</view>
|
||||
|
||||
Reference in New Issue
Block a user