index.vue 13 KB

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