| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- <template>
- <view class="content">
- <view class="row-box">
- <view class="title">充值金额</view>
- <view class="row">
- <text class="tit">¥</text>
- <input class="input" type="number" v-model="money" placeholder="请输入充值金额" placeholder-class="placeholder" />
- </view>
- </view>
- <!-- #ifndef MP -->
- <view class="list">
- <radio-group @change="tabRadio">
- <label>
- <view class="box">
- <view class="icon iconfont iconzhifubao"></view>
- <view class="title-box">
- <view class="title"><text>支付宝充值</text></view>
- </view>
- <view class="right"><radio value="alipay" color="#5dbc7c" :checked="type == 'alipay'" /></view>
- </view>
- </label>
- <label>
- <view class="box1">
- <view class="icon iconfont iconweixin1"></view>
- <view class="title-box">
- <view class="title"><text>微信充值</text></view>
- </view>
- <view class="right"><radio value="weixin" color=" #5dbc7c" :checked="type == 'weixin'" /></view>
- </view>
- </label>
- </radio-group>
- </view>
- <!-- #endif -->
- <button class="add-btn up" :class="{ 'active-bg': payLoding }" @click="!payLoding ? confirm() : ''">确认</button>
- </view>
- </template>
- <script>
- import { getMoneyStyle } from '@/utils/rocessor.js';
- // #ifdef H5
- import { rechargeWechat } from '@/api/wallet.js';
- // #endif
- // #ifdef MP
- import { rechargeRoutine } from '@/api/wallet.js';
- // #endif
- import { mapState } from 'vuex';
- export default {
- filters: {
- getMoneyStyle
- },
- data() {
- return {
- type: 'weixin',
- money: '', //充值金额
- payLoding: false //是否加载中
- };
- },
- onLoad(options) {},
- computed: {
- // #ifdef H5
- ...mapState(['weichatObj'])
- // #endif
- },
- methods: {
- // 跳转
- navTo(url) {
- uni.navigateTo({
- url: url
- });
- },
- // 切换选中对象
- tabRadio(e) {
- this.type = e;
- console.log(this.type,'this.type')
- },
- // 提交
- confirm() {
- let obj = this;
- obj.payLoding = true;
- console.log(obj.money);
- if ( obj.money == '') {
- this.$api.msg('金额不能为空');
- obj.payLoding = false;
- return
- }
- // #ifdef APP-PLUS
- if(obj.type == 'alipay')
- {
- uni.requestPayment({
- provider: 'alipay',
- orderInfo: 'orderInfo', //微信、支付宝订单数据
- success: function (res) {
- console.log('success:' + JSON.stringify(res));
- },
- fail: function (err) {
- console.log('fail:' + JSON.stringify(err));
- }
- });
- }else{
- uni.requestPayment({
- provider: 'weixin',
- orderInfo: 'orderInfo', //微信、支付宝订单数据
- success: function (res) {
- console.log('success:' + JSON.stringify(res));
- },
- fail: function (err) {
- console.log('fail:' + JSON.stringify(err));
- }
- });
- }
- // #endif
-
- // #ifdef H5
- rechargeWechat({ price: this.money, from: this.type })
- .then(e => {
- let da = e.data.data;
- obj.weichatObj.chooseWXPay({
- timestamp: da.timestamp,
- nonceStr: da.nonceStr,
- package: da.package,
- signType: da.signType,
- paySign: da.paySign,
- success: function(res) {
- uni.navigateTo({
- url: '/pages/money/rechargeSuccess'
- });
- /* uni.showToast({
- title: '充值成功',
- duration: 2000,
- position: 'top'
- }); */
- }
- });
- obj.payLoding = false;
- })
- .catch(e => {
- obj.payLoding = false;
- console.log(e);
- });
- // #endif
-
- // #ifdef MP
- rechargeRoutine({ price: this.money})
- .then(e => {
- let da = e.data;
- wx.requestPayment({
- timeStamp: da.timestamp,
- nonceStr: da.nonceStr,
- package: da.package,
- signType: da.signType,
- paySign: da.paySign,
- success: function(res) {
- uni.redirectTo({
- url: '/pages/money/paySuccess'
- });
- },
- fail:function(res){
- uni.showToast({
- title: '支付失败',
- duration: 3000
- });
- },
- complete:function(){}
- })
-
- obj.payLoding = false;
- })
- .catch(e => {
- obj.payLoding = false;
- console.log(e);
- });
- // #endif
- }
- }
- };
- </script>
- <style lang="scss">
- page {
- height: 100%;
- }
- .add-btn {
- &.modified {
- color: $base-color;
- }
- &.up {
- background:$base-color;
- color: #fff;
- }
- display: flex;
- align-items: center;
- justify-content: center;
- width: 560rpx;
- height: 80rpx;
- margin: 0 auto;
- margin-top: 60rpx;
- font-size: $font-lg;
- border-radius: 40rpx;
- }
- .row-box {
- border-top: 1px solid #EEEEEE;
- padding: 20rpx 30rpx;
- background: #fff;
- .title {
- font-size: $font-base + 2rpx;
- color: $font-color-dark;
- }
- .row {
- display: flex;
- align-items: center;
- position: relative;
- height: 80rpx;
- .tit {
- flex-shrink: 0;
- width: 40rpx;
- font-size: 30rpx;
- color: $font-color-dark;
- }
- .input {
- flex: 1;
- font-size: 30rpx;
- color: $font-color-dark;
- }
- .iconlocation {
- font-size: 36rpx;
- color: $font-color-light;
- }
- .buttom {
- color: $font-color;
- font-size: $font-base;
- }
- }
- }
- .list {
- padding:0 30rpx;
- margin-top: 20rpx;
- background-color: #ffffff;
- .box {
- display: flex;
- align-items: center;
- width: 100%;
- height: 100rpx;
- border-bottom: 1px solid $border-color-light;
- }
- .box1{
- display: flex;
- align-items: center;
- width: 100%;
- height: 100rpx;
- }
- .icon {
- font-size: 48rpx;
- padding-right: 20rpx;
- }
- .iconweixin1 {
- color: #18bf16;
- }
- .iconzhifubao {
- color: #08aaec;
- }
- .title-box {
- flex-grow: 1;
- text-align: left;
- .title {
- font-size: $font-base + 2rpx;
- color: #333333;
- }
- /* .node {
- font-size: $font-base;
- color: #333333;
- } */
- }
- image {
- width: 25rpx;
- height: 25rpx;
- }
- }
- /deep/ .uni-radio-input {
- width: 45rpx;
- height: 45rpx;
- }
- .active-bg {
- background-color: $color-gray !important;
- }
- </style>
|