bookticket.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117
  1. <template>
  2. <view class="pages">
  3. <view class="" :style="{height: navHeight+'px' }"></view>
  4. <view class="navbar-box">
  5. <u-navbar title="订单详情" :safeAreaInsetTop="true" @leftClick="leftClick" :titleStyle="{color:'#fff'}"
  6. leftIconColor="#fff" bgColor="transparent"></u-navbar>
  7. </view>
  8. <view class="page-wrap">
  9. <view class="base-info">
  10. <view class="up u-flex">
  11. <image class="img" :src="pageContent.performImg" mode="aspectFill" alt="">
  12. <view class="text">
  13. <view class="name text-item">{{pageContent.performName}}-{{pageContent.goodsName}}</view>
  14. <view class="time text-item">日期 {{pageContent.timeDate}}({{pageContent.timeWeek}})</view>
  15. <view class="time text-item">场次 {{pageContent.performTimeStart}} -
  16. {{pageContent.performTimeEnd}}</view>
  17. <view class="num text-item">{{pageContent.goodsName}} / {{pageContent.seatTypeName}}</view>
  18. <view class=" text-item">{{pageContent.auditoriumName}}</view>
  19. <!-- <view class="position text-item">{{performInfo.name}}</view> -->
  20. <!-- <view class="addr u-flex u-row-between">
  21. <view class="u-line-1">地址:遵义市《伟大转折》演艺中心</view>
  22. <u-icon name="arrow-right" color="#2D2D2D" size="36rpx"></u-icon>
  23. </view> -->
  24. </view>
  25. </view>
  26. <view class="down">
  27. <view class="num-wrap u-flex u-row-between">
  28. <view class="title">选购数量</view>
  29. <view class="num">{{totalVisitor}}</view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="block-wrap purchaser">
  34. <view class="block-title u-flex">
  35. <view class="name">购票人信息</view>
  36. <!-- <text>用于入园身份验证</text> -->
  37. </view>
  38. <view class="" v-if="vuex_member_info.isAuth">
  39. <view class="item">姓名:{{pageContent.purchaser.name}}</view>
  40. <view class="item">手机号:{{pageContent.purchaser.mobile|hidePhoneNumber}}</view>
  41. <view class="item">身份证:{{pageContent.purchaser.idcard|maskID}}</view>
  42. </view>
  43. <view class="un-auth" v-else @click="$u.route('center/factorauth',{from:'bookticket'})">
  44. 请先<text style="color: #ED0000;">实名认证</text>
  45. </view>
  46. </view>
  47. <view class="block-wrap visitors">
  48. <view class="block-title u-flex">
  49. <view class="name">观影人信息</view>
  50. <text v-if="needIdcardNumber">需要{{needIdcardNumber}}张身份证</text>
  51. <!-- <text>用于入园身份验证</text> -->
  52. </view>
  53. <view class="people-list u-flex u-flex-wrap">
  54. <view class="people btn" v-if="visitors.length>0" v-for="(visitor,index) in visitors" :key="index">
  55. {{visitor.name}}
  56. </view>
  57. <view class="btn u-flex u-row-center"
  58. @click="visitorShow = true">
  59. <u-icon name="plus-circle" color="#2D2D2D" size="32rpx"></u-icon>
  60. <text class="text">新增/更换</text>
  61. </view>
  62. </view>
  63. <!-- <view class="no-people u-flex" v-if="!visitors.length>0">
  64. <text>游客</text>
  65. <text class="right" @click="visitorShow = true">点击选择游客</text>
  66. </view> -->
  67. <view class="peoples" v-if="visitors.length>0">
  68. <view class="peoples-item u-flex u-row-between" v-for="(visitor,index) in visitors" :key="index">
  69. <view class="left u-flex">
  70. <u-icon @click="delVisitor(visitor)" name="close-circle" color="#2D2D2D"
  71. size="32rpx"></u-icon>
  72. <text style="margin-left: 8rpx;">观影人{{ index + 1 }}</text>
  73. <text class="name">{{visitor.name}}</text>
  74. <!-- <text class="people-id">{{ visitor.idcard | maskID }}</text> -->
  75. </view>
  76. <view class="right" @click="editVisitor(visitor)">编辑</view>
  77. </view>
  78. </view>
  79. </view>
  80. <view class="coupon u-flex u-row-between block-wrap" @click="selectCoupon">
  81. <view class="left">优惠券</view>
  82. <view class="right u-flex">
  83. <text v-if="couponList.length<1||Number(this.totalPrice)<=0">暂无可用</text>
  84. <text v-if="coupon.quota" style="color: #EF2929;">已选1张优惠券</text>
  85. <text v-if="couponList.length>0&&!coupon.quota&&Number(this.totalPrice)>0">未选择优惠券</text>
  86. <u-icon name="arrow-right" color="#7F7F7F" size="24rpx"></u-icon>
  87. </view>
  88. </view>
  89. <view class="notice">
  90. <view class="title u-flex u-row-between u-border-bottom">
  91. <text>购票须知</text>
  92. </view>
  93. <view class="notice-item parse-content">
  94. <u-parse :content="pageContent.ticketNotice"></u-parse>
  95. </view>
  96. <!-- <view class="notice-item">
  97. 1.由于设备故障等不可抗力因素,存在少量场次取消的情况,会
  98. 进行退票退款
  99. </view>
  100. <view class="notice-item">
  101. 2.由于影院系统不稳定等因素,存在出票失败的情况,会进行退款
  102. </view>
  103. <view class="notice-item">
  104. 3.取票码可以在“我的-订单页”中查看
  105. </view> -->
  106. </view>
  107. </view>
  108. <u-popup :show="visitorShow">
  109. <view class="people-show-content">
  110. <view class="title">
  111. <view class="cancel" @click="visitorShow=false">取消</view>
  112. 选择观影人
  113. </view>
  114. <view class="add-btn u-flex u-row-center" @click="addVisitor">
  115. <!-- <image class="img" :src="staticUrl+'/img/car.png'" ></image> -->
  116. 添加观影人信息
  117. </view>
  118. <view class="list">
  119. <u-checkbox-group v-model="selectedVisitor" iconPlacement="left">
  120. <view class="people u-flex u-row-between" v-for="(item,index) in visitorList" :key="index">
  121. <u-checkbox activeColor="#ED0303" :label="item.name" :name="item.idcard"></u-checkbox>
  122. <u-icon name="edit-pen-fill" color="#7F7F7F" size="32rpx"
  123. @click="editVisitor(item)"></u-icon>
  124. </view>
  125. </u-checkbox-group>
  126. </view>
  127. <view class="full-btn" @click="confirmVisitor">确定</view>
  128. </view>
  129. </u-popup>
  130. <view class="page-bottom">
  131. <view class="inner u-flex u-row-between">
  132. <view class="left u-flex u-col-top">
  133. <text>实付金额:</text>
  134. <view class="total-price">
  135. ¥{{finalPrice}}
  136. <view class="bottom-coupon" v-if="coupon.quota">
  137. 优惠券共减¥{{couponAmount}}
  138. </view>
  139. </view>
  140. </view>
  141. <view class="right">
  142. <view class="btn active" v-if="totalPrice>=0&&cansubmit&&vuex_member_info.isAuth"
  143. @click="setTemplate">立即支付</view>
  144. <!-- <u-button @click="setTemplate" class="btn active" v-if="totalPrice>0&&cansubmit&&vuex_member_info.isAuth">立即支付</u-button> -->
  145. <view class="btn" v-else>立即支付</view>
  146. </view>
  147. </view>
  148. </view>
  149. <u-modal
  150. :show="umodal.show"
  151. :title="umodal.title"
  152. :content='umodal.content'
  153. confirmColor="#ED0303"
  154. @confirm="modalConfirm"
  155. ></u-modal>
  156. </view>
  157. </template>
  158. <script>
  159. import { locale } from "moment/moment";
  160. import {
  161. systemInfo
  162. } from "@/mixin.js";
  163. // #ifdef H5
  164. import wxH5 from "weixin-jsapi";
  165. // #endif
  166. export default {
  167. mixins: [systemInfo],
  168. data() {
  169. return {
  170. performId: '',
  171. performInfo: {},
  172. pageData: {}, //上个页面传过来的数据
  173. pageContent: {
  174. performName: '',
  175. goodsName: '',
  176. timeDate: '',
  177. timeWeek: '',
  178. seatTypeName: '',
  179. auditoriumName: '',
  180. performTimeEnd: '',
  181. performTimeStart: '',
  182. purchaser: {
  183. mobile: '',
  184. idcard: ''
  185. },
  186. ticketNotice: '',
  187. viewerList: [],
  188. }, //页面信息
  189. ticketNotice: '',
  190. cansubmit: true,
  191. staticUrl: this.$commonConfig.staticUrl,
  192. visitors: [], //确认的游客
  193. visitorShow: false, //游客弹层
  194. visitorList: [], //游客列表
  195. selectedVisitor: [], //选中的游客(id)
  196. params: {}, //要提交的数据
  197. orderId: '', //订单提交获取
  198. payResult: {}, //gotoPay结果
  199. paysuccess: false, //支付结果
  200. templateIdList: [], //微信小程序订阅消息
  201. umodal:{
  202. show:false,
  203. title:'温馨提示',
  204. content:''
  205. },
  206. scene:null,
  207. retailId:null,//分销码
  208. label:null,//scene解析出来的
  209. retailId:null,
  210. couponList:[],
  211. }
  212. },
  213. watch: {
  214. visitors: {
  215. handler: function(newValue, oldValue) {
  216. this.findOrderCoupons();
  217. console.log(`The value changed to ${newValue.length}`);
  218. },
  219. immediate: false
  220. }
  221. },
  222. computed: {
  223. finalPrice(){
  224. let discount = 0;
  225. let price = this.totalPrice||0;
  226. if(this.coupon.type==1){
  227. discount = this.coupon.quota || 0; // 如果没有优惠券,默认为0
  228. price = Math.max(this.totalPrice - discount,0);
  229. }else if(this.coupon.type==2){
  230. price = this.totalPrice*(this.coupon.quota/100);
  231. }
  232. // console.log('price',price);
  233. // console.log('price',typeof price);
  234. if(typeof price=='string'){
  235. price = Number(price)
  236. }
  237. return price.toFixed(2)
  238. },
  239. totalPrice() {
  240. let that = this;
  241. return this.visitors.reduce((total, item) => {
  242. let price = Number(that.pageData.salePrice);
  243. if(this.pageContent.personnelNum!==0){
  244. total = price
  245. }else{
  246. total += price;
  247. }
  248. return total;
  249. }, 0).toFixed(2);
  250. },
  251. totalVisitor() {
  252. let that = this;
  253. return this.visitors.reduce((total, item) => {
  254. total += 1;
  255. return total;
  256. }, 0);
  257. },
  258. needIdcardNumber(){
  259. if(this.pageContent.oneMany===1&&this.pageContent.personnelNum!==0){
  260. return this.pageContent.personnelNum
  261. }else if(this.pageContent.oneMany===1&&this.pageContent.personnelNum===0){
  262. return null
  263. }else if(this.pageContent.oneMany===2){
  264. return 1
  265. }
  266. },
  267. couponAmount() {
  268. let amount = 0;
  269. if (this.coupon.type == 1) {
  270. amount = this.coupon.quota || 0; // 如果没有优惠券,默认为0
  271. } else if (this.coupon.type == 2) {
  272. // 将总价和折扣转化为整数
  273. const totalPrice = Math.round(this.totalPrice * 100); // 以分为单位
  274. const discountRate = this.coupon.quota; // 折扣百分比
  275. const discountAmount = totalPrice * (discountRate / 100);
  276. const finalAmount = totalPrice - discountAmount;
  277. amount = finalAmount / 100; // 结果转换回以元为单位
  278. // console.log('this.totalPrice',this.totalPrice);
  279. // console.log('this.coupon.quota',this.coupon.quota);
  280. // console.log('amount',amount);
  281. }
  282. return amount.toFixed(2);
  283. },
  284. },
  285. onShow() {
  286. this.getSettlement();
  287. if(this.totalPrice>0){
  288. this.findOrderCoupons()
  289. }
  290. },
  291. onLoad(page) {
  292. console.log('page', page);
  293. this.pageData = page;
  294. this.performId = page.performId;
  295. this.pageData.performTimeId = page.performTimeId;
  296. this.pageData.seatTypeId = page.seatTypeId
  297. this.getSystemInfo();
  298. this.getSettlement();
  299. this.getTemplateIdList(); //获取模板列表
  300. },
  301. onUnload() {
  302. this.$u.vuex('coupon', {});
  303. },
  304. methods: {
  305. leftClick(e) {
  306. let pages = getCurrentPages();
  307. if (pages.length == 1) {
  308. uni.$u.route('/pages/index/index')
  309. } else {
  310. uni.navigateBack()
  311. };
  312. },
  313. getSettlement() {
  314. this.$u.api.getSettlement(this.pageData).then(res => {
  315. // console.log('getSettlement',res.data);
  316. this.pageContent = res.data;
  317. this.getMemberAll();
  318. }).catch(err => {
  319. console.log('getSettlement', err);
  320. })
  321. },
  322. getMemberAll() {
  323. let that = this;
  324. // const userId = this.vuex_member_info.id;
  325. const userId = this.pageContent.viewerList[0]?.id;
  326. this.$u.api.selectMemberAll({
  327. userid: userId
  328. }).then(res => {
  329. // console.log('getMemberAll',res.data);
  330. this.visitorList = res.data.list;
  331. // this.visitors = this.visitorList.filter(obj => obj.memberId==userId);
  332. this.selectedVisitor = [];
  333. this.visitorList.forEach(visitor => {
  334. if (this.visitors.find(item => item.idcard === visitor.idcard)) {
  335. this.selectedVisitor.push(visitor.idcard);
  336. }
  337. });
  338. this.visitors = this.visitorList.filter(obj => that.selectedVisitor.includes(obj.idcard));
  339. console.log('this.visitorList',this.visitorList);
  340. console.log('this.selectedVisitor',this.selectedVisitor);
  341. console.log('this.visitors',this.visitors);
  342. }).catch(err => {
  343. console.log('getMemberAll', err);
  344. })
  345. },
  346. confirmVisitor() {
  347. let that = this;
  348. if(this.needIdcardNumber&&this.needIdcardNumber!==this.selectedVisitor.length){
  349. uni.showToast({
  350. title:`身份证数量应该为${this.needIdcardNumber}张`,
  351. icon:'none'
  352. })
  353. return false
  354. }
  355. // console.log('selectedVisitor',this.selectedVisitor);
  356. this.visitorShow = false;
  357. this.visitors = this.visitorList.filter(obj => that.selectedVisitor.includes(obj.idcard)).map(item => {
  358. return {
  359. name: item.name,
  360. mobile: item.mobile,
  361. idcard: item.idcard
  362. }
  363. });
  364. // console.log('this.visitors',this.visitors);
  365. },
  366. delVisitor(visitor) {
  367. // console.log('delVisitor',visitor);
  368. // console.log('this.visitors',this.visitors);
  369. this.visitors = this.visitors.filter(obj => obj.idcard != visitor.idcard);
  370. this.selectedVisitor = this.selectedVisitor.filter(item => item != visitor.idcard);
  371. // console.log('this.visitors',this.visitors);
  372. // console.log('this.selectedVisitor',this.selectedVisitor);
  373. },
  374. addVisitor() {
  375. uni.$u.route('/center/people', {
  376. type: 'addVisitor',
  377. fromPage: 'bookticket'
  378. });
  379. },
  380. editVisitor(item) {
  381. uni.$u.route('/center/people', {
  382. type: 'editVisitor',
  383. fromPage: 'bookticket',
  384. id: item.id,
  385. name: item.name,
  386. mobile: item.mobile,
  387. idcard: item.idcard,
  388. });
  389. },
  390. getTemplateIdList() {
  391. this.$u.api.templateIdList({
  392. templateLabel: 'order_pay'
  393. }).then(res => {
  394. // console.log('getTemplateIdList', res.data);
  395. this.templateIdList = res.data.list.map(item => {
  396. return item.templateId
  397. });
  398. // if(this.templateIdList.length>0){
  399. // this.templateEven();
  400. // }
  401. }).catch(err => {
  402. console.log('getTemplateIdList', err);
  403. })
  404. },
  405. async submitorder() {
  406. let _this = this;
  407. let retailId = null;
  408. try {
  409. retailId = await new Promise((resolve, reject) => {
  410. uni.getStorage({
  411. key: 'retailId',
  412. success: function (res) {
  413. console.log('getPositionData retailId====', res.data);
  414. resolve(res.data);
  415. },
  416. fail: function (error) {
  417. reject(error);
  418. }
  419. });
  420. });
  421. console.log('getPositionData retailId', retailId);
  422. } catch (error) {
  423. console.error('获取retailId失败', error);
  424. // 在这里可以添加处理失败的逻辑
  425. }
  426. this.retailId = retailId;
  427. console.log('submitorder retailId',this.retailId);
  428. if(this.pageContent.oneMany === 2 && this.pageContent.personnelNum!==0){//一证多票,补齐观影人信息
  429. let dontNeedCardsNumber = this.pageContent.personnelNum - this.visitors.length;
  430. if(dontNeedCardsNumber>0){//
  431. for (let i = 0;i<dontNeedCardsNumber;i++) {
  432. console.log('dontNeedCardsNumber',dontNeedCardsNumber);
  433. this.visitors.push({
  434. name: this.visitors[0].name,
  435. idcard: this.visitors[0].idcard,
  436. mobile: this.visitors[0].mobile,
  437. });
  438. }
  439. }
  440. }
  441. let params = {
  442. performId: this.pageContent.performId,
  443. goodsList: [{
  444. goodsId: this.pageContent.goodsId,
  445. salePeice: this.pageContent.salePrice,
  446. saleNum: 1
  447. }],
  448. auditoriumId: this.pageContent.auditoriumId,
  449. performTimeId: this.pageContent.performTimeId,
  450. seatTypeId: this.pageContent.seatTypeId,
  451. purchaser: {
  452. name: this.pageContent.purchaser.name,
  453. mobile: this.pageContent.purchaser.mobile,
  454. idcard: this.pageContent.purchaser.idcard
  455. },
  456. viewerList: this.visitors,
  457. label:this.label,
  458. retailId:this.retailId,
  459. coupon:{
  460. memberCouponId:null
  461. }
  462. }
  463. if(this.coupon.quota){
  464. // console.log('this.coupon',this.coupon);
  465. params.coupon.memberCouponId = this.coupon.id;
  466. // return
  467. }
  468. console.log('submitorder params',params);
  469. // return
  470. // #ifdef MP
  471. params['source'] = 1
  472. // #endif
  473. // #ifdef H5
  474. params['source'] = 4
  475. // #endif
  476. this.cansubmit = false;
  477. // console.log('pageData',this.pageData);
  478. // console.log('visitors',this.visitors);
  479. // console.log('params',params);
  480. this.$u.api.submitOrder(params,{custom:{toast:false}}).then(res => {
  481. // console.log('submitOrder',res.data);
  482. this.orderId = res.data.orderId;
  483. // this.templateEven()
  484. this.gotoPay();
  485. }).catch(err => {
  486. this.cansubmit = true;
  487. uni.hideLoading();
  488. // uni.$u.toast(err.msg);
  489. // if (err.msg.includes('限购')) {
  490. this.umodal.title = '';
  491. this.umodal.content = err.msg;
  492. this.umodal.show = true;
  493. // setTimeout(() => {
  494. // uni.$u.route('/center/order', {
  495. // status: 0
  496. // });
  497. // }, 2000)
  498. // }
  499. console.log('submitOrder', err);
  500. })
  501. },
  502. modalConfirm(){
  503. this.umodal.show = false;
  504. },
  505. // 订阅消息
  506. templateEven() {
  507. let that = this
  508. wx.showModal({
  509. title: '温馨提示',
  510. content: '为更好的促进与您的交流,服务号需要实时向您发送消息',
  511. confirmText: "同意",
  512. cancelText: "拒绝",
  513. success: function(res) {
  514. if (res.confirm) {
  515. //调用订阅消息
  516. // console.log('用户点击确定');
  517. //调用订阅
  518. that.setTemplate();
  519. } else if (res.cancel) {
  520. // console.log('用户点击取消');
  521. ///显示第二个弹说明一下
  522. wx.showModal({
  523. title: '温馨提示',
  524. content: '拒绝后您将无法获取实时的消息',
  525. confirmText: "知道了",
  526. showCancel: false,
  527. success: function(res) {
  528. that.gotoPay();
  529. ///点击知道了的后续操作
  530. ///如跳转首页面
  531. }
  532. });
  533. }
  534. }
  535. });
  536. },
  537. // 设置小程序订阅消息
  538. setTemplate() {
  539. if(this.needIdcardNumber&&this.needIdcardNumber!==this.visitors.length){
  540. uni.showToast({
  541. title:'观影人信息不正确',
  542. icon:'none'
  543. })
  544. return false
  545. }
  546. let that = this;
  547. // console.log('templateIdList', this.templateIdList);
  548. // #ifdef MP
  549. uni.requestSubscribeMessage({
  550. tmplIds: that.templateIdList,
  551. success(res) {
  552. // that.gotoPay();
  553. console.log("设置小程序订阅消息 success:", res);
  554. },
  555. fail(res) {
  556. console.log("设置小程序订阅消息 fail:", res);
  557. },
  558. complete(res) {
  559. // that.gotoPay();
  560. that.submitorder();
  561. console.log("设置小程序订阅消息 complete:", res);
  562. }
  563. })
  564. // #endif
  565. // #ifdef H5
  566. that.gotoPay()
  567. // #endif
  568. },
  569. gotoPay() {
  570. this.$u.api.gotoPay({
  571. orderId: this.orderId,
  572. openid: ''
  573. }).then(res => {
  574. // this.payResult = res.data.payInfo;
  575. // this.payResult.package = res.data.payInfo.packageValue;
  576. // ygh
  577. if(!res.data.needPay){
  578. //this.payQuery();
  579. uni.$u.route('/center/orderdetails', {
  580. type:'redirectTo',
  581. id: this.orderId
  582. });
  583. }else {
  584. this.payResult = res.data.payInfo;
  585. this.payResult.package = res.data.payInfo.packageValue;
  586. // #ifdef H5
  587. this.initConfig(this.payResult)
  588. // #endif
  589. // #ifdef MP
  590. this.wxPay()
  591. // #endif
  592. }
  593. // if(this.params.paymentMode==1||this.params.paymentMode==4){
  594. // this.wxPay()
  595. // }else{
  596. // uni.$u.route('/shopping/paysuccess');
  597. // }
  598. // console.log('gotoPayres', res.data);
  599. }).catch(err => {
  600. this.cansubmit = true;
  601. // this.paypass = '';
  602. // this.checkPassShow = false;
  603. console.log('gotoPay', err);
  604. })
  605. },
  606. wxPay() {
  607. let that = this;
  608. uni.requestPayment({
  609. ...this.payResult,
  610. "provider": "wxpay",
  611. "orderInfo": {
  612. // "appid": "wx499********7c70e", // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
  613. // "noncestr": "c5sEwbaNPiXAF3iv", // 随机字符串
  614. // "package": "Sign=WXPay", // 固定值
  615. // "partnerid": "148*****52", // 微信支付商户号
  616. // "prepayid": "wx202254********************fbe90000", // 统一下单订单号
  617. // "timestamp": 1597935292, // 时间戳(单位:秒)
  618. // "sign": "A842B45937F6EFF60DEC7A2EAA52D5A0" // 签名,这里用的 MD5/RSA 签名
  619. },
  620. success(res) {
  621. that.payQuery();
  622. },
  623. fail(e) {
  624. uni.$u.route('/center/order', {
  625. status: 0
  626. });
  627. console.log('wxPayfail', e);
  628. },
  629. complete() {
  630. this.cansubmit = true;
  631. }
  632. })
  633. },
  634. payQuery() {
  635. let that = this;
  636. let retryCount = 0;
  637. let maxRetryCount = 5; // 设置最大重试次数
  638. let interval = 2000; // 设置间隔时间为2秒
  639. let timeout = 10000; // 设置超时时间为10秒
  640. let timer;
  641. uni.showLoading({
  642. title: '支付结果查询中'
  643. })
  644. timer = setInterval(() => {
  645. retryCount++;
  646. if (retryCount > maxRetryCount || retryCount * interval > timeout) {
  647. clearInterval(timer);
  648. uni.hideLoading();
  649. console.log("支付查询超时或达到最大重试次数");
  650. // 在这里添加超时或达到最大重试次数的处理逻辑
  651. uni.$u.route('/center/order');
  652. } else {
  653. console.log("第" + retryCount + "次查询");
  654. // 调用查询支付状态的方法
  655. // 如果支付状态为成功,则清除定时器并处理成功的逻辑
  656. // 如果支付状态为失败,则清除定时器并处理失败的逻辑
  657. this.$u.api.payQuery({
  658. orderId: this.orderId
  659. }).then(res => {
  660. // 0-未支付 1-已支付 2-支付中 3-支付失败 4-支付退款
  661. let payStatus = res.data.payStatus;
  662. if (payStatus === 1) {
  663. uni.$u.route('/center/orderdetails', {
  664. type:'redirectTo',
  665. id: res.data.orderId
  666. });
  667. // uni.$u.route('/center/order', {
  668. // status: 3
  669. // });
  670. // uni.$u.route('/center/paysuccess');
  671. } else if (payStatus === 0 || payStatus === 2) {
  672. this.payQuery()
  673. } else if (payStatus === 3) {
  674. uni.toast('支付失败')
  675. }
  676. clearInterval(timer);
  677. }).catch(err => {
  678. console.log('payQuery', err);
  679. }).finally(() => {
  680. uni.hideLoading()
  681. this.cansubmit = true;
  682. })
  683. }
  684. }, interval);
  685. },
  686. /**
  687. * 公众号微信支付
  688. */
  689. initConfig() {
  690. // #ifdef H5
  691. let that = this
  692. wxH5.config({
  693. debug: false, // 这里一般在测试阶段先用ture,等打包给后台的时候就改回false,
  694. appId: that.payResult.appId, // 必填,公众号的唯一标识
  695. timestamp: that.payResult.timeStamp, // 必填,生成签名的时间戳
  696. nonceStr: that.payResult.nonceStr, // 必填,生成签名的随机串
  697. signature: that.payResult.paySign, // 必填,签名
  698. jsApiList: ['chooseWXPay', 'checkJsApi'] // 必填,需要使用的JS接口列表
  699. })
  700. wxH5.ready(() => {
  701. wxH5.chooseWXPay({
  702. timestamp: that.payResult.timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
  703. nonceStr: that.payResult.nonceStr, // 支付签名随机串,不长于 32 位
  704. package: that.payResult.packageValue, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
  705. signType: 'SHA1', // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
  706. paySign: that.payResult.paySign, // 支付签名
  707. success: () => {
  708. that.payQuery();
  709. },
  710. fail: (e) => {
  711. uni.$u.route('/center/order', {
  712. status: 0
  713. });
  714. console.log('wxPayfail', e);
  715. },
  716. cancel: () => {
  717. uni.$u.route('/center/order', {
  718. status: 0
  719. });
  720. that.cansubmit = true;
  721. }
  722. })
  723. })
  724. // #endif
  725. },
  726. selectCoupon(){
  727. if(Number(this.totalPrice)<=0){
  728. return
  729. }
  730. this.$u.route('/center/couponselect',{
  731. salePrice:this.totalPrice,
  732. performId:this.performId,
  733. goodsId: this.pageContent.goodsId
  734. })
  735. },
  736. findOrderCoupons() {
  737. let param = {
  738. salePrice: this.totalPrice,
  739. performId: this.performId,
  740. goodsId: this.pageContent.goodsId
  741. };
  742. this.$u.api.findOrderCoupons(param)
  743. .then(res => {
  744. this.couponList = res.data.list || [];
  745. console.log('this.couponList',this.couponList);
  746. console.log('this.coupon.id',this.coupon.id);
  747. if (this.couponList.length < 1 || !this.couponList.some(obj => obj.id === this.coupon.id)) {
  748. this.$u.vuex('coupon', {});
  749. }
  750. })
  751. .catch(err => {
  752. // console.log('findOrderCoupons',err.data);
  753. });
  754. },
  755. }
  756. }
  757. </script>
  758. <style>
  759. page {
  760. background: linear-gradient(180deg, #ED0000 0%, #F9FBFD 50%, #fff 100%);
  761. background-repeat: no-repeat;
  762. }
  763. </style>
  764. <style lang="scss" scoped>
  765. .base-info {
  766. border-radius: 30rpx;
  767. overflow: hidden;
  768. background: radial-gradient(circle at -26rpx 294rpx, transparent 8%, #fff 4%) left, radial-gradient(circle at calc(100% + 26rpx) 294rpx, transparent 8%, #fff 4%) right;
  769. background-size: 50% 100%;
  770. background-repeat: no-repeat;
  771. padding: 34rpx 36rpx;
  772. box-sizing: border-box;
  773. margin: 30rpx 0 40rpx;
  774. .up {
  775. margin-bottom: 36rpx;
  776. .img {
  777. display: block;
  778. width: 172rpx;
  779. height: 230rpx;
  780. border-radius: 20rpx;
  781. margin-right: 32rpx;
  782. }
  783. .text {
  784. flex: 1;
  785. font-size: 22rpx;
  786. font-weight: 400;
  787. color: #606060;
  788. line-height: 1;
  789. }
  790. .text-item {
  791. margin-bottom: 18rpx;
  792. }
  793. .name {
  794. font-size: 32rpx;
  795. line-height: 1.5;
  796. font-weight: bold;
  797. color: #2D2D2D;
  798. }
  799. .addr {
  800. font-size: 24rpx;
  801. font-weight: 500;
  802. color: #2D2D2D;
  803. }
  804. }
  805. .down {
  806. position: relative;
  807. &:before {
  808. content: '';
  809. width: calc(100% + 26rpx);
  810. height: 1px;
  811. position: absolute;
  812. left: -13rpx;
  813. top: -2rpx;
  814. border-top: 4rpx dashed #F39FA0;
  815. }
  816. .num-wrap {
  817. padding-top: 36rpx;
  818. .title {
  819. font-size: 14px;
  820. color: #4E4E4E;
  821. }
  822. }
  823. }
  824. }
  825. .block-wrap {
  826. background: #FFFFFF;
  827. box-shadow: 0rpx 0rpx 20rpx 2rpx rgba(221, 221, 221, 0.5);
  828. border-radius: 20rpx;
  829. margin-bottom: 28rpx;
  830. padding: 32rpx 30rpx 34rpx;
  831. .block-title {
  832. // padding-left: 16rpx;
  833. position: relative;
  834. margin-bottom: 22rpx;
  835. font-size: 24rpx;
  836. font-weight: 500;
  837. color: #CACACA;
  838. // &:before{
  839. // content: '';
  840. // width: 6rpx;
  841. // height: 32rpx;
  842. // background: #1677FF;
  843. // border-radius: 4rpx;
  844. // position: absolute;
  845. // left: 0;
  846. // top: 50%;
  847. // margin-top: -16rpx;
  848. // }
  849. .name {
  850. font-size: 32rpx;
  851. font-weight: bold;
  852. color: #2D2D2D;
  853. margin-right: 20rpx;
  854. }
  855. }
  856. .no-people {
  857. font-size: 28rpx;
  858. font-weight: 400;
  859. color: #7F7F7F;
  860. .right {
  861. margin-left: 20rpx;
  862. color: #1677FF;
  863. }
  864. }
  865. .peoples {
  866. font-size: 28rpx;
  867. font-weight: 400;
  868. color: #7F7F7F;
  869. margin-bottom: 24rpx;
  870. .peoples-item {
  871. margin-bottom: 10rpx;
  872. }
  873. .name {
  874. margin-left: 20rpx;
  875. margin-right: 28rpx;
  876. font-size: 28rpx;
  877. font-weight: bold;
  878. color: #363636;
  879. }
  880. .people-id {
  881. font-size: 20rpx;
  882. font-weight: 400;
  883. color: #606060;
  884. }
  885. .right {
  886. font-size: 28rpx;
  887. font-weight: 400;
  888. color: #ED0303;
  889. }
  890. }
  891. }
  892. .people-list {
  893. margin-bottom: 20rpx;
  894. .btn {
  895. width: 185rpx;
  896. height: 60rpx;
  897. line-height: 60rpx;
  898. font-size: 24rpx;
  899. font-weight: 500;
  900. color: #2D2D2D;
  901. background-color: #F1F1F1;
  902. border: 1px solid #F1F1F1;
  903. border-radius: 8rpx;
  904. margin-bottom: 12rpx;
  905. .text {
  906. margin-left: 16rpx;
  907. }
  908. &.people {
  909. margin-right: 16rpx;
  910. text-align: center;
  911. background-color: #FFF2F2;
  912. border-color: #ED0303;
  913. }
  914. }
  915. }
  916. .visitors {
  917. margin-bottom: 20rpx;
  918. }
  919. .people-show-content {
  920. background: #FFFFFF;
  921. border-radius: 40rpx 40rpx 0rpx 0rpx;
  922. padding: 30rpx 40rpx;
  923. .title {
  924. position: relative;
  925. font-size: 32rpx;
  926. font-weight: 500;
  927. color: #606060;
  928. margin-bottom: 46rpx;
  929. text-align: center;
  930. .cancel {
  931. position: absolute;
  932. left: 0;
  933. top: 0;
  934. }
  935. }
  936. .add-btn {
  937. margin-bottom: 28rpx;
  938. background: #ffdee1;
  939. border-radius: 44rpx;
  940. padding: 26rpx;
  941. font-size: 24rpx;
  942. font-weight: 400;
  943. color: #ff1616;
  944. .img {
  945. width: 28rpx;
  946. height: 36rpx;
  947. margin-right: 36rpx;
  948. }
  949. }
  950. .list {
  951. /deep/ .u-radio-group {
  952. flex-wrap: wrap;
  953. }
  954. /deep/ .u-checkbox-group {
  955. flex-wrap: wrap;
  956. }
  957. overflow-y: auto;
  958. height: 40vh;
  959. .people {
  960. width: 100%;
  961. margin-bottom: 24rpx;
  962. }
  963. }
  964. .btn {}
  965. }
  966. .coupon {
  967. .left{
  968. font-weight: bold;
  969. font-size: 28rpx;
  970. color: #2D2D2D;
  971. }
  972. .right{
  973. font-weight: 400;
  974. font-size: 24rpx;
  975. color: #606060;
  976. }
  977. /deep/ .u-icon{
  978. top: 1px;
  979. margin-left: 5px;
  980. position: relative;
  981. }
  982. }
  983. .notice {
  984. background: #FFFFFF;
  985. box-shadow: 0rpx 0rpx 16rpx 2rpx rgba(232, 232, 232, 0.5);
  986. border-radius: 16rpx;
  987. padding: 44rpx 36rpx;
  988. margin-bottom: 24rpx;
  989. .title {
  990. font-size: 28rpx;
  991. font-weight: bold;
  992. color: #2D2D2D;
  993. padding-bottom: 20rpx;
  994. margin-bottom: 26rpx;
  995. border-bottom-style: dashed;
  996. }
  997. .notice-item {
  998. font-size: 24rpx;
  999. font-weight: 400;
  1000. color: #7F7F7F;
  1001. line-height: 36rpx;
  1002. margin-bottom: 8rpx;
  1003. }
  1004. }
  1005. .page-bottom {
  1006. position: relative;
  1007. z-index: 1001;
  1008. height: 98rpx;
  1009. padding: 24rpx 20rpx 50rpx;
  1010. .inner {
  1011. position: fixed;
  1012. background-color: #fff;
  1013. height: 98rpx;
  1014. left: 0;
  1015. right: 0;
  1016. bottom: 0;
  1017. padding: 24rpx 20rpx 50rpx;
  1018. box-shadow: 0rpx -4rpx 12rpx 0rpx rgba(215, 215, 215, 0.5);
  1019. .total-price {
  1020. font-size: 40rpx;
  1021. font-weight: bold;
  1022. color: #ED0000;
  1023. .bottom-coupon{
  1024. font-size: 24rpx;
  1025. }
  1026. }
  1027. .btn {
  1028. font-size: 28rpx;
  1029. height: 80rpx;
  1030. line-height: 80rpx;
  1031. border-radius: 50rpx;
  1032. padding: 0 50rpx;
  1033. background-color: #eee;
  1034. color: #333;
  1035. text-align: center;
  1036. &.active {
  1037. background: linear-gradient(90deg, #FF7979 0%, #ED0000 100%);
  1038. color: #fff;
  1039. }
  1040. }
  1041. }
  1042. }
  1043. .purchaser {
  1044. .item {
  1045. margin-bottom: 10rpx;
  1046. font-size: 26rpx;
  1047. color: #333;
  1048. }
  1049. .un-auth {
  1050. padding: 26rpx;
  1051. background-color: #eee;
  1052. color: #333;
  1053. text-align: center;
  1054. border-radius: 8rpx;
  1055. }
  1056. }
  1057. </style>