index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930
  1. <template>
  2. <view class="page" v-if="payPriceShow">
  3. <view class="pay-price">
  4. <view class="price">
  5. <text class="unit" v-if="paytype!='piPay'">{{$t(`¥`)}}</text>
  6. <text class="unit" v-else>Pi</text>
  7. <numberScroll :num='payPriceShow' color="#E93323" width='30' height='50' fontSize='50'></numberScroll>
  8. </view>
  9. <view class="count-down">
  10. {{$t(`支付剩余时间`)}}:
  11. <countDown :is-day="false" :tip-text="' '" :day-text="' '" :hour-text="' : '" :minute-text="' : '"
  12. :second-text="' '" :datatime="invalidTime"></countDown>
  13. </view>
  14. </view>
  15. <view class="payment">
  16. <view class="title">
  17. {{$t(`支付方式`)}}
  18. </view>
  19. <view class="item acea-row row-between-wrapper" v-for="(item,index) in cartArr" :key="index"
  20. v-show='item.payStatus' @click="payType(item.number || 0, item.value, index)">
  21. <view class="left acea-row row-between-wrapper">
  22. <view class="iconfont" :class="item.icon"></view>
  23. <view class="text">
  24. <view class="name">{{$t(item.name)}}</view>
  25. <view class="info" v-if="item.value == 'yue'">
  26. {{$t(item.title)}} <span class="money">{{$t(`¥`)}}{{ item.number }}</span>
  27. </view>
  28. <view class="info" v-else>{{$t(item.title)}}</view>
  29. </view>
  30. </view>
  31. <view class="iconfont" :class="active==index?'icon-xuanzhong11 font-num':'icon-weixuan'"></view>
  32. </view>
  33. </view>
  34. <view class="btn">
  35. <view class="button acea-row row-center-wrapper" @click='goPay(number, paytype)'>{{$t(`确认支付`)}}</view>
  36. <view class="wait-pay" @click="waitPay">{{$t(`暂不支付`)}}</view>
  37. </view>
  38. <view v-show="false" v-html="formContent"></view>
  39. </view>
  40. </template>
  41. <script>
  42. import countDown from '@/components/countDown';
  43. import numberScroll from '@/components/numberScroll.vue'
  44. import {
  45. getCashierOrder,
  46. orderPay
  47. } from '@/api/order.js';
  48. import {
  49. basicConfig
  50. } from '@/api/public.js'
  51. import {
  52. piPay,
  53. piPaySuccess,
  54. piPayReadSuccess,
  55. piPayCancel
  56. } from '@/api/pi.js'
  57. export default {
  58. components: {
  59. countDown,
  60. numberScroll
  61. },
  62. data() {
  63. return {
  64. checked: false,
  65. datatime: 1676344056,
  66. //支付方式
  67. cartArr: [{
  68. "name": this.$t(`微信支付`),
  69. "icon": "icon-weixin2",
  70. value: 'weixin',
  71. title: this.$t(`使用微信快捷支付`),
  72. payStatus: 1,
  73. },
  74. {
  75. "name": this.$t(`支付宝支付`),
  76. "icon": "icon-zhifubao",
  77. value: 'alipay',
  78. title: this.$t(`使用支付宝支付`),
  79. payStatus: 1,
  80. },
  81. {
  82. "name": this.$t(`余额支付`),
  83. "icon": "icon-yuezhifu",
  84. value: 'yue',
  85. title: this.$t(`可用余额`),
  86. payStatus: 1,
  87. },
  88. {
  89. "name": this.$t(`线下支付`),
  90. "icon": "icon-yuezhifu1",
  91. value: 'offline',
  92. title: this.$t(`使用线下付款`),
  93. payStatus: 2,
  94. }, {
  95. "name": this.$t(`好友代付`),
  96. "icon": "icon-haoyoudaizhifu",
  97. value: 'friend',
  98. title: this.$t(`找微信好友支付`),
  99. payStatus: 1,
  100. },
  101. ],
  102. orderId: 0,
  103. fromType: '',
  104. active: 0,
  105. //支付金额
  106. payPrice: 0,
  107. // 支付显示的金额
  108. payPriceShow: 0,
  109. //pi支付金额
  110. piPrice:0,
  111. payPostage: 0,
  112. offlinePostage: false,
  113. invalidTime: 0,
  114. initIn: false,
  115. jumpData: {
  116. orderId: '',
  117. msg: ''
  118. },
  119. formContent: ''
  120. }
  121. },
  122. watch: {
  123. cartArr: {
  124. handler(newV, oldValue) {
  125. let newPayList = [];
  126. newV.forEach((item, index) => {
  127. if (item.payStatus) {
  128. item.index = index;
  129. newPayList.push(item)
  130. }
  131. });
  132. this.active = newPayList[0].index;
  133. this.paytype = newPayList[0].value;
  134. this.number = newPayList[0].number || 0;
  135. },
  136. immediate: true,
  137. deep: true
  138. }
  139. },
  140. onLoad(options) {
  141. //初始化
  142. if(Pi){
  143. Pi.init({
  144. version: "2.0"
  145. // ,sandbox: true
  146. })
  147. this.cartArr.push({
  148. "name": this.$t(`PI支付`),
  149. "icon": "icon-haoyoudaizhifu",
  150. value: 'piPay',
  151. title: this.$t(`使用pi支付`),
  152. payStatus: 1,
  153. })
  154. }
  155. if (options.order_id){ this.orderId = options.order_id};
  156. if (options.from_type){ this.fromType = options.from_type};
  157. this.getBasicConfig()
  158. },
  159. onShow() {
  160. let options = wx.getEnterOptionsSync();
  161. console.log(options)
  162. if (options.scene == '1038' && options.referrerInfo.appId == 'wxef277996acc166c3' && this.initIn) {
  163. // 代表从收银台小程序返回
  164. let extraData = options.referrerInfo.extraData;
  165. this.initIn = false
  166. if (!extraData) {
  167. // "当前通过物理按键返回,未接收到返参,建议自行查询交易结果";
  168. this.$util.Tips({
  169. title: this.$t(`取消支付`)
  170. }, {
  171. tab: 5,
  172. url: `/pages/goods/order_pay_status/index?order_id=${this.orderId}&msg=${this.$t(`取消支付`)}&type=3&totalPrice=${this.payPriceShow}&status=2`
  173. });
  174. } else {
  175. if (extraData.code == 'success') {
  176. this.$util.Tips({
  177. title: this.$t(`支付成功`),
  178. icon: 'success'
  179. }, {
  180. tab: 5,
  181. url: `/pages/goods/order_pay_status/index?order_id=${this.orderId}&msg=${this.jumpData.msg}&type=3&totalPrice=${this.payPriceShow}`
  182. });
  183. } else if (extraData.code == 'cancel') {
  184. // "支付已取消";
  185. this.$util.Tips({
  186. title: this.$t(`取消支付`)
  187. }, {
  188. tab: 5,
  189. url: `/pages/goods/order_pay_status/index?order_id=${this.orderId}&msg=${this.$t(`取消支付`)}&type=3&totalPrice=${this.payPriceShow}&status=2`
  190. });
  191. } else {
  192. // "支付失败:" + extraData.errmsg;
  193. uni.reLaunch({
  194. url: `/pages/goods/order_pay_status/index?order_id=${this.orderId}&msg=${this.$t(`支付失败`)}&totalPrice=${this.payPriceShow}`
  195. })
  196. }
  197. }
  198. }
  199. },
  200. methods: {
  201. getBasicConfig() {
  202. basicConfig().then(res => {
  203. //微信支付是否开启
  204. this.cartArr[0].payStatus = res.data.pay_weixin_open || 0
  205. //支付宝是否开启
  206. this.cartArr[1].payStatus = res.data.ali_pay_status || 0;
  207. //#ifdef MP
  208. this.cartArr[1].payStatus = 0;
  209. //#endif
  210. //余额支付是否开启
  211. this.cartArr[2].payStatus = res.data.yue_pay_status
  212. if (res.data.offline_pay_status) {
  213. this.cartArr[3].payStatus = 1
  214. } else {
  215. this.cartArr[3].payStatus = 0
  216. }
  217. //好友代付是否开启
  218. this.cartArr[4].payStatus = res.data.friend_pay_status || 0;
  219. this.getCashierOrder()
  220. }).catch(err => {
  221. uni.hideLoading();
  222. return this.$util.Tips({
  223. title: err
  224. })
  225. })
  226. },
  227. getCashierOrder() {
  228. uni.showLoading({
  229. title: this.$t(`创建订单中`)
  230. });
  231. getCashierOrder(this.orderId, this.fromType).then(res => {
  232. console.log(res)
  233. this.payPrice = this.payPriceShow = res.data.pay_price;
  234. this.piPrice = (+res.data.pi_price)+'';
  235. this.payPostage = res.data.pay_postage
  236. this.offlinePostage = res.data.offline_postage
  237. this.invalidTime = res.data.invalid_time
  238. this.cartArr[2].number = res.data.now_money;
  239. uni.hideLoading();
  240. }).catch(err => {
  241. uni.hideLoading();
  242. return this.$util.Tips({
  243. title: err
  244. })
  245. })
  246. },
  247. payType(number, paytype, index) {
  248. this.active = index;
  249. this.paytype = paytype;
  250. this.number = number;
  251. if(paytype=='piPay'){
  252. this.payPriceShow = this.piPrice;
  253. }else{
  254. this.payPriceShow = this.payPrice;
  255. }
  256. if (this.offlinePostage) {
  257. if (paytype == 'offline') {
  258. this.payPriceShow = this.$util.$h.Sub(this.payPrice, this.payPostage);
  259. } else {
  260. this.payPriceShow = this.payPrice;
  261. }
  262. }
  263. },
  264. formpost(url, postData) {
  265. let tempform = document.createElement("form");
  266. tempform.action = url;
  267. tempform.method = "post";
  268. tempform.target = "_self";
  269. tempform.style.display = "none";
  270. for (let x in postData) {
  271. let opt = document.createElement("input");
  272. opt.name = x;
  273. opt.value = postData[x];
  274. tempform.appendChild(opt);
  275. }
  276. document.body.appendChild(tempform);
  277. this.$nextTick(e => {
  278. tempform.submit();
  279. })
  280. },
  281. waitPay() {
  282. uni.reLaunch({
  283. url: '/pages/goods/order_pay_status/index?order_id=' + this.orderId + '&msg=取消支付&type=3' +
  284. '&status=2&totalPrice=' + this.payPriceShow
  285. })
  286. },
  287. goPay(number, paytype) {
  288. let that = this;
  289. if (!that.orderId) return that.$util.Tips({
  290. title: that.$t(`请选择要支付的订单`)
  291. });
  292. if (paytype == 'yue' && parseFloat(number) < parseFloat(that.payPriceShow)) return that.$util.Tips({
  293. title: that.$t(`余额不足`)
  294. });
  295. uni.showLoading({
  296. title: that.$t(`支付中`)
  297. });
  298. if (paytype == 'friend' && that.orderId) {
  299. uni.hideLoading();
  300. return uni.navigateTo({
  301. url: '/pages/users/payment_on_behalf/index?order_id=' + that.orderId + '&spread=' +
  302. that.$store.state.app.uid,
  303. success: res => {},
  304. fail: () => {},
  305. complete: () => {}
  306. });
  307. }
  308. if (paytype == 'piPay') {
  309. // Authenticate the user, and get permission to request payments from them:
  310. const scopes = ['payments'];
  311. Pi.authenticate(scopes, (payment) => {
  312. return piPayReadSuccess({
  313. payment
  314. }).then((res) => {}).catch((res) => {
  315. uni.showModal({
  316. title: '错误can',
  317. content: res,
  318. showCancel: false,
  319. success: res => {},
  320. fail: () => {},
  321. complete: () => {}
  322. });
  323. })
  324. }).then(function(auth) {
  325. // window.alert('成功auth' + auth)
  326. Pi.createPayment({
  327. // 支付金额
  328. amount: that.piPrice,
  329. // 支付说明
  330. memo: "请求支付商品Pi币", // e.g: "Digital kitten #1234",
  331. // 用于保存自己要用的数据,后台查询时可获取到
  332. metadata: {
  333. tip: '我来支付了'
  334. }, // e.g: { kittenId: 1234 }
  335. }, {
  336. // 请求支付调用
  337. onReadyForServerApproval: function(paymentId) {
  338. // 请求服务器授权允许支付
  339. piPay({
  340. paymentId
  341. }).then((res) => {
  342. // window.alert('成功'+JSON.parse(res))
  343. }).catch((res) => {
  344. // window.alert('错误'+JSON.parse(res))
  345. })
  346. },
  347. // 请求服务器端调起支付成功确认
  348. onReadyForServerCompletion: function(paymentId, txid) {
  349. piPaySuccess({
  350. paymentId,
  351. txid,
  352. orderid:that.orderId
  353. }).then((res) => {
  354. uni.hideLoading();
  355. let goPages = `/pages/goods/order_pay_status/index?order_id=${that.orderId}&msg=${res.msg}&type=3&totalPrice=${this.payPriceShow}&Pi=${that.piPrice}`;
  356. // window.alert(ok)
  357. if(res.data.status==200){
  358. that.$util.Tips({
  359. title: that.$t(`支付成功`),
  360. icon: 'success'
  361. }, {
  362. tab: 5,
  363. url: goPages
  364. });
  365. }else{
  366. return that.$util.Tips({
  367. title: res.msg
  368. }, {
  369. tab: 5,
  370. url: goPages
  371. });
  372. }
  373. }).catch((res) => {
  374. uni.hideLoading();
  375. // let ok = '错误'+JSON.stringify(res)
  376. // window.alert(ok)
  377. uni.showModal({
  378. title: '错误re',
  379. content: JSON.stringify(res),
  380. showCancel: false,
  381. });
  382. })
  383. },
  384. onCancel: function(paymentId) {
  385. piPayCancel({
  386. paymentId
  387. }).then((res) => {
  388. uni.showModal({
  389. title: 'onCancel',
  390. content: JSON.stringify(res),
  391. showCancel: false,
  392. });
  393. }).catch((res) => {
  394. uni.showModal({
  395. title: '错误onCancel',
  396. content: JSON.stringify(res),
  397. showCancel: false,
  398. });
  399. })
  400. },
  401. onError: function(error, payment) {
  402. uni.showModal({
  403. title: '错误',
  404. content: error + (payment ? JSON.stringify(payment) : ''),
  405. showCancel: false,
  406. });
  407. },
  408. });
  409. }).catch(function(error) {
  410. uni.showModal({
  411. title: '错误',
  412. content: error,
  413. showCancel: false,
  414. });
  415. });
  416. return
  417. }
  418. orderPay({
  419. uni: that.orderId,
  420. paytype: paytype,
  421. type: that.friendPay ? 1 : 0,
  422. // #ifdef H5
  423. quitUrl: location.port ? location.protocol + '//' + location.hostname + ':' + location
  424. .port +
  425. '/pages/goods/order_details/index?order_id=' + this.orderId : location.protocol +
  426. '//' + location.hostname +
  427. '/pages/goods/order_details/index?order_id=' + this.orderId
  428. // #endif
  429. // #ifdef APP-PLUS
  430. quitUrl: '/pages/goods/order_details/index?order_id=' + this.orderId
  431. // #endif
  432. }).then(res => {
  433. let status = res.data.status,
  434. orderId = res.data.result.orderId,
  435. jsConfig = res.data.result.jsConfig,
  436. goPages = '/pages/goods/order_pay_status/index?order_id=' + this.orderId + '&msg=' +
  437. res
  438. .msg +
  439. '&type=3' + '&totalPrice=' + this.payPriceShow,
  440. friendPay = '/pages/users/payment_on_behalf/index?order_id=' + this.orderId +
  441. '&spread=' +
  442. this
  443. .$store.state.app.uid
  444. switch (status) {
  445. case 'ORDER_EXIST':
  446. case 'EXTEND_ORDER':
  447. uni.hideLoading();
  448. return that.$util.Tips({
  449. title: res.msg
  450. }, {
  451. tab: 5,
  452. url: goPages
  453. });
  454. case 'ALLINPAY_PAY':
  455. uni.hideLoading();
  456. // #ifdef MP
  457. this.initIn = true
  458. wx.openEmbeddedMiniProgram({
  459. appId: 'wxef277996acc166c3',
  460. extraData: {
  461. cusid: jsConfig.cusid,
  462. appid: jsConfig.appid,
  463. version: jsConfig.version,
  464. trxamt: jsConfig.trxamt,
  465. reqsn: jsConfig.reqsn,
  466. notify_url: jsConfig.notify_url,
  467. body: jsConfig.body,
  468. remark: jsConfig.remark,
  469. validtime: jsConfig.validtime,
  470. randomstr: jsConfig.randomstr,
  471. paytype: jsConfig.paytype,
  472. sign: jsConfig.sign,
  473. signtype: jsConfig.signtype
  474. }
  475. })
  476. this.jumpData = {
  477. orderId: res.data.result.orderId,
  478. msg: res.msg,
  479. }
  480. // #endif
  481. // #ifdef APP-PLUS
  482. plus.runtime.openURL(jsConfig.payinfo);
  483. setTimeout(e => {
  484. uni.reLaunch({
  485. url: goPages
  486. })
  487. }, 1000)
  488. // #endif
  489. // #ifdef H5
  490. this.formpost(res.data.result.pay_url, jsConfig)
  491. // #endif
  492. break;
  493. case 'PAY_ERROR':
  494. uni.hideLoading();
  495. return that.$util.Tips({
  496. title: res.msg
  497. }, {
  498. tab: 5,
  499. url: goPages
  500. });
  501. break;
  502. case 'SUCCESS':
  503. uni.hideLoading();
  504. if (paytype !== 'friend') {
  505. return that.$util.Tips({
  506. title: res.msg,
  507. icon: 'success'
  508. }, {
  509. tab: 4,
  510. url: goPages
  511. });
  512. } else {
  513. return that.$util.Tips({
  514. title: res.msg,
  515. icon: 'success'
  516. }, {
  517. tab: 4,
  518. url: friendPay
  519. });
  520. }
  521. break;
  522. case 'WECHAT_PAY':
  523. that.toPay = true;
  524. // #ifdef MP
  525. /* that.toPay = true; */
  526. let mp_pay_name = ''
  527. if (uni.requestOrderPayment) {
  528. mp_pay_name = 'requestOrderPayment'
  529. } else {
  530. mp_pay_name = 'requestPayment'
  531. }
  532. uni[mp_pay_name]({
  533. timeStamp: jsConfig.timestamp,
  534. nonceStr: jsConfig.nonceStr,
  535. package: jsConfig.package,
  536. signType: jsConfig.signType,
  537. paySign: jsConfig.paySign,
  538. success: function(res) {
  539. uni.hideLoading();
  540. if (that.BargainId || that.combinationId || that.pinkId ||
  541. that
  542. .seckillId || that.discountId)
  543. return that.$util.Tips({
  544. title: that.$t(`支付成功`),
  545. icon: 'success'
  546. }, {
  547. tab: 4,
  548. url: goPages
  549. });
  550. return that.$util.Tips({
  551. title: that.$t(`支付成功`),
  552. icon: 'success'
  553. }, {
  554. tab: 5,
  555. url: goPages
  556. });
  557. },
  558. fail: function(e) {
  559. uni.hideLoading();
  560. return that.$util.Tips({
  561. title: that.$t(`取消支付`)
  562. }, {
  563. tab: 5,
  564. url: goPages + '&status=2'
  565. });
  566. },
  567. complete: function(e) {
  568. uni.hideLoading();
  569. //关闭当前页面跳转至订单状态
  570. if (res.errMsg == 'requestPayment:cancel' || e.errMsg ==
  571. 'requestOrderPayment:cancel') return that.$util
  572. .Tips({
  573. title: that.$t(`取消支付`)
  574. }, {
  575. tab: 5,
  576. url: goPages + '&status=2'
  577. });
  578. },
  579. })
  580. // #endif
  581. // #ifdef H5
  582. this.$wechat.pay(res.data.result.jsConfig).then(res => {
  583. return that.$util.Tips({
  584. title: that.$t(`支付成功`),
  585. icon: 'success'
  586. }, {
  587. tab: 5,
  588. url: goPages
  589. });
  590. }).catch(res => {
  591. if (!this.$wechat.isWeixin()) {
  592. uni.redirectTo({
  593. url: goPages + '&msg=' + that.$t(`支付失败`) +
  594. '&status=2'
  595. // '&msg=支付失败&status=2'
  596. })
  597. }
  598. if (res.errMsg == 'chooseWXPay:cancel') return that.$util.Tips({
  599. title: that.$t(`取消支付`)
  600. }, {
  601. tab: 5,
  602. url: goPages + '&status=2'
  603. });
  604. })
  605. // #endif
  606. // #ifdef APP-PLUS
  607. uni.requestPayment({
  608. provider: 'wxpay',
  609. orderInfo: jsConfig,
  610. success: (e) => {
  611. let url = goPages;
  612. uni.showToast({
  613. title: that.$t(`支付成功`)
  614. })
  615. setTimeout(res => {
  616. uni.redirectTo({
  617. url: url
  618. })
  619. }, 2000)
  620. },
  621. fail: (e) => {
  622. let url = '/pages/goods/order_pay_status/index?order_id=' +
  623. orderId +
  624. '&msg=' + that.$t(`支付失败`);
  625. uni.showModal({
  626. content: that.$t(`支付失败`),
  627. showCancel: false,
  628. success: function(res) {
  629. if (res.confirm) {
  630. uni.redirectTo({
  631. url: url
  632. })
  633. } else if (res.cancel) {}
  634. }
  635. })
  636. },
  637. complete: () => {
  638. uni.hideLoading();
  639. },
  640. });
  641. // #endif
  642. break;
  643. case 'PAY_DEFICIENCY':
  644. uni.hideLoading();
  645. //余额不足
  646. return that.$util.Tips({
  647. title: res.msg
  648. }, {
  649. tab: 5,
  650. url: goPages + '&status=1'
  651. });
  652. break;
  653. case "WECHAT_H5_PAY":
  654. uni.hideLoading();
  655. that.$util.Tips({
  656. title: that.$t(`等待支付中`)
  657. }, {
  658. tab: 4,
  659. url: goPages + '&status=0'
  660. });
  661. setTimeout(() => {
  662. location.href = res.data.result.jsConfig.h5_url;
  663. }, 1500);
  664. break;
  665. case 'ALIPAY_PAY':
  666. //#ifdef H5
  667. uni.hideLoading();
  668. that.$util.Tips({
  669. title: that.$t(`等待支付中`)
  670. }, {
  671. tab: 4,
  672. url: goPages + '&status=0'
  673. });
  674. that.formContent = res.data.result.jsConfig;
  675. setTimeout(() => {
  676. document.getElementById('alipaysubmit').submit();
  677. }, 1500);
  678. //#endif
  679. // #ifdef MP
  680. uni.navigateTo({
  681. url: `/pages/users/alipay_invoke/index?id=${orderId}&link=${jsConfig.qrCode}`
  682. });
  683. // #endif
  684. // #ifdef APP-PLUS
  685. uni.requestPayment({
  686. provider: 'alipay',
  687. orderInfo: jsConfig,
  688. success: (e) => {
  689. uni.showToast({
  690. title: that.$t(`支付成功`)
  691. })
  692. let url = '/pages/goods/order_pay_status/index?order_id=' +
  693. orderId +
  694. '&msg=' + that.$t(`支付成功`);
  695. setTimeout(res => {
  696. uni.redirectTo({
  697. url: url
  698. })
  699. }, 2000)
  700. },
  701. fail: (e) => {
  702. let url = '/pages/goods/order_pay_status/index?order_id=' +
  703. orderId +
  704. '&msg=' + that.$t(`支付失败`);
  705. uni.showModal({
  706. content: that.$t(`支付失败`),
  707. showCancel: false,
  708. success: function(res) {
  709. if (res.confirm) {
  710. uni.redirectTo({
  711. url: url
  712. })
  713. } else if (res.cancel) {}
  714. }
  715. })
  716. },
  717. complete: () => {
  718. uni.hideLoading();
  719. },
  720. });
  721. // #endif
  722. break;
  723. }
  724. }).catch(err => {
  725. uni.hideLoading();
  726. return that.$util.Tips({
  727. title: err
  728. }, () => {
  729. that.$emit('onChangeFun', {
  730. action: 'pay_fail'
  731. });
  732. });
  733. })
  734. }
  735. }
  736. }
  737. </script>
  738. <style lang="scss" scoped>
  739. .page {
  740. padding-bottom: 200rpx;
  741. .pay-price {
  742. display: flex;
  743. justify-content: center;
  744. flex-direction: column;
  745. align-items: center;
  746. padding: 50rpx 0 40rpx 0;
  747. .price {
  748. color: #E93323;
  749. margin-bottom: 20rpx;
  750. display: flex;
  751. align-items: flex-end;
  752. .unit {
  753. font-size: 34rpx;
  754. font-weight: 500;
  755. line-height: 41rpx;
  756. }
  757. .num {
  758. font-size: 50rpx;
  759. font-weight: 600;
  760. }
  761. }
  762. .count-down {
  763. display: flex;
  764. align-items: center;
  765. background-color: #fff;
  766. padding: 8rpx 28rpx;
  767. border-radius: 40rpx;
  768. font-size: 24rpx;
  769. color: #E93323;
  770. .time {
  771. margin-top: 0 !important;
  772. }
  773. /deep/.red {
  774. margin: 0 !important;
  775. }
  776. }
  777. }
  778. .payment {
  779. width: 690rpx;
  780. border-radius: 14rpx 14rpx;
  781. background-color: #fff;
  782. z-index: 999;
  783. margin: 0 30rpx;
  784. .title {
  785. color: #666666;
  786. font-size: 26rpx;
  787. padding: 30rpx 0 0 30rpx;
  788. }
  789. .payMoney {
  790. font-size: 28rpx;
  791. color: #333333;
  792. text-align: center;
  793. margin-top: 50rpx;
  794. .font-color {
  795. margin-left: 10rpx;
  796. .money {
  797. font-size: 40rpx;
  798. }
  799. }
  800. }
  801. }
  802. .payment.on {
  803. transform: translate3d(0, 0, 0);
  804. }
  805. .icon-xuanzhong11 {
  806. color: #E93323 !important;
  807. }
  808. .payment .item {
  809. border-bottom: 1rpx solid #eee;
  810. height: 130rpx;
  811. margin-left: 30rpx;
  812. padding-right: 30rpx;
  813. }
  814. .payment .item:last-child {
  815. border-bottom: none;
  816. }
  817. .payment .item .left {
  818. flex: 1;
  819. }
  820. .payment .item .left .text {
  821. flex: 1;
  822. }
  823. .payment .item .left .text .name {
  824. font-size: 30rpx;
  825. color: #333;
  826. }
  827. .payment .item .left .text .info {
  828. font-size: 22rpx;
  829. color: #999;
  830. }
  831. .payment .item .left .text .info .money {
  832. color: #ff9900;
  833. }
  834. .payment .item .left .iconfont {
  835. font-size: 50rpx;
  836. color: #09bb07;
  837. margin-right: 28rpx;
  838. }
  839. .payment .item .left .iconfont.icon-zhifubao {
  840. color: #00aaea;
  841. }
  842. .payment .item .left .iconfont.icon-yuezhifu {
  843. color: #ff9900;
  844. }
  845. .payment .item .left .iconfont.icon-yuezhifu1 {
  846. color: #eb6623;
  847. }
  848. .payment .item .left .iconfont.icon-tonglianzhifu1 {
  849. color: #305fd8;
  850. }
  851. .payment .item .iconfont {
  852. font-size: 40rpx;
  853. color: #ccc;
  854. }
  855. .icon-haoyoudaizhifu {
  856. color: #F34C3E !important;
  857. }
  858. .btn {
  859. position: fixed;
  860. left: 30rpx;
  861. display: flex;
  862. flex-direction: column;
  863. align-items: center;
  864. bottom: 30rpx;
  865. bottom: calc(30rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  866. bottom: calc(30rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  867. }
  868. .wait-pay {
  869. color: #aaa;
  870. font-size: 24rpx;
  871. padding-top: 20rpx;
  872. }
  873. .button {
  874. width: 690rpx;
  875. height: 90rpx;
  876. border-radius: 45rpx;
  877. color: #FFFFFF;
  878. background-color: #E93323;
  879. }
  880. }
  881. </style>