123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537 |
- <!-- 充值 -->
- <template>
- <view class="page">
-
- <block v-if="is_iospay">
- <ul class="profile" >
- <li>充值方式:</li>
-
- <li>
- iOS内购
- <span v-if="fee>0" style="font-size: 12px;margin-left: 5px;color: #FF0000;">手续费{{fee}}%</span>
-
- </li>
- </ul>
- <ul class="profile" style="text-align: center;">
-
- <block v-for="(m,index) in money_arr" :key="index">
-
- <span :class="{'money':true,'active':index==money_select}" @tap="select_money(index)">{{m}}元</span>
- </block>
-
-
- </ul>
- <view style="margin:15px auto;display:block;width: 80%;">
-
-
- <button class="button1" @tap="submit_iospay=true">下一步</button>
-
-
- </view>
- <iospay v-if="submit_iospay" type="recharge" :money_select="money_select" :money="money" @cancel_pay="submit_iospay=false;"></iospay>
- </block>
- <block v-else>
- <block v-if="step==0">
-
- <ul class="profile" >
- <li>充值方式:</li>
-
- <li>
- <block v-for="(m,index) in paytype" :key="index">
- <span :class="{'money':true,'active':index==selected}" @tap="clicktype(index)">{{m.name}}</span>
- </block>
- </li>
- </ul>
-
-
- <ul class="profile" v-if="banklist.length>1" >
- <li>渠道:</li>
-
- <li>
-
- <block v-for="(m,index) in banklist" :key="index">
-
- <span :class="{'money':true,'active':index==bankselected}" @tap="clickbank(index)">{{m.title}}</span>
- </block>
-
-
- </li>
- </ul>
-
-
- <ul class="profile" >
- <li>充值金额:</li>
-
- <li>
-
- <input type="text" v-model="money" style="width: 50px;display: inline-block;vertical-align: middle;margin-right: 5px;" class="input1" />元
-
- <span v-if="fee>0" style="font-size: 12px;margin-left: 5px;color: #FF0000;">手续费{{fee}}%</span>
-
-
- </li>
- </ul>
-
- <ul class="profile" style="text-align: center;">
-
-
- <block v-for="(m,index) in money_arr" :key="index">
-
- <span :class="{'money':true,'active':index==money_select}" @tap="select_money(index)">{{m}}元</span>
- </block>
-
-
- </ul>
- <view style="margin:15px auto;display:block;width: 80%;">
-
-
- <button class="button1" @tap="submit()">下一步</button>
-
-
- </view>
-
- </block>
- <block v-else>
-
- <view v-if="postdata.bank.method=='bank'" class="banklist">
- <view >
- <view >
- 汇款银行:
- </view>
- <view >
- <span class='blur'>
- {{postdata.bank.bankname}}
- </span>
- <button class="btn1" @tap="copy(postdata.bank.bankname)">复制</button>
- </view>
-
- </view>
-
-
- <view >
- <view >
- 开户姓名:
- </view>
- <view >
- <span class='blur'>
- {{postdata.bank.realname}}
- </span>
- <button class="btn1" @tap="copy(postdata.bank.realname)">复制</button>
- </view>
-
- </view>
- <view >
- <view >
- 银行卡号:
- </view>
- <view >
- <span class='blur'>
- {{postdata.bank.number}}
- </span>
- <button class="btn1" @tap="copy(postdata.bank.number)">复制</button>
- </view>
-
- </view>
- <view >
- <view >
- 汇款金额:
- </view>
- <view >
- <span style='color:#FF0000'>
- {{postdata.money}}
- </span>
- 元
- <button class="btn1" @tap="copy(postdata.bank.money)">复制</button>
- </view>
- </view>
- </view>
-
- <view v-else class="qrcode">
- <view class="money"><span>¥</span>{{postdata.money}}</view>
- <view class="image">
-
- <image :src="photo(postdata.bank.qrcode)" mode="widthFix"></image>
- </view>
- <view class="tips">
- 扫描上面的二维码完成转账操作
- </view>
-
- </view>
- <view style="margin:15px auto;display:block;width: 80%;">
- <button class="button1" @tap="sub_ok()">我已完成付款</button>
- </view>
-
- </block>
-
-
-
- </block>
-
- </view>
- </template>
- <script>
- import http from "../../library/http.js"
- import config from "../../config.js"
- import iospay from "../../components/iospay.vue"
- export default {
- components: {
- iospay,
-
-
- },
- data () {
- return {
- money:'',
- user: uni.getStorageSync('userInfo'),
- system: uni.getStorageSync('system'),
- setting: uni.getStorageSync('rechargeset'),
- paytype:[],
- selected:0,
- money_arr:[50,100,200,500],
- money_select:1,
- fee:0,
- set:[],
- online:false,
- banklist:[],
- bankselected:0,
- postdata:[],
- step:0,
- order:[],
- is_iospay:false,
- submit_iospay:false,
-
- }
- },
- methods:{
-
- copy(data){
- uni.setClipboardData({
- data:data,
- success() {
- uni.showToast({
- title:'复制成功',
- icon:'none'
- })
- },
- fail: () => {
- uni.showToast({
- title:'复制失败',
- icon:'none'
- })
- }
- })
- },
- clicktype(num){
- this.selected=num;
- if(this.online==true){
- var set =this.setting.setting[this.paytype[num]['id']];
- this.banklist=[];
- }else{
- var set =this.paytype[num]['bank'][0];
- this.banklist=this.paytype[num]['bank'];
- }
- this.bankselected=0;
- this.set=set;
- this.fee=set.fee;
- },
- clickbank(num){
- this.bankselected=num;
- this.set=this.banklist[num];
- this.fee=this.set.fee;
- },
- select_money(num){
- this.money_select=num;
- this.money=this.money_arr[num];
- },
- setmethod(){
- try{
- var paytype=[];
- this.online=this.setting.online;
-
- if(this.online==true){
-
- for(var ii in this.setting.way){
- for(var jj in this.setting.method){
- if(this.setting.method[jj]==ii){
- paytype.push({id:ii,name:this.setting.way[ii]}) ;
- break;
- }
- }
- }
-
- }else{
- for(var ii in this.setting.way){
- for(var jj in this.setting.method){
- if(this.setting.method[jj]==ii){
- var bank=this.setting.bank[ii];
- var name={min:bank[0]['min'],max:bank[0]['max'],fee:bank[0]['fee']};
-
- paytype.push({id:ii,name:this.setting.way[ii],bank:bank}) ;
- break;
- }
- }
- }
- }
-
- this.paytype=paytype;
- this.clicktype(this.selected)
- }catch(e){
- //TODO handle the exception
- }
-
-
- },
- getseting(){
- this.setmethod();
- http.setWait(false).post('user.php?act=rechargeset',{}).then(res=>{
- this.setting=res.data;
-
- uni.setStorageSync('rechargeset',this.setting)
- this.setmethod();
- })
- },
- photo(image_url){
- if(image_url.indexOf('http')<=-1) image_url=config.imgUri+image_url;
-
- return this.image_cache(image_url);
- },
- submit(){
-
- // return this.pay(13182832);
- var rechargeMin =this.set['min'] //最小充值金额
- var rechargeMax =this.set['max'];
- var rechargeMoney =this.money; //用户充值金额
-
-
- if (rechargeMoney == "") {
- uni.showToast({
- title:'请填写充值金额',
- icon:'none'
- })
- return false;
- }
-
- if (rechargeMoney == 0) {
- uni.showToast({
- title:'充值金额不能为0!',
- icon:'none'
- })
- return false;
- }
-
- if (isNaN(rechargeMoney)) {
- uni.showToast({
- title:'提现金额必须为数字',
- icon:'none'
- })
- parent.layer.msg('充值金额必须为数字!',{ type: 1, anim: 2 ,time:1000});
-
- return false;
- }
- if (parseFloat(rechargeMoney) - parseFloat(rechargeMin) < 0) {
- uni.showToast({
- title:'每次最少充值'+ rechargeMin + '元!',
- icon:'none'
- })
-
- return false;
- }
-
- if (parseFloat(rechargeMoney) - parseFloat(rechargeMax) >0) {
- uni.showToast({
- title:'每次最多充值'+ rechargeMax+ '元!',
- icon:'none'
- })
-
- return false;
- }
- if(this.$action.check_userlock()==false) return false;
-
- if(this.online==true){
- var posdata={money:rechargeMoney,type:this.paytype[this.selected]['id'],userid:this.user.id,online:this.online};
- http.setWait(true).post('pay.php?act=recharge',posdata).then(res=>{
-
- var params = {url: res.data};
- return this.$jump('web.index',params);
-
- })
- }else{
-
- this.postdata={money:rechargeMoney,type:this.paytype[this.selected]['id'],userid:this.user.id,bank:this.banklist[this.bankselected],online:this.online};
- this.step=1;
- uni.setNavigationBarTitle({
- title:'请完成转账操作'
- })
- }
-
- // console.log(posdata)
-
-
- },
- sub_ok(){
- var postdata=this.postdata;
- postdata.bank=JSON.stringify(postdata.bank);
-
- http.setWait(true).post('pay.php?act=recharge1',postdata).then(res=>{
- uni.showModal({
- title: '提示',
- content: "充值已提交,大概1-5分钟内到账",
- showCancel: true,
- cancelText: '关闭',
- confirmText: '查看账单',
- success: res => {
- if(res.confirm) {
- uni.redirectTo({
- url:"/pages/mine/order"
- })
- }else{
- this.step=0;
- }
- }
- });
-
- })
-
- }
- },
- onLoad(opts) {
- if(opts.money!=null && opts.money!=undefined) this.money=opts.money;
- else this.money=this.money_arr[this.money_select];
- // #ifdef APP-PLUS
- if( plus.os.name=='iOS' && this.system.iospay==1) {
- this.is_iospay=true;
- this.money_arr=this.system.iospay_money.split('|');
- this.money_select=0;
- this.money=this.money_arr[this.money_select];
- this.fee=this.system.iospay_fee;
- }else{
- this.getseting();
- }
- // #endif
- // #ifndef APP-PLUS
- this.getseting();
- // #endif
- }
-
- }
- </script>
- <style scoped>
- @import "@/static/css/user.css";
- .page{
- background-color: #fafafa;
- }
- .profile,.login-lines1{
- background-color: #fff;
- margin: 10px auto;
- width: 100%;
- vertical-align: middle;
- }
- .profile li{
- vertical-align: middle;
- }
- .profile li:first-child{
- width:100px
- }
- .profile li:last-child{
- width:calc(100% - 110px)
- }
- .input1{
- max-width: 150px;
- }
- .profile .money{
- height: 25px;
- line-height: 25px;
- margin: 5px 5px;
- text-align: center;
- border-radius: 5px;
- background-color: #fff;
- border:1px solid #666;
- color: #555;
- width: 70px;
- display: inline-block;
- cursor: pointer;
- }
- .profile .money.active{
- background-color: #2319dc;
- border-color: #2319dc;
- color: #fff;
- }
- .qrcode{
- display: flex;
- flex-direction: column;
- text-align: center;
- align-items: center;
-
- }
- .qrcode .money{
- font-size: 40px;
- line-height:50px;
- height: 50px;
- color: #000;
- font-weight: 600;
- margin-top: 20px;
- }
- .qrcode .money > span{
- font-size: 16px;
- }
- .qrcode .image {
- margin-top: 10px;
-
- }
- .qrcode .image > image{
- width: 250px;
-
- }
- .qrcode .tips{
- font-size: 14px;
- color: #666;
- margin-top: 10px;
- }
-
- .banklist{
- display: flex;
- flex-direction: column;
- text-align: center;
- align-items: center;
- width: 100%;
- }
- .banklist > view{
- background-color: #fff;
- margin-top: 10px;
- height: 50px;
- line-height: 50px;
- display: flex;
- flex-direction: row;
- width: 100%;
- font-size: 14px;
- }
- .banklist > view > view:first-child{
- width: 100px;
- text-align: right;
- color:#666;
- }
- .banklist > view > view:nth-child(2){
-
- text-align: left;
- padding-left: 5px;
- }
- .blur{
- color: #2319DC;
- }
- .btn1{
- display: inline-block;
- height: 25px;line-height: 25px;
- margin: 0 10px;
- padding: 0 10px;
- border-radius: 5px;
- color: #000;
- background-color: #eee;
- vertical-align: middle;
- font-size: 14px;
- }
- </style>
|