upsell-share.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. }else {
  87. uni.$u.toast(res.msg);
  88. }
  89. });
  90. },
  91. close() {
  92. this.showPopup = false;
  93. },
  94. viewRules() {
  95. // 打开活动规则弹窗
  96. this.$emit("view-rules");
  97. this.close();
  98. },
  99. //调用助力接口 /api/token/order/inviteClickHelp
  100. inviteClickHelp() {
  101. let upsellCode = this.upsellCode || uni.getStorageInfoSync("upsellCode");
  102. uni.$u.http
  103. .post(`/token/order/inviteClickHelp?upsellCode=${upsellCode}`)
  104. .then((res) => {
  105. if (res.code == 200) {
  106. this.close();
  107. this.inviteDone = 0;
  108. uni.$u.toast("助力成功");
  109. } else {
  110. uni.$u.toast(res.msg);
  111. }
  112. });
  113. },
  114. },
  115. };
  116. </script>
  117. <style lang="scss" scoped>
  118. .share-container {
  119. position: relative;
  120. padding: 40rpx;
  121. border-radius: 24rpx;
  122. text-align: center;
  123. background: url("https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/bg.png")
  124. no-repeat center center;
  125. background-size: 100% 100%;
  126. }
  127. .title-text view {
  128. font-size: 50rpx;
  129. font-weight: bold;
  130. color: #000;
  131. }
  132. .rules-button-container {
  133. display: flex;
  134. justify-content: center;
  135. margin: 20rpx 0 40rpx;
  136. .rules-button {
  137. position: relative;
  138. &::before,
  139. &::after {
  140. content: "";
  141. position: absolute;
  142. top: 50%;
  143. width: 80rpx;
  144. height: 2rpx;
  145. background-color: #39c248;
  146. }
  147. &::before {
  148. left: -90rpx;
  149. }
  150. &::after {
  151. right: -90rpx;
  152. }
  153. }
  154. }
  155. .user-info {
  156. .avatar-container {
  157. margin: 0 auto 20rpx;
  158. width: 140rpx;
  159. height: 140rpx;
  160. border-radius: 50%;
  161. overflow: hidden;
  162. }
  163. .username {
  164. font-size: 28rpx;
  165. color: #333;
  166. background: #39c248;
  167. padding: 6rpx 20rpx;
  168. border-radius: 30rpx;
  169. color: #fff;
  170. display: inline-block;
  171. position: relative;
  172. top: -50rpx;
  173. }
  174. }
  175. .help-button {
  176. height: 90rpx;
  177. background: linear-gradient(to bottom, #47d46c, #24ad3c);
  178. font-size: 32rpx;
  179. color: #ffffff;
  180. border-radius: 10rpx;
  181. line-height: 90rpx;
  182. width: 100%;
  183. margin-top: 20rpx;
  184. border: none;
  185. }
  186. .close-button {
  187. position: absolute;
  188. bottom: -120rpx;
  189. left: 50%;
  190. transform: translateX(-50%);
  191. image {
  192. width: 70rpx;
  193. height: 70rpx;
  194. }
  195. }
  196. </style>