index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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. },
  126. activityRules: '',
  127. myActivationCode: [],
  128. };
  129. },
  130. async fetch() {
  131. // 页面初始化后触发
  132. try {
  133. // await this.getActiveInfo();
  134. this.$native.setShareInfo(this.shareInfo);
  135. await Promise.all([
  136. this.getActivityRules(),
  137. this.type === 2 && this.getMyActivationCode(),
  138. ]);
  139. } catch (error) {
  140. this.$toast.error(error.message);
  141. }
  142. },
  143. head: {
  144. title: '邀请好友',
  145. // share: {
  146. // title: '标题',
  147. // content: '内容',
  148. // gotoUrl: 'http://localhost',
  149. // shareImg: 'http://localhost',
  150. // },
  151. },
  152. computed: {
  153. dataList() {
  154. switch (this.type) {
  155. case 1: {
  156. return [
  157. { label: '今日收益(星币)', value: this.data.todayIncomeStarCoin },
  158. { label: '总收益(星币)', value: this.data.totalIncomeStarCoin },
  159. {
  160. label: '今日购买订单数',
  161. value: this.data.todayBuyOrderSuccessCount,
  162. },
  163. { label: '累计推广订单', value: this.data.totalBuyOrderCount },
  164. {
  165. label: '今日购买成功客户',
  166. value: this.data.todayBuyOrderSuccessCount,
  167. },
  168. {
  169. label: '累计购买成功客户',
  170. value: this.data.totalBuyOrderSuccessCount,
  171. },
  172. // { label: '可提现星币数量', value: this.data.withdrawStarCoinNum },
  173. ];
  174. }
  175. case 2: {
  176. return [
  177. { label: '今日获取的激活码', value: this.data.todayIncomeStarCoin },
  178. { label: '总激活码', value: this.data.totalIncomeStarCoin },
  179. {
  180. label: '今日购买订单数',
  181. value: this.data.todayBuyOrderSuccessCount,
  182. },
  183. { label: '累计推广订单', value: this.data.totalBuyOrderCount },
  184. {
  185. label: '今日购买成功客户',
  186. value: this.data.todayBuyOrderSuccessCount,
  187. },
  188. {
  189. label: '累计购买成功客户',
  190. value: this.data.totalBuyOrderSuccessCount,
  191. },
  192. // { label: '可提现星币数量', value: this.data.withdrawStarCoinNum },
  193. ];
  194. }
  195. default: {
  196. return [];
  197. }
  198. }
  199. },
  200. type() {
  201. return this.data.type;
  202. },
  203. shareInfo() {
  204. if (this.$userAgent.isMiniProgram) {
  205. return {
  206. title: '双子星APP',
  207. path: '/pages/home/home',
  208. imgUrl: location.origin + require('~/assets/image/logo.png'),
  209. };
  210. }
  211. const url =
  212. location.origin +
  213. this.$router.resolve({
  214. path: '/activity/invite-user/register',
  215. query: {
  216. invitationUserName: this.data.inviteUserName,
  217. activityId: this.data.activityId,
  218. type: this.type,
  219. },
  220. }).href;
  221. return {
  222. title: '双子星APP',
  223. desc: '分享好友购买云机套餐,返星币换现金',
  224. link: url,
  225. imgUrl: location.origin + require('~/assets/image/logo.png'),
  226. };
  227. },
  228. },
  229. mounted() {
  230. // this.$userAgent.isMiniProgram &&
  231. // this.$wx.miniProgram.postMessage({
  232. // data: {
  233. // action: 'updateAppMessageShareData',
  234. // params: {
  235. // title: '双子星云手机',
  236. // path: '/pages/home/home',
  237. // imageUrl:
  238. // location.origin +
  239. // require('~/assets/image/activity/invite-user/bg@2x.png'),
  240. // // promise: null,
  241. // },
  242. // },
  243. // });
  244. },
  245. methods: {
  246. // async getActiveInfo() {
  247. // const res = await this.$axios.$get(
  248. // '/activity/v1/inviteUser/orderRelation/starCoinOverview',
  249. // );
  250. // res.data.type = 2;
  251. // this.data = res.data;
  252. // },
  253. async getMyActivationCode() {
  254. const res = await this.$axios.$get(
  255. '/activity/v1/inviteUser/orderRelation/myActivationCode',
  256. );
  257. this.myActivationCode = res.data;
  258. },
  259. async share() {
  260. // console.log(this);
  261. if (this.data.status !== 1) {
  262. if (this.data.status === 0) {
  263. throw new Error('当前活动已过期');
  264. }
  265. if (this.data.status === 2) {
  266. throw new Error('当前活动未开启');
  267. }
  268. if (this.data.status === 3) {
  269. throw new Error('当前活动已结束');
  270. }
  271. throw new Error('未知活动状态');
  272. }
  273. this.$tongji.trackEvent('活动', '分享', '', 0);
  274. // if (this.$userAgent.isMiniProgram) {
  275. // // 小程序环境
  276. // await clipboard.writeText(`${this.shareInfo.gotoUrl} 唔即云手机`);
  277. // this.$toast.success('链接复制成功');
  278. // } else
  279. if (this.$userAgent.isSzx || this.$userAgent.isSzxBrowser) {
  280. // app环境
  281. this.$native.share(this.shareInfo);
  282. } else {
  283. // 浏览器环境
  284. await clipboard.writeText(`${this.shareInfo.gotoUrl} 唔即云手机`);
  285. // throw new Error('1231');
  286. this.$toast.success('链接复制成功');
  287. }
  288. },
  289. async getActivityRules() {
  290. const agreementCoding = { 1: 'iuserrules01', 2: 'iuserrules02' }[
  291. this.type
  292. ];
  293. if (agreementCoding) {
  294. const res = await this.$axios.$get(
  295. '/public/v5/agreementApi/content/getContentByType',
  296. {
  297. params: {
  298. agreementCoding,
  299. type: 1,
  300. },
  301. },
  302. );
  303. this.activityRules = res.data.content
  304. .replace(/[\d\D]*<body>([\d\D]+)<\/body>[\d\D]*/i, '$1')
  305. .replace(/<div class="phone-container">([\d\D]+)<\/div>/g, '$1');
  306. }
  307. },
  308. },
  309. };
  310. </script>
  311. <style lang="scss" scoped>
  312. .invite-user {
  313. color: #333;
  314. // background-image: url('~/assets/image/activity/invite-user/bg@2x.png');
  315. background-size: 100% auto;
  316. // background-position-y: -44px;
  317. overflow: hidden;
  318. padding-bottom: 30px;
  319. &.bg-1 {
  320. background-image: url('~/assets/image/activity/invite-user/bg@2x.png');
  321. }
  322. &.bg-2 {
  323. background-image: url('~/assets/image/activity/invite-user/bg-2@2x.png');
  324. }
  325. }
  326. .box {
  327. width: 373px;
  328. box-sizing: border-box;
  329. margin: auto;
  330. border-image-source: url('~/assets/image/activity/invite-user/box@2x.png');
  331. border-image-slice: 38 * 2 20 * 2 30 * 2 fill;
  332. // border-image-width: 200px;
  333. // border-image-slice: 200%;
  334. border-width: 38px 15px 15px;
  335. // border-width: 1px;
  336. border-style: solid;
  337. position: relative;
  338. + .box {
  339. margin-top: 30px;
  340. }
  341. .box-header {
  342. position: absolute;
  343. top: -30px;
  344. // left: 141px;
  345. left: 0;
  346. right: 0;
  347. text-align: center;
  348. padding: 0 130px;
  349. color: #fff;
  350. }
  351. .box-main {
  352. padding: 30px 15px 20px;
  353. }
  354. }
  355. .box1 {
  356. margin-top: 275px;
  357. .box-main {
  358. // padding: 30px 15px 20px;
  359. padding-left: 0;
  360. padding-right: 0;
  361. }
  362. .cybz-content {
  363. width: 305px;
  364. height: 75px;
  365. margin: auto;
  366. display: block;
  367. // margin-top: 30px;
  368. }
  369. .cybz-content-text {
  370. // display: flex;
  371. display: grid;
  372. // width: 305px;
  373. // padding: 0 28px;
  374. // align-items: center;
  375. // margin: auto;
  376. // justify-content: space-between;
  377. grid-template-columns: 1fr 1fr 1fr;
  378. font-size: 12px;
  379. color: #333;
  380. .cybz-content-text-item {
  381. // width: 0;
  382. // flex: auto;
  383. text-align: center;
  384. }
  385. }
  386. .share-button {
  387. display: block;
  388. margin: auto;
  389. width: 302px !important;
  390. height: 62px !important;
  391. background-image: url('~/assets/image/activity/invite-user/share-button@2x.png');
  392. background-size: 100% 100%;
  393. margin-top: 24px;
  394. // margin-bottom: 24px;
  395. color: #dd1b0d;
  396. font-size: 22px;
  397. font-weight: bold;
  398. }
  399. }
  400. .box2 {
  401. .label {
  402. // font-size: 14px;
  403. }
  404. .value {
  405. color: #ff6600;
  406. // font-size: 24px;
  407. }
  408. .box-main {
  409. padding-left: 20px;
  410. padding-right: 20px;
  411. }
  412. }
  413. .box4 {
  414. .box-main {
  415. // padding-left: 20px;
  416. // padding-top: 0;
  417. }
  418. }
  419. </style>