| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- <template>
- <view class="attach">
- <view class="flex-row justify-center">
- <view class="grid">
- <view class="flex-col gridItem" @click="navigateToPage('/pages/directPromotionList/directPromotionList')">
- <view class="title flex-row justify-center">
- <text>累计邀约</text>
- </view>
- <view class="number flex-row justify-center">
- <text>{{homeStaticsData.totalInvite || 0}}</text>
- </view>
- </view>
- <view class="flex-col gridItem leftBorder" @click="navigateToPage('/pages/CouponUsage/CouponUsage')">
- <view class="title flex-row justify-center">
- <text>用券情况</text>
- </view>
- <view class="number flex-row justify-center">
- <text>{{homeStaticsData.useCoupon || 0}}/{{homeStaticsData.totalUseCoupon || 0}}</text>
- </view>
- </view>
- <view class="flex-col gridItem leftBorder">
- <view class="title flex-row justify-center">
- <text>关联邀请</text>
- </view>
- <view class="number flex-row justify-center">
- <text>{{homeStaticsData.unionInvite || 0}}</text>
- </view>
- </view>
- <view class="flex-col gridItem" @click="navigateToPage('/pages/earningsList/earningsList')">
- <view class="title flex-row justify-center">
- <text>推广业绩</text>
- </view>
- <view class="number flex-row justify-center">
- <text>{{homeStaticsData.performance || 0}}</text>
- </view>
- </view>
- </view>
- </view>
- <view class="flex-row justify-center">
- <view class="qrView" @click="qrCodePopup">
- <uv-qrcode v-if="showQrCode" ref="qrcode" size="600rpx" :value="qrcodeUrl" :options="options"></uv-qrcode>
- <view class="flex-col justify-center" v-else style="width: 600rpx;height: 600rpx">
- <view class="flex-row justify-center">该规则推广次数已达上限</view>
- <view class="flex-row justify-center">推广次数:{{roleBindRuleList[value].presentCount}}</view>
- <view class="flex-row justify-center">已推次数:{{roleBindRuleList[value].nowCount}}</view>
- </view>
- </view>
- </view>
- <view class="flex-row">
- <view class="flex-col justify-center">
- <text class="roleSelectLabel">选择规则:</text>
- </view>
- <view class="roleSelect">
- <uni-data-select placement="top" style="width:492rpx;background: #FFFFFF" v-model="value" :localdata="roleBindRuleList" @change="selectChange" :clear="false"></uni-data-select>
- </view>
- </view>
- <uni-popup ref="createQrCodePopup" type="center">
- <view class="createQrCodePopup flex-col justify-center">
- <view class="flex-row justify-center">
- <uv-qrcode ref="qrcode" size="600rpx" :value="qrcodeUrl" :options="options"></uv-qrcode>
- </view>
- <view class="xoIcon" @click="closePopup">
- <u-icon name="close-circle" color="#666" size="35"></u-icon>
- </view>
- </view>
- </uni-popup>
- </view>
- </template>
- <script>
- import commonUtils from '../../../common/js/utils/commonUtils'
- export default {
- props:{
- height: {
- type: String,
- default () {
- return ''
- }
- },
- },
- data() {
- return {
- homeStaticsData:{},
- qrCreateTime:'',
- roleBindRuleList:[],
- userInfo:{},
- qrcodeUrl:this.$xcxUrl+'?expandUserId={expandUserId}&ruleId={ruleId}×tamp={timestamp}&type=1&expand1=1',
- options: {
- // 指定二维码前景,一般可在中间放logo
- foregroundImagePadding:2,
- foregroundImageBorderRadius:5,
- foregroundImageSrc: '/static/logo.png'
- },
- value:0,
- showQrCode:true
- }
- },
- created() {
- this.userInfo = uni.getStorageSync('spreadUserInfo')
- this.getRuleByRoleId(this.userInfo.roleId)
- this.homeStatics()
- },
- methods: {
- selectChange(e){
- this.createQrCode()
- },
- homeStatics(){
- this.$api.service.homeStatics({
- type:1
- }).then(res=>{
- console.log('获取首页拓客数据',res)
- this.homeStaticsData = res.data.data
- })
- },
- formatDate(){
- this.qrCreateTime = commonUtils.formatDate(new Date())
- },
- qrCodePopup(){
- this.$refs.createQrCodePopup.open()
- console.log('++++qrcodeUrl+++++',this.qrcodeUrl)
- },
- navigateToPage(url){
- uni.navigateTo({
- url:url
- })
- },
- //查询角色已经绑定的规则
- getRuleByRoleId(roleId){
- this.$api.service.getRuleByRoleId({
- roleId:roleId
- }).then(res=>{
- this.roleBindRuleList = res.data.data
- for (let i = 0;i<this.roleBindRuleList.length;i++){
- this.roleBindRuleList[i].value = i;
- this.roleBindRuleList[i].text = this.roleBindRuleList[i].title
- }
- this.createQrCode()
- })
- },
- createQrCode(){
- if (!this.roleBindRuleList.length || this.roleBindRuleList.length ===0){
- this.showQrCode = false
- uni.showToast({
- icon: 'error',
- duration: 2000,
- title: '当前没有推广规则'
- });
- return
- }
- if (this.roleBindRuleList[this.value].isLimit == 1 && this.roleBindRuleList[this.value].nowCount == this.roleBindRuleList[this.value].presentCount){
- this.showQrCode = false
- return
- }
- this.showQrCode = true
- let data = {
- expandUserId:this.userInfo.id,
- ruleId: this.roleBindRuleList[this.value].id,
- timestamp:new Date().getTime() + (60 * 1000 * 60 * 24 * 365 * 10)
- };
- this.qrcodeUrl = this.$xcxUrl+'?expandUserId={expandUserId}&ruleId={ruleId}×tamp={timestamp}&type=1&expand1=1';
- for (let key in data) {
- let regexp = new RegExp("{" + key + "}"); // 构造正则表达式
- this.qrcodeUrl = this.qrcodeUrl.replace(regexp, data[key]); // 执行替换操作
- }
- console.log('++++qrcodeUrl+++++',this.qrcodeUrl)
- },
- closePopup(){
- this.$refs.createQrCodePopup.close()
- },
- }
- }
- </script>
- <style scoped lang="scss">
- @import './index.rpx.css';
- </style>
|