upsell-share.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. upsellCode: "",
  57. };
  58. },
  59. methods: {
  60. open(upsellCode) {
  61. this.showPopup = true;
  62. this.upsellCode = upsellCode;
  63. this.getInviteHelpQuery(upsellCode);
  64. },
  65. //获取分享的邀请人信息 /token/order/inviteHelpQuery
  66. getInviteHelpQuery(upsellCode) {
  67. uni.$u.http
  68. .post(`/token/order/inviteHelpQuery?upsellCode=${upsellCode}`)
  69. .then((res) => {
  70. console.log(res, 'res')
  71. if (res.code == 200) {
  72. this.avatarUrl = res.data.imgPath;
  73. this.username = res.data.nickName;
  74. this.inviteDone = res.data.inviteDone;
  75. } else {
  76. this.username = res.msg;
  77. uni.showToast({
  78. icon: "none",
  79. title: res.msg,
  80. });
  81. }
  82. });
  83. },
  84. close() {
  85. this.showPopup = false;
  86. uni.removeStorageSync("upsellCode");
  87. },
  88. viewRules() {
  89. // 打开活动规则弹窗
  90. this.$emit("view-rules");
  91. },
  92. //调用助力接口 /api/token/order/inviteClickHelp
  93. inviteClickHelp() {
  94. let upsellCode = this.upsellCode || uni.getStorageInfoSync("upsellCode");
  95. uni.$u.http
  96. .post(`/token/order/inviteClickHelp?upsellCode=${upsellCode}`)
  97. .then((res) => {
  98. if (res.code == 200) {
  99. this.close();
  100. this.inviteDone = 0;
  101. uni.showToast({
  102. icon: "none",
  103. title: "助力成功",
  104. });
  105. this.$emit("inviteSuccess");
  106. } else {
  107. uni.showToast({
  108. icon: "none",
  109. title: res.msg || "助力失败",
  110. });
  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") 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>