bookticket.vue 36 KB

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