paymentOrder.vue 26 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045
  1. <template>
  2. <view class="content">
  3. <u-navbar title="去支付" :autoBack="true"> </u-navbar>
  4. <view class="inner" v-if="order">
  5. <!-- 时间、价格 -->
  6. <view class="time-price">
  7. <text class="time">请在{{payLimitTime}}前完成支付</text>
  8. <view class="price-box">
  9. <text class="unit">¥</text>
  10. <text class="num">{{payMoney.toFixed(2)}}</text>
  11. </view>
  12. <text class="desc" v-if="payType==2">代收金额{{payDelivery.toFixed(2)}},请您在收到快递后支付尾款给快递人员。</text>
  13. <text class="desc" v-if="payType==3">货到付款金额{{payDelivery.toFixed(2)}},请您在收到快递后支付给快递人员。</text>
  14. </view>
  15. <!-- 支付方式 -->
  16. <view class="pay-type">
  17. <view class="title">支付方式</view>
  18. <!-- 改价订单只能选择微信支付和物流代收 -->
  19. <radio-group @change="payTypeChange" v-if="order.isEditMoney!=null&&order.isEditMoney==1">
  20. <view class="item">
  21. <view class="left">
  22. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/wecha_pay.png"
  23. mode=""></image>
  24. <text class="text">微信支付</text>
  25. </view>
  26. <label>
  27. <radio :value="1" :checked="order.payType=='1'" />
  28. </label>
  29. </view>
  30. <view class="item">
  31. <view class="left">
  32. <image src="/static/images/zfb.png" mode=""></image>
  33. <text class="text">支付宝支付</text>
  34. </view>
  35. <label>
  36. <radio :value="99" :checked="order.payType=='99'" />
  37. </label>
  38. </view>
  39. <view class="item">
  40. <view class="left">
  41. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/pay_de.png" mode="">
  42. </image>
  43. <text class="text">物流代收</text>
  44. </view>
  45. <label>
  46. <radio :value="2" :checked="order.payType=='2'" />
  47. </label>
  48. </view>
  49. </radio-group>
  50. <radio-group @change="payTypeChange" v-else-if="order.orderCreateType!=null&& order.orderCreateType==3">
  51. <view class="item">
  52. <view class="left">
  53. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/wecha_pay.png"
  54. mode=""></image>
  55. <text class="text">微信支付</text>
  56. </view>
  57. <label>
  58. <radio :value="1" :checked="order.payType=='1'" />
  59. </label>
  60. </view>
  61. <view class="item">
  62. <view class="left">
  63. <image src="/static/images/zfb.png" mode=""></image>
  64. <text class="text">支付宝支付</text>
  65. </view>
  66. <label>
  67. <radio :value="99" :checked="order.payType=='99'" />
  68. </label>
  69. </view>
  70. <view class="item">
  71. <view class="left">
  72. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/pay_de.png" mode="">
  73. </image>
  74. <text class="text">物流代收</text>
  75. </view>
  76. <label>
  77. <radio :value="2" :checked="order.payType=='2'" />
  78. </label>
  79. </view>
  80. <!-- <view class="item" v-if="user!=null&&user.level==1 "> -->
  81. <view class="item">
  82. <view class="left">
  83. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/pay_1.png" mode="">
  84. </image>
  85. <text class="text">货到付款</text>
  86. </view>
  87. <label>
  88. <radio :value="3" :checked="order.payType=='3'" />
  89. </label>
  90. </view>
  91. </radio-group>
  92. <radio-group @change="payTypeChange" v-else-if="order.orderCreateType!=null&& order.orderCreateType==2">
  93. <view class="item" v-if="payType==1||payType==4">
  94. <view class="left">
  95. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/wecha_pay.png"
  96. mode=""></image>
  97. <text class="text">微信支付</text>
  98. </view>
  99. <label>
  100. <radio :value="1" :checked="order.payType=='1'" />
  101. </label>
  102. </view>
  103. <view class="item">
  104. <view class="left">
  105. <image src="/static/images/zfb.png" mode=""></image>
  106. <text class="text">支付宝支付</text>
  107. </view>
  108. <label>
  109. <radio :value="99" :checked="order.payType=='99'" />
  110. </label>
  111. </view>
  112. <view class="item" v-if="payType==2||payType==4">
  113. <view class="left">
  114. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/pay_de.png" mode="">
  115. </image>
  116. <text class="text">物流代收</text>
  117. </view>
  118. <label>
  119. <radio :value="2" :checked="order.payType=='2'" />
  120. </label>
  121. </view>
  122. <!-- <view class="item" v-if="user!=null&&user.level==1 "> -->
  123. <view class="item" v-if="payType==1||payType==4">
  124. <view class="left">
  125. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/pay_1.png" mode="">
  126. </image>
  127. <text class="text">货到付款</text>
  128. </view>
  129. <label>
  130. <radio :value="3" :checked="order.payType=='3'" />
  131. </label>
  132. </view>
  133. </radio-group>
  134. <radio-group @change="payTypeChange"
  135. v-else-if="order.orderCreateType!=null&&(order.orderCreateType==1)">
  136. <view class="item">
  137. <view class="left">
  138. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/wecha_pay.png"
  139. mode=""></image>
  140. <text class="text">微信支付</text>
  141. </view>
  142. <label>
  143. <radio :value="1" checked />
  144. </label>
  145. </view>
  146. <view class="item">
  147. <view class="left">
  148. <image src="/static/images/zfb.png" mode=""></image>
  149. <text class="text">支付宝支付</text>
  150. </view>
  151. <label>
  152. <radio :value="99" :checked="order.payType=='99'" />
  153. </label>
  154. </view>
  155. </radio-group>
  156. </view>
  157. <!-- 订单详情查看 -->
  158. <view class="order-info">
  159. <view class="title">订单信息</view>
  160. <view class="item">
  161. <text class="label">订单编号</text>
  162. <view class="sn-box">
  163. <text class="text">{{order.orderCode}}</text>
  164. <view class="copy-btn" @click="copyOrderSn(order.orderCode)">复制</view>
  165. </view>
  166. </view>
  167. <view class="item">
  168. <text class="label">下单时间</text>
  169. <text class="text">{{order.createTime}}</text>
  170. </view>
  171. <view class="item">
  172. <text class="label">订单金额</text>
  173. <text class="text" v-if="order!=null">{{order.payPrice.toFixed(2)}}</text>
  174. </view>
  175. <!-- <view class="item">
  176. <text class="label">支付方式</text>
  177. <text class="text">微信支付</text>
  178. </view> -->
  179. </view>
  180. </view>
  181. <view class="btn-box">
  182. <view class="btn" @click="payOrder()">去支付</view>
  183. <!-- <view class="other-btn" >
  184. 亲友代付
  185. <button class="share" data-name="shareBtn" open-type="share">分享</button>
  186. </view> -->
  187. </view>
  188. <!-- <ykscreenRecord></ykscreenRecord> -->
  189. <uni-popup ref="popPayType" type="bottom" borderRadius="10rpx 10rpx 0px 0px">
  190. <view class="pay-box">
  191. <view class="title">请选择支付方式</view>
  192. <view class="pay-list">
  193. <!-- <view class="pay-item alipay" @click="doAlipay()">
  194. <image src="/static/images/alipay.png"></image>
  195. <view class="name">支付宝支付</view>
  196. </view> -->
  197. <view class="pay-item wx" @click="doWxPay()">
  198. <image src="/static/images/wx.png"></image>
  199. <view class="name">微信支付</view>
  200. </view>
  201. </view>
  202. </view>
  203. </uni-popup>
  204. <uni-popup ref="popTip" type="dialog">
  205. <uni-popup-dialog cancelText="支付失败" confirmText="支付成功" mode="base" content="是否已支付成功?" title="提示"
  206. :duration="2000" :before-close="true" @close="confirmTip" @confirm="confirmTip"></uni-popup-dialog>
  207. </uni-popup>
  208. </view>
  209. </template>
  210. <script>
  211. import {
  212. getUserInfo
  213. } from '@/api/user'
  214. import {
  215. getStoreConfig
  216. } from '@/api/common'
  217. import {
  218. editPayType,
  219. pay,
  220. getStoreOrderById,
  221. orderBindUser,
  222. aliPayment,
  223. wxPayment,
  224. } from '@/api/storeOrder'
  225. import {
  226. H5WxPayment
  227. } from '@/api/packageOrder'
  228. import ykscreenRecord from "@/components/yk-screenRecord/yk-screenRecord.vue"
  229. export default {
  230. components: {
  231. ykscreenRecord
  232. },
  233. data() {
  234. return {
  235. orderId: null,
  236. payDelivery: 0,
  237. payMoney: 0,
  238. config: null,
  239. payType: 1,
  240. payLimitTime: null,
  241. order: null,
  242. user: null,
  243. }
  244. },
  245. onLoad(option) {
  246. // this.orderId = JSON.parse(option.orderId);
  247. this.orderId = option.orderId
  248. // this.orderBindUser(this.orderId)
  249. this.getStoreOrderById();
  250. this.getStoreConfig();
  251. this.getUserInfo();
  252. },
  253. methods: {
  254. payFun() {
  255. var data = {
  256. orderId: this.orderId
  257. };
  258. var that = this;
  259. uni.showLoading();
  260. getStoreOrderById(data).then(
  261. res => {
  262. this.$refs.popTip.close();
  263. uni.hideLoading();
  264. if (res.order.paid == 1) {
  265. uni.redirectTo({
  266. url: "/pages_user/user/storeOrderDetail?id=" + that.orderId
  267. })
  268. } else {
  269. uni.showToast({
  270. title: '未支付成功',
  271. icon: 'none'
  272. });
  273. }
  274. },
  275. rej => {}
  276. );
  277. },
  278. confirmTip() {
  279. uni.showLoading({
  280. title: "请稍侯...",
  281. mask: true
  282. });
  283. setTimeout(() => {
  284. uni.hideLoading();
  285. this.payFun();
  286. }, 2000);
  287. },
  288. doWxPay() {
  289. var that = this;
  290. var data = {
  291. orderId: this.orderId,
  292. };
  293. // #ifdef H5
  294. if (String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger") {
  295. uni.showLoading();
  296. H5WxPayment(data).then(
  297. res => {
  298. uni.hideLoading()
  299. if (res.code == 200) {
  300. if (res.type == "tz") {
  301. window.location.href = res.data.body.url
  302. // uni.setStorageSync("h5PayUrl",res.data.body.url);
  303. // console.log(res.data.body.url)
  304. // uni.redirectTo({
  305. // url:"/pages/store/payH5"
  306. // })
  307. } else if (res.type == 'hf') {
  308. var payObj = JSON.parse(res.data.pay_info);
  309. jweixin.config({
  310. debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  311. appId: payObj.appId, // 必填,公众号的唯一标识
  312. timestamp: payObj.timeStamp, // 必填,生成签名的时间戳
  313. nonceStr: payObj.nonceStr, // 必填,生成签名的随机串
  314. signature: payObj.paySign, // 必填,签名
  315. jsApiList: ['chooseWXPay'] // 必填,需要使用的JS接口列表
  316. })
  317. jweixin.ready(function() {
  318. jweixin.chooseWXPay({
  319. timestamp: payObj.timeStamp, // 时间戳
  320. nonceStr: payObj.nonceStr, // 随机数
  321. package: payObj.package, //
  322. signType: payObj.signType,
  323. paySign: payObj.paySign, // 签名
  324. success: function() {
  325. uni.showToast({
  326. title: '支付成功'
  327. });
  328. setTimeout(() => {
  329. uni.navigateTo({
  330. url: `/pages/store/packageOrderPaySuccess?orderId=${that.orderId}`
  331. });
  332. }, 2000);
  333. },
  334. cancel: function() {
  335. uni.showToast({
  336. title: '取消支付',
  337. icon: 'none'
  338. });
  339. },
  340. fail: function(res) {
  341. uni.showToast({
  342. title: '支付失败' + JSON.stringify(res),
  343. icon: 'none'
  344. });
  345. }
  346. })
  347. })
  348. }
  349. } else {
  350. uni.showToast({
  351. icon: 'none',
  352. title: res.msg,
  353. });
  354. }
  355. },
  356. rej => {}
  357. );
  358. } else {
  359. uni.showToast({
  360. title: '请在微信内打开',
  361. icon: 'none'
  362. })
  363. }
  364. // #endif
  365. // #ifdef APP-PLUS
  366. plus.share.getServices(function(res) {
  367. var sweixin = null;
  368. for (var i = 0; i < res.length; i++) {
  369. var t = res[i];
  370. if (t.id == 'weixin') {
  371. sweixin = t;
  372. }
  373. }
  374. if (sweixin) {
  375. console.log('调起小程序')
  376. // that.$refs.popPayType.close()
  377. that.$refs.popTip.open()
  378. //唤起微信跳转小程序
  379. sweixin.launchMiniProgram({
  380. // id: "gh_0b4b9e32adba",
  381. id: getApp().globalData.miniprogamId,
  382. // path:'pages_order/packagePayment?orderId='+that.orderId+"&payMethod=app",
  383. path: 'pages/shopping/paymentOrder?orderId=' + that.orderId + "&payMethod=app",
  384. type: 0
  385. }, function() {
  386. console.log("微信唤起成功");
  387. return true;
  388. }, function(e) {
  389. console.log("微信唤起失败", e);
  390. uni.showToast({
  391. title: '微信唤起失败,请检查是否有微信应用',
  392. icon: 'none'
  393. })
  394. return false;
  395. })
  396. } else {
  397. uni.showToast({
  398. title: '微信唤起失败,请检查是否有微信应用',
  399. icon: 'none',
  400. duration: 3000
  401. });
  402. return false;
  403. }
  404. }, function(res) {
  405. console.log(JSON.stringify(res));
  406. });
  407. // #endif
  408. },
  409. orderBindUser(orderId) {
  410. uni.showLoading({
  411. title: '加载中...'
  412. })
  413. orderBindUser({
  414. orderId: orderId
  415. }).then(res => {
  416. uni.hideLoading()
  417. if (res.code == 200) {
  418. this.getStoreOrderById();
  419. this.getStoreConfig();
  420. this.getUserInfo();
  421. // uni.showShareMenu({
  422. // withShareTicket:true,
  423. // //小程序的原生菜单中显示分享按钮,才能够让发送给朋友与分享到朋友圈两个按钮可以点击
  424. // menus:["shareAppMessage"] //不设置默认发送给朋友
  425. // })
  426. } else {
  427. uni.showToast({
  428. icon: 'none',
  429. title: res.msg,
  430. });
  431. }
  432. }).catch(() => {
  433. uni.hideLoading()
  434. });
  435. },
  436. getUserInfo() {
  437. getUserInfo().then(
  438. res => {
  439. if (res.code == 200) {
  440. if (res.user != null) {
  441. this.user = res.user;
  442. }
  443. } else {
  444. uni.showToast({
  445. icon: 'none',
  446. title: "请求失败",
  447. });
  448. }
  449. },
  450. rej => {}
  451. );
  452. },
  453. getStoreConfig() {
  454. getStoreConfig().then(
  455. res => {
  456. if (res.code == 200) {
  457. this.config = res.data
  458. console.log(this.config);
  459. }
  460. },
  461. rej => {}
  462. );
  463. },
  464. payTypeChange(e) {
  465. this.editPayType(e.detail.value)
  466. },
  467. copyOrderSn(text) {
  468. // 复制方法
  469. uni.setClipboardData({
  470. data: text,
  471. success: () => {
  472. uni.showToast({
  473. title: '内容已成功复制到剪切板',
  474. icon: 'none'
  475. })
  476. }
  477. });
  478. },
  479. getStoreOrderById() {
  480. var data = {
  481. orderId: this.orderId
  482. };
  483. var that = this;
  484. uni.showLoading();
  485. getStoreOrderById(data).then(
  486. res => {
  487. if (res.code == 200) {
  488. console.log(res);
  489. uni.hideLoading();
  490. that.order = res.order;
  491. that.payLimitTime = res.payLimitTime;
  492. //套餐订单处理
  493. if (res.productPackage != null) {
  494. this.payType = res.productPackage.payType;
  495. console.log(this.payType)
  496. if (this.order.payType == 4) {
  497. this.order.payType = 1;
  498. }
  499. }
  500. this.editPayType(this.order.payType)
  501. } else {
  502. uni.showToast({
  503. icon: 'none',
  504. title: res.msg,
  505. });
  506. }
  507. },
  508. rej => {}
  509. );
  510. },
  511. editPayType(payType) {
  512. var data = {
  513. orderId: this.orderId,
  514. payType: payType
  515. };
  516. var that = this;
  517. uni.showLoading();
  518. editPayType(data).then(
  519. res => {
  520. if (res.code == 200) {
  521. console.log(res);
  522. uni.hideLoading();
  523. that.order = res.order;
  524. //this.payType=this.order.payType
  525. this.payMoney = this.order.payMoney;
  526. this.payDelivery = this.order.payDelivery;
  527. } else {
  528. uni.showToast({
  529. icon: 'none',
  530. title: res.msg,
  531. });
  532. }
  533. },
  534. rej => {}
  535. );
  536. },
  537. otherPayOrder() {
  538. uni.navigateTo({
  539. url: '/pages_user/user/otherPaymentOrder?orderId=' + this.orderId
  540. })
  541. },
  542. doWxPay() {
  543. var that = this;
  544. var data = {
  545. orderId: this.orderId,
  546. };
  547. // #ifdef H5
  548. if (String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger") {
  549. uni.showLoading();
  550. H5WxPayment(data).then(
  551. res => {
  552. uni.hideLoading()
  553. if (res.code == 200) {
  554. if (res.type == "tz") {
  555. window.location.href = res.data.body.url
  556. // uni.setStorageSync("h5PayUrl",res.data.body.url);
  557. // console.log(res.data.body.url)
  558. // uni.redirectTo({
  559. // url:"/pages/store/payH5"
  560. // })
  561. } else if (res.type == 'hf') {
  562. var payObj = JSON.parse(res.data.pay_info);
  563. jweixin.config({
  564. debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  565. appId: payObj.appId, // 必填,公众号的唯一标识
  566. timestamp: payObj.timeStamp, // 必填,生成签名的时间戳
  567. nonceStr: payObj.nonceStr, // 必填,生成签名的随机串
  568. signature: payObj.paySign, // 必填,签名
  569. jsApiList: ['chooseWXPay'] // 必填,需要使用的JS接口列表
  570. })
  571. jweixin.ready(function() {
  572. jweixin.chooseWXPay({
  573. timestamp: payObj.timeStamp, // 时间戳
  574. nonceStr: payObj.nonceStr, // 随机数
  575. package: payObj.package, //
  576. signType: payObj.signType,
  577. paySign: payObj.paySign, // 签名
  578. success: function() {
  579. uni.showToast({
  580. title: '支付成功'
  581. });
  582. setTimeout(() => {
  583. uni.navigateTo({
  584. url: `/pages/store/packageOrderPaySuccess?orderId=${that.orderId}`
  585. });
  586. }, 2000);
  587. },
  588. cancel: function() {
  589. uni.showToast({
  590. title: '取消支付',
  591. icon: 'none'
  592. });
  593. },
  594. fail: function(res) {
  595. uni.showToast({
  596. title: '支付失败' + JSON.stringify(res),
  597. icon: 'none'
  598. });
  599. }
  600. })
  601. })
  602. }
  603. } else {
  604. uni.showToast({
  605. icon: 'none',
  606. title: res.msg,
  607. });
  608. }
  609. },
  610. rej => {}
  611. );
  612. } else {
  613. uni.showToast({
  614. title: '请在微信内打开',
  615. icon: 'none'
  616. })
  617. }
  618. // #endif
  619. // #ifdef APP-PLUS
  620. plus.share.getServices(function(res) {
  621. var sweixin = null;
  622. for (var i = 0; i < res.length; i++) {
  623. var t = res[i];
  624. if (t.id == 'weixin') {
  625. sweixin = t;
  626. }
  627. }
  628. if (sweixin) {
  629. console.log('调起小程序')
  630. // that.$refs.popPayType.close()
  631. that.$refs.popTip.open()
  632. //唤起微信跳转小程序
  633. sweixin.launchMiniProgram({
  634. // id: "gh_0b4b9e32adba",
  635. id: getApp().globalData.miniprogamId,
  636. // path:'pages_order/packagePayment?orderId='+that.orderId+"&payMethod=app",
  637. path: 'pages/shopping/paymentOrder?orderId=' + that.orderId + "&payMethod=app",
  638. type: 0
  639. }, function() {
  640. console.log("微信唤起成功");
  641. return true;
  642. }, function(e) {
  643. console.log("微信唤起失败", e);
  644. uni.showToast({
  645. title: '微信唤起失败,请检查是否有微信应用',
  646. icon: 'none'
  647. })
  648. return false;
  649. })
  650. } else {
  651. uni.showToast({
  652. title: '微信唤起失败,请检查是否有微信应用',
  653. icon: 'none',
  654. duration: 3000
  655. });
  656. return false;
  657. }
  658. }, function(res) {
  659. console.log(JSON.stringify(res));
  660. });
  661. // #endif
  662. },
  663. async payOrder() {
  664. let params = {
  665. orderId: this.orderId,
  666. type: 'store'
  667. }
  668. let that = this
  669. if (this.order.payType == 1) {
  670. const res = await wxPayment(params)
  671. if (res.code == 200) {
  672. let payData = res.data
  673. uni.requestPayment({
  674. provider: 'wxpay',
  675. orderInfo: {
  676. appid: payData.appId,
  677. noncestr: payData.nonceStr,
  678. package: payData.packageValue,
  679. partnerid: payData.partnerId,
  680. prepayid: payData.prepayId,
  681. timestamp: payData.timeStamp,
  682. sign: payData.sign,
  683. },
  684. success: function(res) {
  685. that.$refs.popTip.open()
  686. uni.hideLoading();
  687. // uni.redirectTo({
  688. // url: `/pages_mall/paymentSuccess?order=${JSON.stringify(that.order)}`
  689. // })
  690. },
  691. fail: function(err) {
  692. that.$refs.popTip.open()
  693. uni.showToast({
  694. icon: 'none',
  695. title: "支付失败",
  696. });
  697. uni.hideLoading();
  698. },
  699. });
  700. }
  701. } else if (this.order.payType == 99) {
  702. const res = await aliPayment(params)
  703. if (res.code == 200) {
  704. let alipayScheme = ''
  705. if (uni.getSystemInfoSync().platform == 'android') {
  706. alipayScheme = `alipays://platformapi/startApp?&saId=10000007&qrcode=${res.data.qr_code}`;
  707. } else {
  708. alipayScheme = `alipay://platformapi/startApp?&saId=10000007&qrcode=${res.data.qr_code}`;
  709. }
  710. console.log(alipayScheme)
  711. plus.runtime.openURL(alipayScheme, function(error) {
  712. console.error('打开支付宝失败: ' + error);
  713. });
  714. that.$refs.popTip.open()
  715. }
  716. }
  717. }
  718. }
  719. }
  720. </script>
  721. <style lang="scss" scoped>
  722. .content {
  723. height: 100%;
  724. min-height: 100vh;
  725. height: 100%;
  726. display: flex;
  727. flex-direction: column;
  728. margin-top: 168rpx;
  729. box-sizing: border-box;
  730. // justify-content: space-between;
  731. .inner {
  732. padding: 20upx;
  733. .time-price {
  734. box-sizing: border-box;
  735. padding: 20upx 0upx;
  736. background: #FFFFFF;
  737. border-radius: 16upx;
  738. display: flex;
  739. flex-direction: column;
  740. align-items: center;
  741. .time {
  742. font-size: 32upx;
  743. font-family: PingFang SC;
  744. font-weight: 500;
  745. color: #222222;
  746. line-height: 1;
  747. text-align: center;
  748. }
  749. .desc {
  750. margin: 30upx 0upx 15upx;
  751. font-size: 26upx;
  752. font-family: PingFang SC;
  753. color: #999999;
  754. line-height: 1;
  755. text-align: center;
  756. }
  757. .price-box {
  758. display: flex;
  759. align-items: flex-end;
  760. margin-top: 28upx;
  761. .unit {
  762. font-size: 32upx;
  763. font-family: PingFang SC;
  764. font-weight: bold;
  765. color: #FF6633;
  766. line-height: 1.3;
  767. margin-right: 10upx;
  768. }
  769. .num {
  770. font-size: 56upx;
  771. font-family: PingFang SC;
  772. font-weight: bold;
  773. color: #FF6633;
  774. line-height: 1;
  775. }
  776. }
  777. }
  778. .pay-type {
  779. box-sizing: border-box;
  780. background: #FFFFFF;
  781. border-radius: 16upx;
  782. margin-top: 20upx;
  783. padding: 40upx 30upx;
  784. display: flex;
  785. flex-direction: column;
  786. justify-content: space-between;
  787. .title {
  788. font-size: 28upx;
  789. font-family: PingFang SC;
  790. font-weight: 500;
  791. color: #999999;
  792. line-height: 1;
  793. margin-bottom: 10upx;
  794. }
  795. .item {
  796. padding: 15upx 0upx;
  797. display: flex;
  798. align-items: center;
  799. justify-content: space-between;
  800. .left {
  801. display: flex;
  802. align-items: center;
  803. image {
  804. width: 44upx;
  805. height: 44upx;
  806. margin-right: 20upx;
  807. }
  808. .text {
  809. font-size: 30upx;
  810. font-family: PingFang SC;
  811. font-weight: bold;
  812. color: #222222;
  813. line-height: 1;
  814. }
  815. }
  816. }
  817. }
  818. .order-info {
  819. margin-top: 20upx;
  820. background: #FFFFFF;
  821. border-radius: 16upx;
  822. padding: 40upx 30upx;
  823. .title {
  824. font-size: 30upx;
  825. font-family: PingFang SC;
  826. font-weight: bold;
  827. color: #222222;
  828. line-height: 1;
  829. }
  830. .item {
  831. margin-top: 40upx;
  832. display: flex;
  833. align-items: center;
  834. justify-content: space-between;
  835. .label {
  836. font-size: 26upx;
  837. font-family: PingFang SC;
  838. font-weight: 500;
  839. color: #666666;
  840. line-height: 1;
  841. }
  842. .text {
  843. font-size: 26upx;
  844. font-family: PingFang SC;
  845. font-weight: 500;
  846. color: #222222;
  847. line-height: 32upx;
  848. }
  849. .cont-text {
  850. font-size: 26upx;
  851. font-family: PingFang SC;
  852. font-weight: 500;
  853. color: #666666;
  854. .bold {
  855. color: #111111;
  856. }
  857. }
  858. .sn-box {
  859. display: flex;
  860. align-items: center;
  861. .copy-btn {
  862. width: 58upx;
  863. height: 32upx;
  864. line-height: 32upx;
  865. text-align: center;
  866. font-size: 22upx;
  867. font-family: PingFang SC;
  868. font-weight: 500;
  869. color: #222222;
  870. background: #F5F5F5;
  871. border-radius: 4upx;
  872. margin-left: 24upx;
  873. }
  874. }
  875. }
  876. .line {
  877. width: 100%;
  878. height: 1px;
  879. background: #F0F0F0;
  880. margin-top: 30upx;
  881. }
  882. }
  883. }
  884. .btn-box {
  885. height: 242upx;
  886. background: #FFFFFF;
  887. display: flex;
  888. align-items: center;
  889. justify-content: center;
  890. flex-direction: column;
  891. .btn {
  892. width: 91.73%;
  893. height: 88upx;
  894. line-height: 88upx;
  895. font-size: 30upx;
  896. font-family: PingFang SC;
  897. font-weight: bold;
  898. color: #FFFFFF;
  899. text-align: center;
  900. background: #2583EB;
  901. border-radius: 44upx;
  902. margin-bottom: 10rpx;
  903. }
  904. .other-btn {
  905. width: 91.73%;
  906. height: 88upx;
  907. line-height: 88upx;
  908. font-size: 30upx;
  909. font-family: PingFang SC;
  910. font-weight: bold;
  911. color: #2583EB;
  912. border: 1rpx solid #2583EB;
  913. text-align: center;
  914. background: #FFFFFF;
  915. border-radius: 44upx;
  916. margin-bottom: 10rpx;
  917. position: relative;
  918. .share {
  919. display: inline-block;
  920. position: absolute;
  921. top: 0;
  922. left: 0;
  923. width: 100%;
  924. height: 100%;
  925. opacity: 0;
  926. }
  927. }
  928. }
  929. }
  930. .pay-box {
  931. border-radius: 30rpx 30rpx 0rpx 0rpx;
  932. padding: 30rpx;
  933. height: 350rpx;
  934. background-color: #fff;
  935. width: 100%;
  936. display: flex;
  937. flex-direction: column;
  938. text-align: center;
  939. justify-content: flex-start;
  940. .title {
  941. font-size: 32rpx;
  942. font-weight: bold;
  943. color: #111;
  944. }
  945. .pay-list {
  946. margin-top: 50rpx;
  947. display: flex;
  948. text-align: center;
  949. justify-content: center;
  950. .pay-item {
  951. margin: 10rpx;
  952. padding: 30rpx 0rpx;
  953. border-radius: 60rpx;
  954. background-color: green;
  955. flex: 1;
  956. display: flex;
  957. text-align: center;
  958. justify-content: center;
  959. image {
  960. width: 40rpx;
  961. height: 40rpx;
  962. }
  963. .name {
  964. margin-left: 15rpx;
  965. font-size: 32rpx;
  966. font-weight: bold;
  967. color: #fff;
  968. }
  969. }
  970. .wx {
  971. background-color: #09ba08;
  972. }
  973. .alipay {
  974. background-color: #04a9ed;
  975. }
  976. }
  977. }
  978. </style>