ticketlist.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085
  1. <template>
  2. <view class="pages">
  3. <view class="navbar-box">
  4. <u-navbar title="演出信息" :safeAreaInsetTop="true" @leftClick="leftClick" :titleStyle="{color:'#fff'}" leftIconColor="#fff" bgColor="transparent"></u-navbar>
  5. </view>
  6. <view class="banner">
  7. <!-- <image class="img" :src="staticUrl+'/img/bookticket-banner.png'" alt=""> -->
  8. <!-- <image class="img" :src="theatre.showImg" alt=""> -->
  9. <u-swiper
  10. :list="performInfo.photoList"
  11. height="554rpx"
  12. indicatorMode="dot"
  13. :indicatorStyle="{bottom:'100rpx'}"
  14. keyName="imageUrl"
  15. radius="0"
  16. @click="previewBanner"
  17. :indicator="false"
  18. circular
  19. ></u-swiper>
  20. <!-- <view class="content">
  21. <view class="share" @click="openShare()">
  22. <image class="icon" :src="staticUrl+'/img/share-ico.png'" ></image>
  23. </view>
  24. </view> -->
  25. </view>
  26. <view class="base-info">
  27. <view class="inner">
  28. <view class="name">{{performInfo.name}}</view>
  29. <view class="addr u-flex u-row-between">
  30. <view class="text">演出地址:{{theatre.address||''}}</view>
  31. <view class="menu u-flex">
  32. <view class="item" @click="goMap">
  33. <image class="icon" :src="staticUrl+'/img/map-ico.png'" ></image>
  34. <text>导航</text>
  35. </view>
  36. <view class="item" @click="phoneCall">
  37. <image class="icon" :src="staticUrl+'/img/phone-call-ico.png'" ></image>
  38. <text>电话</text>
  39. </view>
  40. <view class="item" @click="openShare()">
  41. <image class="icon" :src="staticUrl+'/img/share-ico-v2.png'" ></image>
  42. <text>分享</text>
  43. </view>
  44. <!-- <u-icon name="arrow-right" color="#ffffff" size="36rpx" @click="goMap"></u-icon>
  45. <u-icon name="arrow-right" color="#ffffff" size="36rpx" @click="goMap"></u-icon> -->
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="tabs-wrap">
  51. <view class="inner">
  52. <u-tabs
  53. :list="tabsArr"
  54. @click="tabsClick"
  55. lineColor="#ED0000"
  56. lineWidth="82rpx"
  57. :activeStyle="{color: '#2D2D2D',fontWeight: 'bold'}"
  58. itemStyle="width:33%; height: 46px;box-sizing:border-box"
  59. >
  60. </u-tabs>
  61. </view>
  62. </view>
  63. <view class="page-wrap">
  64. <view class="ticket" v-if="tabsIndex==0">
  65. <view class="date-block">
  66. <view class="title">演出日期</view>
  67. <view class="date-list u-flex">
  68. <view class="date-item"
  69. :class="{active:dateIndex==index,dot:performDateList.find(item => item.performDate === `${date.year}-${date.month}-${date.day}`) !== undefined}"
  70. @click="dateClick(index)"
  71. v-for="(date,index) in dateList" :key="index">
  72. <!-- <view class="name">{{ date.name || ' ' }}</view> -->
  73. <!-- <view class="name">
  74. {{ performDateList.find(item => item.performDate === date.fullDay ) !== undefined?'有演出':'无演出' }}
  75. </view> -->
  76. <view class="name">
  77. {{date.fullDay|checkWeekDate}}
  78. </view>
  79. <view class="date">{{ date.month }} - {{ date.day }}</view>
  80. <image class="selected-img" :src="staticUrl+'/img/selected.png'"></image>
  81. </view>
  82. <view class="date-item more-date u-flex u-row-center" @click="calendarShow = true">
  83. <view class="text">
  84. <view class="">更多</view>
  85. <view class="">日期</view>
  86. </view>
  87. <u-icon name="arrow-right" color="#7F7F7F" size="24rpx"></u-icon>
  88. </view>
  89. </view>
  90. </view>
  91. <!-- <view class="date-block auditorium generic-block">
  92. <view class="title">演出厅</view>
  93. <view class="date-list u-flex u-flex-wrap">
  94. <view class="date-item" :class="{active:auditoriumIndex==index}" @click="auditoriumClick(index)" v-for="(date,index) in auditoriumList" :key="index">
  95. <view class="name">{{ date.name }}</view>
  96. </view>
  97. </view>
  98. </view> -->
  99. <view class="date-block session-wrap generic-block">
  100. <view class="title">演出场次</view>
  101. <view class="empty" v-if="auditoriumList.length>=1&&sessionList.length<1">
  102. 当前日期暂无演出场次,请重新选择
  103. </view>
  104. <view class="date-list u-flex u-flex-wrap" v-else>
  105. <view class="date-item" :class="{active:sessionIndex==index}" @click="sessionClick(index)" v-for="(date,index) in sessionList" :key="index">
  106. <view class="name">{{ date.performTimeStart}} - {{date.performTimeEnd}}</view>
  107. </view>
  108. </view>
  109. </view>
  110. <!-- <view class="date-block session-wrap">
  111. <view class="title">演出场次</view>
  112. <view class="session">
  113. <view class="session-item" :class="{active:sessionIndex==index}" @click="sessionClick(index)" v-for="(date,index) in sessionList" :key="index">
  114. {{ date.performTimeStart}} - {{date.performTimeEnd}}
  115. </view>
  116. </view>
  117. <view class="empty" v-if="auditoriumList.length>=1&&sessionList.length<1">
  118. 当前日期暂无演出场次,请重新选择
  119. </view>
  120. </view> -->
  121. <view class="date-block ticket-type generic-block">
  122. <view class="title">票务信息</view>
  123. <view class="empty" v-if="ticketTypeList.length<1">
  124. 暂无门票
  125. </view>
  126. <view class="date-list u-flex u-flex-wrap">
  127. <view class="date-item" :class="{active:ticketTypeIndex==index}" @click="ticketTypeClick(index)" v-for="(date,index) in ticketTypeList" :key="index">
  128. <view class="name">{{ date.goodsName }}</view>
  129. </view>
  130. </view>
  131. <!-- <view class="type-item" :class="{active:sessionIndex==index}" v-for="(item,index) in ticketTypeList" :key="index">
  132. <view class="name-price u-flex u-row-between">
  133. <view class="name">{{item.goodsName}}</view>
  134. <view class="prices">¥ {{item.salePrice}} 起</view>
  135. </view>
  136. <view class="bottom u-flex u-row-between">
  137. <view class="left u-flex" v-html="item.goodsSnapshot||''">
  138. </view>
  139. <view class="btn" @click="book(item)" v-if="item.quantity!==0&&sessionList.length>=1">预定</view>
  140. <view class="btn disabled" v-else>无票</view>
  141. </view>
  142. </view> -->
  143. </view>
  144. <view class="date-block position-select generic-block">
  145. <view class="title u-flex u-row-between">
  146. <view class="">类型选择</view>
  147. <view v-if="positionData.seatImg" class="" style="font-size: 24rpx;color: #aaa" @click="showSeatImg">票区图</view>
  148. </view>
  149. <view class="empty" v-if="positionArr.length<1">
  150. 没有座位信息
  151. </view>
  152. <view class="date-list u-flex u-flex-wrap">
  153. <view class="date-item" :class="{active:positionIndex==index,'stock-over':date.stockNum<1&&date.stockNum!==-1}" @click="positionClick(index,date)" v-for="(date,index) in positionArr" :key="index">
  154. <view class="name">{{ date.seatTypeName }} <br />¥ {{date.salePrice}}</view>
  155. <view class="sold-out" v-if="date.stockNum<1&&date.stockNum!==-1">售罄</view>
  156. </view>
  157. </view>
  158. </view>
  159. <view class="book-btn full-btn" v-if="positionArr.length>=1&&sessionList.length>=1&&(positionIndex||positionIndex===0)" @click="book()">确定</view>
  160. <view class="full-btn gray" v-else>确定</view>
  161. </view>
  162. <!-- ticket end -->
  163. <view class="details" v-if="tabsIndex==1">
  164. <view class="details-block">
  165. <view class="title">剧情简介</view>
  166. <view class="intro parse-content">
  167. <u-parse :content="performInfo.performSnapshot"></u-parse>
  168. </view>
  169. </view>
  170. <view class="details-block actors">
  171. <view class="title u-flex u-row-between">
  172. 演职人员
  173. <view class="right u-flex" @click="$u.route('pages/actors',{performId:performId})">
  174. <text>更多</text>
  175. <u-icon name="arrow-right" color="#7F7F7F" size="24rpx"></u-icon>
  176. </view>
  177. </view>
  178. <view class="actor-list">
  179. <u-scroll-list :indicator="false">
  180. <view class="item" v-for="(item, index) in actorsArr" :key="index">
  181. <image class="img" :src="item.performerHead||staticUrl+'/img/actors.png'"></image>
  182. <view class="text">
  183. <view class="name">{{item.performerName}}</view>
  184. <view class="role u-line-1">{{item.performerRole}}</view>
  185. </view>
  186. </view>
  187. </u-scroll-list>
  188. <u-empty text="暂无" v-if="actorsArr.length<1"></u-empty>
  189. </view>
  190. </view>
  191. </view>
  192. <view class="viewingTips parse-content" v-if="tabsIndex==2">
  193. <u-parse :content="formerNotice"></u-parse>
  194. </view>
  195. </view>
  196. <!-- :maxDate="maxDate" -->
  197. <u-calendar
  198. ref="calendar"
  199. :formatter="formatter"
  200. :maxDate="maxDate"
  201. monthNum="12"
  202. :show="calendarShow"
  203. color="#EF1010"
  204. :closeOnClickOverlay="true"
  205. @close="closeCalendar"
  206. @confirm="confirmCalendar">
  207. </u-calendar>
  208. <!-- 分享选择弹出内容 -->
  209. <view class="share-option" :class="{shareShow:shareShow}">
  210. <view class="overlay" v-if="shareShow" @click="shareShow=false"></view>
  211. <!-- #ifdef MP-WEIXIN -->
  212. <button class="share-option-item wx-share" data-name="shareBtn" open-type="share">
  213. 发送给朋友
  214. </button>
  215. <!-- #endif -->
  216. <view class="share-option-item" @click="getPoster">生成海报</view>
  217. <view class="share-option-item" @click="shareShow=false">取消</view>
  218. </view>
  219. <u-popup :show="posterShow" @close="posterShow=false" ref="uni-popup">
  220. <view class="poster-wrap u-flex u-col-center">
  221. <view class="poster-inner">
  222. <view class="close-wrap" @click="posterShow=false">
  223. <u-icon name="close-circle" color="#fff" size="56rpx"></u-icon>
  224. </view>
  225. <view class="poster" id="poster" ref="poster" >
  226. <u--image :showLoading="false" :src="posterSrc" width="100%" height="65vh" mode="aspectFit"></u--image>
  227. </view>
  228. <!-- savePoster -->
  229. <view class="poster-btn" @click="saveImage">保存图片</view>
  230. </view>
  231. </view>
  232. </u-popup>
  233. <canvas canvas-id="canvas" class="canvas" style="width: 574px; height: 1042px;"></canvas>
  234. </view>
  235. </template>
  236. <script>
  237. import moment from 'moment';
  238. import { systemInfo } from "@/mixin.js";
  239. // 日历
  240. const d = new Date()
  241. const year = d.getFullYear()
  242. let month = d.getMonth() + 1
  243. month = month < 10 ? `0${month}` : month
  244. const date = d.getDate()
  245. // 日历
  246. // 算最大日期
  247. const maxd = new Date()
  248. maxd.setMonth(maxd.getMonth() + 12) // 将月份加3
  249. const maxdyear = maxd.getFullYear()
  250. let maxdmonth = maxd.getMonth() + 1
  251. maxdmonth = maxdmonth < 10 ? `0${maxdmonth}` : maxdmonth
  252. const maxddate = maxd.getDate()
  253. const theMaxDate = `${maxdyear}-${maxdmonth}-${maxddate}`
  254. // console.log('theMaxDate=============================',theMaxDate) //输出:
  255. //算最大日期
  256. let parentThis= null;
  257. export default {
  258. mixins:[systemInfo],
  259. data() {
  260. return {
  261. performId:'',
  262. staticUrl:this.$commonConfig.staticUrl,
  263. tabsArr:[
  264. {name:'票务购买'},
  265. {name:'演出详情'},
  266. {name:'观影须知'}
  267. ],
  268. theatre:{},
  269. tabsIndex:0,
  270. dateList:[],
  271. dateIndex:0,
  272. calendarShow:false,//日历
  273. // maxDate:`${year}-${month}-${date + 30}`,
  274. maxDate:theMaxDate,
  275. auditoriumList:[],//演艺厅
  276. auditoriumIndex:0,
  277. sessionList:[],//演出场次
  278. sessionIndex:0,
  279. ticketTypeList:[],//门票
  280. actorsArr:[],
  281. shareShow:false,
  282. posterShow:false,
  283. posterSrc:'',
  284. posterSrcType:null,
  285. performInfo:{},//节目详情
  286. formerNotice:{},//节目观影须知
  287. performDateList:[],//有票的日期
  288. // firstGet:0,
  289. ticketTypeIndex:0,
  290. positionData:{},//座位信息接口
  291. positionArr:[],
  292. positionIndex:null,
  293. }
  294. },
  295. onShow() {
  296. },
  297. onLoad(page) {
  298. // console.log('ticketlist page',page);
  299. parentThis = this;
  300. const scene = decodeURIComponent(page.scene);
  301. scene&&uni.setStorage({
  302. key:'scene',
  303. data:scene
  304. });
  305. // console.log('scene=========',scene);
  306. if(scene&&scene!='undefined'){
  307. this.$u.api.uncompress({scene:scene}).then(res=>{
  308. this.performId = res.data.performId;
  309. this.getPerformData();
  310. // this.getSystemInfo();
  311. let today = new Date();
  312. this.setDate(today);
  313. this.getPerformInfo();
  314. this.getPerformerNotice();
  315. // this.label = res.data.label;
  316. // console.log('uncompress',res.data);
  317. }).catch(err=>{
  318. console.log('uncompress',err);
  319. })
  320. }else{
  321. this.performId = page.id;
  322. this.getPerformData();
  323. // this.getSystemInfo();
  324. let today = new Date();
  325. this.setDate(today);
  326. this.getPerformInfo();
  327. this.getPerformerNotice();
  328. }
  329. },
  330. onReady() {
  331. // 如果需要兼容微信小程序的话,需要用此写法
  332. this.$refs.calendar.setFormatter(this.formatter);
  333. },
  334. methods: {
  335. leftClick(e){
  336. let pages = getCurrentPages();
  337. if(pages.length==1){
  338. uni.$u.route('/pages/index/index')
  339. }else{
  340. uni.navigateBack()
  341. };
  342. },
  343. uncompress(scene){
  344. this.$u.api.uncompress({scene:scene}).then(res=>{
  345. this.performId = res.data.performId;
  346. // this.label = res.data.label;
  347. // console.log('uncompress',res.data);
  348. }).catch(err=>{
  349. console.log('uncompress',err);
  350. })
  351. },
  352. getPerformData(){
  353. this.$u.api.performSell({performId:this.performId}).then(res=>{
  354. // console.log('getPerformData',res.data);
  355. this.theatre = res.data.theatreList[0];
  356. this.auditoriumList = res.data.theatreList[0].auditoriumList;
  357. // this.ticketTypeList = res.data.goodsList;
  358. // this.performDateList = this.auditoriumList[this.auditoriumIndex].performDateList;
  359. this.getDate()
  360. // console.log('auditoriumList',this.auditoriumList);
  361. }).catch(err=>{
  362. console.log('getPoster',err);
  363. })
  364. },
  365. getPerformInfo(){
  366. this.$u.api.performInfo({id:this.performId}).then(res=>{
  367. // console.log('getPerformInfo',res.data);
  368. this.performInfo = res.data;
  369. this.actorsArr = res.data.performerList;
  370. }).catch(err=>{
  371. console.log('getPerformInfo',err);
  372. })
  373. },
  374. getPerformerNotice(){
  375. this.$u.api.performerNotice({performId:this.performId}).then(res=>{
  376. // console.log('getPerformerNotice',res.data);
  377. this.formerNotice = res.data.performNotice;
  378. }).catch(err=>{
  379. console.log('getPerformerNotice',err);
  380. })
  381. },
  382. getDate(){
  383. let param = {
  384. auditoriumId:this.auditoriumList[this.auditoriumIndex]?.id,//演艺厅ID(演艺厅列表)
  385. performId:this.performId,
  386. };
  387. this.$u.api.getAuditoriumDate(param).then(res=>{
  388. // console.log('getDate',res.data);
  389. this.performDateList = res.data.list||[];
  390. this.setDate();
  391. // this.getTimes();
  392. }).catch(err=>{
  393. console.log('getDate',err);
  394. })
  395. },
  396. getTimes(){
  397. // this.firstGet++;
  398. uni.showLoading();
  399. let auditoriumId= this.auditoriumList[this.auditoriumIndex]?.id;
  400. if(!auditoriumId){return}
  401. // console.log('this.dateList',this.dateList);
  402. // console.log('this.dateIndex',this.dateIndex);
  403. let dateOBJ = this.dateList[this.dateIndex];
  404. let param = {
  405. auditoriumId:auditoriumId,//演艺厅ID(演艺厅列表)
  406. performId:this.performId,
  407. date:`${dateOBJ.year}-${dateOBJ.month}-${dateOBJ.day}`
  408. };
  409. // console.log('param',param);
  410. this.$u.api.getAuditoriumTimes(param).then(res=>{
  411. // console.log('getTimes',res.data);
  412. this.sessionList = res.data.list.map(item=>{
  413. item.performTimeStart = item.performTimeStart;
  414. item.performTimeEnd = item.performTimeEnd;
  415. return item
  416. });
  417. this.sessionIndex = 0;
  418. let session = this.sessionList[this.sessionIndex];
  419. this.getPositionData();
  420. }).catch(err=>{
  421. console.log('getPoster',err);
  422. })
  423. },
  424. formatter: (day) => {
  425. if(!parentThis){
  426. return
  427. }
  428. day.date = moment(day.date).format("YYYY-MM-DD HH:mm:ss")
  429. // console.log('day',day);
  430. // console.log('thisthisthisthisthisthisthisthisthis',parentThis);
  431. // console.log('==================================',day.date.toISOString().split('T')[0]);
  432. let ticket = parentThis.performDateList.find(item => item.performDate === day.date.split(' ')[0]);
  433. if(ticket){
  434. day.dot = true
  435. }
  436. // if(ticket&&ticket.ishave){
  437. // day.bottomInfo = '有票'
  438. // day.dot = true
  439. // }else if(ticket){
  440. // day.dot = true
  441. // }
  442. return day
  443. },
  444. setDate(firstDay,isSelect){
  445. // console.log('this.performDateList',this.performDateList);
  446. if(this.performDateList[0]?.performDate&&!isSelect){
  447. // firstDay = new Date(this.performDateList[0].performDate);
  448. const uniquePerformDateList = Array.from(new Set(this.performDateList.map(JSON.stringify))).map(JSON.parse);//去重
  449. // console.log('uniquePerformDateList',uniquePerformDateList);
  450. let arr = uniquePerformDateList.slice(0, 3);//只要前三项
  451. this.dateList = arr.map(item=>{
  452. // console.log('uniquePerformDateList item',item);
  453. let day = item.performDate.split('-');
  454. // console.log('setDate day',day);
  455. return { year:day[0],month:String(day[1]),day:String(day[2]), fullDay:`${day[0]}-${String(day[1])}-${String(day[2])}`}
  456. });
  457. // console.log('this.dateList',this.dateList);
  458. this.dateIndex = 0;
  459. this.getTimes();
  460. //
  461. return
  462. }
  463. // console.log('this.dateListthis.dateListthis.dateListthis.dateList',this.dateList);
  464. // 前端写演出日期(今天,明天,后天)
  465. let today = firstDay||new Date();
  466. // console.log('today=========',today);
  467. let tomorrow = new Date(today.getTime());
  468. tomorrow.setDate(today.getDate() + 1);
  469. let afterTomorrow = new Date(today.getTime());
  470. afterTomorrow.setDate(today.getDate() + 2);
  471. this.dateList = [
  472. {
  473. year: today.getFullYear(),
  474. month: String(today.getMonth() + 1).padStart(2, '0'),
  475. day: String(today.getDate()).padStart(2, '0'),
  476. name: '日期',
  477. fullDay:`${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${ String(today.getDate()).padStart(2, '0')}`
  478. },
  479. {
  480. year: tomorrow.getFullYear(),
  481. month: String(tomorrow.getMonth() + 1).padStart(2, '0'),
  482. day: String(tomorrow.getDate()).padStart(2, '0'),
  483. name: '日期',
  484. fullDay:`${tomorrow.getFullYear()}-${String(tomorrow.getMonth() + 1).padStart(2, '0')}-${ String(tomorrow.getDate()).padStart(2, '0')}`
  485. },
  486. {
  487. year: afterTomorrow.getFullYear(),
  488. month: String(afterTomorrow.getMonth() + 1).padStart(2, '0'),
  489. day: String(afterTomorrow.getDate()).padStart(2, '0'),
  490. name: '日期',
  491. fullDay:`${afterTomorrow.getFullYear()}-${String(afterTomorrow.getMonth() + 1).padStart(2, '0')}-${ String(afterTomorrow.getDate()).padStart(2, '0')}`
  492. }
  493. ];
  494. this.getTimes()
  495. // console.log('this.dateList ',this.dateList);
  496. },
  497. dateClick(index){
  498. this.dateIndex = index;
  499. this.ticketTypeIndex = 0;
  500. this.positionIndex = 0;
  501. this.getTimes()
  502. },
  503. auditoriumClick(index){
  504. this.auditoriumIndex = index;
  505. this.getDate();
  506. },
  507. confirmCalendar(e){
  508. // console.log('confirmCalendar',e);
  509. // this.getDate(e)
  510. this.dateIndex = 0;
  511. this.setDate( new Date(e),true );
  512. // console.log('maxDate',this.maxDate);
  513. // console.log('dateList',this.dateList);
  514. this.calendarShow = false;
  515. },
  516. closeCalendar(){
  517. this.calendarShow = false;
  518. },
  519. tabsClick(e){
  520. // console.log('tabsClick',e);
  521. this.tabsIndex = e.index;
  522. },
  523. sessionClick(index){
  524. if(this.sessionIndex==index){
  525. // console.log('不变');
  526. return
  527. }
  528. this.sessionIndex = index;
  529. let session = this.sessionList[this.sessionIndex];
  530. this.getPositionData();
  531. this.ticketTypeIndex = 0;
  532. this.positionIndex = 0;
  533. console.log('sessionClick',this.sessionList[this.sessionIndex]);
  534. },
  535. getPositionData(){
  536. let session = this.sessionList[this.sessionIndex]||{};
  537. let ticketType = this.ticketTypeList[this.ticketTypeIndex];
  538. let params ={
  539. performId:this.performId,
  540. // goodsId:ticketType.id,
  541. auditoriumId:this.auditoriumList[this.auditoriumIndex].id,
  542. performTimeId:session.id,
  543. }
  544. this.$u.api.selectRegion(params).then(res=>{
  545. // console.log('getPositionData',res.data);
  546. this.positionData = res.data;
  547. // this.positionArr = res.data.regionPriceList||[];
  548. this.ticketTypeList = res.data.goodsList||[];
  549. this.goodsSnapshot = this.ticketTypeList[this.ticketTypeIndex]?.goodsSnapshot;
  550. this.positionArr = this.ticketTypeList[this.ticketTypeIndex]?.regionList||[];
  551. let sellableProductIndex = this.findFirstSellableProductIndex();
  552. this.positionIndex = sellableProductIndex;
  553. uni.hideLoading();
  554. }).catch(err=>{
  555. uni.hideLoading();
  556. console.log('getPositionData',err);
  557. })
  558. },
  559. ticketTypeClick(index){
  560. if(this.ticketTypeIndex==index){
  561. // console.log('不变');
  562. return
  563. }
  564. this.ticketTypeIndex = index;
  565. // this.getPositionData();
  566. this.positionArr = this.ticketTypeList[this.ticketTypeIndex]?.regionList||[];
  567. let sellableProductIndex = this.findFirstSellableProductIndex();
  568. this.positionIndex = sellableProductIndex;
  569. },
  570. positionClick(index,date){
  571. if(this.positionIndex==index){
  572. // console.log('不变');
  573. return
  574. }else if(date.stockNum<1&&date.stockNum!==-1){
  575. uni.showToast({
  576. title:'已售罄',
  577. icon:'none'
  578. })
  579. return
  580. }
  581. this.positionIndex = index;
  582. },
  583. findFirstSellableProductIndex(){
  584. // 检查数组是否为空
  585. if (!Array.isArray(this.positionArr) || this.positionArr.length === 0) {
  586. return null;
  587. }
  588. // 遍历数组,找到第一个可售的产品
  589. for (let i = 0; i < this.positionArr.length; i++) {
  590. if (this.positionArr[i].stockNum > 0 || this.positionArr[i].stockNum === -1) {
  591. return i; // 返回第一个可售产品的索引
  592. }
  593. }
  594. return null;
  595. },
  596. book(item){
  597. // console.log('book',item);
  598. // console.log('performInfo',this.performInfo);
  599. let session = this.sessionList[this.sessionIndex];
  600. // console.log('session',session);
  601. let performTimeStart = session.performTimeStart;
  602. let performTimeEnd = session.performTimeEnd;
  603. let dateOBJ = this.dateList[this.dateIndex];
  604. let ticketType = this.ticketTypeList[this.ticketTypeIndex];
  605. let seatType = this.positionArr[this.positionIndex];
  606. // console.log('ticketType',ticketType);
  607. let theatre = this.theatre;
  608. let params ={
  609. performId:this.performId,
  610. goodsId:ticketType.id,
  611. auditoriumId:this.auditoriumList[this.auditoriumIndex].id,
  612. performTimeId:session.id,
  613. seatTypeId:seatType.seatTypeId,
  614. salePrice:seatType.salePrice,
  615. theatreId:theatre.id,
  616. theatreName:theatre.name
  617. }
  618. // console.log('book params',params);
  619. uni.$u.route('pages/bookticket',params)
  620. // 调整选择位置类型页面
  621. // uni.$u.route('pages/chosenposition',{
  622. // goodsId:item.id,
  623. // performId:this.performId,
  624. // performName:this.performInfo.name,
  625. // day:`${dateOBJ.year}-${dateOBJ.month}-${dateOBJ.day}`,
  626. // performTimeStart:session.performTimeStart,
  627. // performTimeEnd:session.performTimeEnd,
  628. // performTimeId:session.id,
  629. // auditoriumId:this.auditoriumList[this.auditoriumIndex].id
  630. // })
  631. },
  632. openShare(){
  633. if(!this.performInfo.posterImg){
  634. uni.$u.toast('没有节目信息');
  635. return false
  636. }
  637. this.shareShow = true;
  638. },
  639. // 海报相关开始
  640. getPoster(item){
  641. this.posterShow = true;
  642. this.shareShow = false;
  643. // 后端生成海报
  644. // this.$u.api.performQrcode({performId:this.performId}).then(res=>{
  645. // this.posterSrc = res.data.imageUrl;
  646. // // console.log('getPoster',res.data);
  647. // }).catch(err=>{
  648. // console.log('getPoster',err);
  649. // })
  650. //前端生成海报
  651. uni.showLoading({
  652. title: '生成海报中'
  653. });
  654. // 前端生成海报开始
  655. let that = this;
  656. const ctx = uni.createCanvasContext('canvas', this);
  657. // 加载海报背景图
  658. uni.getImageInfo({
  659. src: this.performInfo.posterImg,
  660. success: res1 => {
  661. const img1 = res1.path;
  662. // 加载海报二维码
  663. uni.getImageInfo({
  664. src: this.performInfo.appletQrcode,
  665. success: res2 => {
  666. const img2 = res2.path;
  667. // 绘制海报背景图
  668. ctx.drawImage(img1, 0, 0, 574, 1042);
  669. // 绘制海报二维码
  670. ctx.drawImage(img2, 398, 868, 114, 114);
  671. // 绘制完成后导出图片并显示
  672. ctx.draw(false, () => {
  673. uni.canvasToTempFilePath({
  674. canvasId: 'canvas',
  675. success: res3 => {
  676. this.posterSrc = res3.tempFilePath;
  677. this.posterSrcType = 'local';
  678. },
  679. fail: err => {
  680. console.error(err);
  681. },
  682. }, this);
  683. });
  684. },
  685. fail: err2 => {
  686. console.error(err2);
  687. },
  688. });
  689. },
  690. fail: err1 => {
  691. console.error(err1);
  692. },
  693. complete: () => {
  694. uni.hideLoading()
  695. }
  696. });
  697. // 前端生成海报结束
  698. },
  699. saveImage() {
  700. const systemInfo = uni.getSystemInfoSync(); // 调用 getSystemInfoSync() 函数获取系统信息
  701. if (systemInfo.ua.indexOf('MicroMessenger') != -1 ){
  702. uni.$u.toast('请长按图片下载');
  703. return
  704. }
  705. let that = this;
  706. uni.showLoading({
  707. title: '保存中'
  708. });
  709. if(this.posterSrcType == 'local'){
  710. let params = {
  711. tempFilePath:that.posterSrc
  712. }
  713. that.saveImageToPhotosAlbum(params);
  714. return
  715. }
  716. uni.downloadFile({
  717. url: this.posterSrc,
  718. success(res) {
  719. if (res.statusCode === 200) {
  720. that.saveImageToPhotosAlbum(res)
  721. } else {
  722. uni.showToast({
  723. title: '下载图片失败',
  724. icon: 'none'
  725. });
  726. }
  727. },
  728. fail(e) {
  729. console.log('下载图片失败', e);
  730. console.log('posterSrc',that.posterSrc);
  731. uni.showToast({
  732. title: '下载图片失败',
  733. icon: 'none'
  734. });
  735. }
  736. });
  737. },
  738. saveImageToPhotosAlbum(res){
  739. let that = this;
  740. uni.saveImageToPhotosAlbum({
  741. filePath: res.tempFilePath,
  742. success() {
  743. uni.showToast({
  744. title: '保存到相册成功',
  745. icon: 'success'
  746. });
  747. },
  748. fail(err) {
  749. console.log('保存图片失败',err);
  750. if (err.errMsg === 'saveImageToPhotosAlbum:fail auth deny') {
  751. uni.getSetting({
  752. success(res) {
  753. if (!res.authSetting['scope.writePhotosAlbum']) {
  754. uni.showModal({
  755. title: '提示',
  756. content: '您还没有授权访问相册,请前往设置页面打开权限。',
  757. confirmText: '去设置',
  758. success(res) {
  759. if (res.confirm) {
  760. uni.openSetting();
  761. }
  762. }
  763. });
  764. } else {
  765. uni.showToast({
  766. title: '保存图片失败',
  767. icon: 'none'
  768. });
  769. }
  770. }
  771. });
  772. } else {
  773. uni.showToast({
  774. title: '保存图片失败',
  775. icon: 'none'
  776. });
  777. }
  778. },
  779. complete() {
  780. uni.hideLoading();
  781. that.posterShow = false;
  782. }
  783. });
  784. },
  785. // 海报相关结束
  786. goMap(){
  787. uni.openLocation({
  788. latitude:Number(this.theatre.latitude), //维度
  789. longitude: Number(this.theatre.longitude), //经度
  790. name: this.theatre.name, //目的地定位名称
  791. scale: 15, //缩放比例
  792. address: this.theatre.address //导航详细地址
  793. })
  794. },
  795. phoneCall(){
  796. // console.log('this.theatre',this.theatre);
  797. uni.makePhoneCall({
  798. phoneNumber: this.theatre.customerServiceMobile,
  799. success() {
  800. console.log('success');
  801. },
  802. fail() {
  803. console.log('fail');
  804. }
  805. });
  806. },
  807. showSeatImg(){
  808. if(!this.positionData.seatImg){
  809. uni.$u.toast('没有图片')
  810. return
  811. }
  812. let urls = [];
  813. urls.push(this.positionData.seatImg)
  814. uni.previewImage({
  815. urls: urls,
  816. })
  817. },
  818. previewBanner(index){
  819. let urls = this.performInfo.photoList.map(item=>{
  820. return item.imageUrl
  821. });
  822. // console.log('urls',urls);
  823. uni.previewImage({
  824. urls: urls,
  825. current:index
  826. })
  827. }
  828. }
  829. }
  830. </script>
  831. <style lang="scss" scoped>
  832. .banner{
  833. position: relative;
  834. .img{
  835. width: 750rpx;
  836. height: 554rpx;
  837. display: block;
  838. }
  839. .content{
  840. position: absolute;
  841. width: 100%;
  842. box-sizing: border-box;
  843. padding: 0 32rpx;
  844. left: 0;
  845. bottom: 200rpx;
  846. }
  847. .share{
  848. overflow: hidden;
  849. margin-bottom: 100rpx;
  850. .icon{
  851. float: right;
  852. display: block;
  853. width: 32rpx;
  854. height: 32rpx;
  855. padding: 10rpx;
  856. border-radius: 50%;
  857. background-color: rgba(0,0,0,0.4);
  858. }
  859. }
  860. }
  861. .base-info{
  862. position: relative;
  863. // margin-bottom: 54rpx;
  864. .inner{
  865. position: relative;
  866. padding: 50rpx 38rpx 58rpx 40rpx;
  867. background-color: #FFFFFF;
  868. border-radius: 32rpx 32rpx 0rpx 0rpx;
  869. margin-top: -30px;
  870. border-bottom: 12rpx solid #F7F8F9;
  871. }
  872. .name{
  873. font-size: 40rpx;
  874. font-weight: 800;
  875. color: #2D2D2D;
  876. margin-bottom: 26rpx;
  877. }
  878. .addr{
  879. font-size: 26rpx;
  880. font-weight: 400;
  881. color: #606060;
  882. }
  883. .menu{
  884. .item{
  885. margin-left: 18rpx;
  886. font-size: 18rpx;
  887. font-weight: 400;
  888. color: #999999;
  889. text-align: center;
  890. }
  891. .icon{
  892. width: 62rpx;
  893. height: 64rpx;
  894. display: block;
  895. margin-bottom: 4rpx;
  896. }
  897. }
  898. }
  899. .tabs-wrap{
  900. position: relative;
  901. margin-bottom: 54rpx;
  902. &::after{
  903. content: '';
  904. width: 100%;
  905. height: 1px;
  906. background-color: #eee;
  907. position: absolute;
  908. left: 0;
  909. right: 0;
  910. bottom: -46rpx;
  911. }
  912. .inner{
  913. position: relative;
  914. padding-top: 48rpx;
  915. background-color: #FFFFFF;
  916. // border-radius: 32rpx 32rpx 0rpx 0rpx;
  917. height: 46rpx;
  918. // margin-top: -30px;
  919. }
  920. }
  921. .date-block{
  922. margin-bottom: 64rpx;
  923. }
  924. .title{
  925. font-size: 32rpx;
  926. font-weight: bold;
  927. color: #2D2D2D;
  928. line-height: 48rpx;
  929. margin-bottom: 38rpx;
  930. }
  931. .empty{
  932. background-color: #636363;
  933. color: #979797;
  934. border-radius: 8rpx;
  935. padding: 24rpx;
  936. text-align: center;
  937. }
  938. .session-wrap{
  939. }
  940. .session{
  941. display: grid;
  942. grid-template-columns: repeat(3, 1fr);
  943. gap: 20rpx;
  944. .session-item{
  945. height: 80rpx;
  946. line-height: 80rpx;
  947. border-radius: 12rpx;
  948. border: 2rpx solid #636363;
  949. text-align: center;
  950. font-size: 24rpx;
  951. font-weight: 400;
  952. color: #636363;
  953. &.active{
  954. color: #ED0000;
  955. border-color: #ED0000;
  956. }
  957. }
  958. }
  959. .ticket-type{
  960. .type-item{
  961. background: #FFFFFF;
  962. box-shadow: 0rpx 2rpx 12rpx 0rpx rgba(180,180,180,0.5);
  963. border-radius: 20rpx;
  964. margin-bottom: 20rpx;
  965. padding: 38rpx 40rpx;
  966. .name-price{
  967. margin-bottom: 26rpx;
  968. }
  969. .name{
  970. font-size: 28rpx;
  971. font-weight: 500;
  972. color: #363636;
  973. }
  974. .prices{
  975. font-size: 36rpx;
  976. font-weight: bold;
  977. color: #ED0000;
  978. }
  979. .ishave{
  980. margin-bottom: 26rpx;
  981. .text{
  982. height: 30rpx;
  983. line-height: 30rpx;
  984. padding: 0 22rpx;
  985. background: #FFC8C8;
  986. border-radius: 20rpx;
  987. font-size: 20rpx;
  988. font-weight: 400;
  989. color: #ED0000;
  990. }
  991. }
  992. .bottom{
  993. font-size: 22rpx;
  994. font-weight: 400;
  995. color: #7F7F7F;
  996. .btn{
  997. height: 60rpx;
  998. line-height: 60rpx;
  999. background: linear-gradient(90deg, #FF7979 0%, #ED0000 100%);
  1000. border-radius: 30rpx;
  1001. padding: 0 36rpx;
  1002. font-size: 28rpx;
  1003. font-weight: 500;
  1004. color: #FFFFFF;
  1005. &.disabled{
  1006. background: #979797;
  1007. }
  1008. }
  1009. }
  1010. }
  1011. }
  1012. .details{
  1013. .title{}
  1014. .details-block{
  1015. background: #FFFFFF;
  1016. box-shadow: 0rpx 2rpx 12rpx 2rpx rgba(221,221,221,0.5);
  1017. border-radius: 20rpx;
  1018. margin-bottom: 24rpx;
  1019. padding: 36rpx;
  1020. &.actors{
  1021. .title{
  1022. .right{
  1023. font-size: 24rpx;
  1024. font-weight: 400;
  1025. color: #7F7F7F;
  1026. }
  1027. }
  1028. }
  1029. }
  1030. .intro{
  1031. font-size: 26rpx;
  1032. font-weight: 400;
  1033. color: #4E4E4E;
  1034. line-height: 40rpx;
  1035. }
  1036. .actor-list{
  1037. .item{
  1038. flex-shrink: 0;
  1039. width: 160rpx;
  1040. text-align: center;
  1041. margin-right: 24rpx;
  1042. }
  1043. .img{
  1044. display: block;
  1045. width: 100%;
  1046. height: 200rpx;
  1047. margin-bottom: 16rpx;
  1048. }
  1049. .name{
  1050. font-size: 28rpx;
  1051. font-weight: 500;
  1052. color: #2D2D2D;
  1053. line-height: 42rpx;
  1054. margin-bottom: 4rpx;
  1055. }
  1056. .role{
  1057. font-size: 24rpx;
  1058. font-weight: 400;
  1059. color: #7F7F7F;
  1060. line-height: 36rpx;
  1061. }
  1062. }
  1063. }
  1064. .canvas{
  1065. position: fixed;
  1066. left: -99999px;
  1067. }
  1068. </style>