123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681 |
- <template>
- <view>
- <form @submit="submitSub" :style="colorStyle">
- <view class="payment-top acea-row row-column row-center-wrapper">
- <span class="name">我的余额</span>
- <view class="pic">
- ¥<span class="pic-font">{{ userinfo.now_money || 0 }}</span>
- </view>
- </view>
- <view class="payment">
- <view class="nav acea-row row-around row-middle" >
- <view class="item" :class="active==index?'on':''" v-for="(item,index) in navRecharge" :key="index" @click="navRecharges(index)" v-if="item != '账户充值'">{{item}}</view>
- </view>
- <view class='tip picList' v-if="active == 0" >
- <view class="pic-box pic-box-color acea-row row-center-wrapper row-column" :class="activePic == index ? 'pic-box-color-active' : ''"
- v-for="(item, index) in picList" :key="index" @click="picCharge(index, item)" v-if="item.price">
- <view class="pic-number-pic">
- {{ item.price }}<span class="pic-number"> 元</span>
- </view>
- <view class="pic-number">赠送:{{ item.give_money }} 元</view>
- </view>
- <view class="pic-box pic-box-color acea-row row-center-wrapper" :class="activePic == picList.length ? 'pic-box-color-active' : ''"
- @click="picCharge(picList.length)">
- <input type="number" placeholder="其他" v-model="money" class="pic-box-money pic-number-pic" :class="activePic == picList.length ? 'pic-box-color-active' : ''" />
- </view>
- <view class="tips-box">
- <view class="tips mt-30">注意事项:</view>
- <view class="tips-samll" v-for="item in rechargeAttention" :key="item">
- {{ item }}
- </view>
- </view>
- </view>
- <!-- 佣金转余额 -->
- <view class="tip" v-else-if="active ==1">
- <view class='input'><text style="padding-left: 0;">¥</text><input @input='inputNum' :maxlength="moneyMaxLeng" placeholder="0.00" type='number' placeholder-class='placeholder' :value="number" name="number" style="padding-right: 0;width: 100%;"></input></view>
- <view class="tips-title">
- <view style="font-weight: bold; font-size: 26rpx;">提示:</view>
- <view style="margin-top: 10rpx;">当前可转入佣金为 <text class='font-color'>¥{{userinfo.commissionCount || 0}}</text>,冻结佣金为<text class='font-color'>¥{{userinfo.broken_commission}}</text></view>
- </view>
- <view class="tips-box">
- <view class="tips mt-30">注意事项:</view>
- <view class="tips-samll" v-for="item in rechargeAttention" :key="item">
- {{ item }}
- </view>
- </view>
- </view>
- <view class="tip" v-else>
- <view class='input'><input placeholder="请输入收款人手机号" type='number' placeholder-class='placeholder' :value="to_phone" name="to_phone" style="width: 100%;padding-right: 0;"></input></view>
- <view class='input'><text style="padding-left: 0;">¥</text><input @input='inputNum' :maxlength="moneyMaxLeng" placeholder="0.00" type='number' placeholder-class='placeholder' :value="number" name="number" style="width: 100%;padding-right: 0;"></input></view>
- <view class='input'><input placeholder="请输入支付密码" type='password' placeholder-class='placeholder' :value="tradepassword" name="tradepassword" style="width: 100%;padding-right: 0;"></input></view>
- <view class="tips-box">
- <view class="tips mt-30">注意事项:</view>
- <view class="tips-samll" v-for="item in rechargeAttention" :key="item">
- {{ item }}
- </view>
- </view>
- </view>
- <button class='but bg-color' formType="submit" > {{active ? (active == 1?'立即转入':'立即转账'): '立即充值' }}</button>
- </view>
- </form>
- <payment :payMode="payMode" :pay_close="pay_close" :is-call="true" @changePayType="changePayType" @onChangeFun="onChangeFun"
- :order_id="pay_order_id" :totalPrice="totalPrice"></payment>
- <home v-if="navigation"></home>
- <view v-show="false" v-html="formContent"></view>
- <!-- #ifdef MP -->
- <authorize v-if="isShowAuth" @authColse="authColse" @onLoadFun="onLoadFun"></authorize>
- <!-- #endif -->
- </view>
- </template>
- <script>
- import {
- getUserInfo,
- rechargeRoutine,
- rechargeRecharge,
- rechargeWechat,
- getRechargeApi,
- memberCardCreate,
- trade
- } from '@/api/user.js';
- import payment from '@/components/payment';
- import {
- toLogin
- } from '@/libs/login.js';
- import {
- orderOfflinePayType
- } from '@/api/order.js';
- import {
- mapGetters
- } from "vuex";
- import home from '@/components/home';
- import colors from "@/mixins/color";
- import {
- openPaySubscribe
- } from '@/utils/SubscribeMessage.js';
- export default {
- components: {
- home,
- payment
- },
- mixins:[colors],
- data() {
- let that = this;
- return {
- now_money: 0,
- navRecharge: ['账户充值', '佣金转入','余额转账'],
- active: 1,
- number: '',
- to_phone: '',
- tradepassword: '',
- userinfo: {},
- placeholder: "0.00",
- from: '',
- isAuto: false, //没有授权的不会自动授权
- isShowAuth: false, //是否隐藏授权
- picList: [],
- activePic: 0,
- money: "",
- numberPic:'',
- rechar_id:0,
- password: '',
- goodsList: [],
- pay_order_id: '',
- payMode: [{
- name: '微信支付',
- icon: 'icon-weixinzhifu',
- value: 'weixin',
- title: '微信快捷支付',
- payStatus: true
- }
- // #ifdef H5 ||APP-PLUS
- ,
- {
- name: '支付宝支付',
- icon: 'icon-zhifubao',
- value: 'alipay',
- title: '支付宝支付',
- payStatus: true
- }
- // #endif
- ],
- pay_close: false,
- payType: '',
- totalPrice: '0',
- formContent: '',
- // #ifdef H5
- isWeixin: this.$wechat.isWeixin(),
- // #endif
- type: '',
- rechargeAttention:[],
- moneyMaxLeng:18
- };
- },
- computed: mapGetters(['isLogin']),
- watch:{
- isLogin:{
- handler:function(newV,oldV){
- if(newV){
- //#ifndef MP
- this.getOrderPayType();
- this.getUserInfo();
- this.getRecharge();
- //#endif
- }
- },
- deep:true
- }
- },
- onLoad(options) {
- if(options.action) {
- this.active = options.action
- }
- // #ifdef H5
- this.from = this.$wechat.isWeixin() ? "weixinh5" : "alipay"
- // #endif
- if (this.isLogin) {
- this.getOrderPayType();
- this.getUserInfo();
- this.getRecharge();
- } else {
- //#ifndef MP
- toLogin();
- //#endif
- //#ifdef MP
- this.isShowAuth = true;
- //#endif
- }
- },
- onShow() {
- uni.removeStorageSync('form_type_cart');
- },
- methods: {
- onLunch() {
- this.getOrderPayType();
- this.getUserInfo();
- this.getRecharge();
-
- },
- inputNum: function(e) {
- let val = e.detail.value;
- let dot = val.indexOf('.');
- if(dot>-1){
- this.moneyMaxLeng = dot+3;
- }else{
- this.moneyMaxLeng = 18
- }
- },
- /**
- * 选择金额
- */
- picCharge(idx, item) {
- this.activePic = idx;
- if (item === undefined) {
- this.rechar_id = 0;
- this.numberPic = "";
- } else {
- this.money = "";
- this.rechar_id = item.id;
- this.numberPic = item.price;
- }
- },
- /**
- * 充值额度选择
- */
- getRecharge() {
- getRechargeApi()
- .then(res => {
- this.picList = res.data.recharge_quota;
- if (this.picList[0]) {
- this.rechar_id = this.picList[0].id;
- this.numberPic = this.picList[0].price;
- }
- this.rechargeAttention = res.data.recharge_attention || [];
- })
- .catch(res => {
- this.$util.Tips({
- title: res
- })
- });
- },
- getOrderPayType() {
- orderOfflinePayType().then(res => {
- const {
- ali_pay_status,
- pay_weixin_open
- } = res.data;
- this.payMode[0].payStatus = !!pay_weixin_open;
- // #ifdef APP-PLUS || H5
- this.payMode[1].payStatus = !!ali_pay_status;
- // #endif
- }).catch(err => {
- uni.showToast({
- title: err,
- icon: 'none'
- });
- });
- },
- onLoadFun: function() {
- this.getOrderPayType();
- this.getUserInfo();
- this.getRecharge();
- this.isShowAuth = false;
- },
- // 授权关闭
- authColse: function(e) {
- this.isShowAuth = e
- },
- navRecharges: function(index) {
- this.active = index;
- },
- /**
- * 获取用户信息
- */
- getUserInfo: function() {
- let that = this;
- getUserInfo().then(res => {
- that.$set(that, 'userinfo', res.data);
- })
- },
- changePayType: function(e) {
- // #ifdef H5
- this.payType = e == 'alipay' ? 'alipay' : this.$wechat.isWeixin() ? 'weixin' : 'weixinh5'
- // #endif
- // #ifndef H5
- this.payType = e == 'alipay' ? 'alipay' : 'routine'
- // #endif
- console.log('双方各大华股份不报错',this.payType);
- },
- onChangeFun: function(e) {
- let opt = e;
- let action = opt.action || null;
- let value = opt.value != undefined ? opt.value : null;
- action && this[action] && this[action](value);
- },
- payClose: function() {
- this.pay_close = false;
- },
- payCheck: function(type) {
- this.createMemberCard(type);
- },
- createMemberCard(type) {
- uni.showLoading({
- title: '正在加载…'
- });
- // #ifdef MP || APP-PLUS
- uni.showLoading({
- title: '正在支付',
- })
- let that = this
- let money = parseFloat(this.money);
- if( this.rechar_id == 0){
- if(Number.isNaN(money)){
- return that.$util.Tips({title: '充值金额必须为数字'});
- }
- if(money <= 0){
- return that.$util.Tips({title: '充值金额不能为0'});
- }
- }else{
- // money = this.numberPic
- }
- rechargeRecharge({
- price: parseFloat(this.totalPrice),
- type: 0,
- rechar_id: this.rechar_id,
- from: this.payType === 'alipay' ? 'alipay' : 'routine'
- }).then(res => {
- uni.hideLoading();
- let data = res.data.data;
- let mp_pay_name=''
- if(uni.requestOrderPayment){
- mp_pay_name='requestOrderPayment'
- }else{
- mp_pay_name='requestPayment'
- }
- uni[mp_pay_name]({
- // #ifdef MP
- timeStamp: data.timestamp,
- nonceStr: data.nonceStr,
- package: data.package,
- signType: data.signType,
- paySign: data.paySign,
- // #endif
- // #ifdef APP-PLUS
- provider: this.payType==='alipay'?'alipay':'wxpay',
- orderInfo: data,
- // #endif
- success: function(res) {
- that.$set(that, 'userinfo.now_money', that.$util.$h.Add(value, that.userinfo.now_money));
- return that.$util.Tips({
- title: '支付成功',
- icon: 'success'
- }, {
- tab: 5,
- url: '/pages/users/user_money/index'
- });
- },
- fail: function() {
- return that.$util.Tips({
- title: '支付失败'
- });
- },
- complete: function(res) {
- if (res.errMsg == 'requestPayment:cancel') return that.$util.Tips({
- title: '取消支付'
- });
- }
- })
- }).catch(err => {
- uni.hideLoading();
- return that.$util.Tips({
- title: err
- })
- });
- // #endif
- // #ifdef H5
- let that = this
- this.pay_close = true;
- this.totalPrice = this.rechar_id == 0 ? this.money : this.numberPic;
- rechargeWechat({
- price: parseFloat(this.totalPrice),
- from: this.payType == '' ? this.$wechat.isWeixin() ? 'weixin' :'weixinh5' : this.payType,
- rechar_id: that.rechar_id
- }).then(res => {
- let data = res.data;
- if (data.type == "weixinh5") {
- uni.showToast({
- title: data.msg,
- success() {
- location.href = data.data.mweb_url;
- }
- });
- }else if(data.type == "alipay") {
- uni.hideLoading();
- uni.hideLoading();
- this.formContent = data.data;
- this.$nextTick(() => {
- document.getElementById('alipaysubmit').submit();
- });
- }else if(data.type == "weixin") {
- this.$wechat.pay(data.data).then(res => {
- this.$util.Tips({
- title: '支付成功',
- icon: 'success'
- }, {
- tab: 5,
- url: '/pages/users/user_money/index'
- });
- }).catch(err => {
- if (err.errMsg == 'chooseWXPay:cancel') {
- uni.showToast({
- title: '取消支付',
- icon: 'none'
- });
- }
- });
- }
- }).catch(err=>{
- uni.hideLoading();
- return that.$util.Tips({
- title: err
- })
- })
- // #endif
- },
- /*
- * 用户充值
- */
- submitSub: function(e) {
- let that = this
- let value = e.detail.value.number;
- // 转入余额
- if (that.active == 1) {
- if (parseFloat(value) < 0 || parseFloat(value) == NaN || value == undefined || value == "") {
- return that.$util.Tips({
- title: '请输入金额'
- });
- }
- uni.showModal({
- title: '转入余额',
- content: '转入余额后无法再次转出,确认是否转入余额',
- success(res) {
- if (res.confirm) {
- // #ifdef MP || APP-PLUS
- rechargeRoutine({
- price: parseFloat(value),
- type: 1
- })
- // #endif
- // #ifdef H5
- rechargeWechat({
- price: parseFloat(value),
- from: that.from,
- type: 1
- })
- // #endif
- .then(res => {
- // that.$set(that, 'userinfo.now_money', that.$util.$h.Add(value, that.userinfo.now_money))
- return that.$util.Tips({
- title: '转入成功',
- icon: 'success'
- }, {
- tab: 5,
- url: '/pages/users/user_money/index'
- });
- }).catch(err => {
- return that.$util.Tips({
- title: err
- })
- });
- } else if (res.cancel) {
- return that.$util.Tips({
- title: '已取消'
- });
- }
- },
- })
- } else if(that.active == 0){
- // #ifdef MP
- this.pay_close = true;
- // #endif
- // #ifndef MP
- this.pay_close = true;
- // #endif
- this.totalPrice = this.rechar_id == 0 ? parseFloat(this.money) : parseFloat(this.numberPic);
- } else {
- let to_phone = e.detail.value.to_phone
- let tradepassword = e.detail.value.tradepassword
- console.log(value,'ddddd')
- trade({
- to_phone: to_phone,
- trade_password: tradepassword,
- money: value*1
- }).then(res => {
- return that.$util.Tips({
- title: '转账成功',
- icon: 'success'
- }, {
- tab: 5,
- url: '/pages/users/user_money/index'
- });
- }).catch(err => {
- return that.$util.Tips({
- title: err
- })
- });
- }
- }
- }
- }
- </script>
- <style lang="scss">
- page {
- width: 100%;
- height: 100%;
- background-color: #fff;
- }
- .bgcolor{
- background-color: var(--view-theme)
- }
- .payment {
- position: relative;
- width: 100%;
- background-color: #fff;
- border-radius: 10rpx;
- padding-top: 25rpx;
- border-top-right-radius: 39rpx;
- border-top-left-radius: 39rpx;
- }
- .payment .nav {
- height: 75rpx;
- line-height: 75rpx;
- padding: 0 100rpx;
- }
- .payment .nav .item {
- font-size: 30rpx;
- color: #333;
- }
- .payment .nav .item.on {
- font-weight: bold;
- border-bottom: 4rpx solid var(--view-theme);
- }
- .payment .input {
- display: flex;
- align-items: center;
- justify-content: center;
- border-bottom: 1px dashed #dddddd;
- margin: 60rpx auto 0 auto;
- padding-bottom: 20rpx;
- font-size: 56rpx;
- color: #333333;
- flex-wrap: nowrap;
-
- }
- .payment .input text {
- padding-left: 106rpx;
- }
- .payment .input input {
- padding-right: 106rpx;
- width: 300rpx;
- height: 94rpx;
- text-align: center;
- font-size: 70rpx;
- }
- .payment .placeholder {
- color: #d0d0d0;
- height: 100%;
- line-height: 94rpx;
- }
- .payment .tip {
- font-size: 26rpx;
- color: #888888;
- padding: 0 30rpx;
- margin-top: 25rpx;
- }
- .payment .but {
- color: #fff;
- font-size: 30rpx;
- width: 700rpx;
- height: 86rpx;
- border-radius: 50rpx;
- margin: 46rpx auto 0 auto;
- line-height: 86rpx;
- }
- .payment-top {
- width: 100%;
- height: 350rpx;
- background-color: var(--view-theme);
- .name {
- font-size: 26rpx;
- color: rgba(255, 255, 255, 0.8);
- margin-top: -38rpx;
- margin-bottom: 30rpx;
- }
- .pic {
- font-size: 32rpx;
- color: #fff;
- }
- .pic-font {
- font-size: 78rpx;
- color: #fff;
- }
- }
- .picList {
- display: flex;
- flex-wrap: wrap;
- margin: 30rpx 0;
- .pic-box {
- width: 32%;
- height: auto;
- border-radius: 20rpx;
- margin-top: 21rpx;
- padding: 20rpx 0;
- margin-right: 12rpx;
- &:nth-child(3n) {
- margin-right: 0;
- }
- }
- .pic-box-color {
- background-color: #f4f4f4;
- color: #656565;
- }
- .pic-number {
- font-size: 22rpx;
- }
- .pic-number-pic {
- font-size: 38rpx;
- margin-right: 10rpx;
- text-align: center;
- }
- .pic-box-color-active {
- background-color: var(--view-theme) !important;
- color: #fff !important;
- }
- }
- .tips-box{
- .tips {
- font-size: 28rpx;
- color: #333333;
- font-weight: 800;
- margin-bottom: 14rpx;
- margin-top: 20rpx;
- }
- .tips-samll {
- font-size: 24rpx;
- color: #333333;
- margin-bottom: 14rpx;
- }
- .tip-box {
- margin-top: 30rpx;
- }
- }
- .tips-title{
- margin-top: 20rpx;
- font-size: 24rpx;
- color: #333;
- }
- </style>
|