index.vue 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629
  1. <template>
  2. <view class="profile-page">
  3. <!-- 顶部导航栏 -->
  4. <view class="header">
  5. <view class="back-btn" @click="goBack">
  6. <text class="back-icon">←</text>
  7. </view>
  8. <text class="header-title">基本资料</text>
  9. <view class="edit-btn" @click="enableEdit">
  10. <text class="edit-text">{{ isEditing ? '保存' : '编辑' }}</text>
  11. </view>
  12. </view>
  13. <!-- 头像和基本信息 -->
  14. <view class="avatar-section">
  15. <view class="avatar-wrapper" @click="chooseAvatar">
  16. <image class="avatar" :src="profile.avatar || defaultAvatar" mode="aspectFill"></image>
  17. <view class="avatar-badge" v-if="profile.isVip">
  18. <text class="vip-icon">👑</text>
  19. </view>
  20. <view class="avatar-edit-hint">
  21. <text class="edit-hint-icon">📷</text>
  22. </view>
  23. </view>
  24. <text class="nickname">{{ profile.realName || profile.nickname || '未设置' }}</text>
  25. <text class="user-id">ID: {{ profile.userId || '未知' }}</text>
  26. </view>
  27. <!-- 编辑提示 -->
  28. <view class="edit-tip" v-if="!isEditing">
  29. <text class="tip-text">💡 点击任意字段即可编辑</text>
  30. </view>
  31. <scroll-view scroll-y class="content-scroll">
  32. <!-- 个人信息 -->
  33. <view class="section">
  34. <view class="section-title">个人信息</view>
  35. <view class="info-item" :class="{ editing: isEditing }" @click="startEdit">
  36. <text class="label">真实姓名</text>
  37. <input v-if="isEditing" class="input" v-model="profile.realName" placeholder="请输入真实姓名" />
  38. <text v-else class="value">{{ profile.realName || '未设置' }}</text>
  39. </view>
  40. <view class="info-item" :class="{ editing: isEditing }" @click="startEdit">
  41. <text class="label">身份证号</text>
  42. <input v-if="isEditing" class="input" v-model="profile.idCard" placeholder="请输入身份证号" />
  43. <text v-else class="value">{{ formatIdCard(profile.idCard) }}</text>
  44. <text class="verify-status verified" v-if="profile.idCard && profile.isRealNameVerified">✓已认证</text>
  45. <text class="verify-status unverified" v-else-if="!profile.idCard">未认证</text>
  46. </view>
  47. <view class="info-item" :class="{ editing: isEditing }" @click="startEdit">
  48. <text class="label">性别</text>
  49. <picker v-if="isEditing" :range="genderOptions" range-key="label" :value="getGenderIndex()" @change="onGenderChange">
  50. <view class="picker-value">{{ getGenderText() }}</view>
  51. </picker>
  52. <text v-else class="value">{{ getGenderText() }}</text>
  53. </view>
  54. <view class="info-item" :class="{ editing: isEditing }" @click="startEdit">
  55. <text class="label">出生日期</text>
  56. <picker v-if="isEditing" mode="date" :value="profile.birthDate" @change="onBirthDateChange">
  57. <view class="picker-value">{{ profile.birthDate || '请选择' }}</view>
  58. </picker>
  59. <text v-else class="value">{{ profile.birthDate || '未设置' }}</text>
  60. </view>
  61. <view class="info-item" :class="{ editing: isEditing }" @click="startEdit">
  62. <text class="label">身高</text>
  63. <input v-if="isEditing" class="input" type="number" v-model="profile.height" placeholder="请输入身高(cm)" />
  64. <text v-else class="value">{{ profile.height ? profile.height + ' cm' : '未设置' }}</text>
  65. </view>
  66. <view class="info-item" :class="{ editing: isEditing }" @click="startEdit">
  67. <text class="label">体重</text>
  68. <input v-if="isEditing" class="input" type="number" v-model="profile.weight" placeholder="请输入体重(kg)" />
  69. <text v-else class="value">{{ profile.weight ? profile.weight + ' kg' : '未设置' }}</text>
  70. </view>
  71. <view class="info-item" :class="{ editing: isEditing }" @click="startEdit">
  72. <text class="label">星座</text>
  73. <picker v-if="isEditing" :range="starOptions" @change="onStarChange">
  74. <view class="picker-value">{{ profile.star || '请选择' }}</view>
  75. </picker>
  76. <text v-else class="value">{{ profile.star || '未设置' }}</text>
  77. </view>
  78. <view class="info-item" :class="{ editing: isEditing }" @click="startEdit">
  79. <text class="label">生肖</text>
  80. <picker v-if="isEditing" :range="animalOptions" @change="onAnimalChange">
  81. <view class="picker-value">{{ profile.animal || '请选择' }}</view>
  82. </picker>
  83. <text v-else class="value">{{ profile.animal || '未设置' }}</text>
  84. </view>
  85. </view>
  86. <!-- 学业与工作 -->
  87. <view class="section">
  88. <view class="section-title">学业与工作</view>
  89. <view class="info-item" :class="{ editing: isEditing }" @click="startEdit">
  90. <text class="label">学历</text>
  91. <picker v-if="isEditing" :range="educationOptions" :value="getEducationIndex()" @change="onEducationChange">
  92. <view class="picker-value">{{ getEducationText() }}</view>
  93. </picker>
  94. <text v-else class="value">{{ getEducationText() }}</text>
  95. <text class="verify-status verified" v-if="profile.educationLevel && profile.isEducationVerified">✓已认证</text>
  96. <text class="verify-status unverified" v-else-if="!profile.educationLevel">未认证</text>
  97. </view>
  98. <view class="info-item" :class="{ editing: isEditing }" @click="startEdit">
  99. <text class="label">学校名称</text>
  100. <input v-if="isEditing" class="input" v-model="profile.schoolName" placeholder="请输入学校名称" />
  101. <text v-else class="value">{{ profile.schoolName || '未设置' }}</text>
  102. </view>
  103. <view class="info-item" :class="{ editing: isEditing }" @click="startEdit">
  104. <text class="label">工作单位</text>
  105. <input v-if="isEditing" class="input" v-model="profile.company" placeholder="请输入工作单位" />
  106. <text v-else class="value">{{ profile.company || '未设置' }}</text>
  107. <text class="verify-status verified" v-if="profile.company && profile.isWorkVerified">✓已认证</text>
  108. <text class="verify-status unverified" v-else-if="!profile.company">未认证</text>
  109. </view>
  110. <view class="info-item" :class="{ editing: isEditing }" @click="startEdit">
  111. <text class="label">职位</text>
  112. <input v-if="isEditing" class="input" v-model="profile.jobTitle" placeholder="请输入职位" />
  113. <text v-else class="value">{{ profile.jobTitle || '未设置' }}</text>
  114. </view>
  115. <view class="info-item" :class="{ editing: isEditing }" @click="startEdit">
  116. <text class="label">薪资范围</text>
  117. <picker v-if="isEditing" :range="salaryOptions" :value="getSalaryIndex()" @change="onSalaryChange">
  118. <view class="picker-value">{{ getSalaryText() }}</view>
  119. </picker>
  120. <text v-else class="value">{{ getSalaryText() }}</text>
  121. </view>
  122. </view>
  123. <!-- 婚姻与住房 -->
  124. <view class="section">
  125. <view class="section-title">婚姻与住房</view>
  126. <view class="info-item" :class="{ editing: isEditing }" @click="startEdit">
  127. <text class="label">婚姻状况</text>
  128. <picker v-if="isEditing" :range="maritalOptions" :value="getMaritalIndex()" @change="onMaritalChange">
  129. <view class="picker-value">{{ getMaritalText() }}</view>
  130. </picker>
  131. <text v-else class="value">{{ getMaritalText() }}</text>
  132. <text class="verify-status verified" v-if="profile.maritalStatus !== null && profile.maritalStatus !== undefined && profile.isMaritalVerified">✓已认证</text>
  133. <text class="verify-status unverified" v-else-if="profile.maritalStatus === null || profile.maritalStatus === undefined">未认证</text>
  134. </view>
  135. <view class="info-item" :class="{ editing: isEditing }" @click="startEdit">
  136. <text class="label">房产</text>
  137. <picker v-if="isEditing" :range="houseOptions" range-key="label" :value="getHouseIndex()" @change="onHouseChange">
  138. <view class="picker-value">{{ getHouseText() }}</view>
  139. </picker>
  140. <text v-else class="value">{{ getHouseText() }}</text>
  141. </view>
  142. <view class="info-item" :class="{ editing: isEditing }" @click="startEdit">
  143. <text class="label">车辆</text>
  144. <picker v-if="isEditing" :range="carOptions" range-key="label" :value="getCarIndex()" @change="onCarChange">
  145. <view class="picker-value">{{ getCarText() }}</view>
  146. </picker>
  147. <text v-else class="value">{{ getCarText() }}</text>
  148. </view>
  149. </view>
  150. <!-- 兴趣爱好 -->
  151. <view class="section">
  152. <view class="section-title">兴趣爱好</view>
  153. <view class="info-item column" @click="startEdit">
  154. <text class="label">兴趣爱好标签</text>
  155. <view class="hobby-tags">
  156. <view class="hobby-tag"
  157. v-for="(hobby, index) in hobbyList"
  158. :key="index"
  159. @click.stop="isEditing ? removeHobbyTag(index) : null"
  160. :class="{ deletable: isEditing }"
  161. >
  162. {{ hobby }}
  163. <text class="delete-icon" v-if="isEditing">×</text>
  164. </view>
  165. <view class="hobby-tag add" v-if="isEditing" @click.stop="addHobby">
  166. + 添加
  167. </view>
  168. <view class="hobby-empty" v-if="hobbyList.length === 0 && !isEditing">
  169. <text class="empty-text">暂无标签</text>
  170. </view>
  171. </view>
  172. </view>
  173. </view>
  174. <!-- 隐私设置 -->
  175. <view class="section">
  176. <view class="section-title">隐私设置</view>
  177. <view class="info-item" :class="{ editing: isEditing }" @click="startEdit">
  178. <text class="label">薪资公开</text>
  179. <switch :checked="profile.privacySalary === 1" @change="onPrivacySalaryChange" :disabled="!isEditing" />
  180. </view>
  181. <view class="info-item" :class="{ editing: isEditing }" @click="startEdit">
  182. <text class="label">手机号公开</text>
  183. <switch :checked="profile.privacyPhone === 1" @change="onPrivacyPhoneChange" :disabled="!isEditing" />
  184. </view>
  185. </view>
  186. <!-- 真实度评分 -->
  187. <view class="section">
  188. <view class="section-title">真实度评分</view>
  189. <view class="authenticity-score">
  190. <view class="score-circle">
  191. <text class="score-number">{{ profile.authenticityScore || 0 }}</text>
  192. <text class="score-total">/100</text>
  193. </view>
  194. <view class="score-tips">
  195. <text class="tip-text">完善资料并通过认证可提升真实度评分</text>
  196. </view>
  197. </view>
  198. </view>
  199. <!-- 底部占位 -->
  200. <view class="bottom-placeholder"></view>
  201. </scroll-view>
  202. <!-- 标签选择弹窗 -->
  203. <view class="hobby-modal" v-if="showHobbyModal" @click="closeHobbyModal">
  204. <view class="modal-content" @click.stop>
  205. <view class="modal-header">
  206. <text class="modal-title">选择兴趣爱好标签</text>
  207. <text class="close-btn" @click="closeHobbyModal">×</text>
  208. </view>
  209. <scroll-view scroll-y class="modal-body">
  210. <!-- 预设标签分类 -->
  211. <view class="hobby-category" v-for="(category, index) in hobbyCategories" :key="index">
  212. <view class="category-title">
  213. <text class="category-icon">{{ category.icon }}</text>
  214. <text class="category-name">{{ category.name }}</text>
  215. </view>
  216. <view class="category-tags">
  217. <view class="preset-tag"
  218. v-for="(tag, tagIndex) in category.tags"
  219. :key="tagIndex"
  220. @click="selectPresetTag(tag)"
  221. :class="{ selected: hobbyList.includes(tag) }"
  222. >
  223. {{ tag }}
  224. <text class="check-icon" v-if="hobbyList.includes(tag)">✓</text>
  225. </view>
  226. </view>
  227. </view>
  228. <!-- 自定义输入 -->
  229. <view class="custom-input-section">
  230. <view class="category-title">
  231. <text class="category-icon">✏️</text>
  232. <text class="category-name">自定义标签</text>
  233. </view>
  234. <view class="input-wrapper">
  235. <input
  236. class="custom-input"
  237. v-model="customHobbyInput"
  238. placeholder="输入自定义标签"
  239. @confirm="addCustomTag"
  240. />
  241. <view class="add-custom-btn" @click="addCustomTag">
  242. <text class="add-text">添加</text>
  243. </view>
  244. </view>
  245. </view>
  246. </scroll-view>
  247. <view class="modal-footer">
  248. <text class="selected-count">已选择 {{ hobbyList.length }}/10 个标签</text>
  249. <view class="done-btn" @click="closeHobbyModal">
  250. <text class="done-text">完成</text>
  251. </view>
  252. </view>
  253. </view>
  254. </view>
  255. </view>
  256. </template>
  257. <script>
  258. import userAuth from '@/utils/userAuth.js'
  259. export default {
  260. data() {
  261. return {
  262. gatewayURL: 'http://localhost:8083',
  263. currentUserId: null,
  264. isEditing: false,
  265. defaultAvatar: 'https://via.placeholder.com/150',
  266. // 用户资料数据
  267. profile: {
  268. userId: null,
  269. avatar: '',
  270. nickname: '',
  271. realName: '',
  272. idCard: '',
  273. gender: null,
  274. birthDate: '',
  275. height: null,
  276. weight: null,
  277. star: '',
  278. animal: '',
  279. educationLevel: null,
  280. schoolName: '',
  281. company: '',
  282. jobTitle: '',
  283. salaryRange: null,
  284. maritalStatus: null,
  285. house: null,
  286. car: null,
  287. hobby: '',
  288. privacySalary: 0,
  289. privacyPhone: 0,
  290. authenticityScore: 0,
  291. isVip: false,
  292. isRealNameVerified: false,
  293. isEducationVerified: false,
  294. isWorkVerified: false,
  295. isMaritalVerified: false
  296. },
  297. // 选项列表
  298. genderOptions: [
  299. { value: 1, label: '男' },
  300. { value: 2, label: '女' }
  301. ],
  302. starOptions: ['白羊座', '金牛座', '双子座', '巨蟹座', '狮子座', '处女座',
  303. '天秤座', '天蝎座', '射手座', '摩羯座', '水瓶座', '双鱼座'],
  304. animalOptions: ['鼠', '牛', '虎', '兔', '龙', '蛇', '马', '羊', '猴', '鸡', '狗', '猪'],
  305. educationOptions: ['高中', '专科', '本科', '硕士', '博士', '无'],
  306. salaryOptions: ['1-5k', '5-10k', '10-20k', '20-50k', '50k+'],
  307. maritalOptions: ['未婚', '离异', '丧偶'],
  308. houseOptions: [
  309. { value: 0, label: '无' },
  310. { value: 1, label: '有' }
  311. ],
  312. carOptions: [
  313. { value: 0, label: '无' },
  314. { value: 1, label: '有' }
  315. ],
  316. // 标签选择弹窗
  317. showHobbyModal: false,
  318. hobbyCategories: [
  319. {
  320. name: '运动健身',
  321. icon: '🏃',
  322. tags: ['运动', '健身', '瑜伽', '爬山', '游泳', '篮球', '足球', '网球']
  323. },
  324. {
  325. name: '文艺休闲',
  326. icon: '🎨',
  327. tags: ['旅游', '阅读', '音乐', '电影', '摄影', '绘画', '舞蹈', '唱歌']
  328. },
  329. {
  330. name: '技能爱好',
  331. icon: '🎹',
  332. tags: ['钢琴', '吉他', '书法', '茶艺', '烹饪', '园艺', '手工', '收藏']
  333. },
  334. {
  335. name: '生活方式',
  336. icon: '🌟',
  337. tags: ['美食', '游戏', '宠物', '时尚', '购物', '化妆']
  338. }
  339. ],
  340. customHobbyInput: ''
  341. }
  342. },
  343. computed: {
  344. hobbyList() {
  345. if (!this.profile.hobby) return []
  346. try {
  347. return JSON.parse(this.profile.hobby)
  348. } catch (e) {
  349. return this.profile.hobby.split(',').filter(item => item)
  350. }
  351. }
  352. },
  353. onLoad() {
  354. // 获取登录用户ID - 使用userAuth工具类
  355. this.currentUserId = userAuth.getUserId()
  356. console.log('=== 个人资料页面 ===')
  357. console.log('用户ID:', this.currentUserId)
  358. console.log('用户ID类型:', typeof this.currentUserId)
  359. // 检查是否已登录(userId为1也是合法的测试用户)
  360. if (this.currentUserId === null || this.currentUserId === undefined || this.currentUserId === 0) {
  361. console.log('未登录,检查登录状态')
  362. this.checkLoginStatus()
  363. } else {
  364. console.log('已登录,用户ID:', this.currentUserId)
  365. // 加载用户资料
  366. this.loadProfile()
  367. }
  368. },
  369. methods: {
  370. // 选择并上传头像
  371. chooseAvatar() {
  372. uni.showActionSheet({
  373. itemList: ['从相册选择', '拍照'],
  374. success: (res) => {
  375. if (res.tapIndex === 0) {
  376. // 从相册选择
  377. this.selectImage('album')
  378. } else if (res.tapIndex === 1) {
  379. // 拍照
  380. this.selectImage('camera')
  381. }
  382. }
  383. })
  384. },
  385. // 选择图片
  386. selectImage(sourceType) {
  387. uni.chooseImage({
  388. count: 1,
  389. sizeType: ['compressed'], // 使用压缩图
  390. sourceType: [sourceType],
  391. success: (res) => {
  392. const tempFilePath = res.tempFilePaths[0]
  393. console.log('选择的图片路径:', tempFilePath)
  394. // 上传图片
  395. this.uploadAvatar(tempFilePath)
  396. },
  397. fail: (err) => {
  398. console.error('选择图片失败:', err)
  399. uni.showToast({
  400. title: '选择图片失败',
  401. icon: 'none'
  402. })
  403. }
  404. })
  405. },
  406. // 上传头像
  407. uploadAvatar(filePath) {
  408. console.log('=== 开始上传头像 ===')
  409. console.log('文件路径:', filePath)
  410. console.log('上传URL:', this.gatewayURL + '/api/avatar/upload')
  411. console.log('用户ID:', this.currentUserId)
  412. uni.showLoading({
  413. title: '上传中...',
  414. mask: true
  415. })
  416. // 使用 uni.uploadFile 上传到服务器
  417. const uploadTask = uni.uploadFile({
  418. url: this.gatewayURL + '/api/avatar/upload',
  419. filePath: filePath,
  420. name: 'file',
  421. timeout: 60000, // 设置超时时间为60秒
  422. formData: {
  423. userId: this.currentUserId
  424. },
  425. success: (uploadRes) => {
  426. uni.hideLoading()
  427. console.log('上传响应:', uploadRes)
  428. console.log('状态码:', uploadRes.statusCode)
  429. // 检查HTTP状态码
  430. if (uploadRes.statusCode !== 200) {
  431. console.error('HTTP错误:', uploadRes.statusCode)
  432. uni.showToast({
  433. title: `服务器错误: ${uploadRes.statusCode}`,
  434. icon: 'none',
  435. duration: 3000
  436. })
  437. return
  438. }
  439. try {
  440. const result = JSON.parse(uploadRes.data)
  441. console.log('解析后的结果:', result)
  442. if (result.code === 200) {
  443. console.log('✅ 头像上传成功:', result.data)
  444. // 更新头像URL
  445. this.profile.avatar = result.data
  446. // 更新本地存储的用户信息
  447. const userInfo = uni.getStorageSync('userInfo')
  448. if (userInfo) {
  449. userInfo.avatarUrl = result.data
  450. uni.setStorageSync('userInfo', userInfo)
  451. console.log('已更新本地缓存')
  452. }
  453. uni.showToast({
  454. title: '头像上传成功',
  455. icon: 'success',
  456. duration: 2000
  457. })
  458. // 刷新页面数据
  459. setTimeout(() => {
  460. this.loadProfile()
  461. }, 500)
  462. } else {
  463. console.error('❌ 业务错误:', result.message)
  464. uni.showToast({
  465. title: result.message || '上传失败',
  466. icon: 'none',
  467. duration: 3000
  468. })
  469. }
  470. } catch (e) {
  471. console.error('❌ 解析响应失败:', e)
  472. console.error('原始响应数据:', uploadRes.data)
  473. uni.showToast({
  474. title: '服务器响应格式错误',
  475. icon: 'none',
  476. duration: 3000
  477. })
  478. }
  479. },
  480. fail: (err) => {
  481. uni.hideLoading()
  482. console.error('❌ 上传失败:', err)
  483. let errorMsg = '上传失败'
  484. if (err.errMsg) {
  485. if (err.errMsg.includes('timeout')) {
  486. errorMsg = '上传超时,请检查网络连接'
  487. } else if (err.errMsg.includes('fail')) {
  488. errorMsg = '网络连接失败'
  489. } else {
  490. errorMsg = err.errMsg
  491. }
  492. }
  493. uni.showToast({
  494. title: errorMsg,
  495. icon: 'none',
  496. duration: 3000
  497. })
  498. }
  499. })
  500. // 监听上传进度
  501. uploadTask.onProgressUpdate((res) => {
  502. console.log('上传进度:', res.progress + '%')
  503. if (res.progress % 20 === 0 || res.progress > 90) {
  504. console.log(`已上传 ${res.totalBytesSent}/${res.totalBytesExpectedToSend} 字节`)
  505. }
  506. })
  507. },
  508. // 检查登录状态
  509. checkLoginStatus() {
  510. const token = uni.getStorageSync('token')
  511. const userInfo = uni.getStorageSync('userInfo')
  512. if (!token || !userInfo) {
  513. // 没有登录信息,跳转到登录页
  514. uni.showModal({
  515. title: '需要登录',
  516. content: '请先登录后查看个人资料',
  517. showCancel: false,
  518. confirmText: '去登录',
  519. success: () => {
  520. uni.navigateTo({
  521. url: '/pages/page3/page3?redirect=' + encodeURIComponent('/pages/profile/index')
  522. })
  523. }
  524. })
  525. return false
  526. }
  527. if (this.currentUserId === null || this.currentUserId === undefined || this.currentUserId === 0) {
  528. // 有登录信息但无法获取用户ID - 登录信息异常
  529. uni.showModal({
  530. title: '登录信息异常',
  531. content: '登录信息不完整,请重新登录',
  532. showCancel: false,
  533. confirmText: '重新登录',
  534. success: () => {
  535. // 清除异常的登录信息
  536. uni.clearStorageSync()
  537. uni.navigateTo({
  538. url: '/pages/page3/page3?redirect=' + encodeURIComponent('/pages/profile/index')
  539. })
  540. }
  541. })
  542. return false
  543. }
  544. return true
  545. },
  546. // 加载用户资料
  547. loadProfile() {
  548. uni.showLoading({
  549. title: '加载中...'
  550. })
  551. uni.request({
  552. url: this.gatewayURL + '/api/user/profile?userId=' + this.currentUserId,
  553. method: 'GET',
  554. success: (res) => {
  555. uni.hideLoading()
  556. console.log('=== 用户资料加载 ===')
  557. console.log('完整响应:', res.data)
  558. if (res.data && res.data.code === 200) {
  559. console.log('原始salaryRange:', res.data.data.salaryRange)
  560. this.profile = { ...this.profile, ...res.data.data }
  561. console.log('合并后的profile.salaryRange:', this.profile.salaryRange)
  562. console.log('显示的薪资文本:', this.getSalaryText())
  563. } else {
  564. uni.showToast({
  565. title: res.data?.message || '加载失败',
  566. icon: 'none'
  567. })
  568. }
  569. },
  570. fail: (err) => {
  571. uni.hideLoading()
  572. console.error('加载用户资料失败:', err)
  573. uni.showToast({
  574. title: '网络请求失败',
  575. icon: 'none'
  576. })
  577. }
  578. })
  579. },
  580. // 格式化身份证号(隐藏中间部分)
  581. formatIdCard(idCard) {
  582. if (!idCard) return '未设置'
  583. if (idCard.length < 8) return idCard
  584. return idCard.substring(0, 6) + '********' + idCard.substring(idCard.length - 4)
  585. },
  586. // 获取性别文本
  587. getGenderText() {
  588. const option = this.genderOptions.find(item => item.value === this.profile.gender)
  589. return option ? option.label : '未设置'
  590. },
  591. // 获取学历文本
  592. getEducationText() {
  593. if (this.profile.educationLevel === null || this.profile.educationLevel === undefined) return '未设置'
  594. const index = this.profile.educationLevel - 1
  595. return this.educationOptions[index] || '未设置'
  596. },
  597. // 获取薪资文本
  598. getSalaryText() {
  599. if (this.profile.salaryRange === null || this.profile.salaryRange === undefined) return '未设置'
  600. const index = this.profile.salaryRange - 1
  601. return this.salaryOptions[index] || '未设置'
  602. },
  603. // 获取薪资选择器的索引
  604. getSalaryIndex() {
  605. if (this.profile.salaryRange === null || this.profile.salaryRange === undefined) {
  606. return 0 // 默认选择第一项
  607. }
  608. const index = this.profile.salaryRange - 1
  609. // 确保索引在有效范围内
  610. return Math.max(0, Math.min(index, this.salaryOptions.length - 1))
  611. },
  612. // 获取性别选择器的索引
  613. getGenderIndex() {
  614. const option = this.genderOptions.findIndex(item => item.value === this.profile.gender)
  615. return Math.max(0, option)
  616. },
  617. // 获取学历选择器的索引
  618. getEducationIndex() {
  619. if (this.profile.educationLevel === null || this.profile.educationLevel === undefined) {
  620. return 0
  621. }
  622. const index = this.profile.educationLevel - 1
  623. return Math.max(0, Math.min(index, this.educationOptions.length - 1))
  624. },
  625. // 获取婚姻状况选择器的索引
  626. getMaritalIndex() {
  627. if (this.profile.maritalStatus === null || this.profile.maritalStatus === undefined) {
  628. return 0
  629. }
  630. return Math.max(0, Math.min(this.profile.maritalStatus, this.maritalOptions.length - 1))
  631. },
  632. // 获取房产选择器的索引
  633. getHouseIndex() {
  634. const option = this.houseOptions.findIndex(item => item.value === this.profile.house)
  635. return Math.max(0, option)
  636. },
  637. // 获取车辆选择器的索引
  638. getCarIndex() {
  639. const option = this.carOptions.findIndex(item => item.value === this.profile.car)
  640. return Math.max(0, option)
  641. },
  642. // 获取婚姻状况文本
  643. getMaritalText() {
  644. if (this.profile.maritalStatus === null || this.profile.maritalStatus === undefined) return '未设置'
  645. const index = this.profile.maritalStatus
  646. return this.maritalOptions[index] || '未设置'
  647. },
  648. // 获取房产文本
  649. getHouseText() {
  650. const option = this.houseOptions.find(item => item.value === this.profile.house)
  651. return option ? option.label : '未设置'
  652. },
  653. // 获取车辆文本
  654. getCarText() {
  655. const option = this.carOptions.find(item => item.value === this.profile.car)
  656. return option ? option.label : '未设置'
  657. },
  658. // 选择器改变事件
  659. onGenderChange(e) {
  660. this.profile.gender = this.genderOptions[parseInt(e.detail.value)].value
  661. },
  662. onBirthDateChange(e) {
  663. this.profile.birthDate = e.detail.value
  664. },
  665. onStarChange(e) {
  666. this.profile.star = this.starOptions[parseInt(e.detail.value)]
  667. },
  668. onAnimalChange(e) {
  669. this.profile.animal = this.animalOptions[parseInt(e.detail.value)]
  670. },
  671. onEducationChange(e) {
  672. // 将字符串转换为数字
  673. this.profile.educationLevel = parseInt(e.detail.value) + 1
  674. },
  675. onSalaryChange(e) {
  676. console.log('=== 薪资选择变化 ===')
  677. console.log('选择的索引:', e.detail.value, typeof e.detail.value)
  678. console.log('对应的薪资选项:', this.salaryOptions[e.detail.value])
  679. // 将字符串转换为数字,避免字符串拼接问题
  680. this.profile.salaryRange = parseInt(e.detail.value) + 1
  681. console.log('更新后的salaryRange:', this.profile.salaryRange, typeof this.profile.salaryRange)
  682. console.log('更新后显示的文本:', this.getSalaryText())
  683. },
  684. onMaritalChange(e) {
  685. // 将字符串转换为数字
  686. this.profile.maritalStatus = parseInt(e.detail.value)
  687. },
  688. onHouseChange(e) {
  689. this.profile.house = this.houseOptions[parseInt(e.detail.value)].value
  690. },
  691. onCarChange(e) {
  692. this.profile.car = this.carOptions[parseInt(e.detail.value)].value
  693. },
  694. onPrivacySalaryChange(e) {
  695. this.profile.privacySalary = e.detail.value ? 1 : 0
  696. },
  697. onPrivacyPhoneChange(e) {
  698. this.profile.privacyPhone = e.detail.value ? 1 : 0
  699. },
  700. // 显示标签选择弹窗
  701. addHobby() {
  702. this.showHobbyModal = true
  703. },
  704. // 关闭标签选择弹窗
  705. closeHobbyModal() {
  706. this.showHobbyModal = false
  707. this.customHobbyInput = ''
  708. },
  709. // 选择预设标签
  710. selectPresetTag(tag) {
  711. if (this.hobbyList.includes(tag)) {
  712. // 如果已选中,则移除
  713. this.removeHobbyTag(this.hobbyList.indexOf(tag))
  714. } else {
  715. // 如果未选中,则添加
  716. this.addHobbyTag(tag)
  717. }
  718. },
  719. // 添加自定义标签
  720. addCustomTag() {
  721. const customTag = this.customHobbyInput.trim()
  722. if (customTag) {
  723. this.addHobbyTag(customTag)
  724. this.customHobbyInput = ''
  725. } else {
  726. uni.showToast({
  727. title: '请输入标签内容',
  728. icon: 'none'
  729. })
  730. }
  731. },
  732. // 添加标签到列表
  733. addHobbyTag(hobbyText) {
  734. let currentHobbies = this.hobbyList.slice()
  735. // 检查是否已存在
  736. if (currentHobbies.includes(hobbyText)) {
  737. uni.showToast({
  738. title: '标签已存在',
  739. icon: 'none'
  740. })
  741. return
  742. }
  743. // 限制标签数量
  744. if (currentHobbies.length >= 10) {
  745. uni.showToast({
  746. title: '最多只能添加10个标签',
  747. icon: 'none'
  748. })
  749. return
  750. }
  751. // 添加新标签
  752. currentHobbies.push(hobbyText)
  753. // 更新hobby字段(转为JSON格式)
  754. this.profile.hobby = JSON.stringify(currentHobbies)
  755. uni.showToast({
  756. title: '标签添加成功',
  757. icon: 'success'
  758. })
  759. },
  760. // 移除标签
  761. removeHobbyTag(index) {
  762. uni.showModal({
  763. title: '确认删除',
  764. content: '确定要删除这个标签吗?',
  765. success: (res) => {
  766. if (res.confirm) {
  767. let currentHobbies = this.hobbyList.slice()
  768. currentHobbies.splice(index, 1)
  769. // 更新hobby字段
  770. this.profile.hobby = currentHobbies.length > 0 ? JSON.stringify(currentHobbies) : ''
  771. uni.showToast({
  772. title: '标签删除成功',
  773. icon: 'success'
  774. })
  775. }
  776. }
  777. })
  778. },
  779. // 点击字段进入编辑模式
  780. startEdit() {
  781. if (!this.isEditing) {
  782. this.isEditing = true
  783. // 提示用户已进入编辑模式
  784. uni.showToast({
  785. title: '已进入编辑模式',
  786. icon: 'none',
  787. duration: 1000
  788. })
  789. }
  790. },
  791. // 启用编辑/保存
  792. enableEdit() {
  793. if (this.isEditing) {
  794. // 保存
  795. this.saveProfile()
  796. } else {
  797. // 进入编辑模式
  798. this.isEditing = true
  799. }
  800. },
  801. // 保存资料
  802. saveProfile(needGoBack = false) {
  803. uni.showLoading({
  804. title: '保存中...'
  805. })
  806. // 准备提交的数据(只包含扩展信息字段)
  807. const submitData = {
  808. userId: this.currentUserId,
  809. realName: this.profile.realName,
  810. idCard: this.profile.idCard,
  811. height: this.profile.height,
  812. weight: this.profile.weight,
  813. star: this.profile.star,
  814. animal: this.profile.animal,
  815. educationLevel: this.profile.educationLevel,
  816. schoolName: this.profile.schoolName,
  817. company: this.profile.company,
  818. jobTitle: this.profile.jobTitle,
  819. salaryRange: this.profile.salaryRange,
  820. maritalStatus: this.profile.maritalStatus,
  821. house: this.profile.house,
  822. car: this.profile.car,
  823. hobby: this.profile.hobby,
  824. privacySalary: this.profile.privacySalary,
  825. privacyPhone: this.profile.privacyPhone
  826. }
  827. uni.request({
  828. url: this.gatewayURL + '/api/user/profile',
  829. method: 'PUT',
  830. data: submitData,
  831. success: (res) => {
  832. uni.hideLoading()
  833. if (res.data && res.data.code === 200) {
  834. uni.showToast({
  835. title: '保存成功',
  836. icon: 'success',
  837. duration: 1500
  838. })
  839. this.isEditing = false
  840. // 重新加载资料
  841. this.loadProfile()
  842. // 如果需要返回,延迟执行返回操作
  843. if (needGoBack) {
  844. setTimeout(() => {
  845. this.performGoBack()
  846. }, 1000)
  847. }
  848. } else {
  849. uni.showToast({
  850. title: res.data?.message || '保存失败',
  851. icon: 'none'
  852. })
  853. }
  854. },
  855. fail: (err) => {
  856. uni.hideLoading()
  857. console.error('保存失败:', err)
  858. uni.showToast({
  859. title: '网络请求失败',
  860. icon: 'none'
  861. })
  862. }
  863. })
  864. },
  865. // 返回上一页
  866. goBack() {
  867. try {
  868. // 如果正在编辑,先提醒保存
  869. if (this.isEditing) {
  870. uni.showModal({
  871. title: '提示',
  872. content: '您正在编辑资料,是否保存后返回?',
  873. showCancel: true,
  874. cancelText: '直接返回',
  875. confirmText: '保存并返回',
  876. success: (res) => {
  877. if (res.confirm) {
  878. // 保存后返回
  879. this.saveProfile(true)
  880. } else {
  881. // 直接返回
  882. this.performGoBack()
  883. }
  884. }
  885. })
  886. } else {
  887. // 直接返回
  888. this.performGoBack()
  889. }
  890. } catch (error) {
  891. console.error('返回操作异常:', error)
  892. // 异常时直接跳转到我的页面
  893. uni.navigateTo({
  894. url: '/pages/mine/index'
  895. })
  896. }
  897. },
  898. // 执行返回操作
  899. performGoBack() {
  900. // 检查页面栈
  901. const pages = getCurrentPages()
  902. console.log('当前页面栈长度:', pages.length)
  903. console.log('页面栈:', pages.map(p => p.route))
  904. if (pages.length > 1) {
  905. // 有上一页,正常返回
  906. uni.navigateBack({
  907. delta: 1,
  908. success: () => {
  909. console.log('返回成功')
  910. },
  911. fail: (err) => {
  912. console.error('返回失败:', err)
  913. // 返回失败时,提示用户并提供选择
  914. uni.showModal({
  915. title: '返回失败',
  916. content: '无法返回上一页,是否跳转到我的页面?',
  917. showCancel: true,
  918. cancelText: '留在此页',
  919. confirmText: '去我的页面',
  920. success: (modalRes) => {
  921. if (modalRes.confirm) {
  922. uni.navigateTo({
  923. url: '/pages/mine/index'
  924. })
  925. }
  926. }
  927. })
  928. }
  929. })
  930. } else {
  931. // 没有上一页,直接跳转到我的页面
  932. console.log('页面栈只有一页,跳转到我的页面')
  933. uni.navigateTo({
  934. url: '/pages/mine/index'
  935. })
  936. }
  937. }
  938. }
  939. }
  940. </script>
  941. <style lang="scss" scoped>
  942. .profile-page {
  943. min-height: 100vh;
  944. background: linear-gradient(180deg, #FF8A9B 0%, #FFB4C0 25%, #FFF0F2 50%, #F8F8F8 100%);
  945. display: flex;
  946. flex-direction: column;
  947. }
  948. /* 顶部导航栏 */
  949. .header {
  950. position: relative;
  951. display: flex;
  952. align-items: center;
  953. justify-content: center;
  954. padding: 25rpx 30rpx;
  955. padding-top: calc(25rpx + env(safe-area-inset-top));
  956. background: linear-gradient(135deg, #FF8A9B 0%, #FFB4C0 100%);
  957. box-shadow: 0 4rpx 20rpx rgba(255, 138, 155, 0.2);
  958. .back-btn {
  959. position: absolute;
  960. left: 30rpx;
  961. width: 70rpx;
  962. height: 70rpx;
  963. display: flex;
  964. align-items: center;
  965. justify-content: center;
  966. background: rgba(255, 255, 255, 0.2);
  967. border-radius: 50%;
  968. .back-icon {
  969. font-size: 44rpx;
  970. color: #FFFFFF;
  971. font-weight: bold;
  972. }
  973. }
  974. .header-title {
  975. font-size: 38rpx;
  976. font-weight: bold;
  977. color: #FFFFFF;
  978. letter-spacing: 2rpx;
  979. }
  980. .edit-btn {
  981. position: absolute;
  982. right: 30rpx;
  983. padding: 12rpx 30rpx;
  984. background: rgba(255, 255, 255, 0.3);
  985. border-radius: 35rpx;
  986. min-width: 100rpx;
  987. display: flex;
  988. align-items: center;
  989. justify-content: center;
  990. .edit-text {
  991. font-size: 28rpx;
  992. color: #FFFFFF;
  993. font-weight: 500;
  994. }
  995. }
  996. }
  997. /* 头像区域 */
  998. .avatar-section {
  999. display: flex;
  1000. flex-direction: column;
  1001. align-items: center;
  1002. padding: 50rpx 0 40rpx;
  1003. .avatar-wrapper {
  1004. position: relative;
  1005. margin-bottom: 25rpx;
  1006. cursor: pointer;
  1007. .avatar {
  1008. width: 180rpx;
  1009. height: 180rpx;
  1010. border-radius: 90rpx;
  1011. border: 6rpx solid #FFFFFF;
  1012. box-shadow: 0 8rpx 30rpx rgba(255, 138, 155, 0.3);
  1013. }
  1014. .avatar-badge {
  1015. position: absolute;
  1016. bottom: 5rpx;
  1017. right: 5rpx;
  1018. width: 50rpx;
  1019. height: 50rpx;
  1020. background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  1021. border-radius: 25rpx;
  1022. display: flex;
  1023. align-items: center;
  1024. justify-content: center;
  1025. border: 4rpx solid #FFFFFF;
  1026. box-shadow: 0 4rpx 15rpx rgba(255, 215, 0, 0.4);
  1027. .vip-icon {
  1028. font-size: 28rpx;
  1029. }
  1030. }
  1031. .avatar-edit-hint {
  1032. position: absolute;
  1033. bottom: 0;
  1034. left: 0;
  1035. right: 0;
  1036. height: 60rpx;
  1037. background: rgba(0, 0, 0, 0.5);
  1038. border-radius: 0 0 90rpx 90rpx;
  1039. display: flex;
  1040. align-items: center;
  1041. justify-content: center;
  1042. .edit-hint-icon {
  1043. font-size: 32rpx;
  1044. color: #FFFFFF;
  1045. }
  1046. }
  1047. }
  1048. .nickname {
  1049. font-size: 40rpx;
  1050. font-weight: bold;
  1051. color: #333333;
  1052. margin-bottom: 12rpx;
  1053. }
  1054. .user-id {
  1055. font-size: 26rpx;
  1056. color: #999999;
  1057. background: rgba(255, 255, 255, 0.8);
  1058. padding: 8rpx 30rpx;
  1059. border-radius: 30rpx;
  1060. }
  1061. }
  1062. /* 编辑提示 */
  1063. .edit-tip {
  1064. margin: 0 30rpx;
  1065. background: linear-gradient(135deg, #E8F5E8 0%, #D4EDDA 100%);
  1066. border-radius: 15rpx;
  1067. padding: 20rpx 25rpx;
  1068. text-align: center;
  1069. border-left: 6rpx solid #28A745;
  1070. .tip-text {
  1071. font-size: 26rpx;
  1072. color: #28A745;
  1073. font-weight: 500;
  1074. }
  1075. }
  1076. /* 滚动内容区域 */
  1077. .content-scroll {
  1078. flex: 1;
  1079. padding: 20rpx 30rpx 0 30rpx;
  1080. box-sizing: border-box;
  1081. }
  1082. /* 各个section */
  1083. .section {
  1084. background-color: #FFFFFF;
  1085. border-radius: 20rpx;
  1086. padding: 30rpx 25rpx;
  1087. margin-bottom: 25rpx;
  1088. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
  1089. width: 100%;
  1090. box-sizing: border-box;
  1091. .section-title {
  1092. font-size: 34rpx;
  1093. font-weight: bold;
  1094. color: #333333;
  1095. margin-bottom: 30rpx;
  1096. padding-bottom: 20rpx;
  1097. padding-left: 30rpx;
  1098. border-bottom: 3rpx solid #F0F0F0;
  1099. display: flex;
  1100. align-items: center;
  1101. position: relative;
  1102. &::before {
  1103. content: '';
  1104. position: absolute;
  1105. left: 5rpx;
  1106. width: 8rpx;
  1107. height: 32rpx;
  1108. background: linear-gradient(135deg, #FF8A9B 0%, #FF6B8A 100%);
  1109. border-radius: 4rpx;
  1110. }
  1111. }
  1112. .info-item {
  1113. display: flex;
  1114. align-items: center;
  1115. justify-content: space-between;
  1116. padding: 30rpx 0;
  1117. padding-left: 30rpx;
  1118. border-bottom: 1rpx solid #F5F5F5;
  1119. min-height: 80rpx;
  1120. position: relative;
  1121. transition: background-color 0.2s;
  1122. &:active {
  1123. background-color: #F8F8F8;
  1124. }
  1125. &:last-child {
  1126. border-bottom: none;
  1127. }
  1128. &.column {
  1129. flex-direction: column;
  1130. align-items: flex-start;
  1131. }
  1132. // 添加右侧编辑提示(只在非编辑模式显示)
  1133. &:not(.editing)::after {
  1134. content: '点击编辑';
  1135. position: absolute;
  1136. right: 30rpx;
  1137. color: #CCCCCC;
  1138. font-size: 22rpx;
  1139. opacity: 0.5;
  1140. pointer-events: none;
  1141. }
  1142. .label {
  1143. font-size: 30rpx;
  1144. color: #333333;
  1145. flex-shrink: 0;
  1146. width: 180rpx;
  1147. font-weight: 500;
  1148. }
  1149. .value {
  1150. flex: 1;
  1151. text-align: right;
  1152. font-size: 30rpx;
  1153. color: #666666;
  1154. padding-left: 20rpx;
  1155. }
  1156. .input {
  1157. flex: 1;
  1158. text-align: right;
  1159. font-size: 30rpx;
  1160. color: #333333;
  1161. padding-left: 20rpx;
  1162. }
  1163. .picker-value {
  1164. flex: 1;
  1165. text-align: right;
  1166. font-size: 30rpx;
  1167. color: #666666;
  1168. padding-left: 20rpx;
  1169. }
  1170. .verify-status {
  1171. margin-left: 15rpx;
  1172. font-size: 22rpx;
  1173. flex-shrink: 0;
  1174. &.verified {
  1175. color: #4CAF50;
  1176. }
  1177. &.unverified {
  1178. color: #999999;
  1179. }
  1180. }
  1181. switch {
  1182. flex-shrink: 0;
  1183. }
  1184. }
  1185. }
  1186. /* 爱好标签 */
  1187. .hobby-tags {
  1188. display: flex;
  1189. flex-wrap: wrap;
  1190. gap: 18rpx;
  1191. margin-top: 20rpx;
  1192. width: 100%;
  1193. .hobby-tag {
  1194. padding: 15rpx 30rpx;
  1195. background: linear-gradient(135deg, #FFE5EC 0%, #FFD0DC 100%);
  1196. border-radius: 35rpx;
  1197. font-size: 26rpx;
  1198. color: #FF6B8A;
  1199. font-weight: 500;
  1200. position: relative;
  1201. display: flex;
  1202. align-items: center;
  1203. transition: all 0.3s;
  1204. &.add {
  1205. border: 2rpx dashed #FF8A9B;
  1206. background: transparent;
  1207. color: #FF8A9B;
  1208. justify-content: center;
  1209. }
  1210. &.deletable {
  1211. padding-right: 50rpx;
  1212. &:active {
  1213. background: linear-gradient(135deg, #FFB8C5 0%, #FFA3B3 100%);
  1214. transform: scale(0.95);
  1215. }
  1216. }
  1217. .delete-icon {
  1218. position: absolute;
  1219. right: 15rpx;
  1220. top: 50%;
  1221. transform: translateY(-50%);
  1222. width: 30rpx;
  1223. height: 30rpx;
  1224. background: rgba(255, 255, 255, 0.8);
  1225. border-radius: 50%;
  1226. display: flex;
  1227. align-items: center;
  1228. justify-content: center;
  1229. font-size: 24rpx;
  1230. color: #FF6B8A;
  1231. font-weight: bold;
  1232. }
  1233. }
  1234. .hobby-empty {
  1235. width: 100%;
  1236. text-align: center;
  1237. padding: 40rpx 0;
  1238. .empty-text {
  1239. font-size: 26rpx;
  1240. color: #999999;
  1241. }
  1242. }
  1243. }
  1244. /* 真实度评分 */
  1245. .authenticity-score {
  1246. display: flex;
  1247. flex-direction: column;
  1248. align-items: center;
  1249. padding: 40rpx 0 20rpx;
  1250. .score-circle {
  1251. width: 200rpx;
  1252. height: 200rpx;
  1253. border-radius: 100rpx;
  1254. background: linear-gradient(135deg, #FF8A9B 0%, #FF6B8A 100%);
  1255. display: flex;
  1256. flex-direction: column;
  1257. align-items: center;
  1258. justify-content: center;
  1259. margin-bottom: 30rpx;
  1260. box-shadow: 0 10rpx 40rpx rgba(255, 107, 138, 0.4);
  1261. position: relative;
  1262. &::before {
  1263. content: '';
  1264. position: absolute;
  1265. width: 220rpx;
  1266. height: 220rpx;
  1267. border-radius: 110rpx;
  1268. border: 2rpx solid rgba(255, 138, 155, 0.3);
  1269. top: -10rpx;
  1270. left: -10rpx;
  1271. }
  1272. .score-number {
  1273. font-size: 68rpx;
  1274. font-weight: bold;
  1275. color: #FFFFFF;
  1276. line-height: 1;
  1277. }
  1278. .score-total {
  1279. font-size: 26rpx;
  1280. color: rgba(255, 255, 255, 0.95);
  1281. margin-top: 5rpx;
  1282. }
  1283. }
  1284. .score-tips {
  1285. background: rgba(255, 138, 155, 0.1);
  1286. padding: 15rpx 30rpx;
  1287. border-radius: 30rpx;
  1288. .tip-text {
  1289. font-size: 24rpx;
  1290. color: #FF6B8A;
  1291. text-align: center;
  1292. }
  1293. }
  1294. }
  1295. .bottom-placeholder {
  1296. height: 80rpx;
  1297. }
  1298. /* 标签选择弹窗 */
  1299. .hobby-modal {
  1300. position: fixed;
  1301. top: 0;
  1302. left: 0;
  1303. right: 0;
  1304. bottom: 0;
  1305. background: rgba(0, 0, 0, 0.6);
  1306. display: flex;
  1307. align-items: center;
  1308. justify-content: center;
  1309. z-index: 9999;
  1310. .modal-content {
  1311. width: 90%;
  1312. max-height: 80vh;
  1313. background: #FFFFFF;
  1314. border-radius: 30rpx;
  1315. overflow: hidden;
  1316. display: flex;
  1317. flex-direction: column;
  1318. }
  1319. .modal-header {
  1320. display: flex;
  1321. align-items: center;
  1322. justify-content: space-between;
  1323. padding: 40rpx 30rpx 20rpx;
  1324. background: linear-gradient(135deg, #FF8A9B 0%, #FFB4C0 100%);
  1325. .modal-title {
  1326. font-size: 32rpx;
  1327. font-weight: bold;
  1328. color: #FFFFFF;
  1329. }
  1330. .close-btn {
  1331. width: 60rpx;
  1332. height: 60rpx;
  1333. display: flex;
  1334. align-items: center;
  1335. justify-content: center;
  1336. font-size: 40rpx;
  1337. color: #FFFFFF;
  1338. background: rgba(255, 255, 255, 0.2);
  1339. border-radius: 30rpx;
  1340. }
  1341. }
  1342. .modal-body {
  1343. flex: 1;
  1344. padding: 30rpx;
  1345. max-height: 60vh;
  1346. }
  1347. .hobby-category {
  1348. margin-bottom: 40rpx;
  1349. &:last-child {
  1350. margin-bottom: 0;
  1351. }
  1352. .category-title {
  1353. display: flex;
  1354. align-items: center;
  1355. margin-bottom: 20rpx;
  1356. .category-icon {
  1357. font-size: 36rpx;
  1358. margin-right: 15rpx;
  1359. }
  1360. .category-name {
  1361. font-size: 28rpx;
  1362. font-weight: bold;
  1363. color: #333333;
  1364. }
  1365. }
  1366. .category-tags {
  1367. display: flex;
  1368. flex-wrap: wrap;
  1369. gap: 15rpx;
  1370. .preset-tag {
  1371. padding: 12rpx 25rpx;
  1372. background: #F5F5F5;
  1373. border-radius: 30rpx;
  1374. font-size: 26rpx;
  1375. color: #666666;
  1376. position: relative;
  1377. transition: all 0.3s;
  1378. &.selected {
  1379. background: linear-gradient(135deg, #FF8A9B 0%, #FF6B8A 100%);
  1380. color: #FFFFFF;
  1381. padding-right: 45rpx;
  1382. }
  1383. &:active {
  1384. transform: scale(0.95);
  1385. }
  1386. .check-icon {
  1387. position: absolute;
  1388. right: 10rpx;
  1389. top: 50%;
  1390. transform: translateY(-50%);
  1391. font-size: 20rpx;
  1392. font-weight: bold;
  1393. }
  1394. }
  1395. }
  1396. }
  1397. .custom-input-section {
  1398. margin-top: 20rpx;
  1399. padding-top: 30rpx;
  1400. border-top: 1rpx solid #F0F0F0;
  1401. .input-wrapper {
  1402. display: flex;
  1403. align-items: center;
  1404. gap: 20rpx;
  1405. .custom-input {
  1406. flex: 1;
  1407. padding: 20rpx 25rpx;
  1408. background: #F8F8F8;
  1409. border-radius: 25rpx;
  1410. font-size: 26rpx;
  1411. border: 2rpx solid transparent;
  1412. &:focus {
  1413. border-color: #FF8A9B;
  1414. background: #FFFFFF;
  1415. }
  1416. }
  1417. .add-custom-btn {
  1418. padding: 20rpx 30rpx;
  1419. background: linear-gradient(135deg, #FF8A9B 0%, #FF6B8A 100%);
  1420. border-radius: 25rpx;
  1421. .add-text {
  1422. font-size: 26rpx;
  1423. color: #FFFFFF;
  1424. font-weight: 500;
  1425. }
  1426. }
  1427. }
  1428. }
  1429. .modal-footer {
  1430. display: flex;
  1431. align-items: center;
  1432. justify-content: space-between;
  1433. padding: 30rpx;
  1434. background: #F8F8F8;
  1435. .selected-count {
  1436. font-size: 26rpx;
  1437. color: #666666;
  1438. }
  1439. .done-btn {
  1440. padding: 20rpx 40rpx;
  1441. background: linear-gradient(135deg, #FF8A9B 0%, #FF6B8A 100%);
  1442. border-radius: 30rpx;
  1443. .done-text {
  1444. font-size: 28rpx;
  1445. color: #FFFFFF;
  1446. font-weight: bold;
  1447. }
  1448. }
  1449. }
  1450. }
  1451. </style>