123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- <template>
- <view class="main">
- <view class="pr" style="z-index:2">
- <view class="plr15">
- <view class="bdr4 bg-white" style="margin-top: 38rpx;box-shadow: 0 0 50rpx 0 rgba(0, 0, 0, 0.1);">
- <view class="" style="height: 350rpx;">
- <view class="text-df text-bold" style="padding-top: 32rpx; margin-left: 28rpx;">
- 兑换金币
- </view>
- <view class="flex flex-wrap align-center justify-around" style="margin-top: 15rpx;margin-left: 28rpx;margin-right: 28rpx">
- <view @click="replaceMoney(item)" :class="num==item.index?'text-lg flex align-center justify-center margin-top moneyActivate':'text-lg flex align-center justify-center margin-top money'"
- v-for="(item,index) in moneyList" :data-index="index" :key="index" style="width: 174rpx;height: 78rpx;border-radius: 16rpx;">
- {{item.price}}元
- </view>
- <input type="number" placeholder="输入金额" :class="num==5?'margin-top padding-lr-sm moneyActivate':'margin-top padding-lr-sm money'"
- style="width: 174rpx;height: 78rpx;border-radius: 16rpx;" value="" @focus="focusstyle" v-model="inputmoney" />
- </view>
- </view>
- <view class="pr" style="padding: 40rpx 40rpx;background-color: #fff;border-radius: 16rpx; border-top: 2rpx solid #efefef; ">
- <view class="tl f14 flex justify-between align-center">
- <view class="m-gray-letter mt5 f12">支付金额</view>
- <view class="m-gray-big f15 fb pr10">¥{{paymentMoney}}</view>
- </view>
- <view class="tl f14 flex justify-between align-center margin-top-sm">
- <view class="m-gray-letter mt5 f12">到账金额</view>
- <view class="m-gray-big f15 fb pr10">¥{{accountMoney}}</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="margin-lr margin-top">
- <view class="text-df" style="color: #999999;font-weight: 400;">
- 温馨提示
- </view>
- <view class="text-sm" style="color: #999999;font-weight: 400;margin-top: 15rpx;">
- <rich-text :nodes="recharge_notice"></rich-text>
- </view>
- </view>
- <view class="margin-lr" style="margin-top: 210rpx;">
- <view class="text-sm margin-bottom" style="color: #999999;text-align: center;">
- 点击充值按钮即表示已阅读并同意 <text style="color: #0B73B9;" @click.stop="gotoxieyi">《充值规则》</text>
- </view>
- <u-button size="default" :ripple="true" @click="recharge" :custom-style="customStyle">充值</u-button>
- </view>
- <view class="cu-tabbar-height"></view>
- </view>
- </template>
- <script>
- export default {
- onLoad() {
- this.paymentMoney = this.moneyList[0].price
- this.accountMoney = this.moneyList[0].price
- this.$util.getAgreement().then(res => {
- this.recharge_protocol = res.data.recharge_protocol
- this.recharge_notice = res.data.recharge_notice
- }).catch(err => {
- })
- },
- data() {
- return {
- paymentMoney: "",
- accountMoney: "",
- inputmoney: '',
- num: 0,
- moneyList: [{
- index: 0,
- price: 0.01
- },
- {
- index: 1,
- price: 100
- },
- {
- index: 2,
- price: 200
- },
- {
- index: 3,
- price: 500
- },
- {
- index: 4,
- price: 1000
- },
- ],
- customStyle: {
- backgroundColor: '#0B73B9',
- color: '#FFFFFF'
- },
- recharge_protocol: "",
- recharge_notice: ""
- };
- },
- watch: {
- inputmoney: function(newtext, jiu) {
- if (typeof newtext === 'string') {
- if (newtext.trim().length !== 0) {
- this.debounce(this.changeStr, 500);
- } else {}
- }
- }
- },
- methods: {
- gotoxieyi() {
- uni.navigateTo({
- url: "../index/agreement?data=" + encodeURIComponent(this.recharge_protocol)
- })
- },
- replaceMoney(item) {
- this.paymentMoney = item.price
- this.accountMoney = item.price
- this.num = item.index
- this.inputmoney = ""
- },
- debounce(fn, wait) {
- if (this.fun !== null) {
- clearTimeout(this.fun)
- }
- this.fun = setTimeout(fn, wait)
- },
- changeStr() {
- this.paymentMoney = this.inputmoney
- this.accountMoney = this.inputmoney
- if (this.inputmoney == "") {
- this.paymentMoney = 0
- this.accountMoney = 0
- }
- },
- focusstyle() {
- this.paymentMoney = 0
- this.accountMoney = 0
- this.num = 5
- },
- recharge: async function() {
- let res = await this.$request.post("/api/v1/order/topup", {
- amount: this.paymentMoney * 100
- })
- if (res.status == 0) {
- uni.requestPayment({
- timeStamp: res.data.timeStamp,
- nonceStr: res.data.nonceStr,
- package: res.data.package,
- signType: res.data.signType,
- paySign: res.data.paySign,
- success: (res) => {
- if (res.errMsg == "requestPayment:ok") {
- uni.showToast({
- title: "充值成功",
- duration: 1500
- })
- setTimeout(() => {
- uni.navigateBack({
- delta: 1
- })
- }, 1500)
- }
- },
- fail: (err) => {
- console.log(err)
- },
- complete: (res) => {
- console.log(res)
- }
- })
- }
- }
- },
- onShow() {
- }
- };
- </script>
- <style lang="scss">
- @import url("../index/mine.css");
- button {
- border-radius: 15rpx;
- }
- .money {
- border: 2rpx solid #C0C0C0;
- }
- .moneyActivate {
- border: 2rpx solid #0B73B9;
- color: #0B73B9;
- background-color: rgba(11, 115, 185, .1);
- }
- .header-content {
- position: absolute;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- width: 100%;
- z-index: -1;
- overflow: hidden;
- box-sizing: border-box;
- }
- .header-box {
- box-shadow: 0px 8rpx 34rpx -6rpx rgba(248, 151, 164, 0.13);
- }
- .header-img {
- width: 36rpx;
- height: 36rpx;
- }
- .tip {
- position: absolute;
- top: 0;
- right: 20%;
- bottom: 0;
- background-color: red;
- width: 12rpx;
- height: 12rpx;
- border-radius: 50%;
- }
- .msg {
- top: -3rpx;
- right: -9rpx;
- }
- swiper {
- height: 320rpx;
- }
- .swiper-wrapper {
- padding: 0 10rpx;
- box-sizing: border-box;
- }
- .swiper-item {
- width: 100%;
- height: 300rpx;
- box-shadow: 0 26rpx 40rpx 0 rgba(255, 255, 255, 0.31);
- background: url("http://file.supermm.me/miniProgram/images/personal/bg_doc.png") no-repeat bottom center;
- }
- .dots {
- position: absolute;
- left: 0;
- right: 0;
- bottom: -40rpx;
- display: flex;
- justify-content: center;
- }
- .dots .dot {
- margin: 0 8rpx;
- width: 14rpx;
- height: 14rpx;
- background: #E4E4E4;
- border-radius: 8rpx;
- transition: all .6s;
- }
- .dots .dot.active {
- width: 24rpx;
- background: rgb(153, 153, 153);
- }
- .game-wrap {
- position: relative;
- width: 100%;
- height: 100%;
- overflow: hidden;
- box-sizing: border-box;
- }
- .game-item {
- height: 100%;
- background: url("https://file.supermm.me/h5/wechat-h5/integral/personeBg001.jpg") no-repeat;
- background-size: 100% 100%;
- background-position: center center;
- border-radius: 100rpx;
- }
- </style>
|