get.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <template>
  2. <view class="get-page">
  3. <!-- Background -->
  4. <image src="/packet/static/get/bg.png" class="bg-image" mode="widthFix"></image>
  5. <!-- Main Content -->
  6. <view class="content-wrapper">
  7. <!-- Header -->
  8. <view class="header-section">
  9. <image src="/packet/static/get/text.png" class="header-logo" mode="widthFix"></image>
  10. </view>
  11. <!-- White Card -->
  12. <view class="white-card">
  13. <!-- Top Amount Row -->
  14. <view class="top-amount-row">
  15. <text class="received-text">¥{{ redBagData.redPrice || 0 }} 红包已到账</text>
  16. <view class="use-btn-wrapper">
  17. <text class="use-btn-text">点击使用</text>
  18. </view>
  19. </view>
  20. <!-- Promo Box -->
  21. <view class="promo-box">
  22. <image src="/packet/static/get/inner-box.png" class="inner-box-bg" mode="widthFix"></image>
  23. <view class="promo-content">
  24. <view class="promo-header">
  25. <text class="promo-amount"><text style="font-size: 30rpx;">¥</text>{{
  26. redBagData.shareSumPrice }}</text>
  27. </view>
  28. <text class="promo-desc">好友助力解锁更高金额</text>
  29. <text class="promo-detail">每邀请 1 位好友最高:你得<text class="highlight-red">¥{{
  30. redBagData.shareGetPrice }}红包</text>,好友得<text class="highlight-red">¥{{
  31. redBagData.shareDGetPrice }}</text>红包</text>
  32. </view>
  33. </view>
  34. <!-- Invite Button -->
  35. <view class="invite-btn-wrapper">
  36. <text class="invite-btn-text">立即邀请</text>
  37. </view>
  38. <!-- Red Packet Cards -->
  39. <view class="red-packets-section">
  40. <view class="packet-card" v-for="(item, index) in 3" :key="index">
  41. <text class="packet-text">邀请好友</text>
  42. <text class="packet-text">双方得红包</text>
  43. </view>
  44. </view>
  45. <!-- Progress Bar -->
  46. <view class="progress-section">
  47. <view class="progress-bar-bg">
  48. <view class="progress-bar-fill" :style="{ width: progressWidth + '%' }"></view>
  49. <image src="/packet/static/get/circle.png" class="progress-dot" :style="{ left: progressWidth + '%' }" mode="aspectFit"></image>
  50. </view>
  51. <text class="progress-text">已邀请{{ redBagData.shareNum || 0 }}人,已领{{ redBagData.shareGetNum || 0
  52. }}元,最高还可得¥{{ maxGetPrice }} 元</text>
  53. </view>
  54. <!-- Continue Scan Button -->
  55. <view class="scan-btn-wrapper">
  56. <text class="scan-btn-text">继续扫码</text>
  57. </view>
  58. <!-- Bottom Text -->
  59. <text class="bottom-text">好友助力成功后,奖励实时到账</text>
  60. </view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. export default {
  66. data() {
  67. return {
  68. bianhao: '', // 红包编号
  69. redBagData: null, // 红包数据
  70. }
  71. },
  72. computed: {
  73. // 计算进度条宽度
  74. progressWidth() {
  75. return this.redBagData ? (this.redBagData.shareGetNum / (this.redBagData.shareSumPrice) * 100) : 0;
  76. },
  77. //最高还可得 redBagData.shareSumPrice - redBagData.shareGetNum 元
  78. maxGetPrice() {
  79. return this.redBagData ? this.redBagData.shareSumPrice - this.redBagData.shareGetNum : 0;
  80. }
  81. },
  82. onLoad(options) {
  83. // 从领取页面跳转过来时,获取编号参数
  84. if (options.bianhao) {
  85. this.bianhao = options.bianhao;
  86. // 调用获取红包接口
  87. this.getRedBagDetail();
  88. }
  89. },
  90. methods: {
  91. // 获取红包详情
  92. async getRedBagDetail() {
  93. if (!this.bianhao) {
  94. uni.showModal({
  95. title: '提示',
  96. content: '红包编号缺失',
  97. showCancel: false
  98. });
  99. return;
  100. }
  101. try {
  102. const res = await this.$u.api.getRedBagAjax(this.bianhao);
  103. if (res.code === 200 || res.code === 0) {
  104. this.redBagData = res.data;
  105. } else {
  106. uni.showToast({
  107. title: res.msg || '获取红包信息失败',
  108. icon: 'none'
  109. });
  110. }
  111. } catch (e) {
  112. console.error('获取红包详情失败:', e);
  113. uni.showToast({
  114. title: '网络错误',
  115. icon: 'none'
  116. });
  117. }
  118. },
  119. handleUse() {
  120. // 使用红包逻辑
  121. uni.showToast({
  122. title: '即将跳转到使用页面',
  123. icon: 'none'
  124. });
  125. },
  126. handleInvite() {
  127. // 邀请好友逻辑
  128. if (this.redBagData && this.redBagData.shareRedLink) {
  129. // 分享红包链接
  130. uni.showModal({
  131. title: '分享红包',
  132. content: '请复制链接分享给好友:' + this.redBagData.shareRedLink,
  133. confirmText: '复制链接',
  134. success: (res) => {
  135. if (res.confirm) {
  136. uni.setClipboardData({
  137. data: this.redBagData.shareRedLink
  138. });
  139. }
  140. }
  141. });
  142. } else {
  143. uni.showToast({
  144. title: '暂无分享链接',
  145. icon: 'none'
  146. });
  147. }
  148. },
  149. handleScan() {
  150. // 继续扫码逻辑
  151. uni.scanCode({
  152. success: (scanRes) => {
  153. // 扫描到新红包,跳转到 index 页面
  154. uni.redirectTo({
  155. url: '/packet/pages/index?bianhao=' + scanRes.result
  156. });
  157. }
  158. });
  159. }
  160. }
  161. }
  162. </script>
  163. <style lang="scss" scoped>
  164. .get-page {
  165. height: 100vh;
  166. position: relative;
  167. display: flex;
  168. flex-direction: column;
  169. align-items: center;
  170. .bg-image {
  171. position: absolute;
  172. top: 0;
  173. left: 0;
  174. bottom: 0;
  175. width: 100%;
  176. height: 100%;
  177. z-index: 0;
  178. }
  179. .content-wrapper {
  180. position: relative;
  181. z-index: 1;
  182. width: 100%;
  183. padding: 40rpx 30rpx;
  184. box-sizing: border-box;
  185. .header-section {
  186. text-align: center;
  187. margin-bottom: 40rpx;
  188. margin-top: 30rpx;
  189. .header-logo {
  190. width: 80%;
  191. display: block;
  192. margin: 0 auto 20rpx;
  193. }
  194. .header-title {
  195. font-size: 48rpx;
  196. font-weight: bold;
  197. color: #1a1a1a;
  198. display: block;
  199. }
  200. }
  201. .white-card {
  202. border-radius: 20rpx;
  203. padding: 40rpx 30rpx;
  204. background: url('/packet/static/get/frame.png') no-repeat center center;
  205. background-size: 100% 100%;
  206. margin-top: 110rpx;
  207. .top-amount-row {
  208. display: flex;
  209. align-items: center;
  210. justify-content: center;
  211. margin: 10rpx 60rpx 30rpx 60rpx;
  212. .received-text {
  213. font-size: 40rpx;
  214. font-weight: bold;
  215. color: #333;
  216. }
  217. .use-btn-wrapper {
  218. position: relative;
  219. width: 160rpx;
  220. height: 50rpx;
  221. background: url('/packet/static/get/use-button.png') no-repeat center center;
  222. background-size: 100% 100%;
  223. border-radius: 25rpx;
  224. display: flex;
  225. align-items: center;
  226. justify-content: center;
  227. margin-left: 20rpx;
  228. .use-btn-image {
  229. width: 100%;
  230. height: 100%;
  231. }
  232. .use-btn-text {
  233. font-size: 28rpx;
  234. color: #333;
  235. font-weight: 500;
  236. }
  237. }
  238. }
  239. .promo-box {
  240. position: relative;
  241. margin-bottom: 30rpx;
  242. padding: 0 10rpx;
  243. .inner-box-bg {
  244. width: 100%;
  245. display: block;
  246. }
  247. .promo-content {
  248. position: absolute;
  249. top: 0;
  250. left: 0;
  251. right: 0;
  252. bottom: 0;
  253. box-sizing: border-box;
  254. display: flex;
  255. flex-direction: column;
  256. align-items: center;
  257. .promo-header {
  258. display: flex;
  259. align-items: center;
  260. justify-content: center;
  261. margin-bottom: 16rpx;
  262. .promo-amount {
  263. font-size: 64rpx;
  264. font-weight: bold;
  265. color: #333;
  266. }
  267. }
  268. .promo-desc {
  269. font-size: 28rpx;
  270. color: #666;
  271. margin-bottom: 12rpx;
  272. }
  273. .promo-detail {
  274. font-size: 24rpx;
  275. color: #666;
  276. line-height: 1.5;
  277. .highlight-red {
  278. color: #ff4444;
  279. font-weight: bold;
  280. }
  281. }
  282. }
  283. }
  284. .invite-btn-wrapper {
  285. position: relative;
  286. width: 300rpx;
  287. height: 90rpx;
  288. margin: 0 auto 40rpx;
  289. background: url('/packet/static/get/button1.png') no-repeat center center;
  290. background-size: 100% 100%;
  291. display: flex;
  292. align-items: center;
  293. justify-content: center;
  294. .invite-btn-text {
  295. font-family: Adobe Heiti Std;
  296. font-size: 42rpx;
  297. color: #FFFFFF;
  298. text-align: center;
  299. }
  300. }
  301. .red-packets-section {
  302. display: flex;
  303. justify-content: center;
  304. gap: 20rpx;
  305. margin-bottom: 30rpx;
  306. .packet-card {
  307. flex: 1;
  308. position: relative;
  309. background: url('/packet/static/get/red-packet.png') no-repeat center center;
  310. background-size: 100% 100%;
  311. height: 184rpx;
  312. max-width: 194rpx;
  313. display: flex;
  314. flex-direction: column;
  315. align-items: center;
  316. padding-top: 24rpx;
  317. .packet-text {
  318. font-size: 26rpx;
  319. color: #003C14;
  320. text-align: center;
  321. }
  322. }
  323. }
  324. .progress-section {
  325. margin-bottom: 30rpx;
  326. padding: 0 30rpx;
  327. .progress-bar-bg {
  328. position: relative;
  329. width: 100%;
  330. height: 15rpx;
  331. background: #BDFAAD;
  332. border-radius: 6rpx;
  333. .progress-bar-fill {
  334. position: absolute;
  335. left: 0;
  336. top: 0;
  337. height: 100%;
  338. background: linear-gradient(90deg, #4CAF50, #8BC34A);
  339. border-radius: 6rpx;
  340. transition: width 0.3s ease;
  341. }
  342. .progress-dot {
  343. position: absolute;
  344. top: 50%;
  345. transform: translateX(-50%) translateY(-50%);
  346. width: 32rpx;
  347. height: 32rpx;
  348. }
  349. }
  350. .progress-text {
  351. display: block;
  352. text-align: center;
  353. font-size: 26rpx;
  354. color: #666;
  355. margin-top: 16rpx;
  356. }
  357. }
  358. .scan-btn-wrapper {
  359. position: relative;
  360. width: 300rpx;
  361. height: 90rpx;
  362. margin: 0 auto 30rpx;
  363. background: url('/packet/static/get/button1.png') no-repeat center center;
  364. background-size: 100% 100%;
  365. display: flex;
  366. align-items: center;
  367. justify-content: center;
  368. .scan-btn-text {
  369. font-family: Adobe Heiti Std;
  370. font-size: 42rpx;
  371. color: #FFFFFF;
  372. text-align: center;
  373. }
  374. }
  375. .bottom-text {
  376. font-family: Adobe Heiti Std;
  377. font-size: 38rpx;
  378. color: #003C14;
  379. text-align: center;
  380. font-style: normal;
  381. margin: 0 auto;
  382. margin-left: 60rpx;
  383. }
  384. }
  385. }
  386. }
  387. </style>