index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <view class="member-center">
  3. <scroll-view class="page" scroll-y>
  4. <!-- 会员状态卡 -->
  5. <view class="status-card">
  6. <view class="status-badge" :class="isFree ? 'badge-free' : 'badge-family'">
  7. <text class="badge-icon">{{ isFree ? '○' : '●' }}</text>
  8. <text class="badge-text">{{ currentLevelName }}</text>
  9. </view>
  10. <view class="status-body" v-if="membership && membership.levelCode !== 'FREE'">
  11. <view class="expiry-row">
  12. <text class="expiry-label">到期时间</text>
  13. <text class="expiry-value">{{ formatDate(membership.endDate) }}</text>
  14. </view>
  15. <view class="days-remaining" v-if="membership.isActive">
  16. <text class="days-num">{{ membership.daysRemaining || 0 }}</text>
  17. <text class="days-unit">天剩余</text>
  18. </view>
  19. <view class="expired-msg" v-else>
  20. <text class="expired-text">会员已过期,续费恢复权益</text>
  21. </view>
  22. </view>
  23. <view class="status-body" v-else>
  24. <text class="free-hint">当前为免费版,开通会员解锁全部特权</text>
  25. </view>
  26. </view>
  27. <!-- 会员权益亮点 -->
  28. <view class="benefit-card">
  29. <text class="benefit-card-title">{{ isFree ? '开通会员,即刻享有' : '您的会员权益' }}</text>
  30. <view class="feature-list">
  31. <view class="feature-item" v-for="(feature, idx) in features" :key="idx">
  32. <text class="feature-check">✓</text>
  33. <text class="feature-text">{{ feature }}</text>
  34. </view>
  35. </view>
  36. <!-- 主按钮:非会员开通 / 会员续费 -->
  37. <button class="btn-main" :class="isFree ? 'btn-upgrade' : 'btn-renew'" @click="goUpgrade">
  38. {{ isFree ? '立即开通会员' : '立即续费' }}
  39. </button>
  40. <view class="benefits-entry" @click="goBenefits">
  41. <text class="benefits-entry-icon">👑</text>
  42. <text class="benefits-entry-text">查看我的权益</text>
  43. <text class="benefits-entry-arrow">›</text>
  44. </view>
  45. </view>
  46. <!-- 我的管家入口 -->
  47. <view class="butler-entry" @click="goButlerSelect">
  48. <view class="butler-entry-icon">🤵</view>
  49. <view class="butler-entry-main">
  50. <text class="butler-entry-title">{{ butlerEntryTitle }}</text>
  51. <text class="butler-entry-sub">{{ butlerEntrySub }}</text>
  52. </view>
  53. <text class="butler-entry-arrow">›</text>
  54. </view>
  55. <!-- 权益对比表 -->
  56. <view class="compare-section">
  57. <text class="section-title">权益对比</text>
  58. <view class="compare-table">
  59. <view class="compare-row header-row">
  60. <text class="compare-cell cell-feature">权益项</text>
  61. <text class="compare-cell cell-free">免费</text>
  62. <text class="compare-cell cell-basic">体验会员</text>
  63. <text class="compare-cell cell-family">家庭会员</text>
  64. <text class="compare-cell cell-premium">高级会员</text>
  65. </view>
  66. <view class="compare-row" v-for="(item, idx) in compareData" :key="idx">
  67. <text class="compare-cell cell-feature">{{ item.name }}</text>
  68. <text class="compare-cell cell-free">{{ item.free }}</text>
  69. <text class="compare-cell cell-basic">{{ item.basic }}</text>
  70. <text class="compare-cell cell-family">{{ item.family }}</text>
  71. <text class="compare-cell cell-premium">{{ item.premium }}</text>
  72. </view>
  73. </view>
  74. </view>
  75. </scroll-view>
  76. </view>
  77. </template>
  78. <script>
  79. import { getMyMembership, getMyButler } from '../../utils/api.js'
  80. import { parseDate } from '../../utils/format.js'
  81. export default {
  82. data() {
  83. return {
  84. membership: null,
  85. isFree: true,
  86. currentLevelName: '免费用户',
  87. features: ['折扣购物', '家庭管理', '推荐佣金', '专属活动', '任务特权', '成长报告'],
  88. compareData: [
  89. { name: '商品折扣', free: '普通价格', basic: '会员折扣', family: '会员折扣', premium: '会员折扣' },
  90. { name: '家庭管理', free: '基础功能', basic: '3个孩子', family: '10个孩子', premium: '20个孩子' },
  91. { name: 'AI健康顾问', free: '—', basic: '3次/月', family: '不限', premium: '不限' },
  92. { name: '报告解读', free: '—', basic: '1次/月', family: '不限', premium: '深度解读' },
  93. { name: '测评预约', free: '仅查看', basic: '1次/月', family: '不限', premium: '优先' },
  94. { name: '管家服务', free: '—', basic: '—', family: '月1次', premium: '周1次' },
  95. { name: '推荐佣金', free: '不可参与', basic: '可参与', family: '可参与', premium: '可参与' },
  96. { name: '专属活动', free: '部分参与', basic: '部分参与', family: '全部参与', premium: '优先参与' }
  97. ],
  98. myButlerInfo: null,
  99. isL2Active: false
  100. }
  101. },
  102. computed: {
  103. butlerEntryTitle() {
  104. return this.myButlerInfo ? ('我的管家 · ' + this.myButlerInfo.nickname) : '我的管家'
  105. },
  106. butlerEntrySub() {
  107. return this.myButlerInfo ? '点击查看或更换' : '久久一生会员可自助选择专属管家'
  108. }
  109. },
  110. onShow() {
  111. this.loadData()
  112. this.loadButlerEntry()
  113. },
  114. methods: {
  115. loadData() {
  116. var that = this
  117. getMyMembership().then(function(res) {
  118. var m = res.data || {}
  119. that.membership = m
  120. if (m.levelCode && m.levelCode !== 'FREE') {
  121. that.isFree = false
  122. that.currentLevelName = m.levelName || '家庭会员'
  123. if (m.levelCode === 'BASIC') {
  124. that.currentLevelName = '体验会员'
  125. } else if (m.levelCode === 'FAMILY') {
  126. that.currentLevelName = '家庭会员'
  127. } else if (m.levelCode === 'PREMIUM') {
  128. that.currentLevelName = '高级会员'
  129. }
  130. } else {
  131. that.isFree = true
  132. that.currentLevelName = '免费用户'
  133. }
  134. }).catch(function() {})
  135. },
  136. goUpgrade() {
  137. uni.navigateTo({ url: '/pages/membership/upgrade' })
  138. },
  139. goBenefits() {
  140. uni.navigateTo({ url: '/pages/membership/benefits' })
  141. },
  142. goButlerSelect() {
  143. uni.navigateTo({ url: '/pages/butler/select' })
  144. },
  145. loadButlerEntry() {
  146. var that = this
  147. getMyButler().then(function (res) {
  148. if (res && res.code === 200 && res.data) {
  149. that.myButlerInfo = res.data
  150. }
  151. }).catch(function () {})
  152. },
  153. formatDate(date) {
  154. if (!date) return ''
  155. var d = parseDate(date)
  156. if (!d) return ''
  157. var month = d.getMonth() + 1
  158. var day = d.getDate()
  159. return d.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day)
  160. }
  161. }
  162. }
  163. </script>
  164. <style scoped>
  165. .page {
  166. min-height: 100vh;
  167. background: #FFF7ED;
  168. padding: 30rpx;
  169. box-sizing: border-box;
  170. }
  171. /* ===== 状态卡片 ===== */
  172. .status-card {
  173. background: linear-gradient(135deg, #F97316 0%, #EA580C 100%);
  174. border-radius: 20rpx;
  175. padding: 40rpx;
  176. margin-bottom: 30rpx;
  177. }
  178. .status-badge {
  179. display: inline-flex;
  180. align-items: center;
  181. padding: 10rpx 24rpx;
  182. border-radius: 9999rpx;
  183. font-size: 24rpx;
  184. }
  185. .badge-free {
  186. background: rgba(255,255,255,0.2);
  187. color: #fff;
  188. }
  189. .badge-family {
  190. background: rgba(255,255,255,0.3);
  191. color: #fff;
  192. }
  193. .badge-icon {
  194. font-size: 20rpx;
  195. margin-right: 8rpx;
  196. }
  197. .badge-text {
  198. font-weight: 600;
  199. }
  200. .status-body {
  201. margin-top: 24rpx;
  202. }
  203. .expiry-row {
  204. display: flex;
  205. justify-content: space-between;
  206. align-items: center;
  207. }
  208. .expiry-label {
  209. font-size: 26rpx;
  210. color: rgba(255,255,255,0.8);
  211. }
  212. .expiry-value {
  213. font-size: 28rpx;
  214. color: #fff;
  215. font-weight: 500;
  216. }
  217. .days-remaining {
  218. display: flex;
  219. align-items: baseline;
  220. justify-content: center;
  221. margin-top: 20rpx;
  222. }
  223. .days-num {
  224. font-size: 56rpx;
  225. font-weight: bold;
  226. color: #FEF3C7;
  227. }
  228. .days-unit {
  229. font-size: 26rpx;
  230. color: rgba(255,255,255,0.7);
  231. margin-left: 8rpx;
  232. }
  233. .expired-msg {
  234. text-align: center;
  235. margin-top: 16rpx;
  236. }
  237. .expired-text {
  238. font-size: 26rpx;
  239. color: #FEF3C7;
  240. }
  241. .free-hint {
  242. font-size: 26rpx;
  243. color: rgba(255,255,255,0.85);
  244. text-align: center;
  245. display: block;
  246. }
  247. /* ===== 权益卡片 ===== */
  248. .benefit-card {
  249. background: #FFFFFF;
  250. border-radius: 20rpx;
  251. padding: 40rpx;
  252. margin-bottom: 30rpx;
  253. box-shadow: 0 4rpx 24rpx rgba(249, 115, 22, 0.08);
  254. }
  255. .benefit-card-title {
  256. font-size: 32rpx;
  257. font-weight: bold;
  258. color: #1E293B;
  259. display: block;
  260. text-align: center;
  261. margin-bottom: 16rpx;
  262. }
  263. .feature-list {
  264. margin: 16rpx 0 24rpx;
  265. }
  266. .feature-item {
  267. display: flex;
  268. align-items: center;
  269. padding: 12rpx 0;
  270. }
  271. .feature-check {
  272. width: 36rpx;
  273. height: 36rpx;
  274. border-radius: 50%;
  275. background: #F97316;
  276. color: #fff;
  277. font-size: 22rpx;
  278. display: flex;
  279. align-items: center;
  280. justify-content: center;
  281. margin-right: 16rpx;
  282. flex-shrink: 0;
  283. }
  284. .feature-text {
  285. font-size: 28rpx;
  286. color: #334155;
  287. }
  288. .btn-main {
  289. width: 100%;
  290. border-radius: 44rpx;
  291. font-size: 32rpx;
  292. font-weight: bold;
  293. padding: 24rpx 0;
  294. border: none;
  295. line-height: 1.4;
  296. }
  297. .btn-upgrade {
  298. background: linear-gradient(135deg, #F97316, #FB923C);
  299. color: #fff;
  300. }
  301. .btn-renew {
  302. background: linear-gradient(135deg, #6366F1, #818CF8);
  303. color: #fff;
  304. }
  305. .btn-main::after {
  306. border: none;
  307. }
  308. .benefits-entry {
  309. display: flex;
  310. align-items: center;
  311. justify-content: center;
  312. margin-top: 24rpx;
  313. padding: 20rpx;
  314. background: #FFF7ED;
  315. border-radius: 16rpx;
  316. }
  317. .benefits-entry-icon {
  318. font-size: 32rpx;
  319. margin-right: 8rpx;
  320. }
  321. .benefits-entry-text {
  322. font-size: 28rpx;
  323. color: #F97316;
  324. font-weight: 500;
  325. }
  326. .benefits-entry-arrow {
  327. font-size: 28rpx;
  328. color: #F97316;
  329. margin-left: 8rpx;
  330. }
  331. /* ===== 权益对比表 ===== */
  332. .compare-section {
  333. background: #FFFFFF;
  334. border-radius: 20rpx;
  335. padding: 30rpx;
  336. box-shadow: 0 4rpx 24rpx rgba(249, 115, 22, 0.08);
  337. }
  338. .section-title {
  339. font-size: 30rpx;
  340. font-weight: bold;
  341. color: #1E293B;
  342. display: block;
  343. margin-bottom: 20rpx;
  344. }
  345. .compare-table {
  346. width: 100%;
  347. }
  348. .compare-row {
  349. display: flex;
  350. padding: 14rpx 0;
  351. border-bottom: 1rpx solid #F1F5F9;
  352. }
  353. .compare-row:last-child {
  354. border-bottom: none;
  355. }
  356. .header-row {
  357. border-bottom: 2rpx solid #FED7AA;
  358. }
  359. .compare-cell {
  360. flex: 1;
  361. font-size: 22rpx;
  362. color: #475569;
  363. text-align: center;
  364. word-break: break-all;
  365. }
  366. .cell-feature {
  367. flex: 1.2;
  368. text-align: left;
  369. color: #334155;
  370. font-weight: 500;
  371. }
  372. .header-row .compare-cell {
  373. color: #F97316;
  374. font-weight: bold;
  375. }
  376. /* ===== 我的管家入口 ===== */
  377. .butler-entry { display: flex; align-items: center; background: #fff; border-radius: 16rpx; padding: 28rpx; margin: 20rpx 0; }
  378. .butler-entry-icon { font-size: 48rpx; margin-right: 20rpx; }
  379. .butler-entry-main { flex: 1; display: flex; flex-direction: column; }
  380. .butler-entry-title { font-size: 30rpx; font-weight: bold; color: #333; }
  381. .butler-entry-sub { font-size: 24rpx; color: #999; margin-top: 6rpx; }
  382. .butler-entry-arrow { font-size: 40rpx; color: #ccc; }
  383. </style>