index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. <template>
  2. <v-container class="invite-user" 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-if="myActivationCode.length"
  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. // 微信环境不支持此正则
  178. // return value.replace(/(?<=^.{4})(.*)(?=.{4}$)/, '***');
  179. return value.replace(/(.{4})(.*)(.{4}$)/, '$1***$3');
  180. },
  181. },
  182. // async asyncData({ $axios }) {
  183. // // 页面初始化前触发
  184. // const res = await $axios.$get(
  185. // '/activity/v1/inviteUser/orderRelation/starCoinOverview',
  186. // );
  187. // res.data.type = 2;
  188. // return {
  189. // data: res.data,
  190. // };
  191. // },
  192. data() {
  193. return {
  194. data: {
  195. todayIncomeStarCoin: 0,
  196. totalIncomeStarCoin: 0,
  197. todayBuyOrderCount: 0,
  198. totalBuyOrderCount: 0,
  199. todayBuyOrderSuccessCount: 0,
  200. totalBuyOrderSuccessCount: 0,
  201. withdrawStarCoinNum: 0,
  202. inviteUserName: null,
  203. activityId: null,
  204. status: 0,
  205. type: 0,
  206. },
  207. activityRules: '',
  208. myActivationCode: [],
  209. myCodeFrom: {
  210. actibityId: null,
  211. pageNum: 1,
  212. pageSize: 8,
  213. },
  214. codeTotal: -1,
  215. codeIsLoading: false,
  216. };
  217. },
  218. async fetch() {
  219. // 页面初始化后触发
  220. try {
  221. await this.getActiveInfo();
  222. this.$native.setShareInfo(this.shareInfo);
  223. await Promise.all([
  224. this.getActivityRules(),
  225. this.type === 2 && this.getMyActivationCode(this.myCodeFrom),
  226. ]);
  227. } catch (error) {
  228. this.$toast.error(error.message);
  229. }
  230. },
  231. head: {
  232. title: '邀请好友',
  233. // share: {
  234. // title: '标题',
  235. // content: '内容',
  236. // gotoUrl: 'http://localhost',
  237. // shareImg: 'http://localhost',
  238. // },
  239. },
  240. computed: {
  241. codeHasMore() {
  242. return (
  243. this.codeTotal < 0 ||
  244. this.myCodeFrom.pageNum * this.myCodeFrom.pageSize < this.codeTotal
  245. );
  246. },
  247. dataList() {
  248. switch (this.type) {
  249. case 1: {
  250. return [
  251. { label: '今日收益(星币)', value: this.data.todayIncomeStarCoin },
  252. { label: '总收益(星币)', value: this.data.totalIncomeStarCoin },
  253. {
  254. label: '今日购买订单数',
  255. value: this.data.todayBuyOrderSuccessCount,
  256. },
  257. { label: '累计推广订单', value: this.data.totalBuyOrderCount },
  258. {
  259. label: '今日购买成功客户',
  260. value: this.data.todayBuyOrderSuccessCount,
  261. },
  262. {
  263. label: '累计购买成功客户',
  264. value: this.data.totalBuyOrderSuccessCount,
  265. },
  266. // { label: '可提现星币数量', value: this.data.withdrawStarCoinNum },
  267. ];
  268. }
  269. case 2: {
  270. return [
  271. {
  272. label: '今日获取的激活码',
  273. value: this.data.todayIncomeActivationCode,
  274. },
  275. { label: '总激活码', value: this.data.totalIncomeActivationCode },
  276. {
  277. label: '今日购买订单数',
  278. value: this.data.todayBuyOrderSuccessCount,
  279. },
  280. { label: '累计推广订单', value: this.data.totalBuyOrderCount },
  281. {
  282. label: '今日购买成功客户',
  283. value: this.data.todayBuyOrderSuccessCount,
  284. },
  285. {
  286. label: '累计购买成功客户',
  287. value: this.data.totalBuyOrderSuccessCount,
  288. },
  289. // { label: '可提现星币数量', value: this.data.withdrawStarCoinNum },
  290. ];
  291. }
  292. default: {
  293. return [];
  294. }
  295. }
  296. },
  297. type() {
  298. return this.data.type;
  299. },
  300. shareInfo() {
  301. if (this.$userAgent.isMiniProgram) {
  302. return {
  303. title: '双子星APP',
  304. path: '/pages/home/home',
  305. imgUrl: location.origin + require('~/assets/image/logo.png'),
  306. };
  307. }
  308. const url =
  309. location.origin +
  310. this.$router.resolve({
  311. path: '/activity/invite-user/register',
  312. query: {
  313. invitationUserName: this.data.inviteUserName,
  314. activityId: this.data.activityId,
  315. type: this.type,
  316. },
  317. }).href;
  318. return {
  319. title: '双子星APP',
  320. desc: '分享好友购买云机套餐,返星币换现金',
  321. link: url,
  322. imgUrl: location.origin + require('~/assets/image/logo.png'),
  323. };
  324. },
  325. },
  326. mounted() {
  327. // this.$userAgent.isMiniProgram &&
  328. // this.$wx.miniProgram.postMessage({
  329. // data: {
  330. // action: 'updateAppMessageShareData',
  331. // params: {
  332. // title: '双子星云手机',
  333. // path: '/pages/home/home',
  334. // imageUrl:
  335. // location.origin +
  336. // require('~/assets/image/activity/invite-user/bg@2x.png'),
  337. // // promise: null,
  338. // },
  339. // },
  340. // });
  341. },
  342. methods: {
  343. async getActiveInfo() {
  344. const res = await this.$axios.$get(
  345. '/activity/v1/inviteUser/orderRelation/starCoinOverview',
  346. );
  347. // res.data.type = 2;
  348. this.data = res.data;
  349. this.myCodeFrom.actibityId = res.data.activityId;
  350. },
  351. async getMyActivationCode(params) {
  352. try {
  353. this.codeIsLoading = true;
  354. const res = await this.$axios.$get(
  355. '/activity/v1/inviteUser/orderRelation/myActivationCode',
  356. {
  357. params,
  358. },
  359. );
  360. this.codeTotal = res.data.total;
  361. this.myActivationCode.push(
  362. ...(res.data.list ?? []),
  363. // ...Array.from({ length: 8 }).fill({
  364. // createTime: '2022-08-01 14:33:11',
  365. // activationCode: 'XXXXXXXXXXXXXXXXXXX',
  366. // activationUse: 1,
  367. // }),
  368. );
  369. this.myCodeFrom = params;
  370. } finally {
  371. this.codeIsLoading = false;
  372. }
  373. },
  374. async share() {
  375. // console.log(this);
  376. if (this.data.status !== 1) {
  377. if (this.data.status === 0) {
  378. throw new Error('当前活动已过期');
  379. }
  380. if (this.data.status === 2) {
  381. throw new Error('当前活动未开启');
  382. }
  383. if (this.data.status === 3) {
  384. throw new Error('当前活动已结束');
  385. }
  386. throw new Error('未知活动状态');
  387. }
  388. this.$tongji.trackEvent('活动', '分享', '', 0);
  389. // if (this.$userAgent.isMiniProgram) {
  390. // // 小程序环境
  391. // await clipboard.writeText(`${this.shareInfo.gotoUrl} 唔即云手机`);
  392. // this.$toast.success('链接复制成功');
  393. // } else
  394. if (this.$userAgent.isSzx || this.$userAgent.isSzxBrowser) {
  395. // app环境
  396. this.$native.share(this.shareInfo);
  397. } else {
  398. // 浏览器环境
  399. await clipboard.writeText(`${this.shareInfo.link} 唔即云手机`);
  400. // throw new Error('1231');
  401. this.$toast.success('链接复制成功');
  402. }
  403. },
  404. async getActivityRules() {
  405. const agreementCoding = { 1: 'iuserrules01', 2: 'iuserrules02' }[
  406. this.type
  407. ];
  408. if (agreementCoding) {
  409. const res = await this.$axios.$get(
  410. '/public/v5/agreementApi/content/getContentByType',
  411. {
  412. params: {
  413. agreementCoding,
  414. type: 1,
  415. },
  416. },
  417. );
  418. this.activityRules = res.data.content
  419. .replace(/[\d\D]*<body>([\d\D]+)<\/body>[\d\D]*/i, '$1')
  420. .replace(/<div class="phone-container">([\d\D]+)<\/div>/g, '$1');
  421. }
  422. },
  423. async copyCode(item) {
  424. await clipboard.writeText(item.activationCode);
  425. this.$toast.success('复制成功');
  426. },
  427. codeLoadMoreIntersect(event) {
  428. if (event[0].isIntersecting && this.codeHasMore && !this.codeIsLoading) {
  429. this.getMyActivationCode({
  430. ...this.myCodeFrom,
  431. pageNum: this.myCodeFrom.pageNum + 1,
  432. });
  433. }
  434. },
  435. },
  436. };
  437. </script>
  438. <style lang="scss" scoped>
  439. .invite-user {
  440. color: #333;
  441. // background-image: url('~/assets/image/activity/invite-user/bg@2x.png');
  442. background-size: 100% auto;
  443. // background-position-y: -44px;
  444. overflow: hidden;
  445. padding: 0;
  446. // padding-bottom: 30px;
  447. padding-bottom: env(safe-area-inset-bottom, 30px);
  448. background-color: #9525e3;
  449. &.bg-1 {
  450. background-image: url('~/assets/image/activity/invite-user/bg@2x.png');
  451. }
  452. &.bg-2 {
  453. background-image: url('~/assets/image/activity/invite-user/bg-2@2x.png');
  454. }
  455. }
  456. .box {
  457. width: 373px;
  458. box-sizing: border-box;
  459. margin: auto;
  460. border-image-source: url('~/assets/image/activity/invite-user/box@2x.png');
  461. border-image-slice: 38 * 2 20 * 2 30 * 2 fill;
  462. // border-image-width: 200px;
  463. // border-image-slice: 200%;
  464. border-width: 38px 15px 15px;
  465. // border-width: 1px;
  466. border-style: solid;
  467. position: relative;
  468. + .box {
  469. margin-top: 30px;
  470. }
  471. .box-header {
  472. position: absolute;
  473. top: -30px;
  474. // left: 141px;
  475. left: 0;
  476. right: 0;
  477. text-align: center;
  478. padding: 0 130px;
  479. color: #fff;
  480. }
  481. .box-main {
  482. padding: 30px 15px 20px;
  483. }
  484. }
  485. .box1 {
  486. margin-top: 275px;
  487. .box-main {
  488. // padding: 30px 15px 20px;
  489. padding-left: 0;
  490. padding-right: 0;
  491. }
  492. .cybz-content {
  493. width: 305px;
  494. height: 75px;
  495. margin: auto;
  496. display: block;
  497. // margin-top: 30px;
  498. }
  499. .cybz-content-text {
  500. // display: flex;
  501. display: grid;
  502. // width: 305px;
  503. // padding: 0 28px;
  504. // align-items: center;
  505. // margin: auto;
  506. // justify-content: space-between;
  507. grid-template-columns: 1fr 1fr 1fr;
  508. font-size: 12px;
  509. color: #333;
  510. .cybz-content-text-item {
  511. // width: 0;
  512. // flex: auto;
  513. text-align: center;
  514. }
  515. }
  516. .share-button {
  517. display: block;
  518. margin: auto;
  519. width: 302px !important;
  520. height: 62px !important;
  521. background-image: url('~/assets/image/activity/invite-user/share-button@2x.png');
  522. background-size: 100% 100%;
  523. margin-top: 24px;
  524. // margin-bottom: 24px;
  525. color: #dd1b0d;
  526. font-size: 22px;
  527. font-weight: bold;
  528. }
  529. }
  530. .box2 {
  531. .label {
  532. // font-size: 14px;
  533. }
  534. .value {
  535. color: #ff6600;
  536. // font-size: 24px;
  537. }
  538. .box-main {
  539. padding-left: 20px;
  540. padding-right: 20px;
  541. }
  542. }
  543. .box3 {
  544. .box-main {
  545. // padding-left: 20px;
  546. // padding-top: 0;
  547. padding-left: 10px;
  548. padding-right: 10px;
  549. }
  550. }
  551. .code-table {
  552. .table-body {
  553. max-height: 30px * 8;
  554. overflow-y: auto;
  555. }
  556. .time-col {
  557. width: 120px;
  558. }
  559. .status-col {
  560. width: 60px;
  561. }
  562. // width: 100%;
  563. tr {
  564. height: 30px;
  565. color: #666;
  566. }
  567. td {
  568. height: 30px;
  569. color: #333;
  570. }
  571. // tbody {
  572. // // max-height: 200px;
  573. // // overflow-y: auto;
  574. // // display: block;
  575. // }
  576. .copy-btn {
  577. min-width: 0 !important;
  578. height: auto !important;
  579. padding: 0 !important;
  580. }
  581. }
  582. </style>