payment.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <template>
  2. <view class="popup">
  3. <view class="box">
  4. <view class="title" v-if="title">{{title}}</view>
  5. <block v-if="step==0" >
  6. <view class="group_detail">
  7. <ul class="profile" style="text-align:center;line-height: 50px;height: 50px;vertical-align: middle;">
  8. <span style="font-size: 20px;vertical-align: middle;">¥</span>
  9. <input type="digit" class="input1" :focus="false0" v-model="money" placeholder="输入金额">
  10. </ul>
  11. <ul class="profile" id="money_list" style="line-height: 30px;height: 30px;text-align: center;padding-top: 5px;" >
  12. <block v-for="(m,index) in money_arr" :key='index'>
  13. <span :class="{'money':true,'active':m==money}" @tap="money=m" >
  14. {{m}}元
  15. </span>
  16. </block>
  17. </ul>
  18. </view>
  19. <view style="padding: 10px 10px;height: 30px;text-align: center;margin-top: 10px;">
  20. <button class="layer_btns cancel" @tap="click_close()" style="margin-right: 15px;">
  21. <uni-icons type='close' style="font-size: 14px;margin-right: 5px;color: #333;font-weight: 600;"></uni-icons>
  22. 关闭</button>
  23. <button class="layer_btns ok" @tap="click_next()">
  24. <uni-icons type='checkbox' style="font-size: 14px;color: #fff;margin-right: 5px;"></uni-icons>下一步
  25. </button>
  26. </view>
  27. </block>
  28. <block v-else>
  29. <view style="text-align:center;line-height: 40px;height:40px;vertical-align: bottom;">
  30. <span style="font-size: 16px;vertical-align: bottom;">¥</span>
  31. <span style="font-size:30px;vertical-align: bottom;font-weight: 600;">{{money}}</span>
  32. </view>
  33. <view class="payMent-input">
  34. <input maxlength="6" class="payMent-input-passInput" type="digit" @input="passInputTwo" v-model="pwdPass" :focus="focus" />
  35. <view class="payMent-input-item ">
  36. <view>
  37. <block v-if="passInputLenght != 0 && passInputLenght <=6" >·</block>
  38. </view>
  39. <view >
  40. <block v-if="passInputLenght >= 2 && passInputLenght <=6" >·</block>
  41. </view>
  42. <view >
  43. <block v-if="passInputLenght >= 3 && passInputLenght <=6" >·</block>
  44. </view>
  45. <view >
  46. <block v-if="passInputLenght >= 4 && passInputLenght <=6" >·</block>
  47. </view>
  48. <view >
  49. <block v-if="passInputLenght >= 5 && passInputLenght <=6" >·</block>
  50. </view>
  51. <view style="border-right: 0px;">
  52. <block v-if="passInputLenght == 6" >·</block>
  53. </view>
  54. </view>
  55. </view>
  56. </block>
  57. <image src="../static/img/closebtn.png" class="close-btn" @tap="click_close()"></image>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import uniIcons from './uni-icons/uni-icons.vue'
  63. import http from "../library/http.js"
  64. export default {
  65. components: {
  66. uniIcons,
  67. },
  68. props: {
  69. getmoney:{
  70. },
  71. fix:{
  72. default:false
  73. },
  74. title:{
  75. default:'支付'
  76. },
  77. type:{
  78. default:'reward',
  79. },
  80. id:{
  81. default:0
  82. },
  83. payinfo:{
  84. default:{}
  85. }
  86. },
  87. data() {
  88. return {
  89. step:0,
  90. money:10,
  91. money_arr:[5,10,50,100],
  92. focus:false,
  93. focus0:false,
  94. user: uni.getStorageSync('userInfo'),
  95. passInputLenght: '',
  96. pwdPassCw: false ,
  97. pwdPass:'',
  98. pwd:''
  99. };
  100. },
  101. methods: {
  102. passInputTwo: function(e) {
  103. this.passInputLenght = e.detail.value.length;
  104. this.pwd= e.detail.value;
  105. // #ifdef APP-PLUS
  106. if (e.detail.value.length == 6) {
  107. plus.key.hideSoftKeybord();
  108. }
  109. // #endif
  110. if (e.detail.value.length == 6){
  111. this.paysubmit();
  112. }
  113. },
  114. paysubmit(){
  115. var data={type:this.type,payinfo:JSON.stringify(this.payinfo),money:this.money,pwd:this.pwd,id:this.id,userid:this.user.id};
  116. http.setWait(true).post('pay.php?act=paymoney',data).then(res=>{
  117. if(res.code==200){
  118. uni.showToast({
  119. title:res.message,
  120. })
  121. this.getuserinfo();
  122. if(this.type=='redpacket' || this.type=='vip'){
  123. this.$emit('payresult',res.data)
  124. }
  125. else this.click_close();
  126. }
  127. else if(res.code==1){
  128. uni.showModal({
  129. title: '提示',
  130. content: "您的余额不足,请先去充值!",
  131. showCancel: true,
  132. cancelText: '取消',
  133. confirmText: '去充值',
  134. success: res => {
  135. if(res.confirm) {
  136. uni.redirectTo({
  137. url:"/pages/mine/recharge"
  138. })
  139. }
  140. }
  141. });
  142. }
  143. })
  144. },
  145. click_close(){
  146. this.$emit('close');
  147. },
  148. click_next(){
  149. if (isNaN(this.money)) {
  150. uni.showToast({
  151. title:'金额必须为数字',
  152. icon:'none'
  153. })
  154. this.focus=true;
  155. return false;
  156. }
  157. if(this.money==''){
  158. uni.showToast({
  159. title:'请输入金额',
  160. icon:'none'
  161. })
  162. this.focus=true;
  163. return false;
  164. }
  165. if(this.money<1){
  166. uni.showToast({
  167. title:'最低支付金额为1元',
  168. icon:'none'
  169. })
  170. this.focus=true;
  171. return false;
  172. }
  173. if(parseFloat(this.money)>parseFloat(this.user.money)){
  174. uni.showModal({
  175. title: '提示',
  176. content: "您的余额不足,请先去充值!",
  177. showCancel: true,
  178. cancelText: '取消',
  179. confirmText: '去充值',
  180. success: res => {
  181. if(res.confirm) {
  182. uni.redirectTo({
  183. url:"/pages/mine/recharge"
  184. })
  185. }
  186. }
  187. });
  188. }
  189. this.step=1;
  190. this.focus=true;
  191. },
  192. getuserinfo(){
  193. var postdata={
  194. id: uni.getStorageSync('access_token')
  195. };
  196. http.setWait(false).post('user.php?act=userinfo',postdata).then(res=>{
  197. this.user=res.data;
  198. uni.setStorageSync('userInfo',this.user)
  199. })
  200. },
  201. init(){
  202. if(this.step==1) {
  203. this.focus=true;
  204. }
  205. else{
  206. this.focus0=true;
  207. }
  208. }
  209. },
  210. mounted() {
  211. if(this.getmoney>0) this.money=this.getmoney;
  212. if(this.fix===true && this.getmoney>0) {
  213. this.step=1;
  214. }
  215. else{
  216. }
  217. this.getuserinfo();
  218. var that=this;
  219. setTimeout(function(){
  220. that.init();
  221. },200)
  222. },
  223. }
  224. </script>
  225. <style lang="scss" scoped>
  226. .popup{
  227. position: fixed;
  228. z-index: 10;
  229. background-color: rgba(0,0,0,0.6);
  230. top:0;
  231. left: 0;
  232. width: 100%;
  233. height: 100vh;
  234. }
  235. .popup .box{
  236. position: fixed;
  237. left: 5%;
  238. width: 90%;
  239. top:25vh;
  240. height: auto;
  241. background-color: #fff;
  242. border-radius: 10px;
  243. }
  244. .popup .box .close-btn{
  245. position: absolute;
  246. right:-9px;
  247. top:-9px;
  248. height: 30px;
  249. width: 30px;
  250. }
  251. .popup .title{
  252. height:45px;
  253. line-height:45px;
  254. text-align: center;
  255. color: #000;
  256. font-size: 16px;font-weight: 600;
  257. width: 100%;
  258. display: block;
  259. border-bottom: 1px solid #DDDDDD;
  260. border-top-left-radius: 10px;
  261. border-top-right-radius: 10px;
  262. margin-bottom: 5px;
  263. }
  264. .popup .textarea {
  265. display: block;
  266. height: 160px;
  267. padding: 5px 10px;
  268. margin: 10px auto;
  269. width: calc(100% - 42px);
  270. border-radius: 5px;
  271. border: 1px solid #ddd;
  272. overflow-y: scroll;
  273. }
  274. .layer_nav{
  275. width: 100%;
  276. display: block;
  277. height: 50px;
  278. line-height: 50px;
  279. padding: 0px !important;
  280. margin: 0px !important;
  281. background-color: #eee;
  282. border-top-right-radius: 8px;
  283. border-top-left-radius: 8px;
  284. }
  285. .layer_nav li{
  286. display: inline-block;
  287. float: left;
  288. color:#666;
  289. background-color: #eee;
  290. text-align: center;
  291. font-size: 16px;
  292. cursor: pointer;
  293. width: 150px;
  294. }
  295. .layer_nav li i{
  296. margin-right: 0px;
  297. }
  298. .layer_nav li.active{
  299. background-color: #3f6df5;
  300. color: #fff;
  301. }
  302. .layer_nav li:first-child{
  303. border-top-left-radius: 8px;
  304. }
  305. .layer_btns{
  306. display: inline-block;
  307. line-height: 30px;
  308. padding: 0px 15px;
  309. border-radius: 5px;
  310. border: 0px;
  311. text-align: center;
  312. cursor: pointer;
  313. height: 30px;
  314. color:#fff;
  315. margin-left:15px;
  316. font-size: 14px;
  317. }
  318. .layer_btns.ok{
  319. background: -webkit-linear-gradient(left top, #3388ff , #2319dc);
  320. background: -o-linear-gradient(bottom right, #3388ff, #2319dc);
  321. background: -moz-linear-gradient(bottom right, #3388ff, #2319dc);
  322. background: linear-gradient(to bottom right, #3388ff , #2319dc);
  323. height:30px !important;
  324. }
  325. .layer_btns.cancel{
  326. border: 1px solid #666;
  327. color: #666;
  328. background-color: #fff;
  329. height: 30px;
  330. line-height: 30px !important;
  331. }
  332. .popup .box{
  333. left: 10%;
  334. width: 80%;
  335. }
  336. .profile{
  337. height: 50px;
  338. line-height: 50px;
  339. clear: both;
  340. width:100%;
  341. margin: 0 auto;
  342. }
  343. .profile li{
  344. display:inline-block;
  345. text-align: left;
  346. }
  347. .profile li:first-child{
  348. text-align: right;
  349. padding-right: 5px;
  350. width:80px; ;
  351. }
  352. .profile li:last-child{
  353. width:calc(100% - 90px);
  354. }
  355. .profile .input1{
  356. width:90px;
  357. height:35px;
  358. line-height: 35px;
  359. padding: 0px 10px;
  360. font-size: 14px;
  361. background-color: transparent;
  362. color: #222;
  363. border:1px solid #ccc;
  364. border-radius: 5px;
  365. display: inline-block;
  366. vertical-align: middle;
  367. text-align: left;
  368. }
  369. .profile .input1::placeholder{
  370. color: #666;
  371. }
  372. .profile .input1:focus{
  373. border-color: #000;
  374. box-shadow: 0 0 15px #000
  375. }
  376. .profile .money{
  377. height: 25px;
  378. line-height: 25px;
  379. margin: 5px 5px;
  380. text-align: center;
  381. border-radius: 5px;
  382. background-color: #fff;
  383. border:1px solid #666;
  384. color: #555;
  385. width:50px;
  386. display: inline-block;
  387. cursor: pointer;
  388. }
  389. .profile .money.active{
  390. background-color: #2319dc;
  391. border-color: #2319dc;
  392. color: #fff;
  393. }
  394. .payMent-input {
  395. width: calc(100% - 30px);
  396. margin: 10px 15px;
  397. height: 80upx;
  398. border-right: 2upx solid #333;
  399. border: 2upx solid #333;
  400. position: relative;
  401. /* border-right: none; */
  402. }
  403. .payMent-input-passInput {
  404. position: absolute !important;
  405. width: 100%;
  406. height: 100%;
  407. top: 0;
  408. left: 0;
  409. z-index: 1;
  410. opacity: 0;
  411. }
  412. .payMent-input-item {
  413. width: 100%;
  414. height: 100%;
  415. display: flex;
  416. flex-direction: row;
  417. justify-content: center;
  418. height: 80upx;
  419. line-height: 80upx;
  420. padding: 0px 0px !important;
  421. overflow: hidden;
  422. }
  423. .payMent-input-item > view{
  424. border-right: 2upx solid #000000; text-align: center;
  425. height: 80upx;
  426. line-height: 80upx !important;
  427. overflow: hidden;
  428. font-size: 34px;
  429. font-weight: 700;
  430. width: calc(16.6% - 1px);
  431. }
  432. </style>