get.vue 15 KB

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