seat.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829
  1. <template name="dever-seat">
  2. <view class="w-100 grace-body">
  3. <view class="bg-f1">
  4. <movable-area :style="'height:'+(seatRow*40+350)+'rpx;width: 100vw;tops:'+(rpxNum*132)+'px'" class="pt-f left-0">
  5. <movable-view :style="'width: 100vw;height:'+(seatRow*40+350)+'rpx;'" :inertia="true" :scale="true" :scale-min="0.95"
  6. :scale-max="2" direction="all" @change="onMove" @scale="onScale">
  7. <picker @change="openHall" :value="hall_index" :range="hall_data" v-if="hall_state">
  8. <view class="Stage dp-f jc-c ai-c fz-22 color-333" style="margin-top:10rpx">
  9. {{hall_data[hall_index]}}
  10. </view>
  11. </picker>
  12. <view style="height: 30rpx;margin-top: 30rpx;margin-bottom: 30rpx;" class="m-0-a mt-48 dp-f jc-c ai-c fz-22 color-999 br-5">{{item.name}}</view>
  13. <view v-for="(item,index) in seatArray" :key="index" class="dp-f jc-c mt-20" :style="'width:'+boxWidth+'px;height:'+seatSize+'px'">
  14. <view v-for="(seat,col) in item" :key="col" class="dp-ib" :style="'width:'+seatSize+'px;height:'+seatSize+'px'"
  15. @click="handleChooseSeat(index,col)">
  16. <image v-if="seat.type===0" class="w-100 h-100" src="@/static/seat/unselected.png" mode="aspectFit"></image>
  17. <image v-else-if="seat.type===1" class="w-100 h-100" src="@/static/seat/selected.png" mode="aspectFit" style="width:40rpx;height:40rpx;"></image>
  18. <image v-else-if="seat.type===2" class="w-100 h-100" :id="seat.TipsId" src="@/static/seat/bought.png" mode="aspectFit" style="width:40rpx;height:40rpx;" :src="seat.User.avatar" @click="showTips(seat.TipsId, seat.Id, seat.Tips, seat.SeatCode, seat.User)"></image>
  19. </view>
  20. </view>
  21. <view class="pt-f bg-line br-15 over-h" :style="'left: '+(10-moveX/scale)+'px;top:112rpx;width:30rpx;'">
  22. <view class="w-100 dp-f ai-c jc-c fz-22 color-fff" :style="'height:'+seatSize+'px;margin-top:20rpx;'" v-for="(m,mindex) in mArr"
  23. :key="mindex">{{m}}</view>
  24. <view :style="'height: 20rpx;'"></view>
  25. </view>
  26. </movable-view>
  27. </movable-area>
  28. <view class="pt-f bottom-bar left-0 dp-f fd-cr z1000">
  29. <view class="bg-white p-all-32" style="width: 750rpx;">
  30. <view class="dp-f ai-c jc-c fz-28 color-333 mb-20" v-if="SelectNum===0">
  31. 推荐选座
  32. <view style="width: 106rpx;height: 60rpx;" class="b-1 br-5 dp-f ai-c jc-c fz-28 ml-20" v-for="(n,numindex) in 4"
  33. :key="n" @click="smartChoose(numindex+1)">
  34. {{numindex+1}}人
  35. </view>
  36. </view>
  37. <view class="dp-f ai-c fw-w fz-28 color-333 mb-20" v-if="SelectNum>0">
  38. <text>已选</text>
  39. <view class="p-all-10 b-1 br-5 dp-f ai-c jc-c fz-28 ml-20" v-for="(optItem,optindex) in optArr" :key="optindex">
  40. {{optItem.RowNum+'排'+optItem.ColumnNum+'座'}}
  41. </view>
  42. </view>
  43. <view style="width: 566rpx;height: 90rpx;" class="dp-f jc-c ai-c br-10 fz-34 color-fff" :class="SelectNum>0?'bg-red-1':'bg-unbtn'"
  44. @click="buySeat">
  45. <text>{{SelectNum>0?('¥ '+aPrice+' 确认座位'):'选择座位后才能观看'}}</text>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <view v-if="show">
  51. <dever-publish :title="title" :is_upload="false" @hideModal="hideTips" @getRefresh="getRefresh" :type="seat_table" :type_id="seat_table_id" :api="api" :playtime="playtime"></dever-publish>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. import deverPublish from '@/lib/dever/components/publish.vue';
  57. export default {
  58. props: {
  59. type : {
  60. type : String,
  61. value : null
  62. },
  63. type_id : {
  64. type : String,
  65. value : null
  66. },
  67. item : {
  68. type : Object,
  69. value : null
  70. },
  71. index : 0
  72. },
  73. components:{
  74. deverPublish
  75. },
  76. data() {
  77. return {
  78. cycle : false,
  79. scaleMin:1,//h5端为解决1无法缩小问题,设为0.95
  80. boxWidth: 400, //屏幕宽度px
  81. space: ' ', //空格
  82. seatArray: [], //影院座位的二维数组,-1为非座位,0为未购座位,1为已选座位(绿色),2为已购座位(红色),一维行,二维列
  83. seatRow: 0, //影院座位行数
  84. seatCol: 0, //影院座位列数
  85. seatSize: 0, //座位尺寸
  86. SelectNum: 0, //选择座位数
  87. moveX: 0, //水平移动偏移量
  88. scale: 1, //放大倍数
  89. minRow: 0, //从第几行开始排座位
  90. minCol: 0, //从第几列开始排座位
  91. showTis: true, //显示选座提示
  92. seatList: [], //接口获取的原始位置
  93. mArr: [], //排数提示
  94. optArr: [], //选中的座位数组。
  95. isWXAPP:false,
  96. price : 1,
  97. fetch : {
  98. user : {},
  99. hall : 1,
  100. disabled : true,
  101. },
  102. show : false,
  103. api : 'app/community/?l=api.addTips',
  104. title : '发布聊天泡泡',
  105. seat_table : '',
  106. seat_table_id : 0,
  107. tipsData : {},
  108. page : 1,
  109. play : false,
  110. playtime : 0,
  111. tipsTimeData : {},
  112. hall_state : false,
  113. hall_data : [],
  114. hall_index : 0,
  115. //手动停止播放
  116. setStop : false,
  117. };
  118. },
  119. computed: {
  120. aPrice() {
  121. if (this.fetch.disabled) {
  122. return (this.SelectNum - 1) * this.price
  123. } else {
  124. return (this.SelectNum) * this.price
  125. }
  126. },
  127. rpxNum() {
  128. return this.boxWidth / 750
  129. },
  130. pxNum() {
  131. return 750 / this.boxWidth
  132. },
  133. },
  134. mounted() {
  135. if (this.item.title) {
  136. this.title = this.item.title;
  137. }
  138. this.price = parseFloat(this.item.seat_price);
  139. this.setHall();
  140. //获取宽度
  141. uni.getSystemInfo({
  142. success: function(e) {
  143. this.boxWidth = e.screenWidth
  144. //#ifdef H5
  145. this.scaleMin = 0.95
  146. //#endif
  147. }
  148. })
  149. this.page = 1;
  150. this.initData(this.hall)
  151. },
  152. methods: {
  153. setHall : function() {
  154. var default_hall = this.Dever.data('hall_' + this.type_id);
  155. if (!default_hall) {
  156. default_hall = 1;
  157. } else {
  158. default_hall = parseInt(default_hall);
  159. }
  160. var hall = parseInt(this.item.hall_num);
  161. this.hall_index = default_hall - 1;
  162. this.hall = default_hall;
  163. var hall_state = false;
  164. for (var i=0; i<hall ; i++) {
  165. this.hall_data[i] = (i+1) + '号厅';
  166. if (this.hall_index == i) {
  167. hall_state = true;
  168. }
  169. }
  170. if (!hall_state) {
  171. this.hall_index = 0;
  172. this.hall = 1;
  173. }
  174. this.hall_state = true;
  175. },
  176. openHall : function(e) {
  177. this.hall_index = e.detail.value;
  178. this.hall = parseInt(this.hall_index+1);
  179. this.Dever.data('hall_' + this.type_id, this.hall);
  180. this.page = 1;
  181. this.initData(this.hall);
  182. },
  183. showTips : function(tipsid, id, tips, code, user) {
  184. if (!this.play && this.playtime == 0) {
  185. this.Dever.alert('播放时才能发送消息');
  186. return;
  187. }
  188. this.seat_table = tips;
  189. this.seat_table_id = id;
  190. this.show = true;
  191. if (this.play) {
  192. this.setStop = true;
  193. this.$emit('stop');
  194. }
  195. },
  196. hideTips : function() {
  197. this.show = false;
  198. if (this.setStop == true) {
  199. this.$emit('start');
  200. this.setStop = false;
  201. }
  202. },
  203. setDisabled : function() {
  204. this.$emit('setDisabled', this.fetch.disabled);
  205. },
  206. tips : function(id, content) {
  207. var id = '#tips_' + this.type_id + '_' + id;
  208. if (this.tipsData[id]) {
  209. this.Dever.layer.close(this.tipsData[id]);
  210. }
  211. this.tipsData[id] = this.Dever.layer.tips(content, id, {
  212. tips: [1, '#0FA6D8'],
  213. tipsMore: true
  214. });
  215. },
  216. getRefresh : function(cate_id, type, type_id, content) {
  217. this.tips(type_id, content);
  218. if (!this.tipsTimeData[this.playtime]) {
  219. this.tipsTimeData[this.playtime] = [];
  220. }
  221. this.tipsTimeData[this.playtime].push({type_id:type_id,content:content});
  222. this.hideTips();
  223. },
  224. initData: function(hall) {
  225. var self = this;
  226. this.cycle && (clearInterval(this.cycle));
  227. this.Dever.get(this, 'app/user/?l=api.seat', {code:this.Dever.config.code,noloading:1, content_id : this.type_id, hall : hall}, function(t) {
  228. self.setDisabled();
  229. let arr = t.seat
  230. //数据说明:SeatCode座位编号,RowNum-行号,ColumnNum-纵号,YCoord-Y坐标,XCoord-X坐标,Status-状态
  231. let row = 0
  232. let col = 0
  233. let minCol = parseInt(arr[0].XCoord)
  234. let minRow = parseInt(arr[0].YCoord)
  235. for (let i of arr) {
  236. minRow = parseInt(i.YCoord) < minRow ? parseInt(i.YCoord) : minRow
  237. minCol = parseInt(i.XCoord) < minCol ? parseInt(i.XCoord) : minCol
  238. row = parseInt(i.YCoord) > row ? parseInt(i.YCoord) : row
  239. col = parseInt(i.XCoord) > col ? parseInt(i.XCoord) : col
  240. self.seat_table = i.Tips
  241. }
  242. self.seatList = arr
  243. self.seatRow = row - minRow + 1
  244. self.seatCol = col - minCol + 3
  245. self.minRow = minRow
  246. self.minCol = minCol - 1
  247. self.initSeatArray()
  248. self.tipsTimeData = {};
  249. self.getData();
  250. });
  251. },
  252. start : function() {
  253. this.play = true;
  254. },
  255. stop : function() {
  256. this.play = false;
  257. this.Dever.layer.closeAll();
  258. },
  259. time : function(time) {
  260. this.playtime = time;
  261. //console.info(time);
  262. if (this.tipsTimeData[time]) {
  263. this.handle(this.tipsTimeData[time]);
  264. }
  265. },
  266. // 获取聊天历史数据
  267. getData : function() {
  268. var self = this;
  269. this.Dever.get(this, 'app/community/?l=api.tips', {code:this.Dever.config.code,noloading:1, type:this.seat_table, pg:this.page}, function(t) {
  270. var arr = Object.keys(t.info);
  271. if (arr.length > 0) {
  272. self.save(t.info);
  273. }
  274. });
  275. },
  276. save : function(data) {
  277. this.tipsTimeData = Object.assign(this.tipsTimeData, data);
  278. this.page++;
  279. this.getData();
  280. },
  281. //执行聊天泡泡
  282. handle : function(items) {
  283. if (!this.play) {
  284. return;
  285. }
  286. this.cycle && (clearInterval(this.cycle));
  287. var i = 0;
  288. var len = items.length;
  289. this.tips(items[i]['type_id'], items[i]['content']);
  290. i++;
  291. this.cycle = setInterval(() => {
  292. var time = 5;
  293. // #ifndef H5
  294. time = Math.ceil(Math.floor(Math.random() * (this.maxTime - this.minTime + 1) + this.minTime));
  295. // #endif
  296. if (!this.play) {
  297. clearInterval(this.cycle);
  298. } else if (i < len) {
  299. this.tips(items[i]['type_id'], items[i]['content']);
  300. i++;
  301. } else {
  302. clearInterval(this.cycle);
  303. }
  304. }, 1000)
  305. },
  306. //初始座位数组
  307. initSeatArray: function() {
  308. let seatArray = Array(this.seatRow).fill(0).map(() => Array(this.seatCol).fill({
  309. type: -1,
  310. SeatCode: '',
  311. RowNum: '',
  312. ColumnNum: ''
  313. }));
  314. this.seatArray = seatArray
  315. this.seatSize = this.boxWidth > 0 ?
  316. parseInt(parseInt(this.boxWidth, 10) / (this.seatCol + 1), 10) :
  317. parseInt(parseInt(414, 10) / (this.seatCol + 1), 10)
  318. this.initNonSeatPlace();
  319. },
  320. //初始化是座位的地方
  321. initNonSeatPlace: function() {
  322. let seat = this.seatList.slice()
  323. let arr = this.seatArray.slice()
  324. for (let num in seat) {
  325. let status = 2 //-1为非座位,0为未购座位,1为已选座位(绿色),2为已购座位(红色)
  326. if (seat[num].Status === 0) {
  327. status = 0
  328. } else if (seat[num].Status === -1) {
  329. status = -1
  330. }
  331. arr[parseInt(seat[num].YCoord) - this.minRow][parseInt(seat[num].XCoord) - this.minCol] = {
  332. type: status,
  333. SeatCode: seat[num].SeatCode,
  334. RowNum: seat[num].RowNum,
  335. ColumnNum: seat[num].ColumnNum,
  336. User: seat[num].User,
  337. Id : seat[num].Id,
  338. Tips : seat[num].Tips,
  339. TipsId : 'tips_' + this.type_id + '_' + seat[num].Id
  340. }
  341. }
  342. this.seatArray = arr.slice()
  343. let mArr = []
  344. for (let i in arr) {
  345. let m = ''
  346. for (let n of arr[i]) {
  347. if (n.SeatCode) {
  348. m = n.RowNum
  349. }
  350. }
  351. if (m) {
  352. mArr.push(m)
  353. } else {
  354. mArr.push('')
  355. }
  356. }
  357. this.mArr = mArr
  358. },
  359. //放大缩小事件
  360. onScale: function(e) {
  361. this.showTis = false
  362. // this.moveX=-e.detail.x
  363. let w = this.boxWidth * 0.5
  364. let s = 1 - e.detail.scale
  365. this.moveX = w * s
  366. this.scale = e.detail.scale
  367. if (s > 0 || s === 0) {
  368. this.showTis = true
  369. }
  370. },
  371. //移动事件
  372. onMove: function(e) {
  373. this.showTis = false
  374. this.moveX = e.detail.x
  375. },
  376. //重置座位
  377. resetSeat: function() {
  378. this.SelectNum = 0
  379. this.optArr = []
  380. //将所有已选座位的值变为0
  381. let oldArray = this.seatArray.slice();
  382. for (let i = 0; i < this.seatRow; i++) {
  383. for (let j = 0; j < this.seatCol; j++) {
  384. if (oldArray[i][j].type === 1) {
  385. oldArray[i][j].type = 0
  386. }
  387. }
  388. }
  389. this.seatArray = oldArray;
  390. },
  391. //选定且购买座位
  392. buySeat: function() {
  393. if (this.SelectNum === 0) {
  394. return
  395. }
  396. let oldArray = [];
  397. for (let i = 0; i < this.seatRow; i++) {
  398. for (let j = 0; j < this.seatCol; j++) {
  399. if (this.seatArray[i][j].type === 1) {
  400. oldArray.push(this.seatArray[i][j].SeatCode)
  401. }
  402. }
  403. }
  404. this.buy(oldArray);
  405. },
  406. buy : function(seat) {
  407. seat = seat.join(',');
  408. var self = this;
  409. this.Dever.confirm('确定购买座位吗?第一个座位免费哦~', function() {
  410. var data = {};
  411. data.code = self.Dever.config.code;
  412. data.seat = seat;
  413. data.content_id = self.type_id;
  414. data.type = self.type;
  415. data.index = self.index;
  416. var location = 'dream/view?code={code}&name=' + self.Dever.config.name;
  417. data.location = location;
  418. data.refer = self.Dever.host + '/' + location;
  419. self.Dever.post('app/user/?l=pay.seat', data, function(t) {
  420. self.Dever.pay(t, t.location, '支付失败');
  421. });
  422. /*
  423. self.Dever.post('app/user/?l=api.seatSave', {code:self.Dever.config.code, seat:seat, content_id : self.type_id}, function(t) {
  424. self.Dever.alert('选座成功,您可以点击头像发布内容~');
  425. self.resetSeat();
  426. self.initData(self.hall);
  427. });
  428. */
  429. })
  430. },
  431. //处理座位选择逻辑
  432. handleChooseSeat: function(row, col) {
  433. let seatValue = this.seatArray[row][col].type;
  434. let newArray = this.seatArray;
  435. //如果是已购座位,直接返回
  436. if (seatValue === 2 || seatValue === -1) return
  437. //如果是已选座位点击后变未选
  438. if (seatValue === 1) {
  439. newArray[row][col].type = 0
  440. this.SelectNum--
  441. this.getOptArr(newArray[row][col], 0)
  442. } else if (seatValue === 0) {
  443. if (this.SelectNum >= 4) {
  444. this.Dever.alert('一次最多只能购买4个座位');
  445. return;
  446. }
  447. newArray[row][col].type = 1
  448. this.SelectNum++
  449. this.getOptArr(newArray[row][col], 1)
  450. }
  451. //必须整体更新二维数组,Vue无法检测到数组某一项更新,必须slice复制一个数组才行
  452. this.seatArray = newArray.slice();
  453. },
  454. //处理已选座位数组
  455. getOptArr: function(item, type) {
  456. let optArr = this.optArr
  457. if (type === 1) {
  458. optArr.push(item)
  459. } else if (type === 0) {
  460. let arr = []
  461. optArr.forEach(v => {
  462. if (v.SeatCode !== item.SeatCode) {
  463. arr.push(v)
  464. }
  465. })
  466. optArr = arr
  467. }
  468. this.optArr = optArr.slice()
  469. },
  470. //推荐选座,参数是推荐座位数目,
  471. smartChoose: function(num) {
  472. //console.log('num===', num)
  473. // 先重置
  474. this.resetSeat()
  475. //找到影院座位水平垂直中间位置的后一排
  476. let rowStart = parseInt((this.seatRow - 1) / 2, 10) + 1;
  477. //先从中间排往后排搜索
  478. let backResult = this.searchSeatByDirection(rowStart, this.seatRow - 1, num);
  479. if (backResult.length > 0) {
  480. this.chooseSeat(backResult);
  481. this.SelectNum += num
  482. return
  483. }
  484. //再从中间排往前排搜索
  485. let forwardResult = this.searchSeatByDirection(rowStart - 1, 0, num);
  486. if (forwardResult.length > 0) {
  487. this.chooseSeat(forwardResult);
  488. this.SelectNum += num
  489. return
  490. }
  491. //提示用户无合法位置可选
  492. alert('无合法位置可选!')
  493. },
  494. //搜索函数,参数:fromRow起始行,toRow终止行,num推荐座位数
  495. searchSeatByDirection: function(fromRow, toRow, num) {
  496. /*
  497. * 推荐座位规则
  498. * (1)初始状态从座位行数的一半处的后一排的中间开始向左右分别搜索,取离中间最近的,如果满足条件,
  499. * 记录下该结果离座位中轴线的距离,后排搜索完成后取距离最小的那个结果座位最终结果,优先向后排进行搜索,
  500. * 后排都没有才往前排搜,前排逻辑同上
  501. *
  502. * (2)只考虑并排且连续的座位,不能不在一排或者一排中间有分隔
  503. *
  504. * */
  505. /*
  506. * 保存当前方向搜索结果的数组,元素是对象,result是结果数组,offset代表与中轴线的偏移距离
  507. * {
  508. * result:Array([x,y])
  509. * offset:Number
  510. * }
  511. *
  512. */
  513. let currentDirectionSearchResult = [];
  514. let largeRow = fromRow > toRow ? fromRow : toRow,
  515. smallRow = fromRow > toRow ? toRow : fromRow;
  516. for (let i = smallRow; i <= largeRow; i++) {
  517. //每一排的搜索,找出该排里中轴线最近的一组座位
  518. let tempRowResult = [],
  519. minDistanceToMidLine = Infinity;
  520. for (let j = 0; j <= this.seatCol - num; j++) {
  521. //如果有合法位置
  522. if (this.checkRowSeatContinusAndEmpty(i, j, j + num - 1)) {
  523. //计算该组位置距离中轴线的距离:该组位置的中间位置到中轴线的距离
  524. let resultMidPos = parseInt((j + num / 2), 10);
  525. let distance = Math.abs(parseInt(this.seatCol / 2) - resultMidPos);
  526. //如果距离较短则更新
  527. if (distance < minDistanceToMidLine) {
  528. minDistanceToMidLine = distance;
  529. //该行的最终结果
  530. tempRowResult = this.generateRowResult(i, j, j + num - 1)
  531. }
  532. }
  533. }
  534. //保存该行的最终结果
  535. currentDirectionSearchResult.push({
  536. result: tempRowResult,
  537. offset: minDistanceToMidLine
  538. })
  539. }
  540. //处理后排的搜索结果:找到距离中轴线最短的一个
  541. //注意这里的逻辑需要区分前后排,对于后排是从前往后,前排则是从后往前找
  542. let isBackDir = fromRow < toRow;
  543. let finalReuslt = [],
  544. minDistanceToMid = Infinity;
  545. if (isBackDir) {
  546. //后排情况,从前往后
  547. currentDirectionSearchResult.forEach((item) => {
  548. if (item.offset < minDistanceToMid) {
  549. finalReuslt = item.result;
  550. minDistanceToMid = item.offset;
  551. }
  552. });
  553. } else {
  554. //前排情况,从后往前找
  555. currentDirectionSearchResult.reverse().forEach((item) => {
  556. if (item.offset < minDistanceToMid) {
  557. finalReuslt = item.result;
  558. minDistanceToMid = item.offset;
  559. }
  560. })
  561. }
  562. //直接返回结果
  563. return finalReuslt
  564. },
  565. /*辅助函数,判断每一行座位从i列到j列是否全部空余且连续
  566. *
  567. */
  568. checkRowSeatContinusAndEmpty: function(rowNum, startPos, endPos) {
  569. let isValid = true;
  570. for (let i = startPos; i <= endPos; i++) {
  571. if (this.seatArray[rowNum][i].type !== 0) {
  572. isValid = false;
  573. break;
  574. }
  575. }
  576. return isValid
  577. },
  578. //辅助函数:返回每一行的某个合理位置的座位数组
  579. generateRowResult: function(row, startPos, endPos) {
  580. let result = [];
  581. for (let i = startPos; i <= endPos; i++) {
  582. result.push([row, i])
  583. }
  584. return result
  585. },
  586. //辅助函数:智能推荐的选座操作
  587. chooseSeat: function(result) {
  588. let opt = this.optArr
  589. let oldArray = this.seatArray.slice();
  590. for (let i = 0; i < result.length; i++) {
  591. //选定座位
  592. oldArray[result[i][0]][result[i][1]].type = 1
  593. this.optArr.push(oldArray[result[i][0]][result[i][1]])
  594. }
  595. this.seatArray = oldArray;
  596. },
  597. }
  598. }
  599. </script>
  600. <style lang="scss" scoped>
  601. .main {
  602. position: relative;
  603. }
  604. .p-all-10{
  605. padding: 10rpx;
  606. }
  607. .ml-10 {
  608. margin-left: 10rpx;
  609. }
  610. .m-0-10 {
  611. margin: 0 10rpx;
  612. }
  613. .bg-unbtn {
  614. background-color: #f9abb3;
  615. }
  616. .bg-red-1 {
  617. background-color: #F45664;
  618. }
  619. .br-10 {
  620. border-radius: 10rpx;
  621. }
  622. .ml-20 {
  623. margin-left: 20rpx;
  624. }
  625. .mb-20 {
  626. margin-bottom: 20rpx;
  627. }
  628. .p-all-32 {
  629. padding: 32rpx;
  630. }
  631. .fd-cr {
  632. flex-direction: column-reverse;
  633. /* 主轴方向从下到上,默认从左到右 */
  634. }
  635. .bottom-bar {
  636. bottom: var(--window-bottom);
  637. }
  638. .color-fff {
  639. color: #fff
  640. }
  641. .br-15 {
  642. border-radius: 15rpx;
  643. }
  644. .over-h {
  645. overflow: hidden;
  646. }
  647. .dp-ib {
  648. display: inline-block;
  649. }
  650. .mt-20 {
  651. margin-top: 20rpx;
  652. }
  653. .pa-v-2 {
  654. /* 定位垂直对齐 */
  655. left: 50%;
  656. transform: translateX(-50%)
  657. }
  658. .b-d-1 {
  659. border: 1px dashed #e5e5e5;
  660. }
  661. .w-100 {
  662. width: 100%;
  663. }
  664. .h-100 {
  665. height: 100%;
  666. }
  667. .bg-f1 {
  668. background-color: #f1f1f1;
  669. }
  670. .h-100vh {
  671. height: 100vh;
  672. }
  673. .pt-f {
  674. position: fixed;
  675. }
  676. .left-0 {
  677. left: 0;
  678. }
  679. .p-0-32 {
  680. padding: 0 32rpx;
  681. }
  682. .pt-20 {
  683. padding-top: 20rpx;
  684. }
  685. .bg-white {
  686. background-color: #fff;
  687. }
  688. .z1000 {
  689. z-index: 1000;
  690. }
  691. .fz-34 {
  692. font-size: 34rpx;
  693. }
  694. .fw-b {
  695. font-weight: bold;
  696. }
  697. .mt-10 {
  698. margin-top: 10rpx;
  699. }
  700. .fz-28 {
  701. font-size: 28rpx;
  702. }
  703. .color-666 {
  704. color: #666666
  705. }
  706. .dp-f {
  707. display: flex;
  708. }
  709. .jc-c {
  710. justify-content: center;
  711. }
  712. .ai-c {
  713. align-items: center;
  714. }
  715. .fz-22 {
  716. font-size: 22rpx;
  717. }
  718. .color-333 {
  719. color: #333333
  720. }
  721. .m-0-a {
  722. margin: 0 auto;
  723. }
  724. .mt-48 {
  725. margin-top: 48rpx;
  726. }
  727. .fz-20 {
  728. font-size: 20rpx;
  729. }
  730. .color-999 {
  731. color: #999999
  732. }
  733. .b-1 {
  734. border: 1px solid #CCCCCC;
  735. }
  736. .br-5 {
  737. border-radius: 5rpx;
  738. }
  739. .Stage {
  740. background-color: #dddddd;
  741. width: 380rpx;
  742. height: 34rpx;
  743. transform: perspective(34rpx) rotateX(-10deg);
  744. margin: 0 auto;
  745. }
  746. .bg-line {
  747. background-color: rgba(0, 0, 0, 0.3);
  748. }
  749. .sel-seat {
  750. background: url('@/static/seat/selected.png') center center no-repeat;
  751. background-size: 100% 100%;
  752. }
  753. .unsel-seat {
  754. background: url('@/static/seat/unselected.png') center center no-repeat;
  755. background-size: 100% 100%;
  756. }
  757. .bought-seat {
  758. background: url('@/static/seat/bought.png') center center no-repeat;
  759. background-size: 100% 100%;
  760. }
  761. </style>