index.vue 17 KB

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