inviteFriend.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. <template>
  2. <view class="invite-link-page">
  3. <view class="container">
  4. <view class="header">
  5. <view class="title">邀请好友</view>
  6. <view class="desc">通过微信分享邀请好友,直接打开小程序</view>
  7. </view>
  8. <view class="main-card">
  9. <!-- <view class="invite-info">
  10. <view class="info-row">
  11. <text class="label">邀请人ID</text>
  12. <text class="value">{{ userId }}</text>
  13. </view>
  14. <view class="info-row">
  15. <text class="label">邀请参数</text>
  16. <text class="value link-text">inviteUserId={{ userId }}</text>
  17. </view>
  18. </view> -->
  19. <view class="invite-info">
  20. <view class="info-row">
  21. <text class="label">邀请人ID</text>
  22. <text class="value">{{ userId }}</text>
  23. </view>
  24. <view class="info-row">
  25. <text class="label">邀请人</text>
  26. <text class="value">{{ userInfo.nickname }}</text>
  27. </view>
  28. </view>
  29. <view class="share-btn primary">
  30. <button open-type="share" class="share-button">
  31. <text class="share-icon"></text>
  32. <text>分享给微信好友</text>
  33. </button>
  34. </view>
  35. </view>
  36. <view class="tips-section">
  37. <view class="tip-title">邀请说明</view>
  38. <view class="tip-list">
  39. <view class="tip-item">
  40. <text class="tip-number">1</text>
  41. <text class="tip-text">点击分享按钮,选择要邀请的好友</text>
  42. </view>
  43. <view class="tip-item">
  44. <text class="tip-number">2</text>
  45. <text class="tip-text">好友点击分享卡片将直接打开小程序登录页</text>
  46. </view>
  47. <view class="tip-item">
  48. <text class="tip-number">3</text>
  49. <text class="tip-text">好友登录后自动绑定邀请关系</text>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="note-section">
  54. <text class="note-title">温馨提示</text>
  55. <text class="note-content">微信小程序的可复制链接需要通过微信官方API生成,如需此功能请联系后端开发配置。当前推荐使用分享按钮邀请好友。</text>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. export default {
  62. name: "InviteFriend",
  63. data() {
  64. return {
  65. userId: '',
  66. invitePath: '',
  67. userInfo: JSON.parse(uni.getStorageSync('userInfo')) || {}
  68. };
  69. },
  70. mounted() {
  71. this.initData();
  72. },
  73. onShareAppMessage() {
  74. return {
  75. title: '邀请你加入健康商城',
  76. path: `/pages/home/index?inviteUserId=${this.userId}`,
  77. imageUrl: '/static/logo.jpg',
  78. success(res) {
  79. uni.showToast({
  80. title: '分享成功',
  81. icon: 'success'
  82. });
  83. },
  84. fail(err) {
  85. uni.showToast({
  86. title: '分享失败',
  87. icon: 'none'
  88. });
  89. }
  90. };
  91. },
  92. methods: {
  93. initData() {
  94. if (this.userInfo) {
  95. this.userId = this.userInfo.userId;
  96. } else {
  97. uni.showToast({
  98. title: '请先登录',
  99. icon: 'none'
  100. });
  101. return;
  102. }
  103. this.invitePath = `/pages/home/index?inviteUserId=${this.userInfo.userId}`;
  104. this.invitePath = `/pages/auth/login?inviteUserId=${this.userInfo.userId}`;
  105. },
  106. handleShare() {
  107. uni.showShareMenu({
  108. withShareTicket: true,
  109. menus: ['shareAppMessage']
  110. });
  111. // uni.showToast({
  112. // title: '请点击右上角分享',
  113. // icon: 'none',
  114. // duration: 2000
  115. // });
  116. }
  117. }
  118. };
  119. </script>
  120. <style lang="less">
  121. .invite-link-page {
  122. min-height: 100vh;
  123. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  124. }
  125. .container {
  126. padding: 60rpx 40rpx;
  127. }
  128. .header {
  129. text-align: center;
  130. margin-bottom: 60rpx;
  131. .title {
  132. font-size: 48rpx;
  133. font-weight: bold;
  134. color: #fff;
  135. margin-bottom: 20rpx;
  136. }
  137. .desc {
  138. font-size: 28rpx;
  139. color: rgba(255, 255, 255, 0.8);
  140. }
  141. }
  142. .main-card {
  143. background: #fff;
  144. border-radius: 24rpx;
  145. padding: 40rpx;
  146. box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.15);
  147. .invite-info {
  148. margin-bottom: 30rpx;
  149. .info-row {
  150. display: flex;
  151. justify-content: space-between;
  152. align-items: center;
  153. padding: 20rpx 0;
  154. border-bottom: 1rpx solid #f0f0f0;
  155. &:last-child {
  156. border-bottom: none;
  157. }
  158. .label {
  159. font-size: 28rpx;
  160. color: #999;
  161. }
  162. .value {
  163. font-size: 28rpx;
  164. color: #333;
  165. font-weight: 500;
  166. &.link-text {
  167. color: #4C49E9;
  168. word-break: break-all;
  169. }
  170. }
  171. }
  172. }
  173. .share-btn {
  174. display: flex;
  175. align-items: center;
  176. justify-content: center;
  177. height: 96rpx;
  178. border-radius: 48rpx;
  179. font-size: 32rpx;
  180. margin-bottom: 20rpx;
  181. .share-icon {
  182. font-family: iconfont;
  183. margin-right: 12rpx;
  184. font-size: 36rpx;
  185. }
  186. &.primary {
  187. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  188. color: #fff;
  189. }
  190. &.secondary {
  191. background: #f5f5f5;
  192. color: #666;
  193. }
  194. }
  195. .share-button {
  196. width: 100%;
  197. height: 100%;
  198. background: transparent;
  199. border: none;
  200. padding: 0;
  201. margin: 0;
  202. font-size: inherit;
  203. color: inherit;
  204. line-height: inherit;
  205. display: flex;
  206. align-items: center;
  207. justify-content: center;
  208. &::after {
  209. display: none;
  210. }
  211. }
  212. }
  213. .tips-section {
  214. margin-top: 40rpx;
  215. background: rgba(255, 255, 255, 0.1);
  216. border-radius: 24rpx;
  217. padding: 30rpx;
  218. .tip-title {
  219. font-size: 30rpx;
  220. font-weight: bold;
  221. color: #fff;
  222. margin-bottom: 24rpx;
  223. }
  224. .tip-list {
  225. .tip-item {
  226. display: flex;
  227. align-items: flex-start;
  228. margin-bottom: 20rpx;
  229. &:last-child {
  230. margin-bottom: 0;
  231. }
  232. .tip-number {
  233. width: 40rpx;
  234. height: 40rpx;
  235. border-radius: 50%;
  236. background: rgba(255, 255, 255, 0.2);
  237. color: #fff;
  238. font-size: 24rpx;
  239. display: flex;
  240. align-items: center;
  241. justify-content: center;
  242. margin-right: 20rpx;
  243. flex-shrink: 0;
  244. }
  245. .tip-text {
  246. font-size: 26rpx;
  247. color: rgba(255, 255, 255, 0.9);
  248. line-height: 1.6;
  249. }
  250. }
  251. }
  252. }
  253. .note-section {
  254. margin-top: 30rpx;
  255. background: rgba(255, 255, 255, 0.08);
  256. border-radius: 16rpx;
  257. padding: 24rpx;
  258. .note-title {
  259. font-size: 26rpx;
  260. font-weight: bold;
  261. color: rgba(255, 255, 255, 0.9);
  262. display: block;
  263. margin-bottom: 12rpx;
  264. }
  265. .note-content {
  266. font-size: 24rpx;
  267. color: rgba(255, 255, 255, 0.7);
  268. line-height: 1.6;
  269. }
  270. }
  271. </style>on-title {
  272. font-size: 32rpx;
  273. font-weight: bold;
  274. color: #333;
  275. margin-bottom: 24rpx;
  276. }
  277. }
  278. .rewards-list {
  279. .reward-item {
  280. display: flex;
  281. align-items: center;
  282. padding: 20rpx 0;
  283. border-bottom: 1rpx solid #f5f5f5;
  284. &:last-child {
  285. border-bottom: none;
  286. }
  287. .reward-icon {
  288. width: 48rpx;
  289. height: 48rpx;
  290. border-radius: 50%;
  291. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  292. color: #fff;
  293. font-size: 24rpx;
  294. display: flex;
  295. align-items: center;
  296. justify-content: center;
  297. margin-right: 20rpx;
  298. }
  299. .reward-info {
  300. flex: 1;
  301. .reward-title {
  302. font-size: 28rpx;
  303. color: #333;
  304. margin-bottom: 6rpx;
  305. }
  306. .reward-desc {
  307. font-size: 24rpx;
  308. color: #999;
  309. }
  310. }
  311. .reward-value {
  312. font-size: 28rpx;
  313. font-weight: bold;
  314. color: #4C49E9;
  315. }
  316. }
  317. }
  318. .share-list {
  319. display: flex;
  320. justify-content: space-around;
  321. .share-item {
  322. display: flex;
  323. flex-direction: column;
  324. align-items: center;
  325. .share-icon {
  326. width: 100rpx;
  327. height: 100rpx;
  328. border-radius: 50%;
  329. display: flex;
  330. align-items: center;
  331. justify-content: center;
  332. margin-bottom: 16rpx;
  333. .iconfont {
  334. font-size: 48rpx;
  335. }
  336. }
  337. .wechat-icon {
  338. background: linear-gradient(135deg, #07c160 0%, #10b981 100%);
  339. color: #fff;
  340. }
  341. .moments-icon {
  342. background: linear-gradient(135deg, #e6d5b8 0%, #d4a373 100%);
  343. color: #fff;
  344. }
  345. .qq-icon {
  346. background: linear-gradient(135deg, #1677ff 0%, #096dd9 100%);
  347. color: #fff;
  348. }
  349. .link-icon {
  350. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  351. color: #fff;
  352. }
  353. .share-name {
  354. font-size: 24rpx;
  355. color: #666;
  356. }
  357. }
  358. }
  359. .invited-section {
  360. .invited-count {
  361. display: flex;
  362. flex-direction: column;
  363. align-items: center;
  364. padding: 30rpx 0;
  365. border-bottom: 1rpx solid #f5f5f5;
  366. .count-num {
  367. font-size: 56rpx;
  368. font-weight: bold;
  369. color: #4C49E9;
  370. }
  371. .count-desc {
  372. font-size: 26rpx;
  373. color: #999;
  374. margin-top: 8rpx;
  375. }
  376. }
  377. .invited-list {
  378. padding-top: 20rpx;
  379. .invited-item {
  380. display: flex;
  381. align-items: center;
  382. padding: 20rpx 0;
  383. border-bottom: 1rpx solid #f5f5f5;
  384. &:last-child {
  385. border-bottom: none;
  386. }
  387. .avatar {
  388. width: 72rpx;
  389. height: 72rpx;
  390. border-radius: 50%;
  391. overflow: hidden;
  392. margin-right: 20rpx;
  393. image {
  394. width: 100%;
  395. height: 100%;
  396. }
  397. }
  398. .info {
  399. flex: 1;
  400. .name {
  401. font-size: 28rpx;
  402. color: #333;
  403. margin-bottom: 6rpx;
  404. }
  405. .time {
  406. font-size: 24rpx;
  407. color: #999;
  408. }
  409. }
  410. .status {
  411. font-size: 22rpx;
  412. color: #999;
  413. padding: 6rpx 16rpx;
  414. border-radius: 20rpx;
  415. background: #f5f5f5;
  416. &.active {
  417. color: #4C49E9;
  418. background: rgba(76, 73, 233, 0.1);
  419. }
  420. }
  421. }
  422. }
  423. .empty {
  424. display: flex;
  425. flex-direction: column;
  426. align-items: center;
  427. padding: 40rpx 0;
  428. .empty-icon {
  429. width: 120rpx;
  430. height: 120rpx;
  431. margin-bottom: 20rpx;
  432. }
  433. .empty-text {
  434. font-size: 28rpx;
  435. color: #999;
  436. margin-bottom: 24rpx;
  437. }
  438. .empty-btn {
  439. padding: 16rpx 48rpx;
  440. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  441. color: #fff;
  442. font-size: 28rpx;
  443. border-radius: 30rpx;
  444. }
  445. }
  446. }
  447. .bottom-btn {
  448. position: fixed;
  449. left: 30rpx;
  450. right: 30rpx;
  451. bottom: 30rpx;
  452. height: 96rpx;
  453. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  454. color: #fff;
  455. font-size: 32rpx;
  456. font-weight: bold;
  457. border-radius: 48rpx;
  458. display: flex;
  459. align-items: center;
  460. justify-content: center;
  461. box-shadow: 0 8rpx 24rpx rgba(102, 126, 234, 0.4);
  462. }
  463. </style>