upsell-share.vue 4.7 KB

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