index.vue 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631
  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. gender: this.profile.gender,
  814. birthDate: this.profile.birthDate,
  815. star: this.profile.star,
  816. animal: this.profile.animal,
  817. educationLevel: this.profile.educationLevel,
  818. schoolName: this.profile.schoolName,
  819. company: this.profile.company,
  820. jobTitle: this.profile.jobTitle,
  821. salaryRange: this.profile.salaryRange,
  822. maritalStatus: this.profile.maritalStatus,
  823. house: this.profile.house,
  824. car: this.profile.car,
  825. hobby: this.profile.hobby,
  826. privacySalary: this.profile.privacySalary,
  827. privacyPhone: this.profile.privacyPhone
  828. }
  829. uni.request({
  830. url: this.gatewayURL + '/api/user/profile',
  831. method: 'PUT',
  832. data: submitData,
  833. success: (res) => {
  834. uni.hideLoading()
  835. if (res.data && res.data.code === 200) {
  836. uni.showToast({
  837. title: '保存成功',
  838. icon: 'success',
  839. duration: 1500
  840. })
  841. this.isEditing = false
  842. // 重新加载资料
  843. this.loadProfile()
  844. // 如果需要返回,延迟执行返回操作
  845. if (needGoBack) {
  846. setTimeout(() => {
  847. this.performGoBack()
  848. }, 1000)
  849. }
  850. } else {
  851. uni.showToast({
  852. title: res.data?.message || '保存失败',
  853. icon: 'none'
  854. })
  855. }
  856. },
  857. fail: (err) => {
  858. uni.hideLoading()
  859. console.error('保存失败:', err)
  860. uni.showToast({
  861. title: '网络请求失败',
  862. icon: 'none'
  863. })
  864. }
  865. })
  866. },
  867. // 返回上一页
  868. goBack() {
  869. try {
  870. // 如果正在编辑,先提醒保存
  871. if (this.isEditing) {
  872. uni.showModal({
  873. title: '提示',
  874. content: '您正在编辑资料,是否保存后返回?',
  875. showCancel: true,
  876. cancelText: '直接返回',
  877. confirmText: '保存并返回',
  878. success: (res) => {
  879. if (res.confirm) {
  880. // 保存后返回
  881. this.saveProfile(true)
  882. } else {
  883. // 直接返回
  884. this.performGoBack()
  885. }
  886. }
  887. })
  888. } else {
  889. // 直接返回
  890. this.performGoBack()
  891. }
  892. } catch (error) {
  893. console.error('返回操作异常:', error)
  894. // 异常时直接跳转到我的页面
  895. uni.navigateTo({
  896. url: '/pages/mine/index'
  897. })
  898. }
  899. },
  900. // 执行返回操作
  901. performGoBack() {
  902. // 检查页面栈
  903. const pages = getCurrentPages()
  904. console.log('当前页面栈长度:', pages.length)
  905. console.log('页面栈:', pages.map(p => p.route))
  906. if (pages.length > 1) {
  907. // 有上一页,正常返回
  908. uni.navigateBack({
  909. delta: 1,
  910. success: () => {
  911. console.log('返回成功')
  912. },
  913. fail: (err) => {
  914. console.error('返回失败:', err)
  915. // 返回失败时,提示用户并提供选择
  916. uni.showModal({
  917. title: '返回失败',
  918. content: '无法返回上一页,是否跳转到我的页面?',
  919. showCancel: true,
  920. cancelText: '留在此页',
  921. confirmText: '去我的页面',
  922. success: (modalRes) => {
  923. if (modalRes.confirm) {
  924. uni.navigateTo({
  925. url: '/pages/mine/index'
  926. })
  927. }
  928. }
  929. })
  930. }
  931. })
  932. } else {
  933. // 没有上一页,直接跳转到我的页面
  934. console.log('页面栈只有一页,跳转到我的页面')
  935. uni.navigateTo({
  936. url: '/pages/mine/index'
  937. })
  938. }
  939. }
  940. }
  941. }
  942. </script>
  943. <style lang="scss" scoped>
  944. .profile-page {
  945. min-height: 100vh;
  946. background: linear-gradient(180deg, #FF8A9B 0%, #FFB4C0 25%, #FFF0F2 50%, #F8F8F8 100%);
  947. display: flex;
  948. flex-direction: column;
  949. }
  950. /* 顶部导航栏 */
  951. .header {
  952. position: relative;
  953. display: flex;
  954. align-items: center;
  955. justify-content: center;
  956. padding: 25rpx 30rpx;
  957. padding-top: calc(25rpx + env(safe-area-inset-top));
  958. background: linear-gradient(135deg, #FF8A9B 0%, #FFB4C0 100%);
  959. box-shadow: 0 4rpx 20rpx rgba(255, 138, 155, 0.2);
  960. .back-btn {
  961. position: absolute;
  962. left: 30rpx;
  963. width: 70rpx;
  964. height: 70rpx;
  965. display: flex;
  966. align-items: center;
  967. justify-content: center;
  968. background: rgba(255, 255, 255, 0.2);
  969. border-radius: 50%;
  970. .back-icon {
  971. font-size: 44rpx;
  972. color: #FFFFFF;
  973. font-weight: bold;
  974. }
  975. }
  976. .header-title {
  977. font-size: 38rpx;
  978. font-weight: bold;
  979. color: #FFFFFF;
  980. letter-spacing: 2rpx;
  981. }
  982. .edit-btn {
  983. position: absolute;
  984. right: 30rpx;
  985. padding: 12rpx 30rpx;
  986. background: rgba(255, 255, 255, 0.3);
  987. border-radius: 35rpx;
  988. min-width: 100rpx;
  989. display: flex;
  990. align-items: center;
  991. justify-content: center;
  992. .edit-text {
  993. font-size: 28rpx;
  994. color: #FFFFFF;
  995. font-weight: 500;
  996. }
  997. }
  998. }
  999. /* 头像区域 */
  1000. .avatar-section {
  1001. display: flex;
  1002. flex-direction: column;
  1003. align-items: center;
  1004. padding: 50rpx 0 40rpx;
  1005. .avatar-wrapper {
  1006. position: relative;
  1007. margin-bottom: 25rpx;
  1008. cursor: pointer;
  1009. .avatar {
  1010. width: 180rpx;
  1011. height: 180rpx;
  1012. border-radius: 90rpx;
  1013. border: 6rpx solid #FFFFFF;
  1014. box-shadow: 0 8rpx 30rpx rgba(255, 138, 155, 0.3);
  1015. }
  1016. .avatar-badge {
  1017. position: absolute;
  1018. bottom: 5rpx;
  1019. right: 5rpx;
  1020. width: 50rpx;
  1021. height: 50rpx;
  1022. background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  1023. border-radius: 25rpx;
  1024. display: flex;
  1025. align-items: center;
  1026. justify-content: center;
  1027. border: 4rpx solid #FFFFFF;
  1028. box-shadow: 0 4rpx 15rpx rgba(255, 215, 0, 0.4);
  1029. .vip-icon {
  1030. font-size: 28rpx;
  1031. }
  1032. }
  1033. .avatar-edit-hint {
  1034. position: absolute;
  1035. bottom: 0;
  1036. left: 0;
  1037. right: 0;
  1038. height: 60rpx;
  1039. background: rgba(0, 0, 0, 0.5);
  1040. border-radius: 0 0 90rpx 90rpx;
  1041. display: flex;
  1042. align-items: center;
  1043. justify-content: center;
  1044. .edit-hint-icon {
  1045. font-size: 32rpx;
  1046. color: #FFFFFF;
  1047. }
  1048. }
  1049. }
  1050. .nickname {
  1051. font-size: 40rpx;
  1052. font-weight: bold;
  1053. color: #333333;
  1054. margin-bottom: 12rpx;
  1055. }
  1056. .user-id {
  1057. font-size: 26rpx;
  1058. color: #999999;
  1059. background: rgba(255, 255, 255, 0.8);
  1060. padding: 8rpx 30rpx;
  1061. border-radius: 30rpx;
  1062. }
  1063. }
  1064. /* 编辑提示 */
  1065. .edit-tip {
  1066. margin: 0 30rpx;
  1067. background: linear-gradient(135deg, #E8F5E8 0%, #D4EDDA 100%);
  1068. border-radius: 15rpx;
  1069. padding: 20rpx 25rpx;
  1070. text-align: center;
  1071. border-left: 6rpx solid #28A745;
  1072. .tip-text {
  1073. font-size: 26rpx;
  1074. color: #28A745;
  1075. font-weight: 500;
  1076. }
  1077. }
  1078. /* 滚动内容区域 */
  1079. .content-scroll {
  1080. flex: 1;
  1081. padding: 20rpx 30rpx 0 30rpx;
  1082. box-sizing: border-box;
  1083. }
  1084. /* 各个section */
  1085. .section {
  1086. background-color: #FFFFFF;
  1087. border-radius: 20rpx;
  1088. padding: 30rpx 25rpx;
  1089. margin-bottom: 25rpx;
  1090. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
  1091. width: 100%;
  1092. box-sizing: border-box;
  1093. .section-title {
  1094. font-size: 34rpx;
  1095. font-weight: bold;
  1096. color: #333333;
  1097. margin-bottom: 30rpx;
  1098. padding-bottom: 20rpx;
  1099. padding-left: 30rpx;
  1100. border-bottom: 3rpx solid #F0F0F0;
  1101. display: flex;
  1102. align-items: center;
  1103. position: relative;
  1104. &::before {
  1105. content: '';
  1106. position: absolute;
  1107. left: 5rpx;
  1108. width: 8rpx;
  1109. height: 32rpx;
  1110. background: linear-gradient(135deg, #FF8A9B 0%, #FF6B8A 100%);
  1111. border-radius: 4rpx;
  1112. }
  1113. }
  1114. .info-item {
  1115. display: flex;
  1116. align-items: center;
  1117. justify-content: space-between;
  1118. padding: 30rpx 0;
  1119. padding-left: 30rpx;
  1120. border-bottom: 1rpx solid #F5F5F5;
  1121. min-height: 80rpx;
  1122. position: relative;
  1123. transition: background-color 0.2s;
  1124. &:active {
  1125. background-color: #F8F8F8;
  1126. }
  1127. &:last-child {
  1128. border-bottom: none;
  1129. }
  1130. &.column {
  1131. flex-direction: column;
  1132. align-items: flex-start;
  1133. }
  1134. // 添加右侧编辑提示(只在非编辑模式显示)
  1135. &:not(.editing)::after {
  1136. content: '点击编辑';
  1137. position: absolute;
  1138. right: 30rpx;
  1139. color: #CCCCCC;
  1140. font-size: 22rpx;
  1141. opacity: 0.5;
  1142. pointer-events: none;
  1143. }
  1144. .label {
  1145. font-size: 30rpx;
  1146. color: #333333;
  1147. flex-shrink: 0;
  1148. width: 180rpx;
  1149. font-weight: 500;
  1150. }
  1151. .value {
  1152. flex: 1;
  1153. text-align: right;
  1154. font-size: 30rpx;
  1155. color: #666666;
  1156. padding-left: 20rpx;
  1157. }
  1158. .input {
  1159. flex: 1;
  1160. text-align: right;
  1161. font-size: 30rpx;
  1162. color: #333333;
  1163. padding-left: 20rpx;
  1164. }
  1165. .picker-value {
  1166. flex: 1;
  1167. text-align: right;
  1168. font-size: 30rpx;
  1169. color: #666666;
  1170. padding-left: 20rpx;
  1171. }
  1172. .verify-status {
  1173. margin-left: 15rpx;
  1174. font-size: 22rpx;
  1175. flex-shrink: 0;
  1176. &.verified {
  1177. color: #4CAF50;
  1178. }
  1179. &.unverified {
  1180. color: #999999;
  1181. }
  1182. }
  1183. switch {
  1184. flex-shrink: 0;
  1185. }
  1186. }
  1187. }
  1188. /* 爱好标签 */
  1189. .hobby-tags {
  1190. display: flex;
  1191. flex-wrap: wrap;
  1192. gap: 18rpx;
  1193. margin-top: 20rpx;
  1194. width: 100%;
  1195. .hobby-tag {
  1196. padding: 15rpx 30rpx;
  1197. background: linear-gradient(135deg, #FFE5EC 0%, #FFD0DC 100%);
  1198. border-radius: 35rpx;
  1199. font-size: 26rpx;
  1200. color: #FF6B8A;
  1201. font-weight: 500;
  1202. position: relative;
  1203. display: flex;
  1204. align-items: center;
  1205. transition: all 0.3s;
  1206. &.add {
  1207. border: 2rpx dashed #FF8A9B;
  1208. background: transparent;
  1209. color: #FF8A9B;
  1210. justify-content: center;
  1211. }
  1212. &.deletable {
  1213. padding-right: 50rpx;
  1214. &:active {
  1215. background: linear-gradient(135deg, #FFB8C5 0%, #FFA3B3 100%);
  1216. transform: scale(0.95);
  1217. }
  1218. }
  1219. .delete-icon {
  1220. position: absolute;
  1221. right: 15rpx;
  1222. top: 50%;
  1223. transform: translateY(-50%);
  1224. width: 30rpx;
  1225. height: 30rpx;
  1226. background: rgba(255, 255, 255, 0.8);
  1227. border-radius: 50%;
  1228. display: flex;
  1229. align-items: center;
  1230. justify-content: center;
  1231. font-size: 24rpx;
  1232. color: #FF6B8A;
  1233. font-weight: bold;
  1234. }
  1235. }
  1236. .hobby-empty {
  1237. width: 100%;
  1238. text-align: center;
  1239. padding: 40rpx 0;
  1240. .empty-text {
  1241. font-size: 26rpx;
  1242. color: #999999;
  1243. }
  1244. }
  1245. }
  1246. /* 真实度评分 */
  1247. .authenticity-score {
  1248. display: flex;
  1249. flex-direction: column;
  1250. align-items: center;
  1251. padding: 40rpx 0 20rpx;
  1252. .score-circle {
  1253. width: 200rpx;
  1254. height: 200rpx;
  1255. border-radius: 100rpx;
  1256. background: linear-gradient(135deg, #FF8A9B 0%, #FF6B8A 100%);
  1257. display: flex;
  1258. flex-direction: column;
  1259. align-items: center;
  1260. justify-content: center;
  1261. margin-bottom: 30rpx;
  1262. box-shadow: 0 10rpx 40rpx rgba(255, 107, 138, 0.4);
  1263. position: relative;
  1264. &::before {
  1265. content: '';
  1266. position: absolute;
  1267. width: 220rpx;
  1268. height: 220rpx;
  1269. border-radius: 110rpx;
  1270. border: 2rpx solid rgba(255, 138, 155, 0.3);
  1271. top: -10rpx;
  1272. left: -10rpx;
  1273. }
  1274. .score-number {
  1275. font-size: 68rpx;
  1276. font-weight: bold;
  1277. color: #FFFFFF;
  1278. line-height: 1;
  1279. }
  1280. .score-total {
  1281. font-size: 26rpx;
  1282. color: rgba(255, 255, 255, 0.95);
  1283. margin-top: 5rpx;
  1284. }
  1285. }
  1286. .score-tips {
  1287. background: rgba(255, 138, 155, 0.1);
  1288. padding: 15rpx 30rpx;
  1289. border-radius: 30rpx;
  1290. .tip-text {
  1291. font-size: 24rpx;
  1292. color: #FF6B8A;
  1293. text-align: center;
  1294. }
  1295. }
  1296. }
  1297. .bottom-placeholder {
  1298. height: 80rpx;
  1299. }
  1300. /* 标签选择弹窗 */
  1301. .hobby-modal {
  1302. position: fixed;
  1303. top: 0;
  1304. left: 0;
  1305. right: 0;
  1306. bottom: 0;
  1307. background: rgba(0, 0, 0, 0.6);
  1308. display: flex;
  1309. align-items: center;
  1310. justify-content: center;
  1311. z-index: 9999;
  1312. .modal-content {
  1313. width: 90%;
  1314. max-height: 80vh;
  1315. background: #FFFFFF;
  1316. border-radius: 30rpx;
  1317. overflow: hidden;
  1318. display: flex;
  1319. flex-direction: column;
  1320. }
  1321. .modal-header {
  1322. display: flex;
  1323. align-items: center;
  1324. justify-content: space-between;
  1325. padding: 40rpx 30rpx 20rpx;
  1326. background: linear-gradient(135deg, #FF8A9B 0%, #FFB4C0 100%);
  1327. .modal-title {
  1328. font-size: 32rpx;
  1329. font-weight: bold;
  1330. color: #FFFFFF;
  1331. }
  1332. .close-btn {
  1333. width: 60rpx;
  1334. height: 60rpx;
  1335. display: flex;
  1336. align-items: center;
  1337. justify-content: center;
  1338. font-size: 40rpx;
  1339. color: #FFFFFF;
  1340. background: rgba(255, 255, 255, 0.2);
  1341. border-radius: 30rpx;
  1342. }
  1343. }
  1344. .modal-body {
  1345. flex: 1;
  1346. padding: 30rpx;
  1347. max-height: 60vh;
  1348. }
  1349. .hobby-category {
  1350. margin-bottom: 40rpx;
  1351. &:last-child {
  1352. margin-bottom: 0;
  1353. }
  1354. .category-title {
  1355. display: flex;
  1356. align-items: center;
  1357. margin-bottom: 20rpx;
  1358. .category-icon {
  1359. font-size: 36rpx;
  1360. margin-right: 15rpx;
  1361. }
  1362. .category-name {
  1363. font-size: 28rpx;
  1364. font-weight: bold;
  1365. color: #333333;
  1366. }
  1367. }
  1368. .category-tags {
  1369. display: flex;
  1370. flex-wrap: wrap;
  1371. gap: 15rpx;
  1372. .preset-tag {
  1373. padding: 12rpx 25rpx;
  1374. background: #F5F5F5;
  1375. border-radius: 30rpx;
  1376. font-size: 26rpx;
  1377. color: #666666;
  1378. position: relative;
  1379. transition: all 0.3s;
  1380. &.selected {
  1381. background: linear-gradient(135deg, #FF8A9B 0%, #FF6B8A 100%);
  1382. color: #FFFFFF;
  1383. padding-right: 45rpx;
  1384. }
  1385. &:active {
  1386. transform: scale(0.95);
  1387. }
  1388. .check-icon {
  1389. position: absolute;
  1390. right: 10rpx;
  1391. top: 50%;
  1392. transform: translateY(-50%);
  1393. font-size: 20rpx;
  1394. font-weight: bold;
  1395. }
  1396. }
  1397. }
  1398. }
  1399. .custom-input-section {
  1400. margin-top: 20rpx;
  1401. padding-top: 30rpx;
  1402. border-top: 1rpx solid #F0F0F0;
  1403. .input-wrapper {
  1404. display: flex;
  1405. align-items: center;
  1406. gap: 20rpx;
  1407. .custom-input {
  1408. flex: 1;
  1409. padding: 20rpx 25rpx;
  1410. background: #F8F8F8;
  1411. border-radius: 25rpx;
  1412. font-size: 26rpx;
  1413. border: 2rpx solid transparent;
  1414. &:focus {
  1415. border-color: #FF8A9B;
  1416. background: #FFFFFF;
  1417. }
  1418. }
  1419. .add-custom-btn {
  1420. padding: 20rpx 30rpx;
  1421. background: linear-gradient(135deg, #FF8A9B 0%, #FF6B8A 100%);
  1422. border-radius: 25rpx;
  1423. .add-text {
  1424. font-size: 26rpx;
  1425. color: #FFFFFF;
  1426. font-weight: 500;
  1427. }
  1428. }
  1429. }
  1430. }
  1431. .modal-footer {
  1432. display: flex;
  1433. align-items: center;
  1434. justify-content: space-between;
  1435. padding: 30rpx;
  1436. background: #F8F8F8;
  1437. .selected-count {
  1438. font-size: 26rpx;
  1439. color: #666666;
  1440. }
  1441. .done-btn {
  1442. padding: 20rpx 40rpx;
  1443. background: linear-gradient(135deg, #FF8A9B 0%, #FF6B8A 100%);
  1444. border-radius: 30rpx;
  1445. .done-text {
  1446. font-size: 28rpx;
  1447. color: #FFFFFF;
  1448. font-weight: bold;
  1449. }
  1450. }
  1451. }
  1452. }
  1453. </style>