upsell-share.vue 4.6 KB

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