bookticket.vue 30 KB

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