<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>
|