packageOrderPay.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362
  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://zkzh-2025.oss-cn-beijing.aliyuncs.com/appimgs/0fdd75d89db84458886d38e615011048.png" mode="widthFix"></image>
  157. <image v-if="item.status!=0" src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/appimgs/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://zkzh-2025.oss-cn-beijing.aliyuncs.com/appimgs/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} 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. orderId:this.orderId
  365. }
  366. if(this.package.isShow==0){
  367. data.couponType=5;
  368. data.cateId=this.package.privateType
  369. }
  370. else if(this.package.isShow==1){
  371. data.couponType=6;
  372. data.cateId=this.package.diseaseType
  373. }
  374. getMyEnableCouponList(data).then(
  375. res => {
  376. if(res.code==200){
  377. this.coupons=res.data;
  378. }
  379. },
  380. err => {
  381. }
  382. );
  383. },
  384. getPackageOrderById(){
  385. var data={orderId:this.orderId};
  386. getPackageOrderById(data).then(res => {
  387. if(res.code==200){
  388. this.order=res.order;
  389. this.choose = res.choose || 0
  390. this.payType = this.choose == 1 ? 3:this.choose == 2 ? 1 :this.payType
  391. this.compute();
  392. this.getPackageById(this.order.packageId);
  393. }
  394. },
  395. rej => {}
  396. );
  397. },
  398. getPackageById(packageId){
  399. let data={packageId:packageId};
  400. if(this.choose == 1 || this.choose == 2) {
  401. data={
  402. packageId:packageId,
  403. choose: this.choose
  404. };
  405. }
  406. getPackageById(data).then(
  407. res => {
  408. if(res.code==200){
  409. this.package=res.data;
  410. this.payTypes=res.data.payType.split(',');
  411. this.payType=this.choose == 1 ? 3:this.choose == 2 ? 1 :this.payType
  412. this.getMyEnableCouponList();
  413. }else{
  414. }
  415. },
  416. rej => {}
  417. );
  418. },
  419. openAddress(){
  420. uni.navigateTo({
  421. url: '/pages/user/address'
  422. });
  423. },
  424. closeTip(){
  425. this.$refs.popTip.close()
  426. },
  427. confirmTip() {
  428. uni.showLoading({title:"请稍侯...",mask:true});
  429. setTimeout(()=>{
  430. uni.hideLoading();
  431. this.getPackagOrderInfo();
  432. },2000);
  433. },
  434. getPackagOrderInfo(){
  435. getPackageOrderById({orderId:this.orderId}).then(res => {
  436. this.$refs.popTip.close();
  437. if(res.code==200){
  438. this.order=res.order;
  439. if(res.order.status==1){ //1:代付款 2:已支付
  440. uni.showToast({title: '未支付成功',icon: 'none'});
  441. }
  442. else if(res.order.status==2){ //1:代付款 2:已支付
  443. this.$refs.popTip.close();
  444. // #ifdef APP-PLUS
  445. if(plus.runtime.channel=="baidu"){ //获取百度渠道标识
  446. let bdCmdType=uni.getStorageSync("bdCmdType");
  447. if(bdCmdType!=null && parseInt(bdCmdType)<=2){
  448. //this.$registerIdCode("orders",2,res.order.payPrice.toString()); //已下单
  449. }
  450. }
  451. // #endif
  452. uni.redirectTo({
  453. url:"./packageOrderPaySuccess?orderId="+this.order.orderId
  454. });
  455. }
  456. }
  457. },
  458. rej => {}
  459. );
  460. },
  461. closeCopyTip(){
  462. this.$refs.popCopyTip.close()
  463. },
  464. confirmCopyTip() {
  465. this.$refs.popCopyTip.close();
  466. var that=this;
  467. uni.setClipboardData({
  468. data:that.alipayQrCode,
  469. success:()=>{
  470. uni.showToast({
  471. title:'内容已成功复制到剪切板',
  472. icon:'none'
  473. })
  474. that.showPayTips=true;
  475. }
  476. });
  477. },
  478. doAlipay(){
  479. var data = {
  480. orderId:this.order.orderId,
  481. };
  482. var that=this;
  483. // #ifdef H5
  484. uni.showLoading();
  485. H5AliPayment(data).then(
  486. res => {
  487. uni.hideLoading()
  488. if(res.code==200){
  489. if(res.type=="tz"){
  490. window.location.href =res.data.body.url
  491. }
  492. else if(res.type=='hf'){
  493. console.log(res)
  494. that.alipayQrCode=res.data.qr_code;
  495. that.$refs.popCopyTip.open();
  496. }
  497. }else{
  498. uni.showToast({icon:'none',title: res.msg});
  499. }
  500. },
  501. rej => {}
  502. );
  503. // #endif
  504. // #ifdef APP-PLUS
  505. const tzCashier=uni.requireNativePlugin("TZBank-Cashier");
  506. uni.showLoading();
  507. aliPayment(data).then(res => {
  508. uni.hideLoading()
  509. this.$refs.popPayType.close();
  510. this.$refs.popTip.open();
  511. console.log("qxj res:"+JSON.stringify(res));
  512. console.log("qxj orderFlowNo:"+res.data.body.orderFlowNo+" businessCstNo:"+res.data.body.orderNo+" platMerCstNo:"+res.data.body.platMerCstNo);
  513. if(res.code==200){
  514. if(res.type=="tz"){
  515. const match = res.data.body.url.match(/[\?&]businessCstNo=([^&]+)/);
  516. const businessCstNo = match ? match[1] : null;
  517. console.log("qxj tzCashier:"+tzCashier+" businessCstNo:"+businessCstNo);
  518. tzCashier.pay({
  519. env:0,
  520. wxMiniProgramType:0,
  521. wxAppId:'wx703c4bd07bbd1695',
  522. wxUniversalLink:"https://yjf.runtzh.com/",
  523. orderFlowNo:res.data.body.orderFlowNo,
  524. businessCstNo:businessCstNo,
  525. platMerCstNo:res.data.body.platMerCstNo
  526. },(res)=>{
  527. console.log("qxj 支付成功:"+JSON.stringify(res));
  528. });
  529. }
  530. else if(res.type=='hf'){
  531. if (uni.getSystemInfoSync().platform == 'android') {
  532. var alipayScheme ='alipays://platformapi/startApp?&saId=10000007&qrcode=' + res.data.qr_code;
  533. }else{
  534. var alipayScheme ='alipay://platformapi/startApp?&saId=10000007&qrcode=' + res.data.qr_code;
  535. }
  536. console.log(alipayScheme)
  537. // 在uni-app中使用plus.runtime.openURL打开URL
  538. plus.runtime.openURL(alipayScheme, function(error) {
  539. // console.error('打开支付宝失败: ' + error.message);
  540. // 处理打开支付宝失败的情况,比如提示用户或者跳转到其他支付方式
  541. });
  542. }
  543. }
  544. else{
  545. uni.showToast({
  546. title:res.msg,
  547. icon:'none'
  548. })
  549. }
  550. },
  551. rej => {}
  552. );
  553. // #endif
  554. },
  555. doWxPay(){
  556. var that=this;
  557. var data = {
  558. orderId:this.orderId,
  559. };
  560. // #ifdef H5
  561. if(String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger"){
  562. uni.showLoading();
  563. H5WxPayment(data).then(
  564. res => {
  565. uni.hideLoading()
  566. if(res.code==200){
  567. if(res.type=="tz"){
  568. window.location.href =res.data.body.url
  569. // uni.setStorageSync("h5PayUrl",res.data.body.url);
  570. // console.log(res.data.body.url)
  571. // uni.redirectTo({
  572. // url:"/pages/store/payH5"
  573. // })
  574. }
  575. else if(res.type=='hf'){
  576. var payObj=JSON.parse(res.data.pay_info);
  577. jweixin.config({
  578. debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  579. appId: payObj.appId, // 必填,公众号的唯一标识
  580. timestamp: payObj.timeStamp, // 必填,生成签名的时间戳
  581. nonceStr: payObj.nonceStr, // 必填,生成签名的随机串
  582. signature: payObj.paySign, // 必填,签名
  583. jsApiList: ['chooseWXPay'] // 必填,需要使用的JS接口列表
  584. })
  585. jweixin.ready(function() {
  586. jweixin.chooseWXPay({
  587. timestamp: payObj.timeStamp, // 时间戳
  588. nonceStr: payObj.nonceStr, // 随机数
  589. package: payObj.package, //
  590. signType: payObj.signType,
  591. paySign: payObj.paySign, // 签名
  592. success: function() {
  593. uni.showToast({ title:'支付成功' });
  594. setTimeout(() => {
  595. uni.navigateTo({
  596. url: `/pages/store/packageOrderPaySuccess?orderId=${that.orderId}`
  597. });
  598. },2000);
  599. },
  600. cancel: function() {
  601. uni.showToast({ title:'取消支付', icon:'none' });
  602. },
  603. fail: function(res) {
  604. uni.showToast({title:'支付失败'+JSON.stringify(res),icon:'none'});
  605. }
  606. })
  607. })
  608. }
  609. }else{
  610. uni.showToast({
  611. icon:'none',
  612. title: res.msg,
  613. });
  614. }
  615. },
  616. rej => {}
  617. );
  618. }
  619. else{
  620. uni.showToast({
  621. title:'请在微信内打开',
  622. icon:'none'
  623. })
  624. }
  625. // #endif
  626. // #ifdef APP-PLUS
  627. plus.share.getServices(function(res){
  628. var sweixin = null;
  629. for(var i=0;i<res.length;i++){
  630. var t = res[i];
  631. if(t.id == 'weixin'){
  632. sweixin = t;
  633. }
  634. }
  635. if(sweixin){
  636. console.log('调起小程序')
  637. that.$refs.popPayType.close()
  638. that.$refs.popTip.open()
  639. //唤起微信跳转小程序
  640. sweixin.launchMiniProgram({
  641. id:getApp().globalData.miniprogamId,
  642. path:'pages_order/packagePayment?orderId='+that.orderId+"&payMethod=app",
  643. type:0
  644. },function(){
  645. console.log("微信唤起成功");
  646. return true;
  647. },function(e){
  648. console.log("微信唤起失败",e);
  649. uni.showToast({
  650. title:'微信唤起失败,请检查是否有微信应用',
  651. icon:'none'
  652. })
  653. return false;
  654. })
  655. }else{
  656. uni.showToast({
  657. title:'微信唤起失败,请检查是否有微信应用',
  658. icon:'none',
  659. duration:3000
  660. });
  661. return false;
  662. }
  663. },function(res){
  664. console.log(JSON.stringify(res));
  665. });
  666. // #endif
  667. },
  668. payOrder(){
  669. var that=this;
  670. var data = {
  671. payType:this.payType,
  672. userCouponId:this.userCouponId,
  673. addressId:this.addressId,
  674. remark:this.order.remark,
  675. orderId:this.order.orderId,
  676. };
  677. uni.showLoading();
  678. pay(data).then(
  679. res => {
  680. console.log(res)
  681. uni.hideLoading()
  682. if(res.code==200){
  683. that.$refs.popPayType.open("bottom")
  684. }else{
  685. uni.showToast({
  686. icon:'none',
  687. title: res.msg,
  688. });
  689. }
  690. },
  691. rej => {}
  692. );
  693. }
  694. }
  695. }
  696. </script>
  697. <style lang="scss">
  698. page{
  699. position: relative;
  700. }
  701. .inner-box{
  702. padding: 20upx 20upx 300upx;
  703. .address-box{
  704. box-sizing: border-box;
  705. min-height: 171upx;
  706. background: #FFFFFF;
  707. border-radius: 16upx;
  708. background-image: url(/static/images/address_bg.png);
  709. background-repeat: no-repeat;
  710. background-size: 100% 30upx;
  711. background-position: left bottom;
  712. padding: 38upx 30upx 36upx;
  713. display: flex;
  714. align-items: center;
  715. justify-content: space-between;
  716. .left{
  717. width: 92%;
  718. .name-box{
  719. display: flex;
  720. align-items: center;
  721. .text{
  722. font-size: 32upx;
  723. font-family: PingFang SC;
  724. font-weight: bold;
  725. color: #111111;
  726. line-height: 1;
  727. &.name{
  728. margin-right: 30upx;
  729. }
  730. }
  731. }
  732. .address{
  733. font-size: 28upx;
  734. font-family: PingFang SC;
  735. font-weight: 500;
  736. color: #666666;
  737. line-height: 42upx;
  738. text-align:left;
  739. margin-top: 23upx;
  740. }
  741. }
  742. .arrow-box{
  743. width: 12upx;
  744. height: 23upx;
  745. display: flex;
  746. align-items: cenetr;
  747. justify-content: cenetr;
  748. image{
  749. width: 100%;
  750. height: 100%;
  751. }
  752. }
  753. }
  754. .goods-list{
  755. margin-top: 20upx;
  756. padding: 0 30upx;
  757. background-color: #FFFFFF;
  758. border-radius: 16upx;
  759. .item{
  760. padding: 30upx 0;
  761. border-bottom: 1px solid #EDEEEF;
  762. display: flex;
  763. align-items: center;
  764. .img-box{
  765. width: 160upx;
  766. height: 160upx;
  767. margin-right: 30upx;
  768. image{
  769. width: 100%;
  770. height: 100%;
  771. }
  772. }
  773. .info-box{
  774. width: calc(100% - 190upx);
  775. height: 160upx;
  776. display: flex;
  777. flex-direction: column;
  778. justify-content: space-between;
  779. .name-box{
  780. font-size: 28upx;
  781. font-family: PingFang SC;
  782. font-weight: 500;
  783. color: #111111;
  784. line-height: 40upx;
  785. .tag{
  786. display: inline-block;
  787. padding: 0 6upx;
  788. height: 30upx;
  789. background: linear-gradient(90deg, #2583EB 0%, #E0F5FF 100%);
  790. border-radius: 4upx;
  791. margin-right: 10upx;
  792. font-size: 22upx;
  793. font-family: PingFang SC;
  794. font-weight: bold;
  795. color: #FFFFFF;
  796. line-height: 30upx;
  797. float: left;
  798. margin-top: 7upx;
  799. }
  800. }
  801. .spec{
  802. margin-top: 10upx;
  803. font-size: 24upx;
  804. font-family: PingFang SC;
  805. font-weight: 500;
  806. color: #999999;
  807. line-height: 1;
  808. }
  809. .price-num{
  810. display: flex;
  811. align-items: center;
  812. justify-content: space-between;
  813. .price{
  814. display: flex;
  815. align-items: flex-end;
  816. .unit{
  817. font-size: 24upx;
  818. font-family: PingFang SC;
  819. font-weight: 500;
  820. color: #111111;
  821. line-height: 1.2;
  822. margin-right: 4upx;
  823. }
  824. .num{
  825. font-size: 32upx;
  826. font-family: PingFang SC;
  827. font-weight: 500;
  828. color: #111111;
  829. line-height: 1;
  830. }
  831. }
  832. .num{
  833. font-size: 24upx;
  834. font-family: PingFang SC;
  835. font-weight: 500;
  836. color: #999999;
  837. line-height: 1;
  838. }
  839. }
  840. }
  841. }
  842. .sub-total{
  843. height: 88upx;
  844. display: flex;
  845. align-items: center;
  846. justify-content: flex-end;
  847. .label{
  848. font-size: 24upx;
  849. font-family: PingFang SC;
  850. font-weight: 500;
  851. color: #999999;
  852. }
  853. .price{
  854. display: flex;
  855. align-items: flex-end;
  856. .unit{
  857. font-size: 24upx;
  858. font-family: PingFang SC;
  859. font-weight: 500;
  860. color: #FF6633;
  861. line-height: 1.2;
  862. margin-right: 4upx;
  863. }
  864. .num{
  865. font-size: 32upx;
  866. font-family: PingFang SC;
  867. font-weight: bold;
  868. color: #FF6633;
  869. line-height: 1;
  870. }
  871. }
  872. }
  873. }
  874. .other-info{
  875. margin-top: 20upx;
  876. background-color: #fff;
  877. border-radius: 20upx;
  878. overflow: hidden;
  879. padding: 0 30upx;
  880. .title{
  881. height: 80upx;
  882. line-height: 80upx;
  883. font-size: 30upx;
  884. color: #000;
  885. font-weight: bold;
  886. border-bottom: 2upx solid #eeeeee;
  887. }
  888. .drug-list{
  889. margin-top: 15rpx;
  890. .drug-item{
  891. padding-bottom: 15upx;
  892. border-bottom: 1px soli #F0F0F0;
  893. display: flex;
  894. align-items: center;
  895. .img-box{
  896. width: 160upx;
  897. height: 160upx;
  898. margin-right: 30upx;
  899. flex-shrink: 0;
  900. image{
  901. width: 100%;
  902. height: 100%;
  903. }
  904. }
  905. .drug-info{
  906. width: calc(100% - 190upx);
  907. height: 160upx;
  908. display: flex;
  909. flex-direction: column;
  910. justify-content: space-between;
  911. .name-box{
  912. font-size: 28upx;
  913. font-family: PingFang SC;
  914. font-weight: 500;
  915. color: #111111;
  916. line-height: 40upx;
  917. .tag{
  918. display: inline-block;
  919. padding: 0 6upx;
  920. height: 30upx;
  921. background: linear-gradient(90deg, #2583EB 0%, #2BC7A4 100%);
  922. border-radius: 4upx;
  923. margin-right: 10upx;
  924. font-size: 22upx;
  925. font-family: PingFang SC;
  926. font-weight: bold;
  927. color: #FFFFFF;
  928. line-height: 30upx;
  929. float: left;
  930. margin-top: 7upx;
  931. }
  932. }
  933. .spec{
  934. font-size: 24upx;
  935. font-family: PingFang SC;
  936. font-weight: 500;
  937. color: #999999;
  938. line-height: 1;
  939. margin-top: 10upx;
  940. }
  941. .num-box{
  942. display: flex;
  943. align-items: center;
  944. justify-content: space-between;
  945. .price{
  946. display: flex;
  947. align-items: flex-end;
  948. .unit{
  949. font-size: 24upx;
  950. font-family: PingFang SC;
  951. font-weight: 500;
  952. color: #111111;
  953. line-height: 1.2;
  954. margin-right: 4upx;
  955. }
  956. .num{
  957. font-size: 32upx;
  958. font-family: PingFang SC;
  959. font-weight: 500;
  960. color: #111111;
  961. line-height: 1;
  962. }
  963. }
  964. .use{
  965. font-size: 24upx;
  966. font-family: PingFang SC;
  967. color: #999999;
  968. }
  969. .amount{
  970. font-size: 24upx;
  971. font-family: PingFang SC;
  972. font-weight: 500;
  973. color: #999999;
  974. line-height: 1;
  975. }
  976. }
  977. }
  978. }
  979. }
  980. .item{
  981. height: 80upx;
  982. display: flex;
  983. align-items: center;
  984. justify-content: space-between;
  985. &:last-child{
  986. border-bottom: none;
  987. }
  988. .left{
  989. flex: 1;
  990. display: flex;
  991. align-items: center;
  992. .label{
  993. min-width: 140rpx;
  994. font-size: 28upx;
  995. color: #000;
  996. }
  997. .text{
  998. font-size: 28upx;
  999. color: #1b1b1b;
  1000. }
  1001. }
  1002. .right{
  1003. display: flex;
  1004. align-items: center;
  1005. justify-content: flex-end;
  1006. .text{
  1007. font-size: 28upx;
  1008. color: #1b1b1b;
  1009. }
  1010. .ic-close{
  1011. margin-left: 10rpx;
  1012. width: 30rpx;
  1013. height:30rpx;
  1014. }
  1015. .ic-back{
  1016. margin-left: 10rpx;
  1017. width: 15rpx;
  1018. height:30rpx;
  1019. }
  1020. }
  1021. .item-btn{
  1022. max-width: 200rpx;
  1023. padding: 0rpx 15rpx;
  1024. height: 48upx;
  1025. border-radius: 24upx;
  1026. line-height: 48upx;
  1027. font-size: 24upx;
  1028. color: #000;
  1029. border: 1upx solid #d8d8d8;
  1030. display: flex;
  1031. align-items: center;
  1032. justify-content: center;
  1033. }
  1034. }
  1035. }
  1036. .remarks{
  1037. height: 88upx;
  1038. padding: 0 30upx;
  1039. background: #FFFFFF;
  1040. border-radius: 16upx;
  1041. margin-top: 20upx;
  1042. display: flex;
  1043. align-items: center;
  1044. input{
  1045. width: 100%;
  1046. font-size: 28upx;
  1047. font-family: PingFang SC;
  1048. font-weight: 500;
  1049. color: #000000;
  1050. }
  1051. .input{
  1052. font-size: 28upx;
  1053. font-family: PingFang SC;
  1054. font-weight: 500;
  1055. color: #999999;
  1056. }
  1057. }
  1058. }
  1059. .btn-box{
  1060. width: 100%;
  1061. padding: 30rpx 30upx 0rpx;
  1062. position: fixed;
  1063. bottom: 0;
  1064. left: 0;
  1065. box-sizing: border-box;
  1066. background-color: #ffffff;
  1067. display: flex;
  1068. flex-direction: column;
  1069. align-items: center;
  1070. justify-content: center;
  1071. .btn{
  1072. margin-bottom: 20rpx;
  1073. width: 100%;
  1074. height: 88upx;
  1075. line-height: 88upx;
  1076. text-align: center;
  1077. font-size: 34upx;
  1078. font-family: PingFang SC;
  1079. font-weight: 400;
  1080. color: #FFFFFF;
  1081. background: #2583EB;
  1082. border-radius: 10upx;
  1083. position: relative;
  1084. .contact-btn {
  1085. position: absolute;
  1086. width:100%;
  1087. height:100%;
  1088. display: flex;
  1089. opacity: 0;
  1090. }
  1091. }
  1092. .btn1{
  1093. margin-bottom: 20rpx;
  1094. width: 100%;
  1095. height: 88upx;
  1096. line-height: 88upx;
  1097. text-align: center;
  1098. font-size: 34upx;
  1099. font-family: PingFang SC;
  1100. font-weight: 400;
  1101. color: #2583EB;
  1102. border: 1rpx solid #2583EB;
  1103. border-radius: 10upx;
  1104. position: relative;
  1105. .contact-btn {
  1106. position: absolute;
  1107. width:100%;
  1108. height:100%;
  1109. display: flex;
  1110. opacity: 0;
  1111. }
  1112. }
  1113. }
  1114. .pay-type{
  1115. box-sizing: border-box;
  1116. background: #FFFFFF;
  1117. border-radius: 16upx;
  1118. margin-top: 20upx;
  1119. padding: 40upx 30upx 20rpx;
  1120. display: flex;
  1121. flex-direction: column;
  1122. justify-content: space-between;
  1123. .title{
  1124. font-size: 28upx;
  1125. font-family: PingFang SC;
  1126. font-weight: 500;
  1127. color: #999999;
  1128. line-height: 1;
  1129. margin-bottom: 10upx;
  1130. }
  1131. .item{
  1132. padding: 15upx 0upx;
  1133. display: flex;
  1134. align-items: center;
  1135. justify-content: space-between;
  1136. .left{
  1137. display: flex;
  1138. align-items: center;
  1139. image{
  1140. width: 44upx;
  1141. height: 44upx;
  1142. margin-right: 20upx;
  1143. }
  1144. .text{
  1145. font-size: 30upx;
  1146. font-family: PingFang SC;
  1147. font-weight: bold;
  1148. color: #222222;
  1149. line-height: 1;
  1150. }
  1151. }
  1152. }
  1153. }
  1154. .coupon{
  1155. background-color: #fff;
  1156. border-radius: 30rpx 30rpx 0rpx 0rpx;
  1157. height: 100%;
  1158. .empty{
  1159. display: flex;
  1160. align-items: center;
  1161. justify-content: center;
  1162. height: 650rpx;
  1163. width: 100%;
  1164. image{
  1165. width: 280rpx;
  1166. height: 200rpx;
  1167. }
  1168. }
  1169. }
  1170. .coupon-box{
  1171. overflow-y: auto;
  1172. padding: 80rpx 20rpx 80rpx;
  1173. height: 650rpx;
  1174. width: 100%;
  1175. display: flex;
  1176. flex-direction: column;
  1177. align-items: flex-start;
  1178. justify-content: flex-start;
  1179. box-sizing: border-box;
  1180. .coupon-item{
  1181. width: 100%;
  1182. display: flex;
  1183. align-items: center;
  1184. justify-content: flex-start;
  1185. margin-bottom: 16rpx;
  1186. height:170rpx;
  1187. &:last-child{
  1188. margin-bottom: 0rpx;
  1189. }
  1190. .left{
  1191. color: #fff;
  1192. font-size: 36rpx;
  1193. font-weight: bold;
  1194. text-align: center;
  1195. display: flex;
  1196. flex-direction: column;
  1197. align-items: center;
  1198. justify-content: center;
  1199. position: relative;
  1200. width: 230rpx;
  1201. image{
  1202. position: absolute;
  1203. width: 230rpx;
  1204. height:170rpx;
  1205. color: #fff;
  1206. }
  1207. .num{
  1208. font-size: 40rpx;
  1209. }
  1210. .pic-num{
  1211. font-size: 20rpx;
  1212. z-index: 99;
  1213. }
  1214. }
  1215. .right{
  1216. display: flex;
  1217. flex-direction: column;
  1218. align-items: flex-start;
  1219. justify-content: flex-start;
  1220. height:170rpx;
  1221. width: calc(100% - 230rpx);
  1222. padding: 0 17rpx 0 24rpx;
  1223. background-color: #fff;
  1224. box-sizing: border-box;
  1225. .title{
  1226. width: 100%;
  1227. font-size: 0.3 * 100rpx;
  1228. color: #282828;
  1229. height: 0.93 * 100rpx;
  1230. line-height: 0.93 * 100rpx;
  1231. border-bottom: 1px solid #f0f0f0;
  1232. }
  1233. .btns{
  1234. display: flex;
  1235. align-items: center;
  1236. justify-content: space-between;
  1237. width: 100%;
  1238. font-size: 0.2 * 100rpx;
  1239. color: #999;
  1240. height: 0.76 * 100rpx;
  1241. .btn{
  1242. width: 1.36 * 100rpx;
  1243. height: 0.44 * 100rpx;
  1244. border-radius: 0.22 * 100rpx;
  1245. font-size: 0.22 * 100rpx;
  1246. color: #fff;
  1247. text-align: center;
  1248. line-height: 0.44 * 100rpx;
  1249. background-color: #2583EB;
  1250. .gray{
  1251. background-color: #ccc;
  1252. }
  1253. }
  1254. }
  1255. }
  1256. }
  1257. }
  1258. .pay-box{
  1259. border-radius: 30rpx 30rpx 0rpx 0rpx;
  1260. padding: 30rpx;
  1261. height: 350rpx;
  1262. background-color: #fff;
  1263. width: 100%;
  1264. display:flex;
  1265. flex-direction: column;
  1266. text-align: center;
  1267. justify-content: flex-start;
  1268. .title{
  1269. font-size: 32rpx;
  1270. font-weight: bold;
  1271. color: #111;
  1272. }
  1273. .pay-list{
  1274. margin-top: 50rpx;
  1275. display:flex;
  1276. text-align: center;
  1277. justify-content: center;
  1278. .pay-item{
  1279. margin: 10rpx;
  1280. padding: 30rpx 0rpx;
  1281. border-radius: 60rpx;
  1282. background-color: green;
  1283. flex: 1;
  1284. display:flex;
  1285. text-align: center;
  1286. justify-content: center;
  1287. image{
  1288. width:40rpx;
  1289. height:40rpx;
  1290. }
  1291. .name{
  1292. margin-left: 15rpx;
  1293. font-size: 32rpx;
  1294. font-weight: bold;
  1295. color: #fff;
  1296. }
  1297. }
  1298. .wx{
  1299. background-color: #09ba08;
  1300. }
  1301. .alipay{
  1302. background-color: #04a9ed;
  1303. }
  1304. }
  1305. }
  1306. </style>