<template>
|
<view class="invite">
|
<u-toast ref="uToast" /><u-no-network></u-no-network>
|
<u-navbar title="邀请好友" safeAreaInsetTop fixed placeholder>
|
<view class="coreshop-navbar-left-slot" slot="left">
|
<u-icon name="arrow-left" size="19" @click="goNavigateBack"></u-icon>
|
<u-line direction="column" :hairline="false" length="16" margin="0 8px"></u-line>
|
<u-icon name="home" size="22" @click="goHome"></u-icon>
|
</view>
|
<view slot="right">
|
</view>
|
</u-navbar>
|
<image class="invite-bg" :src="$globalConstVars.apiFilesUrl+'/static/images/my/invite-bg.png'" mode=""></image>
|
<view class="invite-c">
|
<view class="invite-w">
|
<view class='invite-w-t'>我的专属邀请码</view>
|
<text class='invite-w-num'>{{code}}</text>
|
<view class='invite-w-detail'>快去分享您的邀请码吧,让更多的好友加入到【{{appTitle}}】,您也可以获得丰厚的奖励!</view>
|
<view class='invite-w-bot'>
|
<view bindtap='commission' @click="toMoney">
|
<text class="cuIcon-coin coreshop-text-red coreship-font-22"></text>
|
<text class='invite-w-bot-red'>¥{{money}}元</text>
|
<text class='invite-w-bot-gray'>邀请收益</text>
|
</view>
|
<view bindtap='recommendUserList' @click="toList">
|
<text class="cuIcon-friend coreshop-text-red coreship-font-22"></text>
|
<text class='invite-w-bot-red'>{{number}}人</text>
|
<text class='invite-w-bot-gray'>邀请人数</text>
|
</view>
|
</view>
|
</view>
|
<view class="invite-w" v-if="!isSuperior">
|
<text class='invite-w-t-blue'>谁推荐你的?</text>
|
<input class='invite-w-input' placeholder='请输入推荐人邀请码' v-model="inviteKey" />
|
<view class='invite-w-btn' @click="setMyInvite">提交</view>
|
</view>
|
<view class='invite-btn'>
|
<!-- #ifdef MP-WEIXIN -->
|
<view class="coreshop-padding-10">
|
<u-button class='' size="small" color="linear-gradient(to right, rgb(66, 83, 216), rgb(213, 51, 186))" open-type="share">
|
<u-icon name="weixin-fill" size="18" labelSize="13" label="分享朋友圈" color="#fff" labelColor="#fff"></u-icon>
|
</u-button>
|
</view>
|
<!-- #endif -->
|
<view class="coreshop-padding-10">
|
<u-button class='' size="small" color="linear-gradient(to right, rgb(66, 83, 216), rgb(213, 51, 186))" @click="createPoster()">
|
<u-icon name="moments" size="18" labelSize="13" label="二维码分享" color="#fff" labelColor="#fff"></u-icon>
|
</u-button>
|
</view>
|
</view>
|
</view>
|
</view>
|
|
</template>
|
<script>
|
export default {
|
data() {
|
return {
|
code: '',
|
money: 0,
|
number: 0,
|
isSuperior: false,
|
inviteKey: '',
|
imageUrl: '/static/images/ShareImage.png',
|
shareUrl: this.$globalConstVars.shareUrl
|
}
|
},
|
computed: {
|
appTitle() {
|
return this.$store.state.config.shopName;
|
}
|
},
|
onShow() {
|
this.getInviteData();
|
},
|
methods: {
|
//获取数据
|
getInviteData() {
|
this.$u.api.myInvite(null).then(res => {
|
this.code = res.data.code;
|
this.money = res.data.money;
|
this.number = res.data.number;
|
this.isSuperior = res.data.isSuperior;
|
});
|
this.getShareUrl();
|
},
|
//去佣金明细
|
toMoney() {
|
this.$u.route('/pages/member/balance/details/details?status=5');
|
},
|
//去邀请列表
|
toList() {
|
this.$u.route('/pages/member/invite/list');
|
},
|
//填写设置要求
|
setMyInvite() {
|
let data = {
|
id: this.inviteKey
|
}
|
this.$u.api.setMyInvite(data).then(res => {
|
if (res.status) {
|
this.$refs.uToast.show({ message: '邀请码填写成功', type: 'success' })
|
this.isSuperior = true;
|
} else {
|
this.$u.toast(res.msg);
|
}
|
});
|
},
|
// 生成邀请海报
|
createPoster() {
|
let data = {
|
client: this.$globalConstVars.shareClient.wxMiNiProgram,
|
url: this.$globalConstVars.shareUrl,
|
type: this.$globalConstVars.shareModel.poster,
|
page: this.$globalConstVars.shareType.index,
|
}
|
let userToken = this.$db.get('userToken')
|
if (userToken && userToken != '') {
|
data.token = userToken
|
}
|
this.$u.api.share(data).then(res => {
|
if (res.status) {
|
this.$u.route('/pages/share/sharePoster/sharePoster?poster=' + encodeURIComponent(res.data))
|
} else {
|
this.$u.toast(res.msg)
|
}
|
})
|
},
|
//获取分享URL
|
getShareUrl() {
|
let data = {
|
client: this.$globalConstVars.shareClient.wxMiNiProgram,
|
url: this.$globalConstVars.shareUrl,
|
type: this.$globalConstVars.shareModel.url,
|
page: this.$globalConstVars.shareType.index,
|
};
|
let userToken = this.$db.get('userToken');
|
if (userToken && userToken != '') {
|
data.token = userToken
|
}
|
this.$u.api.share(data).then(res => {
|
this.shareUrl = res.data
|
});
|
}
|
},
|
//分享
|
onShareAppMessage(res) {
|
return {
|
title: this.$store.state.config.shareTitle,
|
imageUrl: this.$store.state.config.shareImage,
|
path: this.shareUrl
|
}
|
},
|
onShareTimeline(res) {
|
return {
|
title: this.$store.state.config.shareTitle,
|
imageUrl: this.$store.state.config.shareImage,
|
path: this.shareUrl
|
}
|
},
|
}
|
</script>
|
<style lang="scss">
|
@import "index.scss";
|
</style>
|