share.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <view class="share-page">
  3. <!-- Background -->
  4. <image src="/packet/static/share/bg.png" class="bg-image" mode="widthFix"></image>
  5. <!-- Main Content -->
  6. <view class="content-wrapper">
  7. <!-- Loop through share list -->
  8. <view class="card" v-for="(item, index) in shareList" :key="index">
  9. <!-- Header -->
  10. <view class="card-header">
  11. <text class="card-title">邀请好友同享最高可得{{ item.shareSumPrice || 15 }}元红包</text>
  12. <text class="card-time">{{ formatExpireTime(item.shareRedBagExpire) }}</text>
  13. </view>
  14. <!-- Progress Section -->
  15. <view class="progress-section">
  16. <!-- Left Icon -->
  17. <image src="/packet/static/share/invite-text.png" class="left-icon" mode="widthFix"></image>
  18. <!-- Center Content -->
  19. <view class="center-content">
  20. <!-- Progress Bubble -->
  21. <view class="progress-bubble">
  22. <text>已领{{ item.shareGetNum || 0 }}元,最高还可得{{ (item.shareSumPrice || 0) - (item.shareGetNum
  23. || 0) }}元</text>
  24. </view>
  25. <!-- Progress Bar -->
  26. <view class="progress-bar-container">
  27. <view class="progress-line"></view>
  28. <view class="progress-dot" :style="{ left: getProgressPercent(item) + '%' }"></view>
  29. </view>
  30. <!-- Progress Labels -->
  31. <view class="progress-labels">
  32. <text class="label">邀请好友</text>
  33. <text class="label">好友领取</text>
  34. <text class="label">获得红包</text>
  35. </view>
  36. </view>
  37. <!-- Right Packet Icon -->
  38. <image src="/packet/static/share/red-packet.png" class="right-packet" mode="widthFix"></image>
  39. </view>
  40. <!-- Share/Detail Button -->
  41. <view class="btn-wrapper">
  42. <image src="/packet/static/share/share-btn.png" class="btn-image" mode="widthFix"></image>
  43. <text class="btn-text">{{ index === 0 ? '立即分享' : '查看详情' }}</text>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. data() {
  52. return {
  53. shareList: [] // 分享列表数据
  54. }
  55. },
  56. onLoad() {
  57. // 获取分享列表
  58. this.getShareList();
  59. },
  60. methods: {
  61. // 获取分享列表
  62. async getShareList() {
  63. try {
  64. const res = await this.$u.api.getShareRedBagListAjax();
  65. if (res.code === 200 || res.code === 0) {
  66. this.shareList = res.data || [];
  67. } else {
  68. uni.showToast({
  69. title: res.msg || '获取分享列表失败',
  70. icon: 'none'
  71. });
  72. }
  73. } catch (e) {
  74. console.error('获取分享列表失败:', e);
  75. uni.showToast({
  76. title: '网络错误',
  77. icon: 'none'
  78. });
  79. }
  80. },
  81. // 计算进度百分比
  82. getProgressPercent(item) {
  83. if (!item.shareNum || item.shareNum === 0) {
  84. return 0;
  85. }
  86. return (item.shareGetNum / item.shareNum) * 100;
  87. },
  88. // 格式化过期时间
  89. formatExpireTime(timeStr) {
  90. if (!timeStr) {
  91. return this.formatTime(new Date());
  92. }
  93. const date = new Date(timeStr);
  94. return this.formatTime(date);
  95. },
  96. // 格式化时间
  97. formatTime(date) {
  98. const year = date.getFullYear();
  99. const month = String(date.getMonth() + 1).padStart(2, '0');
  100. const day = String(date.getDate()).padStart(2, '0');
  101. const hours = String(date.getHours()).padStart(2, '0');
  102. const minutes = String(date.getMinutes()).padStart(2, '0');
  103. const seconds = String(date.getSeconds()).padStart(2, '0');
  104. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  105. },
  106. handleShare() {
  107. // 分享逻辑
  108. uni.showToast({
  109. title: '分享成功',
  110. icon: 'success'
  111. });
  112. },
  113. handleViewDetail() {
  114. // 查看详情逻辑
  115. uni.showToast({
  116. title: '查看详情',
  117. icon: 'none'
  118. });
  119. }
  120. }
  121. }
  122. </script>
  123. <style lang="scss" scoped>
  124. .share-page {
  125. min-height: 100vh;
  126. position: relative;
  127. display: flex;
  128. flex-direction: column;
  129. align-items: center;
  130. padding: 40rpx 30rpx;
  131. box-sizing: border-box;
  132. .bg-image {
  133. position: fixed;
  134. top: 0;
  135. left: 0;
  136. width: 100%;
  137. height: 100%;
  138. z-index: 0;
  139. }
  140. .content-wrapper {
  141. position: relative;
  142. z-index: 1;
  143. width: 100%;
  144. max-width: 700rpx;
  145. padding-top: 60rpx;
  146. .card {
  147. background: #fff;
  148. border-radius: 24rpx;
  149. overflow: hidden;
  150. margin-bottom: 40rpx;
  151. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
  152. .card-header {
  153. background: linear-gradient(135deg, #4CAF50 0%, #66BB6A 100%);
  154. padding: 24rpx 30rpx;
  155. display: flex;
  156. justify-content: space-between;
  157. align-items: center;
  158. .card-title {
  159. font-size: 28rpx;
  160. font-weight: 600;
  161. color: #fff;
  162. flex: 1;
  163. }
  164. .card-time {
  165. font-size: 22rpx;
  166. color: rgba(255, 255, 255, 0.9);
  167. white-space: nowrap;
  168. margin-left: 20rpx;
  169. }
  170. }
  171. .progress-section {
  172. padding: 40rpx 30rpx;
  173. display: flex;
  174. align-items: flex-start;
  175. gap: 20rpx;
  176. .left-icon {
  177. width: 80rpx;
  178. height: 80rpx;
  179. flex-shrink: 0;
  180. }
  181. .center-content {
  182. flex: 1;
  183. display: flex;
  184. flex-direction: column;
  185. align-items: center;
  186. .progress-bubble {
  187. background: linear-gradient(135deg, #4CAF50 0%, #66BB6A 100%);
  188. padding: 12rpx 28rpx;
  189. border-radius: 24rpx;
  190. margin-bottom: 24rpx;
  191. text {
  192. font-size: 24rpx;
  193. color: #fff;
  194. font-weight: 500;
  195. }
  196. }
  197. .progress-bar-container {
  198. position: relative;
  199. width: 100%;
  200. height: 8rpx;
  201. background: linear-gradient(90deg, #E8F5E9 0%, #C8E6C9 100%);
  202. border-radius: 4rpx;
  203. margin-bottom: 20rpx;
  204. .progress-line {
  205. position: absolute;
  206. left: 0;
  207. top: 0;
  208. height: 100%;
  209. width: 100%;
  210. background: linear-gradient(90deg, #4CAF50 0%, #8BC34A 100%);
  211. border-radius: 4rpx;
  212. }
  213. .progress-dot {
  214. position: absolute;
  215. top: 50%;
  216. transform: translate(-50%, -50%);
  217. width: 36rpx;
  218. height: 36rpx;
  219. background: linear-gradient(135deg, #4CAF50 0%, #66BB6A 100%);
  220. border-radius: 50%;
  221. box-shadow: 0 4rpx 12rpx rgba(76, 175, 80, 0.4);
  222. border: 4rpx solid #fff;
  223. }
  224. }
  225. .progress-labels {
  226. display: flex;
  227. justify-content: space-between;
  228. width: 100%;
  229. .label {
  230. font-size: 24rpx;
  231. color: #666;
  232. text-align: center;
  233. flex: 1;
  234. }
  235. }
  236. }
  237. .right-packet {
  238. width: 90rpx;
  239. height: 90rpx;
  240. flex-shrink: 0;
  241. }
  242. }
  243. .btn-wrapper {
  244. position: relative;
  245. display: flex;
  246. justify-content: center;
  247. padding: 0 30rpx 40rpx;
  248. .btn-image {
  249. width: 320rpx;
  250. height: 88rpx;
  251. display: block;
  252. }
  253. .btn-text {
  254. position: absolute;
  255. top: 0;
  256. left: 50%;
  257. transform: translateX(-50%);
  258. width: 320rpx;
  259. text-align: center;
  260. line-height: 88rpx;
  261. font-size: 32rpx;
  262. color: #fff;
  263. font-weight: 600;
  264. letter-spacing: 2rpx;
  265. }
  266. }
  267. }
  268. }
  269. }
  270. </style>