reduce-share.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <custom-popup v-model="showPopup" mode="center" border-radius="24" width="540rpx" :bg-color="'transparent'">
  3. <view class="share-container">
  4. <!-- 标题 -->
  5. <view class="title-text">
  6. <view>好友邀您助力</view>
  7. <view>减少买书消费</view>
  8. </view>
  9. <!-- 活动规则按钮 -->
  10. <view class="rules-button-container">
  11. <u-button class="rules-button" :custom-style="rulesButtonStyle" @click="viewRules">查看活动规则</u-button>
  12. </view>
  13. <!-- 用户信息区域 -->
  14. <view class="user-info">
  15. <view class="avatar-container">
  16. <u-avatar :src="avatarUrl" size="140"></u-avatar>
  17. </view>
  18. <view class="username">{{ username }}</view>
  19. </view>
  20. <!-- 助力按钮 -->
  21. <button class="help-button" @click="inviteClickHelp" v-if="inviteDone == 1">
  22. 点击助力
  23. </button>
  24. <button class="help-button" @click="close" v-if="inviteDone == 0">
  25. 助力成功
  26. </button>
  27. <!-- 关闭按钮 -->
  28. <view class="close-button" @click="close">
  29. <image src="/static/img/activity/close2.png" mode="widthFix"></image>
  30. </view>
  31. </view>
  32. </custom-popup>
  33. </template>
  34. <script>
  35. import customPopup from "@/components/custom-popup.vue";
  36. export default {
  37. components: {
  38. customPopup,
  39. },
  40. data() {
  41. return {
  42. showPopup: false,
  43. avatarUrl: "", // 用户头像URL
  44. username: "", // 用户名,带星号
  45. // 自定义按钮样式
  46. rulesButtonStyle: {
  47. backgroundColor: "#39c248",
  48. color: "#FFFFFF",
  49. fontSize: "28rpx",
  50. width: "280rpx",
  51. height: "80rpx",
  52. borderRadius: "40rpx",
  53. },
  54. // 邀请可以助力 0-否(完成不能再助力) 1-是
  55. inviteDone: 1,
  56. reduceCode: "",
  57. };
  58. },
  59. methods: {
  60. open(reduceCode) {
  61. this.showPopup = true;
  62. this.reduceCode = reduceCode;
  63. this.getInviteHelpQuery(reduceCode);
  64. },
  65. //获取分享的邀请人信息
  66. getInviteHelpQuery(reduceCode) {
  67. this.$u.api.reduceHelpQueryAjax(reduceCode).then((res) => {
  68. console.log(res, 'res')
  69. if (res.code == 200) {
  70. this.avatarUrl = res.data.imgPath;
  71. this.username = res.data.nickName;
  72. this.inviteDone = res.data.inviteDone;
  73. } else {
  74. this.username = res.msg;
  75. uni.showToast({
  76. icon: "none",
  77. title: res.msg,
  78. });
  79. }
  80. });
  81. },
  82. close() {
  83. this.showPopup = false;
  84. uni.removeStorageSync("reduceCode");
  85. },
  86. viewRules() {
  87. // 打开活动规则弹窗
  88. this.$emit("view-rules");
  89. },
  90. //调用助力接口
  91. inviteClickHelp() {
  92. let reduceCode = this.reduceCode || uni.getStorageSync("reduceCode");
  93. this.$u.api.reduceClickHelpAjax({ reduceCode: reduceCode }).then((res) => {
  94. if (res.code == 200) {
  95. this.close();
  96. this.inviteDone = 0;
  97. uni.showToast({
  98. icon: "none",
  99. title: "助力成功",
  100. duration: 2000
  101. });
  102. this.$emit("inviteSuccess");
  103. } else {
  104. uni.showToast({
  105. icon: "none",
  106. title: res.msg || "助力失败",
  107. duration: 2000
  108. });
  109. }
  110. });
  111. },
  112. },
  113. };
  114. </script>
  115. <style lang="scss" scoped>
  116. .share-container {
  117. position: relative;
  118. padding: 40rpx;
  119. border-radius: 24rpx;
  120. text-align: center;
  121. background: url("https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/bg.png") no-repeat center center;
  122. background-size: 100% 100%;
  123. }
  124. .title-text view {
  125. font-size: 50rpx;
  126. font-weight: bold;
  127. color: #000;
  128. }
  129. .rules-button-container {
  130. display: flex;
  131. justify-content: center;
  132. margin: 20rpx 0 40rpx;
  133. .rules-button {
  134. position: relative;
  135. &::before,
  136. &::after {
  137. content: "";
  138. position: absolute;
  139. top: 50%;
  140. width: 80rpx;
  141. height: 2rpx;
  142. background-color: #39c248;
  143. }
  144. &::before {
  145. left: -90rpx;
  146. }
  147. &::after {
  148. right: -90rpx;
  149. }
  150. }
  151. }
  152. .user-info {
  153. .avatar-container {
  154. margin: 0 auto 20rpx;
  155. width: 140rpx;
  156. height: 140rpx;
  157. border-radius: 50%;
  158. overflow: hidden;
  159. }
  160. .username {
  161. font-size: 28rpx;
  162. color: #333;
  163. background: #39c248;
  164. padding: 6rpx 20rpx;
  165. border-radius: 30rpx;
  166. color: #fff;
  167. display: inline-block;
  168. position: relative;
  169. top: -50rpx;
  170. }
  171. }
  172. .help-button {
  173. height: 90rpx;
  174. background: linear-gradient(to bottom, #47d46c, #24ad3c);
  175. font-size: 32rpx;
  176. color: #ffffff;
  177. border-radius: 10rpx;
  178. line-height: 90rpx;
  179. width: 100%;
  180. margin-top: 20rpx;
  181. border: none;
  182. }
  183. .close-button {
  184. position: absolute;
  185. bottom: -120rpx;
  186. left: 50%;
  187. transform: translateX(-50%);
  188. image {
  189. width: 70rpx;
  190. height: 70rpx;
  191. }
  192. }
  193. </style>