invite-fission.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. <template>
  2. <v-container class="invite-user" fluid>
  3. <div class="rule" @click="show = true">规则</div>
  4. <div class="box1">
  5. <div class="award-container">
  6. <div class="card" v-for="(item,index) in levelNameList" :key="index">
  7. <div class="card-name">{{ item.rewardGiveaways }}</div>
  8. <div class="card-desc">{{ item.satisfyConditions }}</div>
  9. </div>
  10. </div>
  11. <v-btn v-if="received" class="share-button" :style="{display: levelNameList.length ? 'block': 'none'}" rounded @click="share()">
  12. 云机免费领取
  13. </v-btn>
  14. <v-btn v-else class="share-button" :style="{display: levelNameList.length ? 'block': 'none'}" rounded @click="share()">
  15. 赶紧分享你的好友,送云机时长
  16. </v-btn>
  17. </div>
  18. <div class="intr-container">
  19. <img src="~/assets/image/activity/invite-user/cybz-content-4@2x.png" alt="">
  20. </div>
  21. <div class="box3">
  22. <div v-if="myActivationCode.length" class="code-table">
  23. <div class="table-body">
  24. <div v-for="(item, index) in myActivationCode" :key="index" class="box-container">
  25. <div class="index-container">{{ index+1 }}</div>
  26. <div class="date-container">{{ item.createTime | formatDate('MM月DD日 HH:mm') }}</div>
  27. <div class="code-container">{{ item.activationCode | activationCodeMask }}</div>
  28. <div class="operation-container"><v-btn text small color="#FF9616" class="copy-btn" @click="copyCode(item)">复制</v-btn></div>
  29. </div>
  30. <div v-if="myActivationCode.length" v-intersect.quiet="codeLoadMoreIntersect" class="flex item-center justify-center">
  31. <v-btn :loading="codeIsLoading" text small>
  32. <template v-if="codeIsLoading">加载中</template>
  33. <template v-else-if="codeHasMore">加载更多</template>
  34. <template v-else>没有更多</template>
  35. </v-btn>
  36. </div>
  37. </div>
  38. </div>
  39. <div v-else class="fwc">
  40. <img src="~/assets/image/activity/invite-user/noReward@2x.png" alt="">
  41. </div>
  42. </div>
  43. <div class="income">
  44. <div class="first-line">
  45. <div class="accumulated-quantity">{{ accumulatedQuantity }}</div>
  46. <div class="quantity-today">{{ quantityObtainedToday }}</div>
  47. </div>
  48. <div class="second-line">
  49. <div class="thirty">{{ thirty }}</div>
  50. <div class="ninety">{{ ninety }}</div>
  51. <div class="oneHundredAndEighty">{{ oneHundredAndEighty }}</div>
  52. <div class="threeHundredAndSixtyFive">{{ threeHundredAndSixtyFive }}</div>
  53. </div>
  54. </div>
  55. <van-popup v-model="show" style="background: transparent;padding-bottom: 60px;width: 100%;">
  56. <activity-invite-user-box class="box4">
  57. <template #title>活动规则</template>
  58. <div class="text-sm" v-html="activityRules"></div>
  59. </activity-invite-user-box>
  60. <van-icon name="close" class="close1" color="#939393" @click="show = false;" />
  61. </van-popup>
  62. </v-container>
  63. </template>
  64. <script>
  65. import { Toast, Dialog } from 'vant';
  66. import NativeShare from 'nativeshare';
  67. import { fileKeyToUrl } from '@/plugins/file-center.js';
  68. export default {
  69. auth: false,
  70. name: 'Fission',
  71. filters: {
  72. activationCodeMask(value) {
  73. return value.replace(/(.{2})(.*)(.{2}$)/, '$1**$3');
  74. },
  75. timeStamp(StatusMinute) {
  76. const day = parseInt(StatusMinute / 60 / 60 / 24);
  77. const hour = parseInt((StatusMinute / 60 / 60) % 24);
  78. const min = parseInt(StatusMinute / 60 % 60);
  79. StatusMinute = '';
  80. if (day > 0) {
  81. StatusMinute = day + '天';
  82. }
  83. if (hour > 0) {
  84. StatusMinute += hour + '小时';
  85. }
  86. if (min > 0) {
  87. StatusMinute += parseFloat(min) + '分钟';
  88. }
  89. return StatusMinute;
  90. }
  91. },
  92. data() {
  93. return {
  94. show: false,
  95. current: 0,
  96. data: {
  97. todayIncomeStarCoin: 0,
  98. totalIncomeStarCoin: 0,
  99. todayBuyOrderCount: 0,
  100. totalBuyOrderCount: 0,
  101. todayBuyOrderSuccessCount: 0,
  102. totalBuyOrderSuccessCount: 0,
  103. withdrawStarCoinNum: 0,
  104. inviteUserName: null,
  105. activityId: null,
  106. status: 0,
  107. type: 2
  108. },
  109. level: {
  110. currentLevelName: '',
  111. activityId: '',
  112. levelAwardDetails: [],
  113. shareFriendCount: 0,
  114. boostValue: 0
  115. },
  116. activityRules: '',
  117. myActivationCode: [],
  118. levelAwardRankings: [],
  119. myCodeFrom: {
  120. activityId: null,
  121. pageNum: 1,
  122. pageSize: 8,
  123. },
  124. codeTotal: -1,
  125. codeIsLoading: false,
  126. client: 1,
  127. token: '',
  128. width: 0,
  129. boostValue: 0,
  130. currentEndTime: 0,
  131. currentRanking: 0,
  132. preRanking: 0,
  133. userType: 1,
  134. received: 0,
  135. shareInfo: {
  136. title: '双子星云手机',
  137. desc: `免费领取一台全能云手机!`,
  138. link: '',
  139. imgUrl: ''
  140. },
  141. showShare: false,
  142. accumulatedQuantity: 0,
  143. quantityObtainedToday: 0,
  144. thirty: 0,
  145. ninety: 0,
  146. oneHundredAndEighty: 0,
  147. threeHundredAndSixtyFive: 0,
  148. levelNameList: []
  149. };
  150. },
  151. async fetch() {
  152. // 页面初始化后触发
  153. try {
  154. this.token = this.$route.query.token;
  155. // await this.getActiveInfo();
  156. // await this.shareCanReceiveCloudPhone();
  157. await Promise.all([
  158. this.getActivityRules(),
  159. // this.type === 2 && this.getMyActivationCode(this.myCodeFrom),
  160. // this.myCodeFrom.activityId && this.getRanking({ activityId: this.myCodeFrom.activityId })
  161. ]);
  162. } catch (error) {
  163. Toast({
  164. message: error.message,
  165. duration: 4000
  166. });
  167. }
  168. if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  169. this.client = 1;
  170. } else if (this.$userAgent.isSzx && this.$userAgent.isIos) {
  171. this.client = 2;
  172. } else if (this.$userAgent.isMiniProgram) {
  173. this.client = 5;
  174. } else {
  175. this.client = 7;
  176. }
  177. },
  178. head: {
  179. title: '邀请好友'
  180. },
  181. computed: {
  182. codeHasMore() {
  183. return (
  184. this.codeTotal < 0 ||
  185. this.myCodeFrom.pageNum * this.myCodeFrom.pageSize < this.codeTotal
  186. );
  187. },
  188. type() {
  189. return 2;
  190. },
  191. },
  192. mounted() {
  193. this.makePoint('activity_Share_PV')
  194. this.makePoint('activity_Share_UV')
  195. this.addUserVisit(12);
  196. this.receiveLevelAward()
  197. },
  198. methods: {
  199. // async shareCanReceiveCloudPhone() {
  200. // try {
  201. // const res = await this.$axios.$get('/resources/register/send/cloud/phone/shareCanReceiveCloudPhone', {}, { headers: { Authorization: this.token } });
  202. // this.received = res.data.received
  203. // this.shareInfo.title = res.data.title
  204. // this.shareInfo.desc = res.data.content
  205. // this.shareInfo.link = res.data.url
  206. // this.shareInfo.imgUrl = fileKeyToUrl(res.data.imgUrl)
  207. // this.$native.setShareInfo(this.shareInfo);
  208. // } catch (err) {
  209. // Toast({
  210. // message: err.message,
  211. // position: 'top'
  212. // });
  213. // }
  214. // },
  215. async shareReceiveCloudPhone() {
  216. try {
  217. const res = await this.$axios.$post('/resources/register/send/cloud/phone/shareReceiveCloudPhone', {}, { headers: { Authorization: this.token } });
  218. Dialog.alert({
  219. message: res.msg,
  220. }).then(() => {
  221. this.showShare = false
  222. });
  223. this.addUserVisit(7);
  224. } catch (err) {
  225. Toast({
  226. message: err.message,
  227. position: 'top'
  228. });
  229. }
  230. },
  231. receiveLevelAward() {
  232. this.$axios.$get('/activity/v4/fissionDistribution/getDetails', { headers: { Authorization: this.token } }).then(res => {
  233. console.log(res)
  234. this.accumulatedQuantity = res.data.accumulatedQuantity
  235. this.quantityObtainedToday = res.data.quantityObtainedToday
  236. this.thirty = res.data.thirty
  237. this.ninety = res.data.ninety
  238. this.oneHundredAndEighty = res.data.oneHundredAndEighty
  239. this.threeHundredAndSixtyFive = res.data.threeHundredAndSixtyFive
  240. this.shareInfo.title = res.data.title
  241. this.shareInfo.desc = res.data.content
  242. this.shareInfo.link = res.data.url
  243. this.shareInfo.imgUrl = fileKeyToUrl(res.data.imgUrl)
  244. this.$native.setShareInfo(this.shareInfo);
  245. this.myActivationCode = res.data.activationCodeList
  246. this.levelNameList = res.data.levelNameList
  247. // this.returnContent.forEach((item,index) => {
  248. // item.content = res.data.levelNameList[index]
  249. // })
  250. }).catch(err => {
  251. console.log(err)
  252. })
  253. },
  254. async myLevelAward() {
  255. const res = await this.$axios.$get(`/activity/v1/level/award/myLevelAward?activityId=${this.myCodeFrom.activityId}`, { headers: { Authorization: this.token } });
  256. this.level = res.data;
  257. if (this.level.levelAwardDetails) {
  258. this.width = 0;
  259. const levelLength = 280 / (this.level.levelAwardDetails.length - 1)
  260. this.level.levelAwardDetails.forEach((item, index) => {
  261. if (item.status > 0) {
  262. if (index > 0) {
  263. this.width += levelLength
  264. }
  265. if (index === 0 || index === this.level.levelAwardDetails.length - 1) {
  266. this.width += 14
  267. }
  268. }
  269. })
  270. }
  271. },
  272. // async getActiveInfo() {
  273. // const res = await this.$axios.$get('/activity/v1/inviteUser/orderRelation/starCoinOverview', { headers: { Authorization: this.token } });
  274. // this.data = res.data;
  275. // this.myCodeFrom.activityId = res.data.activityId;
  276. // if (this.myCodeFrom.activityId) {
  277. // await this.myLevelAward();
  278. // }
  279. // },
  280. // async getMyActivationCode(params) {
  281. // try {
  282. // this.codeIsLoading = true;
  283. // const res = await this.$axios.$get('/activity/v1/inviteUser/orderRelation/myActivationCode', { params, headers: { Authorization: this.token } });
  284. // this.codeTotal = res.data.total;
  285. // this.myActivationCode.push(
  286. // ...(res.data.list ?? [])
  287. // );
  288. // this.myCodeFrom = params;
  289. // } finally {
  290. // this.codeIsLoading = false;
  291. // }
  292. // },
  293. // async getRanking(params) {
  294. // try {
  295. // this.codeIsLoading = true;
  296. // const res = await this.$axios.$get('/activity/v1/level/award/ranking', { params, headers: { Authorization: this.token } });
  297. // this.boostValue = res.data.boostValue
  298. // this.currentEndTime = res.data.currentEndTime
  299. // this.currentRanking = res.data.currentRanking
  300. // this.preRanking = res.data.preRanking
  301. // this.levelAwardRankings = res.data.levelAwardRankings;
  302. // this.userType = res.data.userType;
  303. // } finally {
  304. // this.codeIsLoading = false;
  305. // }
  306. // },
  307. share() {
  308. // if (this.data.status !== 1) {
  309. // if (this.data.status === 0) {
  310. // Toast({
  311. // message: '当前活动已过期',
  312. // position: 'top'
  313. // });
  314. // return
  315. // }
  316. // if (this.data.status === 2) {
  317. // Toast({
  318. // message: '当前活动未开启',
  319. // position: 'top'
  320. // });
  321. // return
  322. // }
  323. // if (this.data.status === 3) {
  324. // Toast({
  325. // message: '当前活动已结束',
  326. // position: 'top'
  327. // });
  328. // return
  329. // }
  330. // Toast({
  331. // message: '未知活动状态',
  332. // position: 'top'
  333. // });
  334. // return
  335. // }
  336. this.$tongji.trackEvent('活动', '分享', '', 0);
  337. if (this.received) {
  338. this.addUserVisit(13);
  339. }
  340. console.log('env',this.$userAgent.isSzx , this.$userAgent.isSzxBrowser)
  341. if (this.$userAgent.isSzx || this.$userAgent.isSzxBrowser) {
  342. // app环境
  343. this.$native.share(this.shareInfo);
  344. console.log(this.shareInfo,'xxxx');
  345. // this.makePoint('activity_Share_分享好友按钮');
  346. } else {
  347. // 浏览器环境
  348. const nativeShare = new NativeShare()
  349. nativeShare.setShareData({
  350. icon: this.shareInfo.imgUrl,
  351. link: this.shareInfo.link,
  352. title: this.shareInfo.content,
  353. desc: this.shareInfo.title,
  354. success: () => {
  355. this.shareReceiveCloudPhone()
  356. },
  357. fail: () => {
  358. Toast({
  359. message: '分享失败',
  360. position: 'center'
  361. })
  362. }
  363. })
  364. try {
  365. nativeShare.call('wechatTimeline')
  366. } catch (err) {
  367. Toast({
  368. message: '您的浏览器不支持分享功能,请下载app使用!',
  369. position: 'center',
  370. duration: 3000
  371. })
  372. setTimeout(() => {
  373. window.open('https://www.androidscloud.com/', '_self');
  374. }, 3000)
  375. }
  376. }
  377. },
  378. makePoint(positionButton) {
  379. this.$axios.$post('/public/v5/buriedPointRecord/reportRecords', [
  380. {
  381. client: this.client,
  382. eventCode: '28_分享活动',
  383. userName: this.$auth.user.username,
  384. positionButton,
  385. operationTime: this.getCurrentTime(),
  386. phoneNumber: this.$auth.user.phone,
  387. deviceId: ''
  388. },
  389. ]);
  390. },
  391. getCurrentTime() {
  392. const date = new Date(); // 当前时间
  393. const year = date.getFullYear() // 年
  394. const month = this.repair(date.getMonth() + 1); // 月
  395. const day = this.repair(date.getDate()); // 日
  396. const hour = this.repair(date.getHours()); // 时
  397. const minute = this.repair(date.getMinutes()); // 分
  398. const second = this.repair(date.getSeconds()); // 秒
  399. // 当前时间
  400. const curTime = year + "-" + month + "-" + day +
  401. " " + hour + ":" + minute + ":" + second;
  402. return curTime;
  403. },
  404. repair(i) {
  405. if (i >= 0 && i <= 9) {
  406. return "0" + i;
  407. } else {
  408. return i;
  409. }
  410. },
  411. async getActivityRules() {
  412. const agreementCoding = {
  413. 1: 'iuserrules01',
  414. 2: 'iuserrules02',
  415. 3: 'iuserrules03',
  416. }[this.type];
  417. if (agreementCoding) {
  418. const res = await this.$axios.$get(
  419. '/public/v4/agreement/content/getContentByType',
  420. {
  421. params: {
  422. agreementCoding,
  423. type: 1,
  424. },
  425. },
  426. );
  427. this.activityRules = res.data.content
  428. .replace(/[\d\D]*<body>([\d\D]+)<\/body>[\d\D]*/i, '$1')
  429. .replace(/<div class="phone-container">([\d\D]+)<\/div>/g, '$1');
  430. }
  431. },
  432. async copyCode(item) {
  433. await this.$native.clipboard.writeText(item.activationCode);
  434. Toast({
  435. message: '复制激活码,请在【我的-兑换中心】兑换'
  436. });
  437. this.makePoint('activity_Share_激活码复制')
  438. },
  439. codeLoadMoreIntersect(event) {
  440. if (event[0].isIntersecting && this.codeHasMore && !this.codeIsLoading) {
  441. this.getMyActivationCode({
  442. ...this.myCodeFrom,
  443. pageNum: this.myCodeFrom.pageNum + 1,
  444. });
  445. }
  446. },
  447. addUserVisit(accessType) {
  448. this.$axios.$post('/user/v5/operateApi/addUserVisit', {
  449. accessType,
  450. loginType: 1
  451. });
  452. }
  453. }
  454. };
  455. </script>
  456. <style lang="scss" scoped>
  457. .rule {
  458. width: 24px;
  459. height: 56px;
  460. line-height: 28px;
  461. background: rgba(0, 0, 0, 0.19);
  462. border-radius: 6px 0px 0px 6px;
  463. font-size: 15px;
  464. font-weight: 400;
  465. color: #FFFFFF;
  466. position: absolute;
  467. right: 0;
  468. top: 28px;
  469. text-align: center;
  470. }
  471. .close1 {
  472. font-size: 30px;
  473. text-align: center;
  474. display: block;
  475. }
  476. .fwc {
  477. text-align: center;
  478. img {
  479. width: 75px;
  480. height: 83px;
  481. margin-top: 120px;
  482. }
  483. }
  484. .invite-user {
  485. color: #333;
  486. background-size: 100% auto;
  487. overflow: hidden;
  488. padding: 0;
  489. padding-bottom: env(safe-area-inset-bottom, 30px);
  490. background-color: #F67350;
  491. background-image: url('~/assets/image/activity/invite-user/bg-7@2x.png');
  492. }
  493. .box1 {
  494. margin: 240px auto 0;
  495. width: 373px;
  496. height: 442px;
  497. background: url('~/assets/image/activity/invite-user/box3@2x.png');
  498. background-size: 100% 100%;
  499. overflow: hidden;
  500. .share-button {
  501. display: block;
  502. margin: auto;
  503. width: 302px !important;
  504. height: 62px !important;
  505. background-image: url('~/assets/image/activity/invite-user/share-button@2x.png');
  506. background-size: 100% 100%;
  507. margin-top: 24px;
  508. color: #dd1b0d;
  509. font-size: 18px;
  510. font-weight: bold;
  511. }
  512. }
  513. .intr-container{
  514. width: 100%;
  515. img{
  516. width: 100%;
  517. }
  518. }
  519. .box3 {
  520. width: 345px;
  521. height: 517px;
  522. margin: 25px auto 0;
  523. background: url('~/assets/image/activity/invite-user/box4@2x.png');
  524. background-size: 100% 100%;
  525. padding: 80px 4px 0;
  526. box-sizing: border-box;
  527. }
  528. .code-table {
  529. .table-body {
  530. max-height: 430px;
  531. overflow-y: auto;
  532. }
  533. tr {
  534. height: 40px;
  535. color: #8F8F8F;
  536. }
  537. td {
  538. height: 40px;
  539. color: #333;
  540. }
  541. .copy-btn {
  542. min-width: 0 !important;
  543. height: auto !important;
  544. padding: 0 !important;
  545. }
  546. }
  547. .box4::v-deep .box-main {
  548. padding-left: 10px;
  549. padding-right: 10px;
  550. }
  551. .box-container{
  552. display: flex;
  553. height: 48px;
  554. align-items: center;
  555. font-size: 12px;
  556. color: #333;
  557. text-align: center;
  558. .index-container{
  559. width: 50px;
  560. }
  561. .date-container{
  562. width: 120px;
  563. }
  564. .code-container{
  565. width: 90px;
  566. }
  567. .operation-container{
  568. width: 50px;
  569. margin-left: 25px;
  570. }
  571. }
  572. .award-container{
  573. display: flex;
  574. flex-wrap: wrap;
  575. justify-content: space-between;
  576. width: 272px;
  577. margin: 38px auto 0;
  578. .card{
  579. display: flex;
  580. flex-direction: column;
  581. justify-content: center;
  582. align-items: center;
  583. width: 119px;
  584. height: 114px;
  585. margin-top: 26px;
  586. background-image: url('~/assets/image/activity/invite-user/card.png');
  587. background-size: 100% 100%;
  588. }
  589. .card-name{
  590. color: #F75921;
  591. font-size: 26px;
  592. font-weight: bold;
  593. line-height: 37px;
  594. margin-top: 34px;
  595. }
  596. .card-desc{
  597. margin-top: 4px;
  598. color: #F75921;
  599. font-size: 12px;
  600. line-height: 17px;
  601. }
  602. }
  603. .income{
  604. position: relative;
  605. width: 373px;
  606. height: 240px;
  607. margin-top: 20px;
  608. margin-bottom: 60px;
  609. background-image: url('~/assets/image/activity/invite-user/income-bg.png');
  610. background-size: contain;
  611. .accumulated-quantity{
  612. position: absolute;
  613. top: 83px;
  614. left: 35px;
  615. font-size: 30px;
  616. color: #FF4C59;
  617. font-weight: bold;
  618. }
  619. .quantity-today{
  620. position: absolute;
  621. top: 83px;
  622. left: 197px;
  623. font-size: 30px;
  624. color: #FF4C59;
  625. font-weight: bold;
  626. }
  627. .thirty{
  628. position: absolute;
  629. top: 172px;
  630. left: 35px;
  631. color: #333333;
  632. font-size: 18px;
  633. font-weight: bold;
  634. }
  635. .ninety{
  636. position: absolute;
  637. top: 172px;
  638. left: 116px;
  639. color: #333333;
  640. font-size: 18px;
  641. font-weight: bold;
  642. }
  643. .oneHundredAndEighty{
  644. position: absolute;
  645. top: 172px;
  646. left: 197px;
  647. color: #333333;
  648. font-size: 18px;
  649. font-weight: bold;
  650. }
  651. .threeHundredAndSixtyFive{
  652. position: absolute;
  653. top: 172px;
  654. left: 283px;
  655. color: #333333;
  656. font-size: 18px;
  657. font-weight: bold;
  658. }
  659. }
  660. </style>