get.vue 14 KB

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