feat: 身份卡改上下两张卡(正面/背面) + 手机号硬门槛
- canvas 重画成上下两张:正面(暖黄,头像/名字性别/性别品种毛色年龄/性格 彩色标签/介绍/物ID+一起生活天数)、背面(蓝色照护信息条 + 主人/电话/疫苗/ 备注/发证机构/有效期 + 走失联系框&小程序码) - 生成前查手机号:没有则唤起 getPhoneNumber 组件,验证成功才生成; 拒绝则提示「无法生成」不出卡 - IDCard 增 age/days;ic-canvas 高度改 1480 否则导出被裁 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/sundynix/pets-be/internal/model"
|
||||
)
|
||||
@@ -14,6 +15,8 @@ type IDCard struct {
|
||||
Gender string `json:"gender"`
|
||||
Breed string `json:"breed"`
|
||||
Birthday string `json:"birthday"` // "2023 年 12 月 15 日"
|
||||
Age string `json:"age"` // 年龄,如 "2岁7个月"
|
||||
Days int `json:"days"` // 一起生活的天数(按到家日)
|
||||
Zodiac string `json:"zodiac"` // 星座,按生日算
|
||||
Weight string `json:"weight"` // 体重,如 "13.5kg"
|
||||
Intro string `json:"intro"`
|
||||
@@ -145,9 +148,15 @@ func (s *Service) GetIDCard(userID, petID string) (*IDCard, error) {
|
||||
allergy = "无"
|
||||
}
|
||||
|
||||
// 一起生活的天数:按到家日算,没填就 0
|
||||
days := 0
|
||||
if pet.ArrivedAt != nil && !pet.ArrivedAt.IsZero() {
|
||||
days = int(time.Since(*pet.ArrivedAt).Hours()/24) + 1
|
||||
}
|
||||
|
||||
card := &IDCard{
|
||||
Name: pet.Name, Species: pet.Type, Gender: pet.Gender, Breed: pet.Breed,
|
||||
Birthday: bd, Zodiac: zodiac, Weight: pet.Weight, Intro: intro,
|
||||
Birthday: bd, Age: pet.Age, Days: days, Zodiac: zodiac, Weight: pet.Weight, Intro: intro,
|
||||
Color: pet.Color, Personality: pet.Personality,
|
||||
AvatarURL: pet.AvatarURL, IDNo: petIDNo(pet), Validity: validity,
|
||||
Owner: owner, Phone: maskPhone(user.Phone), Allergy: allergy, Notes: pet.Notes,
|
||||
|
||||
Reference in New Issue
Block a user