zhaojs
2023-09-15 39e2103e28830337c3be4dbd3dc7ad0a829ee78b
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
<template>
    <view class="container">
        <view class="position-relative">
            <image src="https://yanfeiobpub.obs.cn-east-3.myhuaweicloud.com/sms_pro/usercenter_bg.png" class="bg"></image>
            <!-- <button type="default" size="mini" class="hym-btn" @tap="memberCode">
                <image src="/static/images/mine/hym.png"></image>
                <text>会员码</text>
            </button> -->
        </view>
        <view style="padding: 0 30rpx;">
            <!-- user box begin -->
            <view class="d-flex flex-column bg-white user-box">
                <view class="d-flex align-items-center">
                    <view class="avatar">
                        <image src='https://yanfeiobpub.obs.cn-east-3.myhuaweicloud.com/sms_pro/user_header.png'></image>
                    </view>
                    <view class="d-flex flex-column flex-fill overflow-hidden" style="margin-top: 20rpx;">
                        <view>
                            {{this.openId}} <span @click="copy()"
                                style="color: #919293;font-size: 14px;margin-left: 10px;">复制</span>
                        </view>
                    </view>
                </view>
                <view>
                    
                </view>
                <!-- user grid begin -->
                 <view class="w-100 d-flex align-items-center just-content-center">
                    
                    <view class="user-grid" @tap="coupons">
                        <view class="value font-size-extra-lg font-weight-bold text-color-base">
                            {{memberInfo?memberInfo.smscount:0}}
                        </view>
                        <view class="font-size-sm text-color-assist">短信余额</view>
                    </view>
                <!--     <view class="user-grid" @tap="integrals">
                        <view class="value font-size-extra-lg font-weight-bold text-color-base">
                            0
                        </view>
                        <view class="font-size-sm text-color-assist">已发数量</view>
                    </view> -->
                </view>
                <!-- user grid end -->
            </view>
            <!-- user box end -->
            <!-- level benefit box begin -->
            <view class="level-benefit-box" @tap="tohis">
                <view class="d-flex align-items-center justify-content-between font-size-base">
                    <view class="text-color-base">短信账单</view>
                    <view class="text-color-primary">></view>
                </view>
            </view>
            <view class="level-benefit-box" @tap="kefu()">
                <view class="d-flex align-items-center justify-content-between font-size-base">
                    <view class="text-color-base">联系客服</view>
                    <view class="text-color-primary">></view>
                </view>
            </view>
            <!-- level benefit box end -->
            <!-- banner begin -->
            <!-- <image src="/static/images/mine/banner.png" class="banner" mode="widthFix"></image> -->
            <!-- bennaer end -->
 
            <!-- service box begin -->
            <view class="service-box">
                <view class="font-size-lg text-color-base font-weight-bold" style="margin-bottom: 20rpx;">充值服务</view>
                <view class="d-flex flex-wrap justify-content-between amounts">
                    <view class="d-flex align-items-center just-content-center amount"
                        :class="{'bg-primary text-color-white': item.selected, 'bg-base text-color-base': !item.selected}"
                        v-for="(item, index) in amounts" :key="index" @tap="handleSelected(index)">
                        <view style="text-align: center;">
                            <view>
                                <span class="font-size-extra-lg font-weight-bold">{{ item.rechargecount}}</span>条
                            </view>
                            <view>
                                {{ item.rechargeamount }}元
                            </view>
                        </view>
                    </view>
                    <!-- <view style="width: 100%;">
                        <button @tap="addSms()" type="primary">充值</button>
 
                    </view> -->
 
                </view>
            </view>
            <!-- service box end -->
        </view>
    </view>
</template>
 
<script>
    let jweixin = require('jweixin-module');
 
    import {
        mapState,
        mapGetters
    } from 'vuex'
    export default {
        data() {
            return {
                newIcon: 'https://img-shop.qmimg.cn/s16/images/2020/05/12/ffb0613dded704b6.png',
                openId: '',
                memberInfo: null,
                amounts: [],
                selectPackage: {}
            }
        },
        computed: {
 
        },
        onLoad() {
            this.getPackage();
        },
        onShow() {
            this.getMemberInfo();
        },
        methods: {
            kefu()
            {
                window.location.href="https://work.weixin.qq.com/kfid/kfcf7fc87ec720b0317";
                // uni.navigateTo({
                //     url:'https://work.weixin.qq.com/kfid/kfc166888de385a7599'
                // })
            },
            copy() {
                uni.setClipboardData({
                    data: this.openId,
                    success: function() {
                        uni.showToast({
                            title: '复制成功',
                            icon: 'none'
                        });
                    }
                });
            },
            addSms() {
                if(!this.selectPackage.id)
                {
                    uni.showToast({
                        title: '请选择充值包',
                        icon: 'none'
                    });
                    return;
                }
                let data = {
                    PackageId: this.selectPackage.id,
                    OpenId: this.openId
                };
                uni.showLoading({
                    title: '加载中'
                })
                this.$http.post('/smsapi/WxBack/GetCreatePayInfo', data).then(e => {
                    if (e.result != null) {
                        jweixin.config({
                            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,线上环境需要改为false
                            appId: e.result.appId, // 必填,公众号的唯一标识
                            timestamp: e.result.timeStamp, // 必填,生成签名的时间戳
                            nonceStr: e.result.nonceStr, // 必填,生成签名的随机串
                            signature: e.result.paySign, // 必填,签名
                            jsApiList: ['chooseWXPay'], // 必填,需要使用的JS接口列表    
                        });
                        uni.hideLoading();
                        jweixin.ready(() => {
                            jweixin.chooseWXPay({
                                appId: e.result.appId, // 必填,公众号的唯一标识
                                timestamp: e.result.timeStamp,
                                nonceStr: e.result.nonceStr, // 支付签名随机串,不长于 32 位
                                package: e.result.package, // 统一支付接口返回的prepay_id参数值
                                signType: e.result.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
                                paySign: e.result.paySign, // 支付签名
                                success: function(res) { //支付成功回调
                                    console.log('支付成功')
                                    uni.showToast({
                                        title: '支付成功',
                                        icon: 'none',
                                        duration: 2000,
                                    })
                                    // //成功后跳转到订单页
                                    this.getMemberInfo();
 
                                },
                                cancel: function(res) {
                                    uni.showToast({
                                        title: '取消支付',
                                        icon: 'none',
                                        duration: 2000,
                                    })
                                    alert('取消支付')
                                },
                                fail: function(res) {
                                    console.log("fail", res);
                                    uni.showToast({
                                        title: '支付失败',
                                        icon: 'none',
                                        duration: 2000,
                                    })
                                    alert('支付失败')
                                }
                            });
                        });
                    }
                }).catch(function(err) {
                    console.log(err);
                })
            },
            getMemberInfo() { //获取用户信息
                this.openId = uni.getStorageSync('smsopenid');
                let data = {
                    OpenId: this.openId
                }
                this.$http.post('/smsapi/SmsBusiness/GetMemberInfo', data).then(e => {
                    if (e.result != null) {
                        this.memberInfo = e.result;
                        uni.setStorageSync("smsmemberinfo", e.result);
                    }
                }).catch(function(err) {
                    console.log(err);
                })
            },
            getPackage() {
                this.$http.post('/smsapi/SmsBusiness/GetSmsPackage', {}).then(e => {
                    this.amounts = e.result;
                }).catch(function(err) {
                    console.log(err);
                })
            },
            tohis() {
                uni.navigateTo({
                    url: '/pages/sendhistory/index'
                })
            },
            handleSelected(index) {
                this.amounts.forEach(item => this.$set(item, 'selected', false))
                this.$set(this.amounts[index], 'selected', true);
                this.selectPackage = this.amounts[index];
                this.addSms();
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    page {
        height: auto;
        min-height: 100%;
    }
 
    .bg {
        width: 100%;
        height: calc(410 / 594 * 750rpx);
    }
 
    .amounts {
        margin-bottom: 40rpx;
 
        .amount {
            width: calc(96% / 3);
            padding: 50rpx 0;
            margin-bottom: 20rpx;
            border-radius: 8rpx;
        }
    }
 
    .hym-btn {
        position: absolute;
        top: 40rpx;
        right: 40rpx;
        color: $color-primary;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50rem;
        font-size: $font-size-sm;
        box-shadow: 0 0 20rpx rgba(66, 66, 66, 0.1);
 
        &::after {
            border: 0;
        }
 
        image {
            width: 30rpx;
            height: 30rpx;
            margin-right: 10rpx;
        }
    }
 
    .user-box {
        position: relative;
        border-radius: 8rpx;
        margin-bottom: 30rpx;
        margin-top: -115rpx;
        box-shadow: $box-shadow;
    }
 
    .avatar {
        position: relative;
        margin-top: -35rpx;
        margin-left: 35rpx;
        margin-right: 35rpx;
        width: 160rpx;
        height: 160rpx;
        border-radius: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: #FFFFFF;
        box-shadow: 0 0 20rpx rgba($color: #000000, $alpha: 0.2);
 
        image {
            width: 140rpx;
            height: 140rpx;
            border-radius: 100%;
        }
 
        .badge {
            position: absolute;
            right: -10rpx;
            bottom: -10rpx;
            background-color: #FFFFFF;
            border-radius: 50rem;
            display: flex;
            align-items: center;
            justify-content: center;
            color: $color-warning;
            font-size: 24rpx;
            padding: 8rpx 16rpx;
            box-shadow: 0 0 20rpx rgba($color: #000000, $alpha: 0.2);
 
            image {
                width: 30rpx;
                height: 30rpx;
            }
        }
    }
 
    .level-benefit {
        margin-left: 35rpx;
        padding: 10rpx 0 10rpx 30rpx;
        border-radius: 50rem 0 0 50rem;
    }
 
    .user-grid {
        width: 25%;
        padding: 30rpx;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
 
        .value {
            margin-bottom: 20rpx;
        }
    }
 
    .level-benefit-box {
        border-radius: 8rpx;
        margin-bottom: 30rpx;
        box-shadow: 0 10rpx 8rpx rgba($color: #878889, $alpha: 0.1);
        width: 100%;
        display: flex;
        padding: 30rpx;
        flex-direction: column;
        background-color: #FFFFFF;
 
        .row {
            display: flex;
            padding: 30rpx 0 20rpx;
            justify-content: space-around;
            align-items: center;
 
            .grid {
                width: 20%;
                display: flex;
                flex-direction: column;
                font-size: $font-size-sm;
                color: $text-color-assist;
                align-items: center;
 
                image {
                    width: 80rpx;
                    height: 80rpx;
                    margin-bottom: 10rpx;
                }
            }
        }
    }
 
    .banner {
        width: 100%;
        border-radius: 8rpx;
        margin-bottom: 30rpx;
    }
 
    .service-box {
        width: 100%;
        background-color: #FFFFFF;
        padding: 32rpx 30rpx 10rpx;
        box-shadow: $box-shadow;
 
        .row {
            display: flex;
            flex-wrap: wrap;
            color: $text-color-assist;
            font-size: $font-size-sm;
            padding-bottom: -40rpx;
 
            .grid {
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                margin-bottom: 40rpx;
                width: 25%;
                position: relative;
 
                .image {
                    image {
                        width: 80rpx;
                        height: 80rpx;
                        margin-bottom: 20rpx;
                    }
                }
 
                .new-badage {
                    width: 40rpx;
                    height: 40rpx;
                    position: absolute;
                    top: 0;
                    right: 30rpx;
                }
            }
        }
    }
</style>