packageOrderPay.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360
  1. <template>
  2. <view>
  3. <!-- #ifdef APP-PLUS -->
  4. <es-nav-title title="支付" ></es-nav-title>
  5. <!-- #endif -->
  6. <view class="inner-box">
  7. <!-- 收货人 -->
  8. <view class="address-box" v-if="address==null" @click="openAddress()">
  9. <view class="left">
  10. <view class="name-box">
  11. <text class="text name">添加收货地址</text>
  12. </view>
  13. </view>
  14. <view class="arrow-box">
  15. <image src="/static/images/arrow_gray.png" mode=""></image>
  16. </view>
  17. </view>
  18. <view class="address-box" v-if="address!=null" @click="openAddress()">
  19. <view class="left">
  20. <view class="name-box">
  21. <text class="text name">{{address.realName}}</text>
  22. <text class="text" v-if="address.phone!=null">{{address.phone}}</text>
  23. </view>
  24. <view class="address">
  25. {{address.address}}
  26. </view>
  27. </view>
  28. <view class="arrow-box">
  29. <image src="/static/images/arrow_gray.png" mode=""></image>
  30. </view>
  31. </view>
  32. <view class="other-info">
  33. <view class="title">支付明细</view>
  34. <view class="item">
  35. <view class="left">
  36. <text class="label">应付金额:</text>
  37. </view>
  38. <view class="right">
  39. <text class="text" >{{payPrice}}</text>
  40. </view>
  41. </view>
  42. <view class="item" v-if="order!=null&&(order.userCouponId==null||order.userCouponId==0)" @click.stop="openCoupon()">
  43. <view class="left">
  44. <text class="label">优惠券:</text>
  45. </view>
  46. <view class="right">
  47. <text class="text">{{couponText}}</text>
  48. <image v-if="userCouponId!=0" @click.stop="delCoupon()" class="ic-close" src="/static/images/close.png"></image>
  49. <image class="ic-back" src="/static/images/arrow_gray.png"></image>
  50. </view>
  51. </view>
  52. <view class="item" >
  53. <view class="left">
  54. <text class="label">优惠金额:</text>
  55. </view>
  56. <view class="right">
  57. <text class="text">{{discountMoney}}</text>
  58. </view>
  59. </view>
  60. <view class="item">
  61. <view class="left">
  62. <text class="label">支付金额:</text>
  63. </view>
  64. <view class="right">
  65. <text class="text">{{payMoney}}</text>
  66. </view>
  67. </view>
  68. <view class="item">
  69. <view class="left">
  70. <text class="label">物流代收:</text>
  71. </view>
  72. <view class="right">
  73. <text class="text">{{payRemain}}</text>
  74. </view>
  75. </view>
  76. <view class="item">
  77. <view class="left">
  78. <text class="label">邮费:</text>
  79. </view>
  80. <view class="right">
  81. <text class="text">{{payDelivery}}</text>
  82. </view>
  83. </view>
  84. </view>
  85. <view class="pay-type">
  86. <view class="title">支付方式</view>
  87. <radio-group @change="payTypeChange" >
  88. <view class="item" v-if="checkPayType('1')&&choose!=1" >
  89. <view class="left" >
  90. <image src="/static/images/wecha_pay.png" mode=""></image>
  91. <text class="text">全款支付</text>
  92. </view>
  93. <label>
  94. <radio :value="1" :checked="payType=='1'" />
  95. </label>
  96. </view>
  97. <view class="item" v-if="checkPayType('2')" >
  98. <view class="left" >
  99. <image src="/static/image/pay_de.png" mode=""></image>
  100. <text class="text">物流代收</text>
  101. </view>
  102. <label>
  103. <radio :value="2" :checked="payType=='2'" />
  104. </label>
  105. </view>
  106. <view class="item" v-if="checkPayType('3')&&choose!=2" >
  107. <view class="left">
  108. <image src="/static/image/pay_1.png" mode=""></image>
  109. <text class="text">货到付款</text>
  110. </view>
  111. <label>
  112. <radio :value="3" :checked="payType=='3'" />
  113. </label>
  114. </view>
  115. </radio-group>
  116. </view>
  117. <!-- <view class="other-info" v-if="payType=='1'&&order!=null&&order.companyId!=null&&order.companyId>0&&giftPrice<=payPrice"> -->
  118. <view class="other-info" v-if="gifts.length>0">
  119. <view class="title">赠品</view>
  120. <view class="drug-list" >
  121. <view v-for="(product) in gifts" class="drug-item" >
  122. <view class="img-box">
  123. <image :src="product.image" mode="aspectFill"></image>
  124. </view>
  125. <view class="drug-info" >
  126. <view>
  127. <view class="name-box ellipsis2">
  128. {{product.productName}}
  129. </view>
  130. <view class="spec">{{product.sku}}</view>
  131. </view>
  132. <view class="num-box">
  133. <view class="use">
  134. {{product.usageMethod}}
  135. </view>
  136. <view class="price">
  137. <text class="unit">¥</text>
  138. <text class="num">{{product.price.toFixed(2)}}</text>
  139. </view>
  140. <view class="amount">x{{product.count}}</view>
  141. </view>
  142. </view>
  143. </view>
  144. </view>
  145. </view>
  146. <!-- 备注 -->
  147. <view class="remarks" v-if="order!=null">
  148. <input type="text" v-model="order.remark" placeholder="备注留言(选填)" placeholder-class="input" />
  149. </view>
  150. </view>
  151. <uni-popup ref="popCoupon" type="bottom" borderRadius="10rpx 10rpx 0px 0px">
  152. <view class="coupon">
  153. <view class="coupon-box" v-if="coupons.length>0" >
  154. <view @click="couponSelect(item)" class="coupon-item" v-for="(item) in coupons">
  155. <view class="left" >
  156. <image v-if="item.status==0" src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/0fdd75d89db84458886d38e615011048.png" mode="widthFix"></image>
  157. <image v-if="item.status!=0" src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/d950e4c7af1e4464be1a7777e9dca576.png" mode="widthFix"></image>
  158. <view style="z-index: 999;">
  159. ¥<span class="num">{{item.price.toFixed(2)}}</span>
  160. </view>
  161. <view class="pic-num" >满{{item.minPrice.toFixed(2)}}元可用</view>
  162. </view>
  163. <view class="right">
  164. <view class="title">
  165. {{item.title}}
  166. </view>
  167. <view class="btns">
  168. <view v-if="item.status==0||item.status==2" >{{item.limitTime}} 到期</view>
  169. <view v-if="item.status==1">使用时间 {{item.useTime}}</view>
  170. <view class="bnt gray" v-if="item.status==1" >已使用</view>
  171. <view class="bnt gray" v-if="item.status==2" >已过期</view>
  172. <view class="btn" v-if="item.status==0" >使用</view>
  173. </view>
  174. </view>
  175. </view>
  176. </view>
  177. <view class="empty" v-if="coupons.length==0">
  178. <image src="https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png"></image>
  179. </view>
  180. </view>
  181. </uni-popup>
  182. <uni-popup ref="popTip" type="dialog">
  183. <uni-popup-dialog cancelText="支付失败" confirmText="支付成功" mode="base" content="是否已支付成功?" title="提示" :duration="2000" :before-close="true" @close="confirmTip" @confirm="confirmTip"></uni-popup-dialog>
  184. </uni-popup>
  185. <!-- 底部按钮 -->
  186. <view class="btn-box">
  187. <view class="btn" v-if="order!=null" @click="payOrder()">支付{{payMoney}}元</view>
  188. </view>
  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="popCopyTip" type="dialog">
  205. <uni-popup-dialog cancelText="取消" confirmText="复制链接" mode="base" content="请点击“复制链接”按钮在浏览器中粘贴打开。?" title="提示" :duration="2000" :before-close="true" @close="closeCopyTip" @confirm="confirmCopyTip"></uni-popup-dialog>
  206. </uni-popup>
  207. </view>
  208. </template>
  209. <script>
  210. import * as jweixin from 'weixin-js-sdk'
  211. import {getConfigByKey} from '@/api/common'
  212. import {getAddressByDefault} from '@/api/userAddress.js'
  213. import {getMyEnableCouponList,loginByMp} from '@/api/user.js'
  214. import {getPackageById} from '@/api/package.js'
  215. import {getPackageOrderById,pay,compute,aliPayment,H5WxPayment,H5AliPayment} from '@/api/packageOrder'
  216. export default {
  217. data() {
  218. return {
  219. giftPrice:0.00,
  220. payTypes:[],
  221. addressId:null,
  222. wxPay: true,
  223. address:null,
  224. orderId:null,
  225. order:null,
  226. items:null,
  227. payType:"1",
  228. couponText:"请选择优惠券",
  229. userCouponId:0,
  230. coupons:[],
  231. couponShow:false,
  232. payMoney:0.00,
  233. discountMoney:0,
  234. payRemain:0,
  235. payDelivery:0,
  236. payPrice:0,
  237. gifts:[],
  238. alipayQrCode:null,
  239. showPayTips:false,
  240. choose: 0
  241. }
  242. },
  243. onLoad(option) {
  244. this.choose = option.choose || 0
  245. this.payType = this.choose == 1 ? 3:this.choose == 2 ? 1 :this.payType
  246. this.orderId=option.orderId;
  247. var that=this;
  248. uni.$on('updateAddress', (e) => {
  249. that.addressId=e.addressId;
  250. that.address=e;
  251. that.address.address=e.province+e.city+e.district+e.detail
  252. });
  253. this.getAddressByDefault();
  254. this.getPackageOrderById();
  255. // this.getPackageById();
  256. this.getConfigByKey();
  257. uni.hideNavigationBarLoading();
  258. },
  259. onShow() {
  260. if(this.showPayTips){
  261. this.$refs.popPayType.close();
  262. this.$refs.popTip.open();
  263. this.showPayTips=false;
  264. }
  265. },
  266. methods: {
  267. getAddressByDefault(){
  268. var data={};
  269. getAddressByDefault(data).then(
  270. res => {
  271. if(res.code==200){
  272. if(res.data!=null){
  273. this.addressId=res.data.addressId;
  274. this.address=res.data;
  275. this.address.address=res.data.province+res.data.city+res.data.district+res.data.detail
  276. }
  277. }else{
  278. uni.showToast({
  279. icon:'none',
  280. title: res.msg,
  281. });
  282. }
  283. },
  284. rej => {}
  285. );
  286. },
  287. getConfigByKey(){
  288. var that=this;
  289. var data={key:"his.package"}
  290. getConfigByKey(data).then(
  291. res => {
  292. if(res.code==200){
  293. this.giftPrice=JSON.parse(res.data).giftPrice;
  294. console.log(this.giftPrice)
  295. }
  296. },
  297. rej => {}
  298. );
  299. },
  300. checkPayType(payType){
  301. var flag=false
  302. this.payTypes.forEach(function(value,index,array){
  303. if(value.toString()==payType.toString()){
  304. flag=true;
  305. }
  306. });
  307. return flag;
  308. },
  309. payTypeChange(e){
  310. console.log(e.detail.value)
  311. this.payType=e.detail.value;
  312. this.compute()
  313. },
  314. couponSelect(item){
  315. this.$refs.popCoupon.close();
  316. //计算金额
  317. this.userCouponId=item.id;
  318. console.log(item)
  319. this.couponText=item.price+"元优惠券"
  320. this.compute()
  321. },
  322. openCoupon(){
  323. this.$refs.popCoupon.open("bottom")
  324. },
  325. delCoupon(){
  326. this.userCouponId=0;
  327. this.couponText="请选择优惠券";
  328. this.compute();
  329. },
  330. compute(){
  331. var data={
  332. payType:this.payType, // choose 1:付邮费领取 2:加粉领取,付邮费领取payType为3
  333. orderId:this.orderId,
  334. userCouponId:this.userCouponId
  335. }
  336. console.log(data)
  337. compute(data).then(
  338. res => {
  339. if(res.code==200){
  340. this.payPrice=res.moneys.payPrice.toFixed(2);
  341. this.payMoney=res.moneys.payMoney.toFixed(2);
  342. this.discountMoney=res.moneys.discountMoney.toFixed(2);
  343. this.payDelivery=res.moneys.payDelivery.toFixed(2);
  344. this.payRemain=res.moneys.payRemain.toFixed(2);
  345. this.gifts=res.moneys.gifts;
  346. }
  347. else{
  348. this.payType=1;
  349. this.compute()
  350. this.userCouponId=0;
  351. this.couponText="请选择优惠券"
  352. uni.showToast({
  353. icon:'none',
  354. title: res.msg,
  355. });
  356. }
  357. },
  358. err => {
  359. }
  360. );
  361. },
  362. getMyEnableCouponList(){
  363. var data={}
  364. if(this.package.isShow==0){
  365. data.couponType=5;
  366. data.cateId=this.package.privateType
  367. }
  368. else if(this.package.isShow==1){
  369. data.couponType=6;
  370. data.cateId=this.package.diseaseType
  371. }
  372. getMyEnableCouponList(data).then(
  373. res => {
  374. if(res.code==200){
  375. this.coupons=res.data;
  376. }
  377. },
  378. err => {
  379. }
  380. );
  381. },
  382. getPackageOrderById(){
  383. var data={orderId:this.orderId};
  384. getPackageOrderById(data).then(res => {
  385. if(res.code==200){
  386. this.order=res.order;
  387. this.choose = res.choose || 0
  388. this.payType = this.choose == 1 ? 3:this.choose == 2 ? 1 :this.payType
  389. this.compute();
  390. this.getPackageById(this.order.packageId);
  391. }
  392. },
  393. rej => {}
  394. );
  395. },
  396. getPackageById(packageId){
  397. let data={packageId:packageId};
  398. if(this.choose == 1 || this.choose == 2) {
  399. data={
  400. packageId:packageId,
  401. choose: this.choose
  402. };
  403. }
  404. getPackageById(data).then(
  405. res => {
  406. if(res.code==200){
  407. this.package=res.data;
  408. this.payTypes=res.data.payType.split(',');
  409. this.payType=this.choose == 1 ? 3:this.choose == 2 ? 1 :this.payType
  410. this.getMyEnableCouponList();
  411. }else{
  412. }
  413. },
  414. rej => {}
  415. );
  416. },
  417. openAddress(){
  418. uni.navigateTo({
  419. url: '/pages/user/address'
  420. });
  421. },
  422. closeTip(){
  423. this.$refs.popTip.close()
  424. },
  425. confirmTip() {
  426. uni.showLoading({title:"请稍侯...",mask:true});
  427. setTimeout(()=>{
  428. uni.hideLoading();
  429. this.getPackagOrderInfo();
  430. },2000);
  431. },
  432. getPackagOrderInfo(){
  433. getPackageOrderById({orderId:this.orderId}).then(res => {
  434. this.$refs.popTip.close();
  435. if(res.code==200){
  436. this.order=res.order;
  437. if(res.order.status==1){ //1:代付款 2:已支付
  438. uni.showToast({title: '未支付成功',icon: 'none'});
  439. }
  440. else if(res.order.status==2){ //1:代付款 2:已支付
  441. this.$refs.popTip.close();
  442. // #ifdef APP-PLUS
  443. if(plus.runtime.channel=="baidu"){ //获取百度渠道标识
  444. let bdCmdType=uni.getStorageSync("bdCmdType");
  445. if(bdCmdType!=null && parseInt(bdCmdType)<=2){
  446. //this.$registerIdCode("orders",2,res.order.payPrice.toString()); //已下单
  447. }
  448. }
  449. // #endif
  450. uni.redirectTo({
  451. url:"./packageOrderPaySuccess?orderId="+this.order.orderId
  452. });
  453. }
  454. }
  455. },
  456. rej => {}
  457. );
  458. },
  459. closeCopyTip(){
  460. this.$refs.popCopyTip.close()
  461. },
  462. confirmCopyTip() {
  463. this.$refs.popCopyTip.close();
  464. var that=this;
  465. uni.setClipboardData({
  466. data:that.alipayQrCode,
  467. success:()=>{
  468. uni.showToast({
  469. title:'内容已成功复制到剪切板',
  470. icon:'none'
  471. })
  472. that.showPayTips=true;
  473. }
  474. });
  475. },
  476. doAlipay(){
  477. var data = {
  478. orderId:this.order.orderId,
  479. };
  480. var that=this;
  481. // #ifdef H5
  482. uni.showLoading();
  483. H5AliPayment(data).then(
  484. res => {
  485. uni.hideLoading()
  486. if(res.code==200){
  487. if(res.type=="tz"){
  488. window.location.href =res.data.body.url
  489. }
  490. else if(res.type=='hf'){
  491. console.log(res)
  492. that.alipayQrCode=res.data.qr_code;
  493. that.$refs.popCopyTip.open();
  494. }
  495. }else{
  496. uni.showToast({icon:'none',title: res.msg});
  497. }
  498. },
  499. rej => {}
  500. );
  501. // #endif
  502. // #ifdef APP-PLUS
  503. const tzCashier=uni.requireNativePlugin("TZBank-Cashier");
  504. uni.showLoading();
  505. aliPayment(data).then(res => {
  506. uni.hideLoading()
  507. this.$refs.popPayType.close();
  508. this.$refs.popTip.open();
  509. console.log("qxj res:"+JSON.stringify(res));
  510. console.log("qxj orderFlowNo:"+res.data.body.orderFlowNo+" businessCstNo:"+res.data.body.orderNo+" platMerCstNo:"+res.data.body.platMerCstNo);
  511. if(res.code==200){
  512. if(res.type=="tz"){
  513. const match = res.data.body.url.match(/[\?&]businessCstNo=([^&]+)/);
  514. const businessCstNo = match ? match[1] : null;
  515. console.log("qxj tzCashier:"+tzCashier+" businessCstNo:"+businessCstNo);
  516. tzCashier.pay({
  517. env:0,
  518. wxMiniProgramType:0,
  519. wxAppId:'wx703c4bd07bbd1695',
  520. wxUniversalLink:"https://yjf.runtzh.com/",
  521. orderFlowNo:res.data.body.orderFlowNo,
  522. businessCstNo:businessCstNo,
  523. platMerCstNo:res.data.body.platMerCstNo
  524. },(res)=>{
  525. console.log("qxj 支付成功:"+JSON.stringify(res));
  526. });
  527. }
  528. else if(res.type=='hf'){
  529. if (uni.getSystemInfoSync().platform == 'android') {
  530. var alipayScheme ='alipays://platformapi/startApp?&saId=10000007&qrcode=' + res.data.qr_code;
  531. }else{
  532. var alipayScheme ='alipay://platformapi/startApp?&saId=10000007&qrcode=' + res.data.qr_code;
  533. }
  534. console.log(alipayScheme)
  535. // 在uni-app中使用plus.runtime.openURL打开URL
  536. plus.runtime.openURL(alipayScheme, function(error) {
  537. // console.error('打开支付宝失败: ' + error.message);
  538. // 处理打开支付宝失败的情况,比如提示用户或者跳转到其他支付方式
  539. });
  540. }
  541. }
  542. else{
  543. uni.showToast({
  544. title:res.msg,
  545. icon:'none'
  546. })
  547. }
  548. },
  549. rej => {}
  550. );
  551. // #endif
  552. },
  553. doWxPay(){
  554. var that=this;
  555. var data = {
  556. orderId:this.orderId,
  557. };
  558. // #ifdef H5
  559. if(String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger"){
  560. uni.showLoading();
  561. H5WxPayment(data).then(
  562. res => {
  563. uni.hideLoading()
  564. if(res.code==200){
  565. if(res.type=="tz"){
  566. window.location.href =res.data.body.url
  567. // uni.setStorageSync("h5PayUrl",res.data.body.url);
  568. // console.log(res.data.body.url)
  569. // uni.redirectTo({
  570. // url:"/pages/store/payH5"
  571. // })
  572. }
  573. else if(res.type=='hf'){
  574. var payObj=JSON.parse(res.data.pay_info);
  575. jweixin.config({
  576. debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  577. appId: payObj.appId, // 必填,公众号的唯一标识
  578. timestamp: payObj.timeStamp, // 必填,生成签名的时间戳
  579. nonceStr: payObj.nonceStr, // 必填,生成签名的随机串
  580. signature: payObj.paySign, // 必填,签名
  581. jsApiList: ['chooseWXPay'] // 必填,需要使用的JS接口列表
  582. })
  583. jweixin.ready(function() {
  584. jweixin.chooseWXPay({
  585. timestamp: payObj.timeStamp, // 时间戳
  586. nonceStr: payObj.nonceStr, // 随机数
  587. package: payObj.package, //
  588. signType: payObj.signType,
  589. paySign: payObj.paySign, // 签名
  590. success: function() {
  591. uni.showToast({ title:'支付成功' });
  592. setTimeout(() => {
  593. uni.navigateTo({
  594. url: `/pages/store/packageOrderPaySuccess?orderId=${that.orderId}`
  595. });
  596. },2000);
  597. },
  598. cancel: function() {
  599. uni.showToast({ title:'取消支付', icon:'none' });
  600. },
  601. fail: function(res) {
  602. uni.showToast({title:'支付失败'+JSON.stringify(res),icon:'none'});
  603. }
  604. })
  605. })
  606. }
  607. }else{
  608. uni.showToast({
  609. icon:'none',
  610. title: res.msg,
  611. });
  612. }
  613. },
  614. rej => {}
  615. );
  616. }
  617. else{
  618. uni.showToast({
  619. title:'请在微信内打开',
  620. icon:'none'
  621. })
  622. }
  623. // #endif
  624. // #ifdef APP-PLUS
  625. plus.share.getServices(function(res){
  626. var sweixin = null;
  627. for(var i=0;i<res.length;i++){
  628. var t = res[i];
  629. if(t.id == 'weixin'){
  630. sweixin = t;
  631. }
  632. }
  633. if(sweixin){
  634. console.log('调起小程序')
  635. that.$refs.popPayType.close()
  636. that.$refs.popTip.open()
  637. //唤起微信跳转小程序
  638. sweixin.launchMiniProgram({
  639. id:"gh_7a6a32e5ef61",
  640. path:'pages_order/packagePayment?orderId='+that.orderId+"&payMethod=app",
  641. type:0
  642. },function(){
  643. console.log("微信唤起成功");
  644. return true;
  645. },function(e){
  646. console.log("微信唤起失败",e);
  647. uni.showToast({
  648. title:'微信唤起失败,请检查是否有微信应用',
  649. icon:'none'
  650. })
  651. return false;
  652. })
  653. }else{
  654. uni.showToast({
  655. title:'微信唤起失败,请检查是否有微信应用',
  656. icon:'none',
  657. duration:3000
  658. });
  659. return false;
  660. }
  661. },function(res){
  662. console.log(JSON.stringify(res));
  663. });
  664. // #endif
  665. },
  666. payOrder(){
  667. var that=this;
  668. var data = {
  669. payType:this.payType,
  670. userCouponId:this.userCouponId,
  671. addressId:this.addressId,
  672. remark:this.order.remark,
  673. orderId:this.order.orderId,
  674. };
  675. uni.showLoading();
  676. pay(data).then(
  677. res => {
  678. console.log(res)
  679. uni.hideLoading()
  680. if(res.code==200){
  681. that.$refs.popPayType.open("bottom")
  682. }else{
  683. uni.showToast({
  684. icon:'none',
  685. title: res.msg,
  686. });
  687. }
  688. },
  689. rej => {}
  690. );
  691. }
  692. }
  693. }
  694. </script>
  695. <style lang="scss">
  696. page{
  697. position: relative;
  698. }
  699. .inner-box{
  700. padding: 20upx 20upx 300upx;
  701. .address-box{
  702. box-sizing: border-box;
  703. min-height: 171upx;
  704. background: #FFFFFF;
  705. border-radius: 16upx;
  706. background-image: url(/static/images/address_bg.png);
  707. background-repeat: no-repeat;
  708. background-size: 100% 30upx;
  709. background-position: left bottom;
  710. padding: 38upx 30upx 36upx;
  711. display: flex;
  712. align-items: center;
  713. justify-content: space-between;
  714. .left{
  715. width: 92%;
  716. .name-box{
  717. display: flex;
  718. align-items: center;
  719. .text{
  720. font-size: 32upx;
  721. font-family: PingFang SC;
  722. font-weight: bold;
  723. color: #111111;
  724. line-height: 1;
  725. &.name{
  726. margin-right: 30upx;
  727. }
  728. }
  729. }
  730. .address{
  731. font-size: 28upx;
  732. font-family: PingFang SC;
  733. font-weight: 500;
  734. color: #666666;
  735. line-height: 42upx;
  736. text-align:left;
  737. margin-top: 23upx;
  738. }
  739. }
  740. .arrow-box{
  741. width: 12upx;
  742. height: 23upx;
  743. display: flex;
  744. align-items: cenetr;
  745. justify-content: cenetr;
  746. image{
  747. width: 100%;
  748. height: 100%;
  749. }
  750. }
  751. }
  752. .goods-list{
  753. margin-top: 20upx;
  754. padding: 0 30upx;
  755. background-color: #FFFFFF;
  756. border-radius: 16upx;
  757. .item{
  758. padding: 30upx 0;
  759. border-bottom: 1px solid #EDEEEF;
  760. display: flex;
  761. align-items: center;
  762. .img-box{
  763. width: 160upx;
  764. height: 160upx;
  765. margin-right: 30upx;
  766. image{
  767. width: 100%;
  768. height: 100%;
  769. }
  770. }
  771. .info-box{
  772. width: calc(100% - 190upx);
  773. height: 160upx;
  774. display: flex;
  775. flex-direction: column;
  776. justify-content: space-between;
  777. .name-box{
  778. font-size: 28upx;
  779. font-family: PingFang SC;
  780. font-weight: 500;
  781. color: #111111;
  782. line-height: 40upx;
  783. .tag{
  784. display: inline-block;
  785. padding: 0 6upx;
  786. height: 30upx;
  787. background: linear-gradient(90deg, #C39A58 0%, #E2C99E 100%);
  788. border-radius: 4upx;
  789. margin-right: 10upx;
  790. font-size: 22upx;
  791. font-family: PingFang SC;
  792. font-weight: bold;
  793. color: #FFFFFF;
  794. line-height: 30upx;
  795. float: left;
  796. margin-top: 7upx;
  797. }
  798. }
  799. .spec{
  800. margin-top: 10upx;
  801. font-size: 24upx;
  802. font-family: PingFang SC;
  803. font-weight: 500;
  804. color: #999999;
  805. line-height: 1;
  806. }
  807. .price-num{
  808. display: flex;
  809. align-items: center;
  810. justify-content: space-between;
  811. .price{
  812. display: flex;
  813. align-items: flex-end;
  814. .unit{
  815. font-size: 24upx;
  816. font-family: PingFang SC;
  817. font-weight: 500;
  818. color: #111111;
  819. line-height: 1.2;
  820. margin-right: 4upx;
  821. }
  822. .num{
  823. font-size: 32upx;
  824. font-family: PingFang SC;
  825. font-weight: 500;
  826. color: #111111;
  827. line-height: 1;
  828. }
  829. }
  830. .num{
  831. font-size: 24upx;
  832. font-family: PingFang SC;
  833. font-weight: 500;
  834. color: #999999;
  835. line-height: 1;
  836. }
  837. }
  838. }
  839. }
  840. .sub-total{
  841. height: 88upx;
  842. display: flex;
  843. align-items: center;
  844. justify-content: flex-end;
  845. .label{
  846. font-size: 24upx;
  847. font-family: PingFang SC;
  848. font-weight: 500;
  849. color: #999999;
  850. }
  851. .price{
  852. display: flex;
  853. align-items: flex-end;
  854. .unit{
  855. font-size: 24upx;
  856. font-family: PingFang SC;
  857. font-weight: 500;
  858. color: #FF6633;
  859. line-height: 1.2;
  860. margin-right: 4upx;
  861. }
  862. .num{
  863. font-size: 32upx;
  864. font-family: PingFang SC;
  865. font-weight: bold;
  866. color: #FF6633;
  867. line-height: 1;
  868. }
  869. }
  870. }
  871. }
  872. .other-info{
  873. margin-top: 20upx;
  874. background-color: #fff;
  875. border-radius: 20upx;
  876. overflow: hidden;
  877. padding: 0 30upx;
  878. .title{
  879. height: 80upx;
  880. line-height: 80upx;
  881. font-size: 30upx;
  882. color: #000;
  883. font-weight: bold;
  884. border-bottom: 2upx solid #eeeeee;
  885. }
  886. .drug-list{
  887. margin-top: 15rpx;
  888. .drug-item{
  889. padding-bottom: 15upx;
  890. border-bottom: 1px soli #F0F0F0;
  891. display: flex;
  892. align-items: center;
  893. .img-box{
  894. width: 160upx;
  895. height: 160upx;
  896. margin-right: 30upx;
  897. flex-shrink: 0;
  898. image{
  899. width: 100%;
  900. height: 100%;
  901. }
  902. }
  903. .drug-info{
  904. width: calc(100% - 190upx);
  905. height: 160upx;
  906. display: flex;
  907. flex-direction: column;
  908. justify-content: space-between;
  909. .name-box{
  910. font-size: 28upx;
  911. font-family: PingFang SC;
  912. font-weight: 500;
  913. color: #111111;
  914. line-height: 40upx;
  915. .tag{
  916. display: inline-block;
  917. padding: 0 6upx;
  918. height: 30upx;
  919. background: linear-gradient(90deg, #2BC7B9 0%, #2BC7A4 100%);
  920. border-radius: 4upx;
  921. margin-right: 10upx;
  922. font-size: 22upx;
  923. font-family: PingFang SC;
  924. font-weight: bold;
  925. color: #FFFFFF;
  926. line-height: 30upx;
  927. float: left;
  928. margin-top: 7upx;
  929. }
  930. }
  931. .spec{
  932. font-size: 24upx;
  933. font-family: PingFang SC;
  934. font-weight: 500;
  935. color: #999999;
  936. line-height: 1;
  937. margin-top: 10upx;
  938. }
  939. .num-box{
  940. display: flex;
  941. align-items: center;
  942. justify-content: space-between;
  943. .price{
  944. display: flex;
  945. align-items: flex-end;
  946. .unit{
  947. font-size: 24upx;
  948. font-family: PingFang SC;
  949. font-weight: 500;
  950. color: #111111;
  951. line-height: 1.2;
  952. margin-right: 4upx;
  953. }
  954. .num{
  955. font-size: 32upx;
  956. font-family: PingFang SC;
  957. font-weight: 500;
  958. color: #111111;
  959. line-height: 1;
  960. }
  961. }
  962. .use{
  963. font-size: 24upx;
  964. font-family: PingFang SC;
  965. color: #999999;
  966. }
  967. .amount{
  968. font-size: 24upx;
  969. font-family: PingFang SC;
  970. font-weight: 500;
  971. color: #999999;
  972. line-height: 1;
  973. }
  974. }
  975. }
  976. }
  977. }
  978. .item{
  979. height: 80upx;
  980. display: flex;
  981. align-items: center;
  982. justify-content: space-between;
  983. &:last-child{
  984. border-bottom: none;
  985. }
  986. .left{
  987. flex: 1;
  988. display: flex;
  989. align-items: center;
  990. .label{
  991. min-width: 140rpx;
  992. font-size: 28upx;
  993. color: #000;
  994. }
  995. .text{
  996. font-size: 28upx;
  997. color: #1b1b1b;
  998. }
  999. }
  1000. .right{
  1001. display: flex;
  1002. align-items: center;
  1003. justify-content: flex-end;
  1004. .text{
  1005. font-size: 28upx;
  1006. color: #1b1b1b;
  1007. }
  1008. .ic-close{
  1009. margin-left: 10rpx;
  1010. width: 30rpx;
  1011. height:30rpx;
  1012. }
  1013. .ic-back{
  1014. margin-left: 10rpx;
  1015. width: 15rpx;
  1016. height:30rpx;
  1017. }
  1018. }
  1019. .item-btn{
  1020. max-width: 200rpx;
  1021. padding: 0rpx 15rpx;
  1022. height: 48upx;
  1023. border-radius: 24upx;
  1024. line-height: 48upx;
  1025. font-size: 24upx;
  1026. color: #000;
  1027. border: 1upx solid #d8d8d8;
  1028. display: flex;
  1029. align-items: center;
  1030. justify-content: center;
  1031. }
  1032. }
  1033. }
  1034. .remarks{
  1035. height: 88upx;
  1036. padding: 0 30upx;
  1037. background: #FFFFFF;
  1038. border-radius: 16upx;
  1039. margin-top: 20upx;
  1040. display: flex;
  1041. align-items: center;
  1042. input{
  1043. width: 100%;
  1044. font-size: 28upx;
  1045. font-family: PingFang SC;
  1046. font-weight: 500;
  1047. color: #000000;
  1048. }
  1049. .input{
  1050. font-size: 28upx;
  1051. font-family: PingFang SC;
  1052. font-weight: 500;
  1053. color: #999999;
  1054. }
  1055. }
  1056. }
  1057. .btn-box{
  1058. width: 100%;
  1059. padding: 30rpx 30upx 0rpx;
  1060. position: fixed;
  1061. bottom: 0;
  1062. left: 0;
  1063. box-sizing: border-box;
  1064. background-color: #ffffff;
  1065. display: flex;
  1066. flex-direction: column;
  1067. align-items: center;
  1068. justify-content: center;
  1069. .btn{
  1070. margin-bottom: 20rpx;
  1071. width: 100%;
  1072. height: 88upx;
  1073. line-height: 88upx;
  1074. text-align: center;
  1075. font-size: 34upx;
  1076. font-family: PingFang SC;
  1077. font-weight: 400;
  1078. color: #FFFFFF;
  1079. background: #FF5C03;
  1080. border-radius: 10upx;
  1081. position: relative;
  1082. .contact-btn {
  1083. position: absolute;
  1084. width:100%;
  1085. height:100%;
  1086. display: flex;
  1087. opacity: 0;
  1088. }
  1089. }
  1090. .btn1{
  1091. margin-bottom: 20rpx;
  1092. width: 100%;
  1093. height: 88upx;
  1094. line-height: 88upx;
  1095. text-align: center;
  1096. font-size: 34upx;
  1097. font-family: PingFang SC;
  1098. font-weight: 400;
  1099. color: #FF5C03;
  1100. border: 1rpx solid #FF5C03;
  1101. border-radius: 10upx;
  1102. position: relative;
  1103. .contact-btn {
  1104. position: absolute;
  1105. width:100%;
  1106. height:100%;
  1107. display: flex;
  1108. opacity: 0;
  1109. }
  1110. }
  1111. }
  1112. .pay-type{
  1113. box-sizing: border-box;
  1114. background: #FFFFFF;
  1115. border-radius: 16upx;
  1116. margin-top: 20upx;
  1117. padding: 40upx 30upx 20rpx;
  1118. display: flex;
  1119. flex-direction: column;
  1120. justify-content: space-between;
  1121. .title{
  1122. font-size: 28upx;
  1123. font-family: PingFang SC;
  1124. font-weight: 500;
  1125. color: #999999;
  1126. line-height: 1;
  1127. margin-bottom: 10upx;
  1128. }
  1129. .item{
  1130. padding: 15upx 0upx;
  1131. display: flex;
  1132. align-items: center;
  1133. justify-content: space-between;
  1134. .left{
  1135. display: flex;
  1136. align-items: center;
  1137. image{
  1138. width: 44upx;
  1139. height: 44upx;
  1140. margin-right: 20upx;
  1141. }
  1142. .text{
  1143. font-size: 30upx;
  1144. font-family: PingFang SC;
  1145. font-weight: bold;
  1146. color: #222222;
  1147. line-height: 1;
  1148. }
  1149. }
  1150. }
  1151. }
  1152. .coupon{
  1153. background-color: #fff;
  1154. border-radius: 30rpx 30rpx 0rpx 0rpx;
  1155. height: 100%;
  1156. .empty{
  1157. display: flex;
  1158. align-items: center;
  1159. justify-content: center;
  1160. height: 650rpx;
  1161. width: 100%;
  1162. image{
  1163. width: 280rpx;
  1164. height: 200rpx;
  1165. }
  1166. }
  1167. }
  1168. .coupon-box{
  1169. overflow-y: auto;
  1170. padding: 80rpx 20rpx 80rpx;
  1171. height: 650rpx;
  1172. width: 100%;
  1173. display: flex;
  1174. flex-direction: column;
  1175. align-items: flex-start;
  1176. justify-content: flex-start;
  1177. box-sizing: border-box;
  1178. .coupon-item{
  1179. width: 100%;
  1180. display: flex;
  1181. align-items: center;
  1182. justify-content: flex-start;
  1183. margin-bottom: 16rpx;
  1184. height:170rpx;
  1185. &:last-child{
  1186. margin-bottom: 0rpx;
  1187. }
  1188. .left{
  1189. color: #fff;
  1190. font-size: 36rpx;
  1191. font-weight: bold;
  1192. text-align: center;
  1193. display: flex;
  1194. flex-direction: column;
  1195. align-items: center;
  1196. justify-content: center;
  1197. position: relative;
  1198. width: 230rpx;
  1199. image{
  1200. position: absolute;
  1201. width: 230rpx;
  1202. height:170rpx;
  1203. color: #fff;
  1204. }
  1205. .num{
  1206. font-size: 40rpx;
  1207. }
  1208. .pic-num{
  1209. font-size: 20rpx;
  1210. z-index: 99;
  1211. }
  1212. }
  1213. .right{
  1214. display: flex;
  1215. flex-direction: column;
  1216. align-items: flex-start;
  1217. justify-content: flex-start;
  1218. height:170rpx;
  1219. width: calc(100% - 230rpx);
  1220. padding: 0 17rpx 0 24rpx;
  1221. background-color: #fff;
  1222. box-sizing: border-box;
  1223. .title{
  1224. width: 100%;
  1225. font-size: 0.3 * 100rpx;
  1226. color: #282828;
  1227. height: 0.93 * 100rpx;
  1228. line-height: 0.93 * 100rpx;
  1229. border-bottom: 1px solid #f0f0f0;
  1230. }
  1231. .btns{
  1232. display: flex;
  1233. align-items: center;
  1234. justify-content: space-between;
  1235. width: 100%;
  1236. font-size: 0.2 * 100rpx;
  1237. color: #999;
  1238. height: 0.76 * 100rpx;
  1239. .btn{
  1240. width: 1.36 * 100rpx;
  1241. height: 0.44 * 100rpx;
  1242. border-radius: 0.22 * 100rpx;
  1243. font-size: 0.22 * 100rpx;
  1244. color: #fff;
  1245. text-align: center;
  1246. line-height: 0.44 * 100rpx;
  1247. background-color: #FF5C03;
  1248. .gray{
  1249. background-color: #ccc;
  1250. }
  1251. }
  1252. }
  1253. }
  1254. }
  1255. }
  1256. .pay-box{
  1257. border-radius: 30rpx 30rpx 0rpx 0rpx;
  1258. padding: 30rpx;
  1259. height: 350rpx;
  1260. background-color: #fff;
  1261. width: 100%;
  1262. display:flex;
  1263. flex-direction: column;
  1264. text-align: center;
  1265. justify-content: flex-start;
  1266. .title{
  1267. font-size: 32rpx;
  1268. font-weight: bold;
  1269. color: #111;
  1270. }
  1271. .pay-list{
  1272. margin-top: 50rpx;
  1273. display:flex;
  1274. text-align: center;
  1275. justify-content: center;
  1276. .pay-item{
  1277. margin: 10rpx;
  1278. padding: 30rpx 0rpx;
  1279. border-radius: 60rpx;
  1280. background-color: green;
  1281. flex: 1;
  1282. display:flex;
  1283. text-align: center;
  1284. justify-content: center;
  1285. image{
  1286. width:40rpx;
  1287. height:40rpx;
  1288. }
  1289. .name{
  1290. margin-left: 15rpx;
  1291. font-size: 32rpx;
  1292. font-weight: bold;
  1293. color: #fff;
  1294. }
  1295. }
  1296. .wx{
  1297. background-color: #09ba08;
  1298. }
  1299. .alipay{
  1300. background-color: #04a9ed;
  1301. }
  1302. }
  1303. }
  1304. </style>