zhaojs
2023-07-31 34db7035c9c7880e00b9328d022be65a29c62cb2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!-- 本示例未包含完整css,获取外链css请参考上文,在hello uni-app项目中查看 -->
<template>
    <view>
        <view>
            <view class="uni-form-item">
                <view class="title">链接key:</view>
                <view>
                    <input v-model="keyname" style="height: 2.4rem; border: 1px solid;" placeholder="输入短链key" />
                </view>
            </view>
            <view class="uni-form-item">
                <view class="title">时间:</view>
                <view>
                    <view style="line-height: 2.3rem;" @click="datetimeshow()">{{showtime}}</view>
                    <h-datetime-picker :startTime="startTime" :endTime="endTime" mode="multiple" ref="pickerDate"
                        @reset="reset" @confirm="confirm"></h-datetime-picker>
                </view>
            </view>
            <view class="uni-form-item">
                <view class="title">发送数量:</view>
                <view>
                    <input v-model="sendcount" style="height: 2.4rem; border: 1px solid;" placeholder="请输入发送数量" />
                </view>
            </view>
            <view class="uni-btn-v">
                <button @click="formSubmit()">查询</button>
            </view>
            <view class="resshowtxt" v-if="res_key">
                <view>
                    链接key:{{res_key}}
                </view>
                <view>
                    Pv:{{res_pv}}------{{pvrate}}
                </view>
                <view>
                    Uv:{{res_uv}}-------{{uvrate}}
                </view>
            </view>
 
        </view>
    </view>
</template>
 
 
<script>
    import timeFormat from "@/uni_modules/h-datetime-picker/js/timeFormat.js"
    export default {
        data() {
            return {
                timeFormat,
                sendcount:10000,
                keyname: '',
                startTime: '',
                endTime: '',
                showtime: '点击选择时间',
                res_key: '',
                res_pv: '',
                res_uv: '',
                pvrate:0,
                uvrate:0
            }
        },
        onLoad() {
            let end_time = new Date();
            let startdate = end_time.setDate(new Date(end_time).getDate() - 3);
            this.startTime = this.timeFormat(startdate, 'yyyy-mm-dd');
            this.endTime = this.timeFormat(new Date(), 'yyyy-mm-dd');
        },
        methods: {
            datetimeshow() {
                this.$refs.pickerDate.open()
            },
            reset() {
                this.showtime = '';
                this.startTime = '';
                this.endTime = '';
            },
            confirm(e) {
                this.showtime = e.start_time.time + "至" + e.end_time.time;
                this.startTime = e.start_time.time;
                this.endTime = e.end_time.time;
            },
            formSubmit() {
                let data = {
                    key: this.keyname,
                    MinCreateTime: this.startTime,
                    MaxCreateTime: this.endTime
                }
                console.log(data);
                uni.showLoading({
                    title: '查询中',
                    mask: true
                });
                var that = this;
                this.$http.post('/openwize/Top/GePvUvByKey', data).then(e => {
                    uni.hideLoading();
                    this.res_key = e.result.key;
                    this.res_pv = e.result.pv;
                    this.res_uv = e.result.uv;
                    if(this.sendcount>0)
                    {//计算点击率
                        this.pvrate=((e.result.pv/this.sendcount).toFixed(2))*100+"%";
                        this.uvrate=((e.result.uv/this.sendcount).toFixed(2))*100+"%";
                    }
                }).catch(function(err) {
                    console.log(err);
                })
            }
        }
    }
</script>
 
 
<style>
    .resshowtxt {
        margin-top: 1rem;
        font-size: 1.5rem;
    }
 
    .uni-form-item {
        display: flex;
        margin: 0.4rem;
    }
 
    .uni-form-item .title {
        padding: 20rpx 0;
        margin-right: 1.6rem;
    }
</style>