123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486 |
- <template>
- <view class="content">
- <view class="bg">
- </view>
- <view class="listBox">
- <view class="list flex">
- <view @click="changeMoney(index)" :class="{action:index==actionIndex}" class="item flex"
- v-for="(item,index) in moneyList">
- <text>{{item.price}}元</text>
- </view>
- </view>
- <view class="flex inputBox">
- <text class="text">自定义金额</text>
- <input class="input" type="number" v-model="money" />
- <text>元</text>
- </view>
- </view>
- <view class="yt-list">
- <view class="yt-list-cell b-b" v-if="fx" @click="type='wxpay'">
- <view class="cell-tit flex">
- <image class="orderIcon" src="../../../static/icon/orderWx.png" mode="widthFix"></image>
- <text class="margin-l-10">微信支付</text>
- </view>
- <image class="checked" v-if="type=='wxpay'" src="../../../static/icon/addressIconXz.png"
- mode="widthFix"></image>
- <view v-else class="noChecked"></view>
- </view>
- <!-- #ifdef APP-PLUS -->
- <view class="yt-list-cell b-b" @click="type='alipay'">
- <view class="cell-tit flex">
- <image class="orderIcon" src="../../../static/icon/orderAli.png" mode="widthFix"></image>
- <text class="margin-l-10">支付宝</text>
- </view>
- <image class="checked" v-if="type=='alipay'" src="../../../static/icon/addressIconXz.png"
- mode="widthFix">
- </image>
- <view v-else class="noChecked"></view>
- </view>
- <!-- #endif -->
- <!-- <view class="yt-list-cell b-b" @click="type='commission'">
- <view class="cell-tit flex">
- <image class="orderIcon" src="../../../static/icon/ye.png" mode="widthFix"></image>
- <text class="margin-l-10">佣金({{commissionMoney}})</text>
- </view>
- <image class="checked" v-if="type=='commission'" src="../../../static/icon/addressIconXz.png"
- mode="widthFix">
- </image>
- <view v-else class="noChecked"></view>
- </view> -->
- </view>
- <view class="base-buttom" :class="{ 'active-bg': payLoding }" @click="!payLoding ? confirm() : ''">确认充值</view>
- </view>
- </template>
- <script>
- import {
- mapState
- } from 'vuex';
- import {
- commissionPay
- } from '@/api/wallet.js';
- // #ifdef APP
- import {
- aliPay,
- wxPay
- } from '@/api/wallet.js';
- // #endif
- // #ifdef H5
- import weixinObj from "@/plugin/jweixin-module/index.js";
- import {
- rechargeWechat
- } from '@/api/wallet.js';
- // #endif
- // #ifdef MP
- import {
- rechargeRoutine
- } from '@/api/wallet.js';
- // #endif
- import {
- rechargeIndex,
- spreadCommission,
- extractBank
- } from '@/api/wallet.js';
- export default {
- data() {
- return {
- actionIndex: 0, //当前选中的充值金额对象
- type: 'alipay',
- money: '', //充值金额
- payLoding: false, //是否加载中
- moneyList: [],
- commissionMoney: 0, //可提现佣金
- };
- },
- onLoad(options) {
- this.rechargeIndex();
- this.extractBank();
- console.log("s");
- },
- computed:{
- ...mapState(['fx'])
- },
- methods: {
- //获取用户金额信息
- extractBank() {
- extractBank({}).then(({
- data
- }) => {
- // 保存佣金信息
- this.commissionMoney = data.commissionCount;
- });
- },
- // 金额修改
- changeMoney(ind) {
- this.actionIndex = ind;
- this.money = this.moneyList[ind].price
- },
- // 查询金额列表
- rechargeIndex() {
- rechargeIndex().then((e) => {
- this.moneyList = e.data.recharge_quota.map((e) => {
- e.price = +e.price;
- return e
- });
- // 设置默认金额值
- this.money = this.moneyList[0].price
- console.log(e);
- })
- },
- // 跳转
- navTo(url) {
- uni.navigateTo({
- url: url
- });
- },
- // 提交
- confirm() {
- const that = this;
- if (that.money < (+that.moneyList[0].price)) {
- uni.showModal({
- title: '失败',
- content: '充值金额不可以低于¥' + that.moneyList[0].price,
- showCancel: false
- });
- return
- }
- that.payLoding = true;
- let pushData = {
- price: this.money,
- // #ifdef H5
- from: 'weixin',
- // #endif
- // #ifdef APP
- from: 'app',
- // #endif
- }
- // 佣金转余额
- if (that.type == 'commission') {
- that.commissionPay(pushData)
- return
- }
- // 微信支付
- if (that.type == 'wxpay') {
- that.wxpay(pushData)
- return
- }
- // #ifdef APP
- // 支付宝支付
- if (that.type == 'alipay') {
- console.log('ali');
- that.alipay(pushData)
- return
- }
- // #endif
- // 微信支付
- },
- commissionPay(pushData) {
- const that = this;
- commissionPay(pushData).then((e) => {
- that.payLoding = false;
- if (e.status == 200) {
- that.extractBank()
- uni.redirectTo({
- url: './paySuccess?type=1'
- });
- return
- }
- uni.showToast({
- title: e.msg
- });
- }).catch(() => {
- that.payLoding = false;
- })
- },
- // #ifdef APP-PLUS
- alipay(pushData) {
- const that = this;
- aliPay(pushData).then((e) => {
- console.log(e.data.data,'jie');
- let orderInfo={};
- that.payLoding = true;
- uni.requestPayment({
- provider: that.type,
- orderInfo:e.data.data,
- success(e) {
- uni.redirectTo({
- url: './paySuccess?type=1'
- });
- },fail(e) {
- console.log(e);
- }
- })
- }).catch(e => {
- that.payLoding = false;
- console.log(e,'cuowu');
- });
- },
- // #endif
- wxpay(pushData) {
- const that = this;
- // #ifdef H5
- console.log(pushData);
- rechargeWechat(pushData)
- .then(e => {
- let da = e.data;
- that.payLoding = false;
- weixinObj.chooseWXPay({
- timestamp: da.timestamp,
- nonceStr: da.nonceStr,
- package: da.package,
- signType: da.signType,
- paySign: da.paySign,
- success: function(res) {
- uni.redirectTo({
- url: './paySuccess?type=1'
- });
- },
- });
- })
- .catch(e => {
- that.payLoding = false;
- console.log(e);
- });
- // #endif
- // #ifdef MP
- rechargeRoutine(pushData)
- .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: './paySuccess?type=1'
- });
- }
- })
- that.payLoding = false;
- })
- .catch(e => {
- that.payLoding = false;
- console.log(e);
- });
- // #endif
- // #ifdef APP
- wxPay(pushData).then((res) => {
- console.log(res.data,'充值');
- that.payLoding = true;
- uni.requestPayment({
- provider: that.type,
- orderInfo: res.data,
- success(e) {
- uni.redirectTo({
- url: './paySuccess?type=1'
- });
- },
- fail(e) {
- console.log('错误', e);
- }
- })
- }).catch(e => {
- that.payLoding = false;
- console.log(e);
- });
- // #endif
- }
- }
- };
- </script>
- <style lang="scss">
- .yt-list {
- background: #fff;
- margin: 0 $page-row-spacing;
- margin-top: 30rpx;
- border-radius: 20rpx;
- .yt-list-cell {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 10rpx 30rpx 10rpx 40rpx;
- line-height: 70rpx;
- position: relative;
- .checked,
- .noChecked {
- width: 36rpx;
- height: 36rpx;
- }
- .noChecked {
- border: 1px solid $font-color-light;
- border-radius: 100rpx;
- }
- &.cell-hover {
- background: #fafafa;
- }
- &.b-b:after {
- left: 30rpx;
- }
- .cell-icon {
- height: 32rpx;
- width: 32rpx;
- font-size: 22rpx;
- color: #fff;
- text-align: center;
- line-height: 32rpx;
- background: #f85e52;
- border-radius: 4rpx;
- margin-right: 12rpx;
- &.hb {
- background: #ffaa0e;
- }
- &.lpk {
- background: #3ab54a;
- }
- }
- .cell-more {
- align-self: center;
- font-size: 24rpx;
- color: $font-color-light;
- margin-left: 8rpx;
- margin-right: -10rpx;
- }
- .cell-tit {
- font-size: 26rpx;
- color: $font-color-light;
- margin-right: 10rpx;
- .orderIcon {
- width: 48rpx;
- }
- }
- .cell-tip {
- font-size: 26rpx;
- color: $font-color-dark;
- &.disabled {
- color: $font-color-light;
- }
- &.active {
- color: $base-color;
- }
- &.red {
- color: $base-color;
- }
- }
- &.desc-cell {
- .cell-tit {
- max-width: 90rpx;
- }
- }
- .desc {
- text-align: right;
- font-size: $font-base;
- color: $font-color-light;
- }
- }
- }
- page {
- height: 100%;
- }
- .content {
- padding-top: 30rpx;
- }
- .active-bg {
- background-color: $color-gray !important;
- }
- .listBox {
- margin: 30rpx;
- margin-top: 0;
- border-radius: 20rpx;
- padding: 20rpx;
- background-color: #FFFFFF;
- position: relative;
- padding-bottom: 30rpx;
- .inputBox {
- font-size: 28rpx;
- font-weight: bold;
- color: $font-color-base;
- margin: 0 20rpx;
- .text {
- flex-shrink: 0;
- }
- .input {
- border-bottom: 1px solid $font-color-disabled;
- flex-grow: 1;
- margin: 0 10rpx;
- height: 30rpx;
- text-align: center;
- }
- }
- }
- .list {
- padding-top: 10rpx;
- flex-wrap: wrap;
- .item {
- justify-content: center;
- width: 210rpx;
- height: 100rpx;
- margin-bottom: 20rpx;
- background-color: #F5F5F5;
- border-radius: 20rpx;
- font-size: 28rpx;
- font-weight: bold;
- color: $font-color-base;
- border: 1px solid #F5F5F5;
- &.action {
- border: 1px solid $color-green;
- color: $color-green;
- }
- }
- }
- .bg {
- background-color: $color-green;
- width: 950rpx;
- position: absolute;
- left: -100rpx;
- border-bottom-left-radius: 1000rpx;
- border-bottom-right-radius: 1000rpx;
- top: 0rpx;
- height: 300rpx;
- }
- .base-buttom {
- position: relative;
- left: auto;
- bottom: auto;
- right: auto;
- }
- </style>
|