invite-new-user.vue 13 KB

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