index.vue 14 KB

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