123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676 |
- <template>
- <v-container class="invite-user" fluid :class="`bg-${type}`">
- <activity-invite-user-box class="box1">
- <template #title>参与步骤</template>
- <v-img
- class="cybz-content"
- :src="returnContent ? returnContent.img : null"
- />
- <div class="cybz-content-text">
- <div class="cybz-content-text-item">分享好友</div>
- <div class="cybz-content-text-item">邀请购买云机</div>
- <div class="cybz-content-text-item">
- {{ returnContent ? returnContent.content : '' }}
- </div>
- </div>
- <v-btn class="share-button" rounded @click="share()">
- <template v-if="!($userAgent.isSzx || $userAgent.isSzxBrowser)"
- >复制链接</template
- >分享好友
- </v-btn>
- <!-- <button @click="share()">邀请</button> -->
- </activity-invite-user-box>
- <activity-invite-user-box class="ox box2">
- <template #title>收益明细</template>
- <div class="grid grid-cols-2 gap-x-4 gap-y-8">
- <div
- v-for="(item, index) in dataList"
- :key="index"
- :class="{
- 'col-span-2': index === 6,
- }"
- >
- <div class="label text-sm">
- <span>{{ item.label }}</span>
- </div>
- <div class="value text-2xl font-bold">
- <span>{{ item.value | formatNumber }}</span>
- </div>
- </div>
- </div>
- </activity-invite-user-box>
- <activity-invite-user-box v-if="type === 2" class="box3">
- <template #title>激活码明细</template>
- <div class="code-table">
- <div class="table-header">
- <table class="w-full">
- <colgroup>
- <col class="time-col" />
- <col class="code-col" />
- <col class="status-col" />
- </colgroup>
- <thead class="text-left text-sm whitespace-nowrap break-normal">
- <tr>
- <th class="">获得的时间</th>
- <th>激活码编号</th>
- <th class="">使用状态</th>
- </tr>
- </thead>
- </table>
- </div>
- <div class="table-body">
- <table class="w-full">
- <colgroup>
- <col class="time-col" />
- <col class="code-col" />
- <col class="status-col" />
- </colgroup>
- <tbody class="text-xs">
- <tr v-for="(item, index) in myActivationCode" :key="index">
- <td class="whitespace-nowrap break-normal">
- {{ item.createTime | formatDate('MM月DD日 HH:mm:ss') }}
- </td>
- <td class="whitespace-nowrap break-normal">
- <div class="flex">
- <span class="font-mono"
- >{{ item.activationCode | activationCodeMask }} </span
- ><span class="mx-1">|</span
- ><v-btn
- text
- small
- color="#991AD2"
- class="copy-btn"
- @click="copyCode(item)"
- >复制</v-btn
- >
- </div>
- </td>
- <td class="whitespace-nowrap break-normal text-right">
- <span v-if="item.activationUse" style="color: #dd1b0d"
- >已使用</span
- >
- <span v-else>未使用</span>
- </td>
- </tr>
- </tbody>
- </table>
- <div
- v-if="myActivationCode.length"
- v-intersect.quiet="codeLoadMoreIntersect"
- class="flex item-center justify-center"
- >
- <!-- <v-progress-circular indeterminate ></v-progress-circular> -->
- <v-btn :loading="codeIsLoading" text small>
- <template v-if="codeIsLoading">加载中</template>
- <template v-else-if="codeHasMore">加载更多</template>
- <template v-else>没有更多</template>
- </v-btn>
- </div>
- </div>
- </div>
- <!-- <div class="code-list">
- <div
- v-for="(item, index) in 10"
- :key="index"
- class="code-item"
- ></div>
- </div> -->
- </activity-invite-user-box>
- <activity-invite-user-box class="box4">
- <template #title>活动规则</template>
- <!-- eslint-disable-next-line vue/no-v-html -->
- <div class="text-sm" v-html="activityRules"></div>
- </activity-invite-user-box>
- <!-- <div class="">invite-user</div> -->
- <!-- <button>刷新数据</button> -->
- <!-- <div class="">{{ data }}</div> -->
- <!-- <div class="text-center">
- <span>分享好友购买云机套餐<br />返星币换现金</span>
- </div>
- <div class="text-center mt-4">
- <van-button type="primary" @click="share()">邀请好友</van-button>
- </div>
- <van-icon name="chat-o" />
- <van-icon name="shape-plus" class-prefix="mdi" />
- <van-button @click="$fetch()">刷新</van-button>
- <div class="ccc">{{ 36666666.123456 | formatNumber }}</div>
- <div class="ccc">{{ '2020-01-01' | formatDate }}</div> -->
- </v-container>
- </template>
- <script>
- // import qs from 'qs';
- // import clipboard from 'clipboardy/browser';
- // import * as clipboard from 'clipboard-polyfill/text';
- // console.log("🚀 ~ file: index.vue ~ line 176 ~ clipboard", clipboard)
- // import { getStarCoinOverview } from '~/api/activity/invite-user.js';
- // import { getContentByType } from '~/api/public/agreement.js';
- export default {
- // auth: false,
- name: 'InviteUser',
- filters: {
- activationCodeMask(value) {
- // 微信环境不支持零宽断言
- // return value.replace(/(?<=^.{4})(.*)(?=.{4}$)/, '***');
- return value.replace(/(.{4})(.*)(.{4}$)/, '$1***$3');
- },
- },
- // async asyncData({ $axios }) {
- // // 页面初始化前触发
- // const res = await $axios.$get(
- // '/activity/v1/inviteUser/orderRelation/starCoinOverview',
- // );
- // res.data.type = 2;
- // return {
- // data: res.data,
- // };
- // },
- data() {
- return {
- data: {
- todayIncomeStarCoin: 0,
- totalIncomeStarCoin: 0,
- todayBuyOrderCount: 0,
- totalBuyOrderCount: 0,
- todayBuyOrderSuccessCount: 0,
- totalBuyOrderSuccessCount: 0,
- withdrawStarCoinNum: 0,
- inviteUserName: null,
- activityId: null,
- status: 0,
- type: 0,
- },
- activityRules: '',
- myActivationCode: [],
- myCodeFrom: {
- activityId: null,
- pageNum: 1,
- pageSize: 8,
- },
- codeTotal: -1,
- codeIsLoading: false,
- };
- },
- async fetch() {
- // 页面初始化后触发
- try {
- await this.getActiveInfo();
- this.$native.setShareInfo(this.shareInfo);
- await Promise.all([
- this.getActivityRules(),
- this.type === 2 && this.getMyActivationCode(this.myCodeFrom),
- ]);
- } catch (error) {
- this.$toast.error(error.message);
- }
- },
- head: {
- title: '邀请好友',
- // share: {
- // title: '标题',
- // content: '内容',
- // gotoUrl: 'http://localhost',
- // shareImg: 'http://localhost',
- // },
- },
- computed: {
- returnContent() {
- return {
- 1: {
- img: require('@/assets/image/activity/invite-user/cybz-content@2x.png'),
- content: '返星币换现金',
- },
- 2: {
- img: require('@/assets/image/activity/invite-user/cybz-content-2@2x.png'),
- content: '返云机时长',
- },
- 3: {
- img: require('@/assets/image/activity/invite-user/cybz-content-3@2x.png'),
- content: '返积分',
- },
- }[this.type];
- },
- // contentImg() {
- // return {
- // 1: require('@/assets/image/activity/invite-user/cybz-content@2x.png'),
- // 2: require('@/assets/image/activity/invite-user/cybz-content-2@2x.png'),
- // 3: require('@/assets/image/activity/invite-user/cybz-content-3@2x.png'),
- // }[this.type];
- // },
- // returnContent() {
- // return { 1: '返星币换现金', 2: '返云机时长', 3: '返积分' }[this.type];
- // },
- codeHasMore() {
- return (
- this.codeTotal < 0 ||
- this.myCodeFrom.pageNum * this.myCodeFrom.pageSize < this.codeTotal
- );
- },
- dataList() {
- switch (this.type) {
- case 1: {
- return [
- { label: '今日收益(星币)', value: this.data.todayIncomeStarCoin },
- { label: '总收益(星币)', value: this.data.totalIncomeStarCoin },
- {
- label: '今日购买订单数',
- value: this.data.todayBuyOrderSuccessCount,
- },
- { label: '累计推广订单', value: this.data.totalBuyOrderCount },
- {
- label: '今日购买成功客户',
- value: this.data.todayBuyOrderSuccessCount,
- },
- {
- label: '累计购买成功客户',
- value: this.data.totalBuyOrderSuccessCount,
- },
- // { label: '可提现星币数量', value: this.data.withdrawStarCoinNum },
- ];
- }
- case 2: {
- return [
- {
- label: '今日获取的激活码',
- value: this.data.todayIncomeActivationCode,
- },
- { label: '总激活码', value: this.data.totalIncomeActivationCode },
- {
- label: '今日购买订单数',
- value: this.data.todayBuyOrderSuccessCount,
- },
- { label: '累计推广订单', value: this.data.totalBuyOrderCount },
- {
- label: '今日购买成功客户',
- value: this.data.todayBuyOrderSuccessCount,
- },
- {
- label: '累计购买成功客户',
- value: this.data.totalBuyOrderSuccessCount,
- },
- // { label: '可提现星币数量', value: this.data.withdrawStarCoinNum },
- ];
- }
- case 3: {
- return [
- {
- label: '今日获取的积分',
- value: this.data.todayIncomeIntegral,
- },
- { label: '总积分', value: this.data.totalIncomeIntegral },
- {
- label: '今日购买订单数',
- value: this.data.todayBuyOrderSuccessCount,
- },
- { label: '累计推广订单', value: this.data.totalBuyOrderCount },
- {
- label: '今日购买成功客户',
- value: this.data.todayBuyOrderSuccessCount,
- },
- {
- label: '累计购买成功客户',
- value: this.data.totalBuyOrderSuccessCount,
- },
- // { label: '可提现星币数量', value: this.data.withdrawStarCoinNum },
- ];
- }
- default: {
- return [];
- }
- }
- },
- type() {
- return this.data.type;
- },
- shareUrl() {
- return (
- location.origin +
- this.$router.resolve({
- path: '/activity/invite-user/register',
- query: {
- invitationUserName: this.data.inviteUserName,
- activityId: this.data.activityId,
- type: this.type,
- },
- }).href
- );
- },
- shareInfo() {
- if (this.$userAgent.isMiniProgram) {
- return {
- title: '双子星APP',
- path: '/pages/home/home',
- imgUrl: location.origin + require('~/assets/image/logo.png'),
- };
- }
- return {
- title: '双子星APP',
- desc: `分享好友购买云机套餐,${this.returnContent?.content}`,
- link: this.shareUrl,
- imgUrl: location.origin + require('~/assets/image/logo.png'),
- };
- },
- },
- mounted() {
- // this.$userAgent.isMiniProgram &&
- // this.$wx.miniProgram.postMessage({
- // data: {
- // action: 'updateAppMessageShareData',
- // params: {
- // title: '双子星云手机',
- // path: '/pages/home/home',
- // imageUrl:
- // location.origin +
- // require('~/assets/image/activity/invite-user/bg@2x.png'),
- // // promise: null,
- // },
- // },
- // });
- },
- methods: {
- async getActiveInfo() {
- const res = await this.$axios.$get(
- '/activity/v1/inviteUser/orderRelation/starCoinOverview',
- );
- // res.data.type = 2;
- this.data = res.data;
- this.myCodeFrom.activityId = res.data.activityId;
- },
- async getMyActivationCode(params) {
- try {
- this.codeIsLoading = true;
- const res = await this.$axios.$get(
- '/activity/v1/inviteUser/orderRelation/myActivationCode',
- {
- params,
- },
- );
- this.codeTotal = res.data.total;
- this.myActivationCode.push(
- ...(res.data.list ?? []),
- // ...Array.from({ length: 8 }).fill({
- // createTime: '2022-08-01 14:33:11',
- // activationCode: 'XXXXXXXXXXXXXXXXXXX',
- // activationUse: 1,
- // }),
- );
- this.myCodeFrom = params;
- } finally {
- this.codeIsLoading = false;
- }
- },
- async share() {
- // console.log(this);
- if (this.data.status !== 1) {
- if (this.data.status === 0) {
- throw new Error('当前活动已过期');
- }
- if (this.data.status === 2) {
- throw new Error('当前活动未开启');
- }
- if (this.data.status === 3) {
- throw new Error('当前活动已结束');
- }
- throw new Error('未知活动状态');
- }
- this.$tongji.trackEvent('活动', '分享', '', 0);
- // if (this.$userAgent.isMiniProgram) {
- // // 小程序环境
- // await clipboard.writeText(`${this.shareInfo.gotoUrl} 唔即云手机`);
- // this.$toast.success('链接复制成功');
- // } else
- if (this.$userAgent.isSzx || this.$userAgent.isSzxBrowser) {
- // app环境
- this.$native.share(this.shareInfo);
- } else {
- // 浏览器环境
- await this.$native.clipboard.writeText(`${this.shareUrl} 双子星云手机`);
- // throw new Error('1231');
- this.$toast.success('链接复制成功');
- }
- },
- async getActivityRules() {
- const agreementCoding = {
- 1: 'iuserrules01',
- 2: 'iuserrules02',
- 3: 'iuserrules03',
- }[this.type];
- if (agreementCoding) {
- const res = await this.$axios.$get(
- '/public/v5/agreementApi/content/getContentByType',
- {
- params: {
- agreementCoding,
- type: 1,
- },
- },
- );
- this.activityRules = res.data.content
- .replace(/[\d\D]*<body>([\d\D]+)<\/body>[\d\D]*/i, '$1')
- .replace(/<div class="phone-container">([\d\D]+)<\/div>/g, '$1');
- }
- },
- async copyCode(item) {
- await this.$native.clipboard.writeText(item.activationCode);
- this.$toast.success('复制成功');
- },
- codeLoadMoreIntersect(event) {
- if (event[0].isIntersecting && this.codeHasMore && !this.codeIsLoading) {
- this.getMyActivationCode({
- ...this.myCodeFrom,
- pageNum: this.myCodeFrom.pageNum + 1,
- });
- }
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .invite-user {
- color: #333;
- // background-image: url('~/assets/image/activity/invite-user/bg@2x.png');
- background-size: 100% auto;
- // background-position-y: -44px;
- overflow: hidden;
- padding: 0;
- // padding-bottom: 30px;
- padding-bottom: env(safe-area-inset-bottom, 30px);
- background-color: #9525e3;
- &.bg-1 {
- background-image: url('~/assets/image/activity/invite-user/bg@2x.png');
- }
- &.bg-2 {
- background-image: url('~/assets/image/activity/invite-user/bg-2@2x.png');
- }
- &.bg-3 {
- background-image: url('~/assets/image/activity/invite-user/bg-3@2x.png');
- }
- }
- // .box {
- // width: 373px;
- // box-sizing: border-box;
- // margin: auto;
- // // border-image-width: 200px;
- // // border-image-slice: 200%;
- // // border-width: 1px;
- // position: relative;
- // z-index: 0;
- // + .box {
- // margin-top: 30px;
- // }
- // .box-header {
- // // position: absolute;
- // position: relative;
- // // top: -30px;
- // z-index: 1;
- // // left: 141px;
- // // left: 0;
- // // right: 0;
- // margin-bottom: -34px;
- // // text-align: center;
- // // padding: 0 130px;
- // display: flex;
- // align-items: center;
- // justify-content: center;
- // flex-direction: column;
- // .box-header-content {
- // color: #fff;
- // border-image-source: url('~/assets/image/activity/invite-user/box-title@2x.png');
- // border-image-slice: 0 140 fill;
- // border-width: 0 70px 0;
- // border-style: solid;
- // height: 38px;
- // display: flex;
- // align-items: center;
- // justify-content: center;
- // flex-direction: column;
- // // width: auto;
- // }
- // }
- // .box-main {
- // z-index: 0;
- // // padding: 30px 15px 20px;
- // border-image-source: url('~/assets/image/activity/invite-user/box-bg@2x.png');
- // border-image-slice: 50 60 80 fill;
- // border-image-width: 30px 30px 40px;
- // border-width: 50px 20px 40px;
- // border-style: solid;
- // // padding-top: 30px;
- // }
- // }
- .box1 {
- margin-top: 275px;
- // ::v-deep .box-main {
- // // padding: 30px 15px 20px;
- // padding-left: 0;
- // padding-right: 0;
- // }
- .cybz-content {
- width: 305px;
- height: 75px;
- margin: auto;
- display: block;
- // margin-top: 30px;
- }
- .cybz-content-text {
- // display: flex;
- display: grid;
- // width: 305px;
- // padding: 0 28px;
- // align-items: center;
- // margin: auto;
- // justify-content: space-between;
- grid-template-columns: 1fr 1fr 1fr;
- font-size: 12px;
- color: #333;
- .cybz-content-text-item {
- // width: 0;
- // flex: auto;
- text-align: center;
- }
- }
- .share-button {
- display: block;
- margin: auto;
- width: 302px !important;
- height: 62px !important;
- background-image: url('~/assets/image/activity/invite-user/share-button@2x.png');
- background-size: 100% 100%;
- margin-top: 24px;
- // margin-bottom: 24px;
- color: #dd1b0d;
- font-size: 22px;
- font-weight: bold;
- }
- }
- .box2 {
- .label {
- // font-size: 14px;
- }
- .value {
- color: #ff6600;
- // font-size: 24px;
- }
- ::v-deep .box-main {
- padding-left: 20px;
- padding-right: 20px;
- }
- }
- .box3 {
- ::v-deep .box-main {
- // padding-left: 20px;
- // padding-top: 0;
- padding-left: 10px;
- padding-right: 10px;
- }
- }
- .code-table {
- .table-body {
- max-height: 30px * 8;
- overflow-y: auto;
- }
- .time-col {
- width: 120px;
- }
- .status-col {
- width: 60px;
- }
- // width: 100%;
- tr {
- height: 30px;
- color: #666;
- }
- td {
- height: 30px;
- color: #333;
- }
- // tbody {
- // // max-height: 200px;
- // // overflow-y: auto;
- // // display: block;
- // }
- .copy-btn {
- min-width: 0 !important;
- height: auto !important;
- padding: 0 !important;
- }
- }
- .box4::v-deep .box-main {
- padding-left: 10px;
- padding-right: 10px;
- }
- </style>
|