my.uvue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. <template>
  2. <view class="page-container">
  3. <!-- 1. 用户信息头部 -->
  4. <view class="user-header">
  5. <image :src="userInfo['avatar']" class="avatar" mode="aspectFill" />
  6. <view class="user-info">
  7. <text class="username">
  8. {{ userInfo['name'] }}
  9. </text>
  10. <view class="badge-row">
  11. <text class="badge vip">
  12. 王牌
  13. </text>
  14. </view>
  15. </view>
  16. <view class="header-actions">
  17. <view class="action-item" @click="contactService">
  18. <u-icon name="customer-service" size="18" color="#666">
  19. </u-icon>
  20. <text>
  21. 客服
  22. </text>
  23. </view>
  24. <view class="action-item" @click="openSettings">
  25. <u-icon name="setting" size="18" color="#666">
  26. </u-icon>
  27. <text>
  28. 设置
  29. </text>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 2. 等级卡片 -->
  34. <view class="level-card">
  35. <view class="level-main">
  36. <text class="level-title">
  37. V{{ userInfo['level'] }}
  38. </text>
  39. <text class="level-sub">
  40. 成长值 {{ userInfo['growthValue'] }}
  41. </text>
  42. </view>
  43. <view class="level-progress">
  44. <text class="progress-text">
  45. 还差{{ userInfo['nextLevelGap'] }}成长值可升至V{{ userInfo['nextLevel'] }}
  46. </text>
  47. <view class="progress-bar">
  48. <view class="progress-fill" :style="{ width: progressWidth }">
  49. </view>
  50. </view>
  51. <view class="progress-labels">
  52. <text>
  53. V1
  54. </text>
  55. <text>
  56. V2
  57. </text>
  58. </view>
  59. </view>
  60. <view class="level-badge" @click="viewLevelDetail">
  61. <u-icon type="vip" size="40" color="#ffffff">
  62. </u-icon>
  63. <text>
  64. 我的等级
  65. </text>
  66. </view>
  67. </view>
  68. <!-- 3. 我的档案 -->
  69. <view class="section-title">
  70. 我的档案
  71. </view>
  72. <view class="profile-stats">
  73. <view class="stat-item">
  74. <text class="stat-value">
  75. 60
  76. </text>
  77. <text class="stat-label">
  78. 签约
  79. </text>
  80. </view>
  81. <view class="stat-item">
  82. <text class="stat-value">
  83. 21
  84. </text>
  85. <text class="stat-label">
  86. 解约
  87. </text>
  88. </view>
  89. <view class="stat-item">
  90. <u-icon type="location" size="24" color="#666">
  91. </u-icon>
  92. <text class="stat-label">
  93. 异地签到
  94. </text>
  95. </view>
  96. <view class="stat-item">
  97. <u-icon type="cart" size="24" color="#666">
  98. </u-icon>
  99. <text class="stat-label">
  100. 购买物料
  101. </text>
  102. </view>
  103. </view>
  104. <!-- 4. 我的工具 -->
  105. <view class="section-title">
  106. 我的工具
  107. </view>
  108. <view class="tools-grid">
  109. <view class="tool-item" v-for="(tool, idx) in tools" :key="idx" @click="handleToolClick(tool)">
  110. <u-icon :type="tool.icon" size="32" :color="tool.color">
  111. </u-icon>
  112. <text class="tool-name">
  113. {{ tool.name }}
  114. </text>
  115. </view>
  116. </view>
  117. <!-- 5. 推广卡片 -->
  118. <view class="promo-cards">
  119. <!-- 邀请好友 -->
  120. <view class="promo-card invite" @click="inviteFriends">
  121. <view class="promo-content">
  122. <text class="promo-title">
  123. 邀请好友赚钱
  124. </text>
  125. <text class="promo-subtitle">
  126. 单次最高可奖200元
  127. </text>
  128. </view>
  129. <u-icon type="gift" size="40" color="#ffd700">
  130. </u-icon>
  131. </view>
  132. <!-- 我的团队 -->
  133. <view class="promo-card team" @click="viewTeam">
  134. <view class="promo-content">
  135. <text class="promo-title">
  136. 我的团队
  137. </text>
  138. <text class="promo-subtitle">
  139. 团队成员100人
  140. </text>
  141. </view>
  142. <u-icon type="person" size="40" color="#4a90e2">
  143. </u-icon>
  144. </view>
  145. </view>
  146. <!-- 6. 城市合伙人 banner -->
  147. <view class="partner-banner" @click="joinPartner">
  148. <view class="partner-content">
  149. <text class="partner-title">
  150. 寻找城市合伙人
  151. </text>
  152. <text class="partner-subtitle">
  153. 全新盈利模式助你创业
  154. </text>
  155. </view>
  156. <view class="partner-icon">
  157. <u-icon type="person" size="50" color="#ffffff">
  158. </u-icon>
  159. <u-icon type="person" size="30" color="#ffffff" style="margin-left: -20rpx;">
  160. </u-icon>
  161. </view>
  162. </view>
  163. </view>
  164. </template>
  165. <script setup lang="ts">
  166. import { ref, reactive } from 'vue';
  167. // --- 用户信息 ---
  168. type UserInfo = {
  169. name : string;
  170. avatar : string;
  171. level : number;
  172. growthValue : number;
  173. nextLevel : number;
  174. nextLevelGap : number;
  175. progressPercent : number;
  176. }
  177. const userInfo = reactive<UserInfo>({
  178. name: '刘大锤',
  179. avatar: 'https://via.placeholder.com/100x100/4a90e2/ffffff?text=LD', // 替换为实际头像
  180. level: 30,
  181. growthValue: 50,
  182. nextLevel: 2,
  183. nextLevelGap: 15,
  184. progressPercent: 75 // (50 / (50+15)) * 100 ≈ 75%
  185. });
  186. // computed helpers to satisfy UTS inference rules
  187. // convert percent to a fixed rpx width (assuming 750rpx full width)
  188. const progressWidth = computed(() => `${userInfo.progressPercent * 7.5}rpx`);
  189. // --- 工具列表 ---
  190. type ToolItem = {
  191. name : string;
  192. icon : string;
  193. color : string;
  194. };
  195. // avoid generic parameter on ref which earlier triggered an "interface does not
  196. // have constructors" error; cast the initial value instead.
  197. const tools = ref([
  198. { name: '学习园地', icon: 'book', color: '#ff9900' },
  199. { name: '问题反馈', icon: 'chat', color: '#52c41a' },
  200. { name: '定制优惠', icon: 'wallet', color: '#1890ff' },
  201. { name: 'VIP俱乐部', icon: 'vip', color: '#faad14' }
  202. ] as ToolItem[]);
  203. // --- 方法 ---
  204. const contactService = () => {
  205. uni.showToast({ title: '联系客服', icon: 'none' });
  206. };
  207. const openSettings = () => {
  208. uni.navigateTo({
  209. url: '/pages/myEdit/setting'
  210. });
  211. };
  212. const viewLevelDetail = () => {
  213. uni.showToast({ title: '查看等级详情', icon: 'none' });
  214. };
  215. const handleToolClick = (tool : ToolItem) => {
  216. uni.showToast({ title: `点击${tool.name}`, icon: 'none' });
  217. };
  218. const inviteFriends = () => {
  219. uni.showModal({
  220. title: '邀请好友',
  221. content: '分享链接邀请好友加入,单次最高可获奖励200元!',
  222. success: (res) => {
  223. if (res.confirm) {
  224. uni.showToast({ title: '已生成邀请链接', icon: 'success' });
  225. }
  226. }
  227. });
  228. };
  229. const viewTeam = () => {
  230. uni.showToast({ title: '查看团队成员', icon: 'none' });
  231. };
  232. const joinPartner = () => {
  233. uni.showModal({
  234. title: '城市合伙人',
  235. content: '全新盈利模式助你创业,立即申请成为城市合伙人!',
  236. success: (res) => {
  237. if (res.confirm) {
  238. uni.showToast({ title: '申请已提交', icon: 'success' });
  239. }
  240. }
  241. });
  242. };
  243. </script>
  244. <style scoped>
  245. /*
  246. UniApp X 默认 page 是 flex-direction: column
  247. 所以 .page-container 会自动垂直排列子元素
  248. */
  249. .page-container {
  250. background-color: #f5f6f8;
  251. /* min-height: 100vh unsupported */
  252. min-height: 1000rpx;
  253. /* width: 100%; default block behavior */
  254. box-sizing: border-box;
  255. padding: 20rpx;
  256. /* gap: 20rpx; */
  257. /* 各模块间间距 */
  258. }
  259. /* --- 用户头部 --- */
  260. .user-header {
  261. display: flex;
  262. flex-direction: row;
  263. align-items: center;
  264. /* gap: 20rpx; */
  265. padding: 20rpx;
  266. background: #ffffff;
  267. border-radius: 16rpx;
  268. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
  269. }
  270. .avatar {
  271. width: 100rpx;
  272. height: 100rpx;
  273. border-radius: 50rpx;
  274. border: 2rpx solid #eee;
  275. }
  276. .user-info {
  277. flex: 1;
  278. display: flex;
  279. flex-direction: column;
  280. /* */
  281. }
  282. .username {
  283. font-size: 32rpx;
  284. font-weight: bold;
  285. color: #333;
  286. }
  287. .badge-row {
  288. display: flex;
  289. flex-direction: row;
  290. /* gap: 10rpx; */
  291. }
  292. .badge {
  293. font-size: 22rpx;
  294. padding: 4rpx 12rpx;
  295. border-radius: 20rpx;
  296. font-weight: bold;
  297. }
  298. .badge.vip {
  299. /* background: linear-gradient(90deg, #4a90e2, #67b26f); */
  300. color: #ffffff;
  301. }
  302. .header-actions {
  303. display: flex;
  304. flex-direction: row;
  305. /* gap: 30rpx; */
  306. }
  307. .action-item {
  308. display: flex;
  309. flex-direction: column;
  310. align-items: center;
  311. /* gap: 4rpx; unsupported */
  312. font-size: 22rpx;
  313. color: #666;
  314. }
  315. /* --- 等级卡片 --- */
  316. .level-card {
  317. /* background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); */
  318. border-radius: 16rpx;
  319. padding: 30rpx;
  320. color: #ffffff;
  321. position: relative;
  322. overflow: hidden;
  323. }
  324. .level-main {
  325. display: flex;
  326. flex-direction: row;
  327. align-items: flex-start;
  328. /* baseline unsupported */
  329. /* gap: 15rpx; not supported by uvue */
  330. margin-bottom: 20rpx;
  331. }
  332. .level-title {
  333. font-size: 48rpx;
  334. font-weight: bold;
  335. }
  336. .level-sub {
  337. font-size: 28rpx;
  338. opacity: 0.9;
  339. }
  340. .level-progress {
  341. margin-bottom: 20rpx;
  342. }
  343. .progress-text {
  344. font-size: 24rpx;
  345. opacity: 0.8;
  346. margin-bottom: 10rpx;
  347. /* display:block removed; inline text is fine */
  348. }
  349. .progress-bar {
  350. /* width: 100%; */
  351. /* 全宽默认,无需指定百分比 */
  352. height: 12rpx;
  353. background: rgba(255, 255, 255, 0.3);
  354. border-radius: 6rpx;
  355. overflow: hidden;
  356. margin-bottom: 8rpx;
  357. }
  358. .progress-fill {
  359. /* 使用与父容器相同的固定高度 */
  360. height: 12rpx;
  361. background: #ffffff;
  362. border-radius: 6rpx;
  363. transition: width 0.3s ease;
  364. }
  365. .progress-labels {
  366. display: flex;
  367. flex-direction: row;
  368. justify-content: space-between;
  369. font-size: 22rpx;
  370. opacity: 0.7;
  371. }
  372. .level-badge {
  373. position: absolute;
  374. top: 20rpx;
  375. right: 20rpx;
  376. display: flex;
  377. flex-direction: column;
  378. align-items: center;
  379. /* */
  380. font-size: 24rpx;
  381. opacity: 0.9;
  382. }
  383. /* --- 章节标题 --- */
  384. .section-title {
  385. font-size: 30rpx;
  386. font-weight: bold;
  387. color: #333;
  388. margin-top: 10rpx;
  389. margin-bottom: 15rpx;
  390. padding-left: 10rpx;
  391. border-left: 4rpx solid #4a90e2;
  392. }
  393. /* --- 档案统计 --- */
  394. .profile-stats {
  395. display: flex;
  396. flex-direction: row;
  397. justify-content: space-around;
  398. background: #ffffff;
  399. border-radius: 16rpx;
  400. padding: 30rpx 20rpx;
  401. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
  402. }
  403. .stat-item {
  404. display: flex;
  405. flex-direction: column;
  406. align-items: center;
  407. }
  408. .stat-value {
  409. font-size: 32rpx;
  410. font-weight: bold;
  411. color: #333;
  412. }
  413. .stat-label {
  414. font-size: 24rpx;
  415. color: #666;
  416. }
  417. /* --- 工具网格 --- */
  418. .tools-grid {
  419. display: flex;
  420. flex-direction: row;
  421. flex-wrap: wrap;
  422. /* gap: 20rpx; */
  423. background: #ffffff;
  424. border-radius: 16rpx;
  425. padding: 30rpx;
  426. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
  427. }
  428. .tool-item {
  429. /* width: calc(25% - 15rpx); not supported */
  430. width: 168rpx;
  431. /* approximate quarter width */
  432. /* 4列,减去gap */
  433. display: flex;
  434. flex-direction: column;
  435. align-items: center;
  436. /* gap: 10rpx; */
  437. padding: 20rpx 0;
  438. }
  439. .tool-name {
  440. font-size: 24rpx;
  441. color: #666;
  442. text-align: center;
  443. }
  444. /* --- 推广卡片 --- */
  445. .promo-cards {
  446. display: flex;
  447. flex-direction: row;
  448. /* gap: 20rpx; */
  449. }
  450. .promo-card {
  451. flex: 1;
  452. border-radius: 16rpx;
  453. padding: 25rpx;
  454. display: flex;
  455. flex-direction: row;
  456. justify-content: space-between;
  457. align-items: center;
  458. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
  459. }
  460. /* .promo-card.invite {
  461. background: linear-gradient(135deg, #fff9e6 0%, #ffeaa7 100%);
  462. }
  463. .promo-card.team {
  464. background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  465. } */
  466. .promo-content {
  467. display: flex;
  468. flex-direction: column;
  469. /* */
  470. }
  471. .promo-title {
  472. font-size: 28rpx;
  473. font-weight: bold;
  474. color: #333;
  475. }
  476. .promo-subtitle {
  477. font-size: 24rpx;
  478. color: #666;
  479. }
  480. /* --- 合伙人 Banner --- */
  481. .partner-banner {
  482. background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%);
  483. border-radius: 16rpx;
  484. padding: 30rpx;
  485. display: flex;
  486. flex-direction: row;
  487. justify-content: space-between;
  488. align-items: center;
  489. color: #ffffff;
  490. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
  491. }
  492. .partner-content {
  493. display: flex;
  494. flex-direction: column;
  495. /* gap: 10rpx; */
  496. }
  497. .partner-title {
  498. font-size: 32rpx;
  499. font-weight: bold;
  500. }
  501. .partner-subtitle {
  502. font-size: 26rpx;
  503. opacity: 0.9;
  504. }
  505. .partner-icon {
  506. display: flex;
  507. flex-direction: row;
  508. align-items: center;
  509. }
  510. </style>