index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. <template>
  2. <v-container class="invite-user pa-0" fluid :class="`bg-${type}`">
  3. <div class="box box1">
  4. <div class="box-header">参与步骤</div>
  5. <div class="box-main">
  6. <v-img
  7. v-if="type === 1"
  8. class="cybz-content"
  9. src="~/assets/image/activity/invite-user/cybz-content@2x.png"
  10. />
  11. <v-img
  12. v-else-if="type === 2"
  13. class="cybz-content"
  14. src="~/assets/image/activity/invite-user/cybz-content-2@2x.png"
  15. />
  16. <div class="cybz-content-text">
  17. <div class="cybz-content-text-item">分享好友</div>
  18. <div class="cybz-content-text-item">邀请购买云机</div>
  19. <div class="cybz-content-text-item">
  20. <template v-if="type === 1">返星币换现金</template>
  21. <template v-else-if="type === 2">返云手机时长</template>
  22. </div>
  23. </div>
  24. <v-btn class="share-button" rounded @click="share()">
  25. <template v-if="!($userAgent.isSzx || $userAgent.isSzxBrowser)"
  26. >复制链接</template
  27. >分享好友赚<template v-if="type === 1">星币</template
  28. ><template v-else-if="type === 2">手机时长</template>
  29. </v-btn>
  30. <!-- <button @click="share()">邀请</button> -->
  31. </div>
  32. <!-- <div class="h-40">13</div> -->
  33. </div>
  34. <div class="box box2">
  35. <div class="box-header">收益明细</div>
  36. <div class="box-main">
  37. <div class="grid grid-cols-2 gap-x-4 gap-y-8">
  38. <div
  39. v-for="(item, index) in dataList"
  40. :key="index"
  41. :class="{
  42. 'col-span-2': index === 6,
  43. }"
  44. >
  45. <div class="label text-sm">
  46. <span>{{ item.label }}</span>
  47. </div>
  48. <div class="value text-2xl font-bold">
  49. <span>{{ item.value | formatNumber }}</span>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. <div v-if="type === 2" class="box box3">
  56. <div class="box-header">激活码明细</div>
  57. <div class="box-main">
  58. <div class="code-table">
  59. <div class="table-header">
  60. <table class="w-full">
  61. <colgroup>
  62. <col class="time-col" />
  63. <col class="code-col" />
  64. <col class="status-col" />
  65. </colgroup>
  66. <thead class="text-left text-sm whitespace-nowrap break-normal">
  67. <tr>
  68. <th class="">获得的时间</th>
  69. <th>激活码编号</th>
  70. <th class="">使用状态</th>
  71. </tr>
  72. </thead>
  73. </table>
  74. </div>
  75. <div class="table-body">
  76. <table class="w-full">
  77. <colgroup>
  78. <col class="time-col" />
  79. <col class="code-col" />
  80. <col class="status-col" />
  81. </colgroup>
  82. <tbody class="text-xs">
  83. <tr v-for="(item, index) in myActivationCode" :key="index">
  84. <td class="whitespace-nowrap break-normal">
  85. {{ item.createTime | formatDate('MM月DD日 HH:mm:ss') }}
  86. </td>
  87. <td class="whitespace-nowrap break-normal">
  88. <div class="flex">
  89. <span class=" font-mono "
  90. >{{ item.activationCode | activationCodeMask }} </span
  91. ><span class="mx-1">|</span
  92. ><v-btn
  93. text
  94. small
  95. color="#991AD2"
  96. class="copy-btn"
  97. @click="copyCode(item)"
  98. >复制</v-btn
  99. >
  100. </div>
  101. </td>
  102. <td class="whitespace-nowrap break-normal text-right">
  103. <span v-if="item.activationUse" style="color: #dd1b0d"
  104. >已使用</span
  105. >
  106. <span v-else>未使用</span>
  107. </td>
  108. </tr>
  109. </tbody>
  110. </table>
  111. <div
  112. v-intersect.quiet="codeLoadMoreIntersect"
  113. class="flex item-center justify-center"
  114. >
  115. <!-- <v-progress-circular indeterminate ></v-progress-circular> -->
  116. <v-btn :loading="codeIsLoading" text small>
  117. <template v-if="codeIsLoading">加载中</template>
  118. <template v-else-if="codeHasMore">加载更多</template>
  119. <template v-else>没有更多</template>
  120. </v-btn>
  121. </div>
  122. </div>
  123. </div>
  124. <!-- <div class="code-list">
  125. <div
  126. v-for="(item, index) in 10"
  127. :key="index"
  128. class="code-item"
  129. ></div>
  130. </div> -->
  131. </div>
  132. </div>
  133. <div class="box box4">
  134. <div class="box-header">活动规则</div>
  135. <!-- eslint-disable-next-line vue/no-v-html -->
  136. <div class="box-main text-sm" v-html="activityRules">
  137. <!-- <p>1、传播过程中有任何疑问,可直接咨询客服</p>
  138. <p>
  139. 2、用户可以通过分享页面或者套餐给想要分享的人,被分享人购买云机套餐后,分享人可获得套餐对应的星币
  140. </p>
  141. <p>
  142. 3、星币为双子星云手机平台唯一认可代币,仅能通过充值、赠送和分享获得,其它渠道途径非法获取的星币,不受平台认可
  143. </p>
  144. <p>4、星币可在双子星购买任一等价值套餐</p>
  145. <p>
  146. 5、请勿利用双子星传播或扩散任何有关于政治、情色等任何违法的信息,一经发现,取消资格,如果触犯任何法律相关问题,平台不负任何责任
  147. </p> -->
  148. </div>
  149. </div>
  150. <!-- <div class="">invite-user</div> -->
  151. <!-- <button>刷新数据</button> -->
  152. <!-- <div class="">{{ data }}</div> -->
  153. <!-- <div class="text-center">
  154. <span>分享好友购买云机套餐<br />返星币换现金</span>
  155. </div>
  156. <div class="text-center mt-4">
  157. <van-button type="primary" @click="share()">邀请好友</van-button>
  158. </div>
  159. <van-icon name="chat-o" />
  160. <van-icon name="shape-plus" class-prefix="mdi" />
  161. <van-button @click="$fetch()">刷新</van-button>
  162. <div class="ccc">{{ 36666666.123456 | formatNumber }}</div>
  163. <div class="ccc">{{ '2020-01-01' | formatDate }}</div> -->
  164. </v-container>
  165. </template>
  166. <script>
  167. // import qs from 'qs';
  168. // import clipboard from 'clipboardy/browser';
  169. import * as clipboard from 'clipboard-polyfill/text';
  170. // import { getStarCoinOverview } from '~/api/activity/invite-user.js';
  171. // import { getContentByType } from '~/api/public/agreement.js';
  172. export default {
  173. // auth: false,
  174. name: 'InviteUser',
  175. filters: {
  176. activationCodeMask(value) {
  177. return value.replace(/(?<=^.{4})(.*)(?=.{4}$)/, '***');
  178. },
  179. },
  180. // async asyncData({ $axios }) {
  181. // // 页面初始化前触发
  182. // const res = await $axios.$get(
  183. // '/activity/v1/inviteUser/orderRelation/starCoinOverview',
  184. // );
  185. // res.data.type = 2;
  186. // return {
  187. // data: res.data,
  188. // };
  189. // },
  190. data() {
  191. return {
  192. data: {
  193. todayIncomeStarCoin: 0,
  194. totalIncomeStarCoin: 0,
  195. todayBuyOrderCount: 0,
  196. totalBuyOrderCount: 0,
  197. todayBuyOrderSuccessCount: 0,
  198. totalBuyOrderSuccessCount: 0,
  199. withdrawStarCoinNum: 0,
  200. inviteUserName: null,
  201. activityId: null,
  202. status: 0,
  203. type: 0,
  204. },
  205. activityRules: '',
  206. myActivationCode: [],
  207. myCodeFrom: {
  208. actibityId: null,
  209. pageNum: 1,
  210. pageSize: 8,
  211. },
  212. codeTotal: -1,
  213. codeIsLoading: false,
  214. };
  215. },
  216. async fetch() {
  217. // 页面初始化后触发
  218. try {
  219. await this.getActiveInfo();
  220. this.$native.setShareInfo(this.shareInfo);
  221. await Promise.all([
  222. this.getActivityRules(),
  223. this.type === 2 && this.getMyActivationCode(this.myCodeFrom),
  224. ]);
  225. } catch (error) {
  226. this.$toast.error(error.message);
  227. }
  228. },
  229. head: {
  230. title: '邀请好友',
  231. // share: {
  232. // title: '标题',
  233. // content: '内容',
  234. // gotoUrl: 'http://localhost',
  235. // shareImg: 'http://localhost',
  236. // },
  237. },
  238. computed: {
  239. codeHasMore() {
  240. return (
  241. this.codeTotal < 0 ||
  242. this.myCodeFrom.pageNum * this.myCodeFrom.pageSize < this.codeTotal
  243. );
  244. },
  245. dataList() {
  246. switch (this.type) {
  247. case 1: {
  248. return [
  249. { label: '今日收益(星币)', value: this.data.todayIncomeStarCoin },
  250. { label: '总收益(星币)', value: this.data.totalIncomeStarCoin },
  251. {
  252. label: '今日购买订单数',
  253. value: this.data.todayBuyOrderSuccessCount,
  254. },
  255. { label: '累计推广订单', value: this.data.totalBuyOrderCount },
  256. {
  257. label: '今日购买成功客户',
  258. value: this.data.todayBuyOrderSuccessCount,
  259. },
  260. {
  261. label: '累计购买成功客户',
  262. value: this.data.totalBuyOrderSuccessCount,
  263. },
  264. // { label: '可提现星币数量', value: this.data.withdrawStarCoinNum },
  265. ];
  266. }
  267. case 2: {
  268. return [
  269. {
  270. label: '今日获取的激活码',
  271. value: this.data.todayIncomeActivationCode,
  272. },
  273. { label: '总激活码', value: this.data.totalIncomeActivationCode },
  274. {
  275. label: '今日购买订单数',
  276. value: this.data.todayBuyOrderSuccessCount,
  277. },
  278. { label: '累计推广订单', value: this.data.totalBuyOrderCount },
  279. {
  280. label: '今日购买成功客户',
  281. value: this.data.todayBuyOrderSuccessCount,
  282. },
  283. {
  284. label: '累计购买成功客户',
  285. value: this.data.totalBuyOrderSuccessCount,
  286. },
  287. // { label: '可提现星币数量', value: this.data.withdrawStarCoinNum },
  288. ];
  289. }
  290. default: {
  291. return [];
  292. }
  293. }
  294. },
  295. type() {
  296. return this.data.type;
  297. },
  298. shareInfo() {
  299. if (this.$userAgent.isMiniProgram) {
  300. return {
  301. title: '双子星APP',
  302. path: '/pages/home/home',
  303. imgUrl: location.origin + require('~/assets/image/logo.png'),
  304. };
  305. }
  306. const url =
  307. location.origin +
  308. this.$router.resolve({
  309. path: '/activity/invite-user/register',
  310. query: {
  311. invitationUserName: this.data.inviteUserName,
  312. activityId: this.data.activityId,
  313. type: this.type,
  314. },
  315. }).href;
  316. return {
  317. title: '双子星APP',
  318. desc: '分享好友购买云机套餐,返星币换现金',
  319. link: url,
  320. imgUrl: location.origin + require('~/assets/image/logo.png'),
  321. };
  322. },
  323. },
  324. mounted() {
  325. // this.$userAgent.isMiniProgram &&
  326. // this.$wx.miniProgram.postMessage({
  327. // data: {
  328. // action: 'updateAppMessageShareData',
  329. // params: {
  330. // title: '双子星云手机',
  331. // path: '/pages/home/home',
  332. // imageUrl:
  333. // location.origin +
  334. // require('~/assets/image/activity/invite-user/bg@2x.png'),
  335. // // promise: null,
  336. // },
  337. // },
  338. // });
  339. },
  340. methods: {
  341. async getActiveInfo() {
  342. const res = await this.$axios.$get(
  343. '/activity/v1/inviteUser/orderRelation/starCoinOverview',
  344. );
  345. // res.data.type = 2;
  346. this.data = res.data;
  347. this.myCodeFrom.actibityId = res.data.activityId;
  348. },
  349. async getMyActivationCode(params) {
  350. try {
  351. this.codeIsLoading = true;
  352. const res = await this.$axios.$get(
  353. '/activity/v1/inviteUser/orderRelation/myActivationCode',
  354. {
  355. params,
  356. },
  357. );
  358. this.codeTotal = res.data.total;
  359. this.myActivationCode.push(
  360. ...(res.data.list ?? []),
  361. // ...Array.from({ length: 8 }).fill({
  362. // createTime: '2022-08-01 14:33:11',
  363. // activationCode: 'XXXXXXXXXXXXXXXXXXX',
  364. // activationUse: 1,
  365. // }),
  366. );
  367. this.myCodeFrom = params;
  368. } finally {
  369. this.codeIsLoading = false;
  370. }
  371. },
  372. async share() {
  373. // console.log(this);
  374. if (this.data.status !== 1) {
  375. if (this.data.status === 0) {
  376. throw new Error('当前活动已过期');
  377. }
  378. if (this.data.status === 2) {
  379. throw new Error('当前活动未开启');
  380. }
  381. if (this.data.status === 3) {
  382. throw new Error('当前活动已结束');
  383. }
  384. throw new Error('未知活动状态');
  385. }
  386. this.$tongji.trackEvent('活动', '分享', '', 0);
  387. // if (this.$userAgent.isMiniProgram) {
  388. // // 小程序环境
  389. // await clipboard.writeText(`${this.shareInfo.gotoUrl} 唔即云手机`);
  390. // this.$toast.success('链接复制成功');
  391. // } else
  392. if (this.$userAgent.isSzx || this.$userAgent.isSzxBrowser) {
  393. // app环境
  394. this.$native.share(this.shareInfo);
  395. } else {
  396. // 浏览器环境
  397. await clipboard.writeText(`${this.shareInfo.link} 唔即云手机`);
  398. // throw new Error('1231');
  399. this.$toast.success('链接复制成功');
  400. }
  401. },
  402. async getActivityRules() {
  403. const agreementCoding = { 1: 'iuserrules01', 2: 'iuserrules02' }[
  404. this.type
  405. ];
  406. if (agreementCoding) {
  407. const res = await this.$axios.$get(
  408. '/public/v5/agreementApi/content/getContentByType',
  409. {
  410. params: {
  411. agreementCoding,
  412. type: 1,
  413. },
  414. },
  415. );
  416. this.activityRules = res.data.content
  417. .replace(/[\d\D]*<body>([\d\D]+)<\/body>[\d\D]*/i, '$1')
  418. .replace(/<div class="phone-container">([\d\D]+)<\/div>/g, '$1');
  419. }
  420. },
  421. async copyCode(item) {
  422. await clipboard.writeText(item.activationCode);
  423. this.$toast.success('复制成功');
  424. },
  425. codeLoadMoreIntersect(event) {
  426. if (event[0].isIntersecting && this.codeHasMore && !this.codeIsLoading) {
  427. this.getMyActivationCode({
  428. ...this.myCodeFrom,
  429. pageNum: this.myCodeFrom.pageNum + 1,
  430. });
  431. }
  432. },
  433. },
  434. };
  435. </script>
  436. <style lang="scss" scoped>
  437. .invite-user {
  438. color: #333;
  439. // background-image: url('~/assets/image/activity/invite-user/bg@2x.png');
  440. background-size: 100% auto;
  441. // background-position-y: -44px;
  442. overflow: hidden;
  443. padding-bottom: 30px;
  444. &.bg-1 {
  445. background-image: url('~/assets/image/activity/invite-user/bg@2x.png');
  446. }
  447. &.bg-2 {
  448. background-image: url('~/assets/image/activity/invite-user/bg-2@2x.png');
  449. }
  450. }
  451. .box {
  452. width: 373px;
  453. box-sizing: border-box;
  454. margin: auto;
  455. border-image-source: url('~/assets/image/activity/invite-user/box@2x.png');
  456. border-image-slice: 38 * 2 20 * 2 30 * 2 fill;
  457. // border-image-width: 200px;
  458. // border-image-slice: 200%;
  459. border-width: 38px 15px 15px;
  460. // border-width: 1px;
  461. border-style: solid;
  462. position: relative;
  463. + .box {
  464. margin-top: 30px;
  465. }
  466. .box-header {
  467. position: absolute;
  468. top: -30px;
  469. // left: 141px;
  470. left: 0;
  471. right: 0;
  472. text-align: center;
  473. padding: 0 130px;
  474. color: #fff;
  475. }
  476. .box-main {
  477. padding: 30px 15px 20px;
  478. }
  479. }
  480. .box1 {
  481. margin-top: 275px;
  482. .box-main {
  483. // padding: 30px 15px 20px;
  484. padding-left: 0;
  485. padding-right: 0;
  486. }
  487. .cybz-content {
  488. width: 305px;
  489. height: 75px;
  490. margin: auto;
  491. display: block;
  492. // margin-top: 30px;
  493. }
  494. .cybz-content-text {
  495. // display: flex;
  496. display: grid;
  497. // width: 305px;
  498. // padding: 0 28px;
  499. // align-items: center;
  500. // margin: auto;
  501. // justify-content: space-between;
  502. grid-template-columns: 1fr 1fr 1fr;
  503. font-size: 12px;
  504. color: #333;
  505. .cybz-content-text-item {
  506. // width: 0;
  507. // flex: auto;
  508. text-align: center;
  509. }
  510. }
  511. .share-button {
  512. display: block;
  513. margin: auto;
  514. width: 302px !important;
  515. height: 62px !important;
  516. background-image: url('~/assets/image/activity/invite-user/share-button@2x.png');
  517. background-size: 100% 100%;
  518. margin-top: 24px;
  519. // margin-bottom: 24px;
  520. color: #dd1b0d;
  521. font-size: 22px;
  522. font-weight: bold;
  523. }
  524. }
  525. .box2 {
  526. .label {
  527. // font-size: 14px;
  528. }
  529. .value {
  530. color: #ff6600;
  531. // font-size: 24px;
  532. }
  533. .box-main {
  534. padding-left: 20px;
  535. padding-right: 20px;
  536. }
  537. }
  538. .box3 {
  539. .box-main {
  540. // padding-left: 20px;
  541. // padding-top: 0;
  542. padding-left: 10px;
  543. padding-right: 10px;
  544. }
  545. }
  546. .code-table {
  547. .table-body {
  548. max-height: 30px * 8;
  549. overflow-y: auto;
  550. }
  551. .time-col {
  552. width: 120px;
  553. }
  554. .status-col {
  555. width: 60px;
  556. }
  557. // width: 100%;
  558. tr {
  559. height: 30px;
  560. color: #666;
  561. }
  562. td {
  563. height: 30px;
  564. color: #333;
  565. }
  566. // tbody {
  567. // // max-height: 200px;
  568. // // overflow-y: auto;
  569. // // display: block;
  570. // }
  571. .copy-btn {
  572. min-width: 0 !important;
  573. height: auto !important;
  574. padding: 0 !important;
  575. }
  576. }
  577. </style>