invite-new-user.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <layout title="邀请好友得现金" :isGoBack="true" padding="0" :isShowNav="!$userAgent.isWx">
  3. <template #right>
  4. <!-- nav right -->
  5. <span @click="onRightHandle">活动规则</span>
  6. </template>
  7. <!-- 微信环境提示浏览器打开 -->
  8. <WxPopTpis v-if="isWeChatBrowser" />
  9. <!-- container -->
  10. <div class="invite-container">
  11. <!-- 分享按钮 -->
  12. <van-button @click="shareHandle" class="share-btn mb-8" round />
  13. <div class="day-statistics mb-3">今日邀请注册人数:{{ registerCount }}</div>
  14. <div class="user-main pt-3 pr-3 pb-3 pl-3 mb-3">
  15. <div class="userinfo">
  16. <img class="avatar mr-1" src="~assets/image/activity/invite-user/invite-new-user/avatar.png" alt="">
  17. <div class="userinfo-text ml-1">
  18. <div class="userinfo-name">{{ nickname }}</div>
  19. </div>
  20. </div>
  21. <div class="possess-warp mb-3">
  22. <div class="withdrawal-text">可提现<span class="withdrawal-money ml-2">¥{{ withdrawalBalance }}</span></div>
  23. <div class="withdrawal-btn" :class="{'disable': withdrawalBalance < withdrawalThreshold || withdrawalBalance === 0 }" @click="()=>(withdrawalBalance >= withdrawalThreshold && withdrawalHandle())">提现</div>
  24. </div>
  25. <div class="userinfo-detail">
  26. <div class="userinfo-detail-item pt-4 pr-3 pb-3 pl-3">
  27. <div class="userinfo-detail-item-content">{{ inviteBuyAmount }}</div>
  28. <div class="userinfo-detail-item-title">累计邀请购买</div>
  29. </div>
  30. <div style="flex: 0 0 11px"></div>
  31. <div class="userinfo-detail-item pt-4 pr-3 pb-3 pl-3">
  32. <div class="userinfo-detail-item-content">{{ accumulatedWithdrawal }}</div>
  33. <div class="userinfo-detail-item-title">累计提现</div>
  34. </div>
  35. </div>
  36. </div>
  37. <div class="record-wrap">
  38. <van-tabs v-model="activeTab" shrink background="#FFFBE2">
  39. <van-tab v-for="(tab, i) in tabs" :title="tab.title" :key="i">
  40. <!-- 邀请记录 -->
  41. <RecordList
  42. v-if="activeTab === 0"
  43. class="mt-3 pr-1 pl-1 list-wrqp"
  44. :data="tab.data"
  45. :key="i"
  46. />
  47. <!-- 购买记录 -->
  48. <BuyRecordList class="mt-3 pr-1 pl-1 list-wrqp" v-if="activeTab === 1" :data="tab.data"/>
  49. <!-- 提现记录 -->
  50. <WithdrawalRecord
  51. v-if="activeTab === 2"
  52. class="mt-3 pr-1 pl-1 list-wrqp"
  53. :data="tab.data"
  54. :key="i"
  55. />
  56. <!-- 分页 -->
  57. <InvitePagination v-if="tab.total" :total="tab.total" :pageSize="tab.query.pageSize" :currentPage="tab.query.pageNum" @onPageChange="pageChangeHandle" />
  58. </van-tab>
  59. </van-tabs>
  60. </div>
  61. <!-- 分享弹窗 -->
  62. <SharePopup ref="sharePopup" :qrText="qrText" :nickname="nickname" />
  63. </div>
  64. </layout>
  65. </template>
  66. <script>
  67. /**
  68. * Date: 2025-4-3 oem商户拉新分佣活动
  69. */
  70. import { Dialog } from 'vant';
  71. import layout from './components/layout';
  72. import RecordList from './components/RecordList';
  73. import InvitePagination from './components/InvitePagination';
  74. import BuyRecordList from './components/BuyRecordList';
  75. import WithdrawalRecord from './components/WithdrawalRecord';
  76. import SharePopup from './components/SharePopup';
  77. import WxPopTpis from './components/WxPopTpis';
  78. export default {
  79. auth: false,
  80. name: 'OemInviteNewUser',
  81. head: {
  82. title: '邀请好友得现金',
  83. },
  84. components: { layout, RecordList, InvitePagination, BuyRecordList, WithdrawalRecord, SharePopup, WxPopTpis },
  85. data() {
  86. return {
  87. qrText: '', // 生成二维码的文本
  88. registerCount: 0, // 今日注册人数
  89. nickname: '', // 用户昵称
  90. withdrawalBalance: 0, // 可提现余额
  91. withdrawalThreshold: 0, // 提现门槛值
  92. inviteBuyAmount: 0, // 累计邀请金额
  93. accumulatedWithdrawal: 0, // 累计提现金额,
  94. // 查询参数
  95. queryData: {
  96. activityId: '', // 活动ID
  97. },
  98. activeTab: 0,
  99. tabs: [{
  100. title: '邀请记录',
  101. requireMethod: 'getInviteRecordList', // 请求定义的方法key
  102. query: {
  103. pageNum: 1, // 页码
  104. pageSize: 5, // 每页数量
  105. },
  106. data: [],
  107. total: 0,
  108. },{
  109. title: '购买记录',
  110. requireMethod: 'getInviteBuyRecordList', // 请求定义的方法key
  111. query: {
  112. pageNum: 1,
  113. pageSize: 5,
  114. },
  115. data: [],
  116. total: 0,
  117. },{
  118. title: '提现记录',
  119. requireMethod: 'getInviteBuyRecordList', // 请求定义的方法key
  120. query: {
  121. pageNum: 1,
  122. pageSize: 5,
  123. },
  124. data: [],
  125. total: 0,
  126. }],
  127. }
  128. },
  129. // 页面初始化后触发
  130. async fetch() {
  131. // 获取参数的token值
  132. let token = this.$route.query.token;
  133. if(!token) {return this.$toast('用户信息获取失败')}
  134. // token参数会自动被系统获取,请求接口自动带上token
  135. await this.getActivityData();
  136. await this.getInviteRecordList();
  137. await this.getInviteBuyRecordList();
  138. await this.getInviteWithdrawalRecordList();
  139. // await this.getActivityRule(this.queryData.activityId);
  140. },
  141. computed: {
  142. // 是否为微信浏览器环境
  143. isWeChatBrowser() {
  144. return this.$userAgent.isWx;
  145. }
  146. },
  147. methods: {
  148. // nav right菜单点击事件
  149. onRightHandle() {
  150. this.$router.push({ path: '/activity/invite-user/invite-new-user-rule', query: { activityId: this.queryData.activityId} })
  151. },
  152. // 分享按钮点击事件
  153. shareHandle() {
  154. this.$refs.sharePopup.showPopup();
  155. },
  156. // 分页点击事件
  157. pageChangeHandle(page) {
  158. let active = this.activeTab;
  159. this.tabs[active].query.pageNum = page;
  160. // 发起请求
  161. this[this.tabs[active].requireMethod]();
  162. },
  163. // 提现按钮点击
  164. withdrawalHandle() {
  165. Dialog.alert({
  166. message: '请到APP内-我的-联系客服提现',
  167. confirmButtonColor: '#1A96D2',
  168. });
  169. },
  170. // 获取活动页上部分数据
  171. async getActivityData() {
  172. const res = await this.$axios.$get('/activity/v5/activity/inviteNewUser/getInviteNewUserPageData');
  173. let {
  174. registerCount, // 今日注册人数
  175. nickname, // 用户昵称
  176. withdrawalBalance, // 可提现余额
  177. withdrawalThreshold, // 提现门槛值
  178. inviteBuyAmount, // 累计邀请金额
  179. activityId, // 活动ID
  180. accumulatedWithdrawal, // 累计提现金额
  181. jumpAddress, // 分享的链接
  182. } = res.data;
  183. // 页面展示数据
  184. this.registerCount = registerCount;
  185. this.nickname = nickname;
  186. this.withdrawalBalance = withdrawalBalance;
  187. this.withdrawalThreshold = withdrawalThreshold;
  188. this.inviteBuyAmount = inviteBuyAmount;
  189. this.accumulatedWithdrawal = accumulatedWithdrawal;
  190. // 查询参数
  191. this.queryData.activityId = activityId;
  192. jumpAddress;
  193. // 生成二维码的文本
  194. this.qrText = jumpAddress;
  195. },
  196. // 获取活动页好友注册记录列表
  197. async getInviteRecordList() {
  198. let {status, success, data} = await this.$axios.$post(
  199. '/activity/v5/activity/inviteNewUser/getInviteNewRegisterUserData',
  200. { ...this.queryData, ...this.tabs[0].query },
  201. );
  202. if(status === 0 && success) {
  203. this.tabs[0].data = data.list;
  204. this.tabs[0].total = data.total;
  205. }
  206. /*
  207. 友注册记录列表数据格式
  208. {
  209. id: 1,
  210. name: '1305677',
  211. phoneNumber: '13800138000',
  212. createTime: '2025-04-03 10:00:00',
  213. money: '100.00',
  214. status: '已提现',
  215. }
  216. */
  217. },
  218. // 获取活动页好友购买记录列表
  219. async getInviteBuyRecordList() {
  220. let {status, success, data} = await this.$axios.$post(
  221. '/activity/v5/activity/inviteNewUser/getInviteNewUserBuyData',
  222. { ...this.queryData, ...this.tabs[1].query },
  223. );
  224. if(status === 0 && success) {
  225. this.tabs[1].data = data.list;
  226. this.tabs[1].total = data.total;
  227. }
  228. },
  229. // 获取活动页好友提现记录列表
  230. async getInviteWithdrawalRecordList() {
  231. let {status, success, data} = await this.$axios.$post(
  232. '/activity/v5/activity/inviteNewUser/getInviteNewUserWithdrawalRecodeList',
  233. {...this.queryData,...this.tabs[2].query },
  234. );
  235. if(status === 0 && success) {
  236. this.tabs[2].data = data.list;
  237. this.tabs[2].total = data.total;
  238. }
  239. },
  240. // 获取邀请url地址,用于生成二维码 id: 活动ID
  241. async getActivityRule(id) {
  242. let {status, success, data} = await this.$axios.$get('/activity/activity/basic/getDetailsById',{
  243. params: { id }
  244. });
  245. if(status === 0 && success) {
  246. // 生成二维码的文本
  247. this.qrText = `${data?.activityInviteNewUser?.jumpAddress}?activityId=${id}&invitationUserName=${this.nickname}`;
  248. }
  249. }
  250. }
  251. }
  252. </script>
  253. <style lang="scss" scoped>
  254. .mb-12{
  255. margin-bottom: 12px;
  256. }
  257. // 动态生成 从 0 到 100px 的样式
  258. @for $i from 0 through 100 {
  259. .mb-#{$i} {
  260. margin-bottom: #{$i}px;
  261. }
  262. .mt-#{$i} {
  263. margin-top: #{$i}px;
  264. }
  265. .ml-#{$i} {
  266. margin-left: #{$i}px;
  267. }
  268. .mr-#{$i} {
  269. margin-right: #{$i}px;
  270. }
  271. }
  272. $-radeus-12: 12px;
  273. $-bg-yellow: rgb(255, 253, 241);
  274. .invite-container {
  275. font-size: 12px;
  276. height: 100%;
  277. width: 100%;
  278. display: flex;
  279. flex-direction: column;
  280. background-image: url('~assets/image/activity/invite-user/invite-new-user/bg-img.png');
  281. background-size: 100% auto;
  282. background-position: top;
  283. background-repeat: no-repeat;
  284. background-color: #EB3043;
  285. padding: 372px 16px 16px;
  286. .share-btn {
  287. height: 56px;
  288. // background-color: #FF505C;
  289. background-image: url('~/assets/image/activity/invite-user/invite-new-user/share-to-earn-commission.png');
  290. background-size: 100% 100%;
  291. background-repeat: no-repeat;
  292. background-position: center;
  293. background-origin: padding-box;
  294. z-index: 0;
  295. }
  296. .day-statistics{
  297. line-height: 32px;
  298. font-size: 14px;
  299. color: #FA393A;
  300. font-weight: 500;
  301. border-radius: $-radeus-12;
  302. background-color: $-bg-yellow;
  303. text-align: center;
  304. }
  305. .user-main{
  306. display: flex;
  307. flex-direction: column;
  308. background-color: $-bg-yellow;
  309. border-radius: $-radeus-12;
  310. .userinfo{
  311. display: flex;
  312. align-items: center;
  313. .avatar{
  314. width: 40px;
  315. height: 40px;
  316. border-radius: 50%;
  317. }
  318. .userinfo-text{
  319. display: flex;
  320. flex-direction: column;
  321. .userinfo-name{
  322. font-size: 14px;
  323. color: #242424;
  324. }
  325. .userinfo-id{
  326. color: #979797;
  327. }
  328. }
  329. }
  330. .possess-warp{
  331. display: flex;
  332. align-items: center;
  333. justify-content: space-between;
  334. .withdrawal-text{
  335. color: #0A132B;
  336. .withdrawal-money{
  337. color: #FA393A;
  338. font-size: 24px;
  339. font-weight: bold;
  340. }
  341. }
  342. .withdrawal-btn{
  343. width: 70px;
  344. line-height: 26px;
  345. border-radius: $-radeus-12;
  346. background-color: #FA393A;
  347. color: #fff;
  348. font-size: 14px;
  349. text-align: center;
  350. &.disable{
  351. background-color: #E0E0E0;
  352. color: #979797;
  353. }
  354. }
  355. }
  356. .userinfo-detail{
  357. display: flex;
  358. align-items: center;
  359. justify-content: space-between;
  360. .userinfo-detail-item{
  361. flex: 1;
  362. display: flex;
  363. flex-direction: column;
  364. align-items: start;
  365. background-color: rgb(255, 242, 231);
  366. border-radius: 12px;
  367. .userinfo-detail-item-content{
  368. font-size: 18px;
  369. font-weight: bold;
  370. color: #242424;
  371. }
  372. .userinfo-detail-item-title{
  373. font-weight: 400;
  374. color: #979797;
  375. }
  376. }
  377. }
  378. }
  379. .record-wrap{
  380. min-height: 220px;
  381. background-color: $-bg-yellow;
  382. border-radius: $-radeus-12;
  383. overflow: hidden;
  384. }
  385. }
  386. </style>