recharge.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. <!-- 充值 -->
  2. <template>
  3. <view class="page">
  4. <block v-if="is_iospay">
  5. <ul class="profile" >
  6. <li>充值方式:</li>
  7. <li>
  8. iOS内购
  9. <span v-if="fee>0" style="font-size: 12px;margin-left: 5px;color: #FF0000;">手续费{{fee}}%</span>
  10. </li>
  11. </ul>
  12. <ul class="profile" style="text-align: center;">
  13. <block v-for="(m,index) in money_arr" :key="index">
  14. <span :class="{'money':true,'active':index==money_select}" @tap="select_money(index)">{{m}}元</span>
  15. </block>
  16. </ul>
  17. <view style="margin:15px auto;display:block;width: 80%;">
  18. 
  19. <button class="button1" @tap="submit_iospay=true">下一步</button>
  20. </view>
  21. <iospay v-if="submit_iospay" type="recharge" :money_select="money_select" :money="money" @cancel_pay="submit_iospay=false;"></iospay>
  22. </block>
  23. <block v-else>
  24. <block v-if="step==0">
  25. <ul class="profile" >
  26. <li>充值方式:</li>
  27. <li>
  28. <block v-for="(m,index) in paytype" :key="index">
  29. <span :class="{'money':true,'active':index==selected}" @tap="clicktype(index)">{{m.name}}</span>
  30. </block>
  31. </li>
  32. </ul>
  33. <ul class="profile" v-if="banklist.length>1" >
  34. <li>渠道:</li>
  35. <li>
  36. <block v-for="(m,index) in banklist" :key="index">
  37. <span :class="{'money':true,'active':index==bankselected}" @tap="clickbank(index)">{{m.title}}</span>
  38. </block>
  39. </li>
  40. </ul>
  41. <ul class="profile" >
  42. <li>充值金额:</li>
  43. <li>
  44. <input type="text" v-model="money" style="width: 50px;display: inline-block;vertical-align: middle;margin-right: 5px;" class="input1" />元
  45. <span v-if="fee>0" style="font-size: 12px;margin-left: 5px;color: #FF0000;">手续费{{fee}}%</span>
  46. </li>
  47. </ul>
  48. <ul class="profile" style="text-align: center;">
  49. <block v-for="(m,index) in money_arr" :key="index">
  50. <span :class="{'money':true,'active':index==money_select}" @tap="select_money(index)">{{m}}元</span>
  51. </block>
  52. </ul>
  53. <view style="margin:15px auto;display:block;width: 80%;">
  54. <button class="button1" @tap="submit()">下一步</button>
  55. </view>
  56. </block>
  57. <block v-else>
  58. <view v-if="postdata.bank.method=='bank'" class="banklist">
  59. <view >
  60. <view >
  61. 汇款银行:
  62. </view>
  63. <view >
  64. <span class='blur'>
  65. {{postdata.bank.bankname}}
  66. </span>
  67. <button class="btn1" @tap="copy(postdata.bank.bankname)">复制</button>
  68. </view>
  69. </view>
  70. <view >
  71. <view >
  72. 开户姓名:
  73. </view>
  74. <view >
  75. <span class='blur'>
  76. {{postdata.bank.realname}}
  77. </span>
  78. <button class="btn1" @tap="copy(postdata.bank.realname)">复制</button>
  79. </view>
  80. </view>
  81. <view >
  82. <view >
  83. 银行卡号:
  84. </view>
  85. <view >
  86. <span class='blur'>
  87. {{postdata.bank.number}}
  88. </span>
  89. <button class="btn1" @tap="copy(postdata.bank.number)">复制</button>
  90. </view>
  91. </view>
  92. <view >
  93. <view >
  94. 汇款金额:
  95. </view>
  96. <view >
  97. <span style='color:#FF0000'>
  98. {{postdata.money}}
  99. </span>
  100. <button class="btn1" @tap="copy(postdata.bank.money)">复制</button>
  101. </view>
  102. </view>
  103. </view>
  104. <view v-else class="qrcode">
  105. <view class="money"><span>¥</span>{{postdata.money}}</view>
  106. <view class="image">
  107. <image :src="photo(postdata.bank.qrcode)" mode="widthFix"></image>
  108. </view>
  109. <view class="tips">
  110. 扫描上面的二维码完成转账操作
  111. </view>
  112. </view>
  113. <view style="margin:15px auto;display:block;width: 80%;">
  114. <button class="button1" @tap="sub_ok()">我已完成付款</button>
  115. </view>
  116. </block>
  117. </block>
  118. </view>
  119. </template>
  120. <script>
  121. import http from "../../library/http.js"
  122. import config from "../../config.js"
  123. import iospay from "../../components/iospay.vue"
  124. export default {
  125. components: {
  126. iospay,
  127. },
  128. data () {
  129. return {
  130. money:'',
  131. user: uni.getStorageSync('userInfo'),
  132. system: uni.getStorageSync('system'),
  133. setting: uni.getStorageSync('rechargeset'),
  134. paytype:[],
  135. selected:0,
  136. money_arr:[50,100,200,500],
  137. money_select:1,
  138. fee:0,
  139. set:[],
  140. online:false,
  141. banklist:[],
  142. bankselected:0,
  143. postdata:[],
  144. step:0,
  145. order:[],
  146. is_iospay:false,
  147. submit_iospay:false,
  148. }
  149. },
  150. methods:{
  151. copy(data){
  152. uni.setClipboardData({
  153. data:data,
  154. success() {
  155. uni.showToast({
  156. title:'复制成功',
  157. icon:'none'
  158. })
  159. },
  160. fail: () => {
  161. uni.showToast({
  162. title:'复制失败',
  163. icon:'none'
  164. })
  165. }
  166. })
  167. },
  168. clicktype(num){
  169. this.selected=num;
  170. if(this.online==true){
  171. var set =this.setting.setting[this.paytype[num]['id']];
  172. this.banklist=[];
  173. }else{
  174. var set =this.paytype[num]['bank'][0];
  175. this.banklist=this.paytype[num]['bank'];
  176. }
  177. this.bankselected=0;
  178. this.set=set;
  179. this.fee=set.fee;
  180. },
  181. clickbank(num){
  182. this.bankselected=num;
  183. this.set=this.banklist[num];
  184. this.fee=this.set.fee;
  185. },
  186. select_money(num){
  187. this.money_select=num;
  188. this.money=this.money_arr[num];
  189. },
  190. setmethod(){
  191. try{
  192. var paytype=[];
  193. this.online=this.setting.online;
  194. if(this.online==true){
  195. for(var ii in this.setting.way){
  196. for(var jj in this.setting.method){
  197. if(this.setting.method[jj]==ii){
  198. paytype.push({id:ii,name:this.setting.way[ii]}) ;
  199. break;
  200. }
  201. }
  202. }
  203. }else{
  204. for(var ii in this.setting.way){
  205. for(var jj in this.setting.method){
  206. if(this.setting.method[jj]==ii){
  207. var bank=this.setting.bank[ii];
  208. var name={min:bank[0]['min'],max:bank[0]['max'],fee:bank[0]['fee']};
  209. paytype.push({id:ii,name:this.setting.way[ii],bank:bank}) ;
  210. break;
  211. }
  212. }
  213. }
  214. }
  215. this.paytype=paytype;
  216. this.clicktype(this.selected)
  217. }catch(e){
  218. //TODO handle the exception
  219. }
  220. },
  221. getseting(){
  222. this.setmethod();
  223. http.setWait(false).post('user.php?act=rechargeset',{}).then(res=>{
  224. this.setting=res.data;
  225. uni.setStorageSync('rechargeset',this.setting)
  226. this.setmethod();
  227. })
  228. },
  229. photo(image_url){
  230. if(image_url.indexOf('http')<=-1) image_url=config.imgUri+image_url;
  231. return this.image_cache(image_url);
  232. },
  233. submit(){
  234. // return this.pay(13182832);
  235. var rechargeMin =this.set['min'] //最小充值金额
  236. var rechargeMax =this.set['max'];
  237. var rechargeMoney =this.money; //用户充值金额
  238. if (rechargeMoney == "") {
  239. uni.showToast({
  240. title:'请填写充值金额',
  241. icon:'none'
  242. })
  243. return false;
  244. }
  245. if (rechargeMoney == 0) {
  246. uni.showToast({
  247. title:'充值金额不能为0!',
  248. icon:'none'
  249. })
  250. return false;
  251. }
  252. if (isNaN(rechargeMoney)) {
  253. uni.showToast({
  254. title:'提现金额必须为数字',
  255. icon:'none'
  256. })
  257. parent.layer.msg('充值金额必须为数字!',{ type: 1, anim: 2 ,time:1000});
  258. return false;
  259. }
  260. if (parseFloat(rechargeMoney) - parseFloat(rechargeMin) < 0) {
  261. uni.showToast({
  262. title:'每次最少充值'+ rechargeMin + '元!',
  263. icon:'none'
  264. })
  265. return false;
  266. }
  267. if (parseFloat(rechargeMoney) - parseFloat(rechargeMax) >0) {
  268. uni.showToast({
  269. title:'每次最多充值'+ rechargeMax+ '元!',
  270. icon:'none'
  271. })
  272. return false;
  273. }
  274. if(this.$action.check_userlock()==false) return false;
  275. if(this.online==true){
  276. var posdata={money:rechargeMoney,type:this.paytype[this.selected]['id'],userid:this.user.id,online:this.online};
  277. http.setWait(true).post('pay.php?act=recharge',posdata).then(res=>{
  278. var params = {url: res.data};
  279. return this.$jump('web.index',params);
  280. })
  281. }else{
  282. this.postdata={money:rechargeMoney,type:this.paytype[this.selected]['id'],userid:this.user.id,bank:this.banklist[this.bankselected],online:this.online};
  283. this.step=1;
  284. uni.setNavigationBarTitle({
  285. title:'请完成转账操作'
  286. })
  287. }
  288. // console.log(posdata)
  289. },
  290. sub_ok(){
  291. var postdata=this.postdata;
  292. postdata.bank=JSON.stringify(postdata.bank);
  293. http.setWait(true).post('pay.php?act=recharge1',postdata).then(res=>{
  294. uni.showModal({
  295. title: '提示',
  296. content: "充值已提交,大概1-5分钟内到账",
  297. showCancel: true,
  298. cancelText: '关闭',
  299. confirmText: '查看账单',
  300. success: res => {
  301. if(res.confirm) {
  302. uni.redirectTo({
  303. url:"/pages/mine/order"
  304. })
  305. }else{
  306. this.step=0;
  307. }
  308. }
  309. });
  310. })
  311. }
  312. },
  313. onLoad(opts) {
  314. if(opts.money!=null && opts.money!=undefined) this.money=opts.money;
  315. else this.money=this.money_arr[this.money_select];
  316. // #ifdef APP-PLUS
  317. if( plus.os.name=='iOS' && this.system.iospay==1) {
  318. this.is_iospay=true;
  319. this.money_arr=this.system.iospay_money.split('|');
  320. this.money_select=0;
  321. this.money=this.money_arr[this.money_select];
  322. this.fee=this.system.iospay_fee;
  323. }else{
  324. this.getseting();
  325. }
  326. // #endif
  327. // #ifndef APP-PLUS
  328. this.getseting();
  329. // #endif
  330. }
  331. }
  332. </script>
  333. <style scoped>
  334. @import "@/static/css/user.css";
  335. .page{
  336. background-color: #fafafa;
  337. }
  338. .profile,.login-lines1{
  339. background-color: #fff;
  340. margin: 10px auto;
  341. width: 100%;
  342. vertical-align: middle;
  343. }
  344. .profile li{
  345. vertical-align: middle;
  346. }
  347. .profile li:first-child{
  348. width:100px
  349. }
  350. .profile li:last-child{
  351. width:calc(100% - 110px)
  352. }
  353. .input1{
  354. max-width: 150px;
  355. }
  356. .profile .money{
  357. height: 25px;
  358. line-height: 25px;
  359. margin: 5px 5px;
  360. text-align: center;
  361. border-radius: 5px;
  362. background-color: #fff;
  363. border:1px solid #666;
  364. color: #555;
  365. width: 70px;
  366. display: inline-block;
  367. cursor: pointer;
  368. }
  369. .profile .money.active{
  370. background-color: #2319dc;
  371. border-color: #2319dc;
  372. color: #fff;
  373. }
  374. .qrcode{
  375. display: flex;
  376. flex-direction: column;
  377. text-align: center;
  378. align-items: center;
  379. }
  380. .qrcode .money{
  381. font-size: 40px;
  382. line-height:50px;
  383. height: 50px;
  384. color: #000;
  385. font-weight: 600;
  386. margin-top: 20px;
  387. }
  388. .qrcode .money > span{
  389. font-size: 16px;
  390. }
  391. .qrcode .image {
  392. margin-top: 10px;
  393. }
  394. .qrcode .image > image{
  395. width: 250px;
  396. }
  397. .qrcode .tips{
  398. font-size: 14px;
  399. color: #666;
  400. margin-top: 10px;
  401. }
  402. .banklist{
  403. display: flex;
  404. flex-direction: column;
  405. text-align: center;
  406. align-items: center;
  407. width: 100%;
  408. }
  409. .banklist > view{
  410. background-color: #fff;
  411. margin-top: 10px;
  412. height: 50px;
  413. line-height: 50px;
  414. display: flex;
  415. flex-direction: row;
  416. width: 100%;
  417. font-size: 14px;
  418. }
  419. .banklist > view > view:first-child{
  420. width: 100px;
  421. text-align: right;
  422. color:#666;
  423. }
  424. .banklist > view > view:nth-child(2){
  425. text-align: left;
  426. padding-left: 5px;
  427. }
  428. .blur{
  429. color: #2319DC;
  430. }
  431. .btn1{
  432. display: inline-block;
  433. height: 25px;line-height: 25px;
  434. margin: 0 10px;
  435. padding: 0 10px;
  436. border-radius: 5px;
  437. color: #000;
  438. background-color: #eee;
  439. vertical-align: middle;
  440. font-size: 14px;
  441. }
  442. </style>