ticketlist.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  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. <view class="content">
  10. <view class="share" @click="openShare(item)">
  11. <image class="icon" :src="staticUrl+'/img/share-ico.png'" ></image>
  12. </view>
  13. <view class="name">{{theatre.name}}</view>
  14. <view class="addr u-flex u-row-between">
  15. <view class="text">{{theatre.address}}</view>
  16. <u-icon name="arrow-right" color="#ffffff" size="36rpx" @click="goMap"></u-icon>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="tabs-wrap">
  21. <view class="inner">
  22. <u-tabs
  23. :list="tabsArr"
  24. @click="tabsClick"
  25. lineColor="#ED0000"
  26. lineWidth="82rpx"
  27. :activeStyle="{color: '#2D2D2D',fontWeight: 'bold'}"
  28. itemStyle="width:33%; height: 46px;box-sizing:border-box"
  29. >
  30. </u-tabs>
  31. </view>
  32. </view>
  33. <view class="page-wrap">
  34. <view class="ticket" v-if="tabsIndex==0">
  35. <view class="date-block auditorium">
  36. <view class="title">演出厅</view>
  37. <view class="date-list u-flex u-flex-wrap">
  38. <view class="date-item" :class="{active:auditoriumIndex==index}" @click="auditoriumClick(index)" v-for="(date,index) in auditoriumList" :key="index">
  39. <view class="name">{{ date.name }}</view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="date-block">
  44. <view class="title">演出日期</view>
  45. <view class="date-list u-flex">
  46. <view class="date-item" :class="{active:dateIndex==index}" @click="dateClick(index)" v-for="(date,index) in dateList" :key="index">
  47. <view class="name">{{ date.name }}</view>
  48. <view class="date">{{ date.month }} - {{ date.day }}</view>
  49. </view>
  50. <view class="date-item more-date u-flex u-row-center" @click="calendarShow = true">
  51. <view class="text">
  52. <view class="">更多</view>
  53. <view class="">日期</view>
  54. </view>
  55. <u-icon name="arrow-right" color="#7F7F7F" size="24rpx"></u-icon>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="date-block session-wrap">
  60. <view class="title">演出场次</view>
  61. <view class="session">
  62. <view class="session-item" :class="{active:sessionIndex==index}" @click="sessionClick(index)" v-for="(date,index) in sessionList" :key="index">
  63. {{ date.performTimeStart}} - {{date.performTimeEnd}}
  64. </view>
  65. </view>
  66. <view class="empty" v-if="auditoriumList.length>=1&&sessionList.length<1">
  67. 当前日期暂无演出场次,请重新选择
  68. </view>
  69. </view>
  70. <view class="date-block ticket-type">
  71. <view class="title">门票</view>
  72. <view class="type-item" :class="{active:sessionIndex==index}" v-for="(item,index) in ticketTypeList" :key="index">
  73. <view class="name-price u-flex u-row-between">
  74. <view class="name">{{item.goodsName}}</view>
  75. <view class="prices">¥ {{item.salePrice}}</view>
  76. </view>
  77. <!-- <view class="ishave">
  78. <text class="text">{{(item.quantity>0&&sessionList.length>=1)?'有票':'无票'}}</text>
  79. </view> -->
  80. <view class="bottom u-flex u-row-between">
  81. <view class="left u-flex">
  82. <!-- 购票须知
  83. <u-icon name="arrow-right" color="#7F7F7F" size="24rpx"></u-icon> -->
  84. </view>
  85. <view class="btn" @click="book(item)" v-if="item.quantity>0&&sessionList.length>=1">预定</view>
  86. <view class="btn disabled" v-else>无票</view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. <!-- ticket end -->
  92. <view class="details" v-if="tabsIndex==1">
  93. <view class="details-block">
  94. <view class="title">剧情简介</view>
  95. <view class="intro">
  96. <u-parse :content="performInfo.performSnapshot"></u-parse>
  97. </view>
  98. </view>
  99. <view class="details-block actors">
  100. <view class="title u-flex u-row-between">
  101. 演职人员
  102. <view class="right u-flex" @click="$u.route('pages/actors',{performId:performId})">
  103. <text>更多</text>
  104. <u-icon name="arrow-right" color="#7F7F7F" size="24rpx"></u-icon>
  105. </view>
  106. </view>
  107. <view class="actor-list">
  108. <u-scroll-list :indicator="false">
  109. <view class="item" v-for="(item, index) in actorsArr" :key="index">
  110. <image class="img" :src="item.performerHead||staticUrl+'/img/actors.png'"></image>
  111. <view class="text">
  112. <view class="name">{{item.performerName}}</view>
  113. <view class="role u-line-1">{{item.performerRole}}</view>
  114. </view>
  115. </view>
  116. </u-scroll-list>
  117. <u-empty text="暂无" v-if="actorsArr.length<1"></u-empty>
  118. </view>
  119. </view>
  120. </view>
  121. <view class="viewingTips" v-if="tabsIndex==2">
  122. <u-parse :content="formerNotice"></u-parse>
  123. </view>
  124. </view>
  125. <u-calendar
  126. ref="calendar"
  127. :maxDate="maxDate"
  128. :show="calendarShow"
  129. color="#EF1010"
  130. :closeOnClickOverlay="true"
  131. @close="closeCalendar"
  132. @confirm="confirmCalendar">
  133. </u-calendar>
  134. <!-- 分享选择弹出内容 -->
  135. <view class="share-option" :class="{shareShow:shareShow}">
  136. <view class="overlay" v-if="shareShow" @click="shareShow=false"></view>
  137. <button class="share-option-item wx-share" data-name="shareBtn" open-type="share">
  138. 发送给朋友
  139. </button>
  140. <view class="share-option-item" @click="getPoster">生成海报</view>
  141. <view class="share-option-item" @click="shareShow=false">取消</view>
  142. </view>
  143. <u-popup :show="posterShow" @close="posterShow=false" ref="uni-popup">
  144. <view class="poster-wrap u-flex u-col-center">
  145. <view class="poster-inner">
  146. <view class="close-wrap" @click="posterShow=false">
  147. <u-icon name="close-circle" color="#fff" size="56rpx"></u-icon>
  148. </view>
  149. <view class="poster" id="poster" ref="poster" >
  150. <u--image :showLoading="true" :src="posterSrc" width="100%" height="65vh" mode="aspectFit"></u--image>
  151. </view>
  152. <!-- savePoster -->
  153. <view class="poster-btn" @click="saveImage">保存图片</view>
  154. </view>
  155. </view>
  156. </u-popup>
  157. <canvas canvas-id="canvas" class="canvas" style="width: 670px; height: 900px;"></canvas>
  158. </view>
  159. </template>
  160. <script>
  161. import { systemInfo } from "@/mixin.js";
  162. // 日历
  163. const d = new Date()
  164. const year = d.getFullYear()
  165. let month = d.getMonth() + 1
  166. month = month < 10 ? `0${month}` : month
  167. const date = d.getDate()
  168. // 日历
  169. export default {
  170. mixins:[systemInfo],
  171. data() {
  172. return {
  173. performId:'',
  174. staticUrl:this.$commonConfig.staticUrl,
  175. tabsArr:[
  176. {name:'票务购买'},
  177. {name:'演出详情'},
  178. {name:'观影须知'}
  179. ],
  180. theatre:{},
  181. tabsIndex:0,
  182. dateList:[],
  183. dateIndex:0,
  184. calendarShow:false,//日历
  185. maxDate:`${year}-${month}-${date + 30}`,
  186. auditoriumList:[],//演艺厅
  187. auditoriumIndex:0,
  188. sessionList:[],//演出场次
  189. sessionIndex:0,
  190. ticketTypeList:[],//门票
  191. actorsArr:[],
  192. shareShow:false,
  193. posterShow:false,
  194. posterSrc:'',
  195. performInfo:{},//节目详情
  196. formerNotice:{},//节目观影须知
  197. }
  198. },
  199. onShow() {
  200. },
  201. onLoad(page) {
  202. console.log('page',page);
  203. this.performId = page.id;
  204. this.getPerformData();
  205. // this.getSystemInfo();
  206. let today = new Date();
  207. this.setDate(today);
  208. this.getPerformInfo();
  209. this.getPerformerNotice();
  210. },
  211. methods: {
  212. leftClick(e){
  213. let pages = getCurrentPages();
  214. if(pages.length==1){
  215. uni.$u.route('/pages/index/index')
  216. }else{
  217. uni.navigateBack()
  218. };
  219. },
  220. getPerformData(){
  221. this.$u.api.performSell({performId:this.performId}).then(res=>{
  222. // console.log('getPerformData',res.data);
  223. this.theatre = res.data.theatreList[0];
  224. this.auditoriumList = res.data.theatreList[0].auditoriumList;
  225. this.ticketTypeList = res.data.goodsList;
  226. this.getTimes()
  227. // console.log('auditoriumList',this.auditoriumList);
  228. }).catch(err=>{
  229. console.log('getPoster',err);
  230. })
  231. },
  232. getPerformInfo(){
  233. this.$u.api.performInfo({id:this.performId}).then(res=>{
  234. // console.log('getPerformInfo',res.data);
  235. this.performInfo = res.data;
  236. this.actorsArr = res.data.performerList;
  237. }).catch(err=>{
  238. console.log('getPerformInfo',err);
  239. })
  240. },
  241. getPerformerNotice(){
  242. this.$u.api.performerNotice({performId:this.performId}).then(res=>{
  243. // console.log('getPerformerNotice',res.data);
  244. this.formerNotice = res.data.performNotice;
  245. }).catch(err=>{
  246. console.log('getPerformerNotice',err);
  247. })
  248. },
  249. getTimes(){
  250. let auditoriumId= this.auditoriumList[this.auditoriumIndex]?.id;
  251. if(!auditoriumId){return}
  252. let dateOBJ = this.dateList[this.dateIndex];
  253. let param = {
  254. auditoriumId:auditoriumId,//演艺厅ID(演艺厅列表)
  255. performId:this.performId,
  256. date:`${dateOBJ.year}-${dateOBJ.month}-${dateOBJ.day}`
  257. };
  258. // console.log('param',param);
  259. this.$u.api.getAuditoriumTimes(param).then(res=>{
  260. // console.log('getTimes',res.data);
  261. this.sessionList = res.data.list.map(item=>{
  262. item.performTimeStart = item.performTimeStart;
  263. item.performTimeEnd = item.performTimeEnd;
  264. return item
  265. });
  266. }).catch(err=>{
  267. console.log('getPoster',err);
  268. })
  269. },
  270. setDate(firstDay){
  271. let today = firstDay;
  272. let tomorrow = new Date();
  273. tomorrow.setDate(today.getDate() + 1);
  274. let afterTomorrow = new Date();
  275. afterTomorrow.setDate(today.getDate() + 2);
  276. this.dateList = [
  277. { year: today.getFullYear(), month: today.getMonth() + 1, day: today.getDate(),name:'今天' },
  278. { year: tomorrow.getFullYear(), month: tomorrow.getMonth() + 1, day: tomorrow.getDate() ,name:'明天'},
  279. { year: afterTomorrow.getFullYear(), month: afterTomorrow.getMonth() + 1, day: afterTomorrow.getDate(),name:'后天' }
  280. ];
  281. this.getTimes()
  282. },
  283. dateClick(index){
  284. this.dateIndex = index;
  285. this.getTimes()
  286. },
  287. auditoriumClick(index){
  288. this.auditoriumIndex = index;
  289. },
  290. confirmCalendar(e){
  291. // console.log('confirmCalendar',e);
  292. this.setDate( new Date(e) );
  293. this.dateIndex = 0;
  294. // console.log('maxDate',this.maxDate);
  295. // console.log('dateList',this.dateList);
  296. this.calendarShow = false;
  297. },
  298. closeCalendar(){
  299. this.calendarShow = false;
  300. },
  301. tabsClick(e){
  302. // console.log('tabsClick',e);
  303. this.tabsIndex = e.index;
  304. },
  305. sessionClick(index){
  306. this.sessionIndex = index;
  307. },
  308. book(item){
  309. // console.log('book',item);
  310. // console.log('performInfo',this.performInfo);
  311. let session = this.sessionList[this.sessionIndex];
  312. // console.log('session',session);
  313. let performTimeStart = session.performTimeStart;
  314. let performTimeEnd = session.performTimeEnd;
  315. let dateOBJ = this.dateList[this.dateIndex];
  316. uni.$u.route('pages/chosenposition',{
  317. goodsId:item.id,
  318. performId:this.performId,
  319. performName:this.performInfo.name,
  320. day:`${dateOBJ.year}-${dateOBJ.month}-${dateOBJ.day}`,
  321. performTimeStart:session.performTimeStart,
  322. performTimeEnd:session.performTimeEnd,
  323. performTimeId:session.id,
  324. auditoriumId:this.auditoriumList[this.auditoriumIndex].id
  325. })
  326. },
  327. openShare(){
  328. this.shareShow = true;
  329. // 前端生成海报开始
  330. let that = this;
  331. const ctx = uni.createCanvasContext('canvas', this);
  332. // 加载海报背景图
  333. uni.getImageInfo({
  334. src: this.performInfo.posterImg,
  335. success: res1 => {
  336. const img1 = res1.path;
  337. // 加载海报二维码
  338. uni.getImageInfo({
  339. src: this.performInfo.appletQrcode,
  340. success: res2 => {
  341. const img2 = res2.path;
  342. // 绘制海报背景图
  343. ctx.drawImage(img1, 0, 0, 670, 900);
  344. // 绘制海报二维码
  345. ctx.drawImage(img2, 468, 724, 188, 166);
  346. // 绘制完成后导出图片并显示
  347. ctx.draw(false, () => {
  348. uni.canvasToTempFilePath({
  349. canvasId: 'canvas',
  350. success: res3 => {
  351. this.posterSrc = res3.tempFilePath;
  352. },
  353. fail: err => {
  354. console.error(err);
  355. },
  356. }, this);
  357. });
  358. },
  359. fail: err2 => {
  360. console.error(err2);
  361. },
  362. });
  363. },
  364. fail: err1 => {
  365. console.error(err1);
  366. },
  367. });
  368. // 前端生成海报结束
  369. },
  370. // 海报相关开始
  371. getPoster(item){
  372. this.posterShow = true;
  373. this.shareShow = false;
  374. // 后端生成海报
  375. // this.$u.api.performQrcode({performId:this.performId}).then(res=>{
  376. // this.posterSrc = res.data.imageUrl;
  377. // // console.log('getPoster',res.data);
  378. // }).catch(err=>{
  379. // console.log('getPoster',err);
  380. // })
  381. },
  382. saveImage() {
  383. let that = this;
  384. uni.showLoading({
  385. title: '保存中'
  386. });
  387. uni.downloadFile({
  388. url: this.posterSrc,
  389. success(res) {
  390. if (res.statusCode === 200) {
  391. uni.saveImageToPhotosAlbum({
  392. filePath: res.tempFilePath,
  393. success() {
  394. uni.showToast({
  395. title: '保存到相册成功',
  396. icon: 'success'
  397. });
  398. },
  399. fail(err) {
  400. console.log('保存图片失败',err);
  401. if (err.errMsg === 'saveImageToPhotosAlbum:fail auth deny') {
  402. uni.getSetting({
  403. success(res) {
  404. if (!res.authSetting['scope.writePhotosAlbum']) {
  405. uni.showModal({
  406. title: '提示',
  407. content: '您还没有授权访问相册,请前往设置页面打开权限。',
  408. confirmText: '去设置',
  409. success(res) {
  410. if (res.confirm) {
  411. uni.openSetting();
  412. }
  413. }
  414. });
  415. } else {
  416. uni.showToast({
  417. title: '保存图片失败',
  418. icon: 'none'
  419. });
  420. }
  421. }
  422. });
  423. } else {
  424. uni.showToast({
  425. title: '保存图片失败',
  426. icon: 'none'
  427. });
  428. }
  429. },
  430. complete() {
  431. uni.hideLoading();
  432. that.posterShow = false;
  433. }
  434. });
  435. } else {
  436. uni.showToast({
  437. title: '下载图片失败',
  438. icon: 'none'
  439. });
  440. }
  441. },
  442. fail() {
  443. uni.showToast({
  444. title: '下载图片失败',
  445. icon: 'none'
  446. });
  447. }
  448. });
  449. },
  450. // 海报相关结束
  451. goMap(){
  452. uni.openLocation({
  453. latitude:Number(this.theatre.latitude), //维度
  454. longitude: Number(this.theatre.longitude), //经度
  455. name: this.theatre.name, //目的地定位名称
  456. scale: 15, //缩放比例
  457. address: this.theatre.address //导航详细地址
  458. })
  459. },
  460. }
  461. }
  462. </script>
  463. <style lang="scss" scoped>
  464. .banner{
  465. position: relative;
  466. .img{
  467. width: 750rpx;
  468. height: 554rpx;
  469. display: block;
  470. }
  471. .content{
  472. position: absolute;
  473. width: 100%;
  474. box-sizing: border-box;
  475. padding: 0 32rpx;
  476. left: 0;
  477. bottom: 100rpx;
  478. }
  479. .share{
  480. overflow: hidden;
  481. margin-bottom: 100rpx;
  482. .icon{
  483. float: right;
  484. display: block;
  485. width: 32rpx;
  486. height: 32rpx;
  487. padding: 10rpx;
  488. border-radius: 50%;
  489. background-color: rgba(0,0,0,0.4);
  490. }
  491. }
  492. .name{
  493. font-size: 44rpx;
  494. font-weight: 800;
  495. color: #FFFFFF;
  496. line-height: 66rpx;
  497. margin-bottom: 38rpx;
  498. }
  499. .addr{
  500. font-size: 24rpx;
  501. font-weight: 400;
  502. color: #FFFFFF;
  503. line-height: 36rpx;
  504. }
  505. }
  506. .tabs-wrap{
  507. position: relative;
  508. margin-bottom: 54rpx;
  509. &::after{
  510. content: '';
  511. width: 100%;
  512. height: 1px;
  513. background-color: #eee;
  514. position: absolute;
  515. left: 0;
  516. right: 0;
  517. bottom: -46rpx;
  518. }
  519. .inner{
  520. position: relative;
  521. padding-top: 50rpx;
  522. background-color: #FFFFFF;
  523. border-radius: 32rpx 32rpx 0rpx 0rpx;
  524. height: 46rpx;
  525. margin-top: -30px;
  526. }
  527. }
  528. .date-block{
  529. margin-bottom: 64rpx;
  530. }
  531. .title{
  532. font-size: 32rpx;
  533. font-weight: bold;
  534. color: #2D2D2D;
  535. line-height: 48rpx;
  536. margin-bottom: 38rpx;
  537. }
  538. .session-wrap{
  539. .empty{
  540. background-color: #636363;
  541. color: #979797;
  542. border-radius: 8rpx;
  543. padding: 24rpx;
  544. text-align: center;
  545. }
  546. }
  547. .session{
  548. display: grid;
  549. grid-template-columns: repeat(3, 1fr);
  550. gap: 20rpx;
  551. .session-item{
  552. height: 80rpx;
  553. line-height: 80rpx;
  554. border-radius: 12rpx;
  555. border: 2rpx solid #636363;
  556. text-align: center;
  557. font-size: 24rpx;
  558. font-weight: 400;
  559. color: #636363;
  560. &.active{
  561. color: #ED0000;
  562. border-color: #ED0000;
  563. }
  564. }
  565. }
  566. .ticket-type{
  567. .type-item{
  568. background: #FFFFFF;
  569. box-shadow: 0rpx 2rpx 12rpx 0rpx rgba(180,180,180,0.5);
  570. border-radius: 20rpx;
  571. margin-bottom: 20rpx;
  572. padding: 38rpx 40rpx;
  573. .name-price{
  574. margin-bottom: 26rpx;
  575. }
  576. .name{
  577. font-size: 28rpx;
  578. font-weight: 500;
  579. color: #363636;
  580. }
  581. .prices{
  582. font-size: 36rpx;
  583. font-weight: bold;
  584. color: #ED0000;
  585. }
  586. .ishave{
  587. margin-bottom: 26rpx;
  588. .text{
  589. height: 30rpx;
  590. line-height: 30rpx;
  591. padding: 0 22rpx;
  592. background: #FFC8C8;
  593. border-radius: 20rpx;
  594. font-size: 20rpx;
  595. font-weight: 400;
  596. color: #ED0000;
  597. }
  598. }
  599. .bottom{
  600. font-size: 22rpx;
  601. font-weight: 400;
  602. color: #7F7F7F;
  603. .btn{
  604. height: 60rpx;
  605. line-height: 60rpx;
  606. background: linear-gradient(90deg, #FF7979 0%, #ED0000 100%);
  607. border-radius: 30rpx;
  608. padding: 0 36rpx;
  609. font-size: 28rpx;
  610. font-weight: 500;
  611. color: #FFFFFF;
  612. &.disabled{
  613. background: #979797;
  614. }
  615. }
  616. }
  617. }
  618. }
  619. .details{
  620. .title{}
  621. .details-block{
  622. background: #FFFFFF;
  623. box-shadow: 0rpx 2rpx 12rpx 2rpx rgba(221,221,221,0.5);
  624. border-radius: 20rpx;
  625. margin-bottom: 24rpx;
  626. padding: 36rpx;
  627. &.actors{
  628. .title{
  629. .right{
  630. font-size: 24rpx;
  631. font-weight: 400;
  632. color: #7F7F7F;
  633. }
  634. }
  635. }
  636. }
  637. .intro{
  638. font-size: 26rpx;
  639. font-weight: 400;
  640. color: #4E4E4E;
  641. line-height: 40rpx;
  642. }
  643. .actor-list{
  644. .item{
  645. flex-shrink: 0;
  646. width: 160rpx;
  647. text-align: center;
  648. margin-right: 24rpx;
  649. }
  650. .img{
  651. display: block;
  652. width: 100%;
  653. height: 200rpx;
  654. margin-bottom: 16rpx;
  655. }
  656. .name{
  657. font-size: 28rpx;
  658. font-weight: 500;
  659. color: #2D2D2D;
  660. line-height: 42rpx;
  661. margin-bottom: 4rpx;
  662. }
  663. .role{
  664. font-size: 24rpx;
  665. font-weight: 400;
  666. color: #7F7F7F;
  667. line-height: 36rpx;
  668. }
  669. }
  670. }
  671. .canvas{
  672. position: absolute;
  673. left: -99999px;
  674. }
  675. </style>