invite-fission.vue 19 KB

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