index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. <template>
  2. <!-- 充值套餐 -->
  3. <view class="mall-recharge">
  4. <view class="white-box">
  5. <view class="account-text">充值账号</view>
  6. <u-input class="account-name" v-model="phone" type="text" maxlength="11" placeholder="请输入手机号"
  7. placeholder-style="font-size:32rpx;font-weight:400" fontSize="56rpx" :customStyle="{ padding: '0'}"
  8. clearable></u-input>
  9. </view>
  10. <view v-if="phone" class="tip flex aic">
  11. <re-image imgSrc="/retail/mall/ic_tip.png" width="28" height="28"></re-image>
  12. <text>请确认账户是否正确无误</text>
  13. </view>
  14. <view class="list-title flex aic">
  15. <span class="title-line"></span>
  16. 您选择的游戏币套餐
  17. </view>
  18. <view class="order-info">
  19. <view class="info-top">
  20. <view class="top-nums flex jcsb aic">
  21. <view>
  22. <span class="yxb-num">{{data.gameCurrency}}</span>
  23. <span class="yxb-text">游戏币</span>
  24. </view>
  25. <view>
  26. <span class="price-text">¥</span>
  27. <span class="price-num">{{data.realPrice}}</span>
  28. </view>
  29. </view>
  30. <view class="info-msg flex jcsb aic">
  31. <view class="msg-left">
  32. <span class="zeng" v-if="data.additionalGameCurrency || data.grabTimes">赠</span>
  33. <span class="game-num"
  34. v-if="data.additionalGameCurrency">{{data.additionalGameCurrency}}游戏币</span>
  35. <!-- <span class="og">
  36. <span class="${additionalGameCurrency && trafficSize ? 'show' : 'hide'}">+</span>
  37. <span class="bold ${trafficSize ? 'show' : 'hide'}">2M</span>
  38. </span> -->
  39. <span class="og red" v-if="data.additionalGameCurrency && data.grabTimes">
  40. <span style="margin-left:2px">+</span>
  41. <view class="red-box">
  42. <re-image width="30" imgSrc="/retail/main/ic_putonghb.png"></re-image>
  43. <span>红包机会x{{data.grabTimes}}</span>
  44. </view>
  45. </span>
  46. </view>
  47. <span class="time-text">{{data.expireDays}}天有效</span>
  48. </view>
  49. </view>
  50. <view class="info-btm">
  51. <view class="date-wrapper flex jcsb aic">
  52. <view>立即生效</view>
  53. <view class="date-box">{{date}}</view>
  54. </view>
  55. <!-- <view class="jubaopen-ctrl margin-top-20 flex jcsb aic jbp">
  56. <view class="jubaop">
  57. <view class="juntop">
  58. <image class="img-4" src="" alt="" />
  59. <span>聚宝盆余额抵扣</span>
  60. <i class="fx-icon icon-wenhao-xianxingyuankuang"></i>
  61. </view>
  62. <view class="dikou">
  63. <span class="gongyou dikoujine"></span>
  64. <span class="kedi kedikoujine"></span>
  65. </view>
  66. <view class="desc">聚宝盆余额整数部分可参与抵扣</view>
  67. </view>
  68. <image class="img-2 check-icon3-i" src="" alt="" />
  69. <span class="check-icon check-icon3"></span>
  70. </view> -->
  71. <!-- <view class="margin-top-30 flex jcsb aic" id="zfbCtrl">
  72. <view class="flex aic">
  73. <image class="img-3" src="" alt="" />
  74. <span>支付宝支付</span>
  75. </view>
  76. <image class="img-2 check-icon2-i" src="" alt="" />
  77. <span class="check-icon check-icon2"></span>
  78. </view> -->
  79. <view class="wx-ctrl flex jcsb aic">
  80. <view class="flex aic">
  81. <re-image width="48" height="48" imgSrc="/retail/mall/weixin-icon.png" alt="" />
  82. <span style="margin-left:16rpx">微信支付</span>
  83. </view>
  84. <re-image width="48" height="48" imgSrc="/retail/mall/yigou.png" alt="" />
  85. <!-- <span class="check-icon check-icon1"></span> -->
  86. </view>
  87. </view>
  88. </view>
  89. <!-- 支付按钮 -->
  90. <view class="btn-wrapper">
  91. <view id="checkBox" class="margin-bottom-17">
  92. <view class="check-text text-center">点击“确认支付”,即代表您已阅读并同意<span class="red" @click="agreeEl">《用户购买协议》</span>
  93. </view>
  94. </view>
  95. <view class="btns flex jcsb aic safe-area-inset-bottom">
  96. <view>
  97. <span class="btn-price-text1">应付款:</span>
  98. <span class="btn-price-text2">¥</span>
  99. <span class="price-num btn-price-num">{{data.realPrice}}</span>
  100. </view>
  101. <u-button class="primary-btn" id="buyBtn" @click="confirm()">确认支付</u-button>
  102. </view>
  103. </view>
  104. <!-- <u-popup :show="isPay" mode="center" :round="10">
  105. <view class="white-box-pay">
  106. <view class="title bold text-center">提示</view>
  107. <view class="text">未完成支付请点击<span class="red">“继续支付”</span></view>
  108. <view class="text">更换金额或支付方式请点击<span class="red">“取消支付”</span></view>
  109. <view class="text">完成支付请点击<span class="red">“完成支付”</span></view>
  110. <view class="btn flex jcc" @click="contPay">
  111. <view class="primary-btn width100" id="payCon">继续支付</view>
  112. </view>
  113. <view class="btn flex jcc" @click="cancel">
  114. <view class="normal-btn width100" id="cancelBtn">取消支付</view>
  115. </view>
  116. <view class="btn flex jcc" @click="enterPayRes">
  117. <span class="line" id="enterPayRes">完成支付</span>
  118. </view>
  119. </view>
  120. </u-popup> -->
  121. </view>
  122. </template>
  123. <script>
  124. import {
  125. doPay,
  126. getPackageDetail,
  127. orderPolling
  128. } from '@/apis/main'
  129. import {
  130. wxPay
  131. } from '@/utils/pay.js'
  132. import config from "@/config"
  133. export default {
  134. // components:{
  135. // 'u-input': () => import('@/plugins/uview-ui/components/u-input')
  136. // }
  137. data() {
  138. return {
  139. phone: '',
  140. id: '',
  141. data: {},
  142. date: '',
  143. timer: null,
  144. time: 1,
  145. orderNo: '',
  146. isPay:false,
  147. wxOpenid:uni.getStorageSync('wxOpenid'),
  148. payDate:''
  149. }
  150. },
  151. onLoad(params) {
  152. this.id = params.id
  153. this.orderNo = params.orderNo
  154. this.getData()
  155. this.getDate()
  156. // if (params.orderNo) {
  157. // this.orderNo = params.orderNo
  158. // this.polling(params.id)
  159. // }
  160. },
  161. methods: {
  162. // getOrder(){
  163. // let orderNo = uni.getStorageSync('orderNo')
  164. // if(orderNo){
  165. // this.polling(orderNo)
  166. // removeStorageSync('orderNo')
  167. // }
  168. // },
  169. agreeEl(){
  170. uni.navigateTo({
  171. url:'/pages/agree/index'
  172. })
  173. },
  174. // 获取日期
  175. getDate() {
  176. let today = new Date();
  177. let year = today.getFullYear();
  178. let month = today.getMonth() + 1;
  179. let day = today.getDate();
  180. let formattedDate = year + "年" + month + "月" + day + "日";
  181. this.date = formattedDate
  182. },
  183. async getData() {
  184. uni.showLoading()
  185. const res = await getPackageDetail({
  186. id: this.id
  187. })
  188. if (res) {
  189. this.data = res
  190. }
  191. uni.hideLoading();
  192. },
  193. // 确认支付
  194. async confirm() {
  195. if (!this.phone) {
  196. uni.showToast({
  197. title: '手机号不能为空',
  198. icon: 'none'
  199. })
  200. return
  201. }
  202. uni.showLoading();
  203. let params = {
  204. orderNo: this.orderNo,
  205. packageId: this.id,
  206. payChannel: 2,
  207. payType: 1,
  208. phone: this.phone,
  209. wxOpenid: this.wxOpenid
  210. }
  211. const res = await doPay(params)
  212. this.payDate = new Date(res.timeStamp)
  213. // let redirect_url = encodeURIComponent(
  214. // `${config.wapUrl}pages/mall/mallRecharge/index?orderNo=${res.orderNo}`)
  215. uni.hideLoading();
  216. const payRes = await wxPay(res)
  217. if (payRes) {
  218. console.log(payRes,88);
  219. this.polling(res.orderNo)
  220. // uni.navigateTo({
  221. // url: `/pages/mall/mallPay/index?mwebUrl=${res.mwebUrl}`
  222. // })
  223. }
  224. // location.href = `${res.mwebUrl}&redirect_url=${redirect_url}`
  225. },
  226. // contPay(){
  227. // confirm()
  228. // },
  229. // // 取消支付
  230. // cancel(){
  231. // this.isPay = false
  232. // },
  233. // // 完成支付
  234. // async enterPayRes(no){
  235. // const res = await orderPolling({
  236. // orderNo: no
  237. // })
  238. // clearTimeout(timer)
  239. // if(res.status === 1){
  240. // uni.navigateTo({
  241. // url: `/pages/mall/mallSuccess/index?gameCurrency=${this.data.gameCurrency}&price=${this.data.price}`
  242. // })
  243. // }else{
  244. // uni.showToast({
  245. // title:'还未支付成功'
  246. // })
  247. // }
  248. // },
  249. // 获取支付状态
  250. async polling(no) {
  251. if (no) {
  252. clearTimeout(this.timer)
  253. const res = await orderPolling({
  254. orderNo: no
  255. })
  256. if (res) {
  257. if (res.status === 1) {
  258. let query = ''
  259. for (let k in res) {
  260. query += `${k}=${res[k]}&`
  261. }
  262. console.log(query,'query');
  263. uni.navigateTo({
  264. url: `/pages/mall/mallSuccess/index?${query}&price=${this.data.price}`
  265. })
  266. } else {
  267. clearTimeout(this.timer)
  268. if (this.times <= 10) {
  269. this.times++
  270. this.timer = setTimeout(() => {
  271. this.polling(no)
  272. }, 1000)
  273. }
  274. }
  275. } else {
  276. this.times = 1
  277. }
  278. }
  279. }
  280. }
  281. }
  282. // const data = reactive({
  283. // })
  284. </script>
  285. <style lang="scss">
  286. .mall-recharge {
  287. padding: 32rpx;
  288. .white-box {
  289. padding: 48rpx 48rpx 56rpx;
  290. background-color: #fff;
  291. border-radius: 32rpx;
  292. .account-text {
  293. font-size: 32rpx;
  294. font-weight: 500;
  295. color: #2C2B28;
  296. line-height: 14rpx;
  297. margin-bottom: 40rpx;
  298. }
  299. .account-name {
  300. color: #2C2B28;
  301. font-weight: bold;
  302. font-size: 56rpx;
  303. line-height: 32rpx;
  304. }
  305. }
  306. .tip {
  307. font-size: 24rpx;
  308. color: #8B8B8B;
  309. margin-top: 16rpx;
  310. margin-left: 46rpx;
  311. text {
  312. margin-left: 6rpx;
  313. }
  314. }
  315. .list-title {
  316. color: #363531;
  317. font-weight: bold;
  318. font-size: 36rpx;
  319. line-height: 36rpx;
  320. margin: 48rpx 0 32rpx;
  321. .title-line {
  322. width: 8rpx;
  323. height: 32rpx;
  324. background-color: #FF8800;
  325. margin-right: 10rpx;
  326. }
  327. }
  328. .order-info {
  329. background-color: #fff;
  330. border-radius: 32rpx;
  331. .info-top {
  332. padding: 40rpx;
  333. border-bottom: 1rpx solid #E8E8E8;
  334. }
  335. .top-nums {
  336. font-weight: bold;
  337. color: #2C2B28;
  338. .yxb-num {
  339. font-size: 48rpx;
  340. margin-right: 8rpx;
  341. }
  342. .yxb-text {
  343. font-size: 24rpx;
  344. color: #564C47;
  345. }
  346. .price-num {
  347. font-size: 48rpx;
  348. }
  349. .price-text {
  350. font-size: 28rpx;
  351. }
  352. }
  353. .info-msg {
  354. margin-top: 32rpx;
  355. font-size: 32rpx;
  356. color: #2C2B28;
  357. font-weight: bold;
  358. white-space: nowrap;
  359. .msg-left {
  360. width: calc(100% - 142rpx);
  361. display: flex;
  362. align-items: center;
  363. font-weight: bold;
  364. font-size: 28rpx;
  365. .game-num {
  366. font-weight: bold;
  367. }
  368. }
  369. .red {
  370. display: flex;
  371. align-items: center;
  372. .red-box {
  373. display: flex;
  374. align-items: center;
  375. }
  376. }
  377. .og {
  378. color: #FF7C00;
  379. }
  380. .time-text {
  381. font-size: 24rpx;
  382. color: #564C47;
  383. font-weight: normal;
  384. }
  385. .zeng {
  386. flex-shrink: 0;
  387. display: inline-block;
  388. background-color: #5CB020;
  389. width: 40rpx;
  390. height: 32rpx;
  391. line-height: 32rpx;
  392. color: #fff;
  393. font-size: 24rpx;
  394. border-radius: 8rpx;
  395. text-align: center;
  396. font-weight: normal;
  397. margin-right: 6rpx;
  398. }
  399. .show {
  400. display: inline-block;
  401. vertical-align: middle;
  402. }
  403. .hide {
  404. display: none;
  405. }
  406. }
  407. }
  408. // .info-msg {
  409. // margin-top: 16rpx;
  410. // font-size: 16rpx;
  411. // color: #2C2B28;
  412. // font-weight: bold;
  413. // .msg-left {
  414. // width: calc(100% - 150rpx);
  415. // display: flex;
  416. // align-items: center;
  417. // font-weight: normal;
  418. // font-size: 12rpx;
  419. // }
  420. // .red {
  421. // display: flex;
  422. // align-items: center;
  423. // .red-box {
  424. // display: flex;
  425. // align-items: center;
  426. // }
  427. // }
  428. // .og {
  429. // color: #FF7C00;
  430. // }
  431. // .time-text {
  432. // font-size: 12rpx;
  433. // color: #564C47;
  434. // font-weight: normal;
  435. // }
  436. // .zeng {
  437. // display: inline-block;
  438. // background-color: #5CB020;
  439. // width: 20rpx;
  440. // height: 16rpx;
  441. // line-height: 16rpx;
  442. // color: #fff;
  443. // font-size: 12rpx;
  444. // border-radius: 4rpx;
  445. // text-align: center;
  446. // font-weight: normal;
  447. // margin-right: 3rpx;
  448. // }
  449. // .show {
  450. // display: inline-block;
  451. // vertical-align: middle;
  452. // }
  453. // .hide {
  454. // display: none;
  455. // }
  456. // }
  457. .info-btm {
  458. padding: 40rpx;
  459. font-size: 32rpx;
  460. color: #2C2B28;
  461. font-weight: 500;
  462. // .date-wrapper {}
  463. .wx-ctrl {
  464. margin-top: 78rpx;
  465. .check-icon1-i {
  466. width: 48rpx;
  467. height: 48rpx;
  468. }
  469. }
  470. .margin-top-40 {
  471. margin-top: 40rpx;
  472. }
  473. .margin-top-30 {
  474. margin-top: 30rpx;
  475. }
  476. .margin-top-20 {
  477. margin-top: 20rpx;
  478. }
  479. img {
  480. width: 24rpx;
  481. height: 24rpx;
  482. }
  483. .img-1 {
  484. margin-right: 16rpx;
  485. }
  486. .img-4 {
  487. margin-right: 16rpx;
  488. }
  489. .img-3 {
  490. margin-right: 16rpx;
  491. transform: scale(0.9);
  492. }
  493. .check-icon {
  494. width: 40rpx;
  495. height: 40rpx;
  496. border: 1rpx solid #bbb;
  497. border-radius: 100%;
  498. margin-right: 2rpx;
  499. }
  500. .jbp {
  501. padding: 10rpx 0rpx 10rpx 0rpx;
  502. border-bottom: 1rpx solid #E8E8E8;
  503. }
  504. .dikou {
  505. // height: 42rpx;
  506. // float:left;
  507. // position:absolute;
  508. // margin-top: 70rpx;
  509. margin-left: 30rpx;
  510. .gongyou {
  511. font-weight: normal;
  512. font-size: 28px;
  513. color: #8B8B8B;
  514. }
  515. .kedi {
  516. font-weight: normal;
  517. font-size: 28px;
  518. color: #FF7C00;
  519. }
  520. }
  521. }
  522. .btn-wrapper {
  523. position: fixed;
  524. left: 0;
  525. bottom: 0;
  526. right: 0;
  527. padding: 24rpx 32rpx 0;
  528. z-index: 200;
  529. background-color: rgb(252, 252, 252);
  530. border-top: 1rpx solid #eee;
  531. box-shadow: 0rpx -4rpx 8rpx 0rpx rgba(109, 84, 52, 0.19);
  532. .btn-price-text1 {
  533. color: #2C2B28;
  534. font-size: 32rpx;
  535. font-weight: bold;
  536. }
  537. .btn-price-text2 {
  538. color: #FF6400;
  539. font-size: 32rpx;
  540. font-weight: bold;
  541. }
  542. .btn-price-num {
  543. font-size: 48rpx;
  544. color: #FF6400;
  545. font-weight: bold;
  546. }
  547. .fx-icon {
  548. font-size: 32rpx;
  549. margin-right: 12rpx;
  550. &.check-icon1 {
  551. color: #281A13;
  552. }
  553. &.check-icon2 {
  554. color: #0087fb;
  555. }
  556. &.check-icon3 {
  557. color: #0087fb;
  558. }
  559. }
  560. .check-text {
  561. color: #281A13;
  562. font-size: 24rpx;
  563. .red {
  564. color: #FF6400;
  565. }
  566. }
  567. .btns {
  568. margin: 24rpx 0 8rpx;
  569. }
  570. .primary-btn {
  571. width: 296rpx;
  572. height: 96rpx;
  573. font-size: 36rpx;
  574. color: #FFFFFF;
  575. background: linear-gradient(140deg, #FF8500 0%, #FFA600 100%);
  576. border-radius: 48rpx;
  577. font-weight: bold;
  578. margin: 0;
  579. }
  580. }
  581. .white-box-pay {
  582. width: 600rpx;
  583. background-color: #fff;
  584. padding: 60rpx;
  585. // border-radius: 32rpx;
  586. .red {
  587. color: #FF591C;
  588. }
  589. .line {
  590. text-decoration: underline;
  591. font-size: 28rpx;
  592. }
  593. .title {
  594. font-size: 36rpx;
  595. color: #333;
  596. margin-bottom: 40rpx;
  597. }
  598. .text {
  599. margin-bottom: 20rpx;
  600. font-size: 28rpx;
  601. color: #666;
  602. line-height: 40rpx;
  603. }
  604. .btn {
  605. margin-bottom: 20rpx;
  606. }
  607. .primary-btn {
  608. font-size: 28rpx;
  609. padding: 28rpx 60rpx;
  610. background-color: #1890ff;
  611. color: #fff;
  612. display: flex;
  613. justify-content: center;
  614. align-items: center;
  615. border-radius: 48rpx;
  616. }
  617. .normal-btn{
  618. font-size: 28rpx;
  619. padding: 28rpx 60rpx;
  620. background-color: #fff;
  621. color: #1890ff;
  622. display: flex;
  623. justify-content: center;
  624. align-items: center;
  625. border-radius: 48rpx;
  626. border: 1px solid #1890ff;
  627. }
  628. }
  629. }
  630. </style>