selectseat.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <page-meta>
  3. <navigation-bar :title="showItem.filmName" background-color="#FFFFFF" front-color="#000000" />
  4. </page-meta>
  5. <view>
  6. <view class="seatSelection-box">
  7. <view class="address">
  8. {{showItem.cinemaName}}
  9. </view>
  10. <view class="logo-box">
  11. <view class="item">
  12. <view class="seat selectable"></view>可选
  13. </view>
  14. <view class="item">
  15. <view class="seat selected"></view>已选
  16. </view>
  17. <view class="item">
  18. <view class="seat notSelect"></view>已售
  19. </view>
  20. </view>
  21. <view class="screen-box">
  22. <image class="screen" src="https://t1-1305573081.cos.ap-shanghai.myqcloud.com/wxapp/static/imgs/%E9%93%B6%E5%B9%95.png"
  23. mode="widthFix"></image>
  24. <text class="screen-name">{{showItem.hallName}}</text>
  25. </view>
  26. <loadSke :loading='loading'>
  27. <view class="seat-box" :style="{'--col':collong}">
  28. <van-checkbox-group :value="seatResult" @change="groupOnChange" :max="max">
  29. <view class="col" v-for="(rowitem,rowindex) in rowlong" :key='rowindex'>
  30. <view v-for="(colitem,colindex) in collong" :key='colindex'>
  31. <van-checkbox use-icon-slot v-if="seatSet(rowindex,colindex,seatList)==='N'" :name="JSON.stringify(seatList[rowindex+1][colindex+1])">
  32. <view class="seat" :class="{selected:selected(rowindex,colindex,seatResult)}" slot="icon"></view>
  33. </van-checkbox>
  34. <view v-else-if="seatSet(rowindex,colindex,seatList)==='LK'" class="seat notSelect"></view>
  35. <view v-else class="seat noneSeat"></view>
  36. </view>
  37. </view>
  38. </van-checkbox-group>
  39. </view>
  40. </loadSke>
  41. </view>
  42. <view class="bottom-box">
  43. <view class="buy-des">
  44. <view class="film-des">
  45. {{showItem.showTime}}
  46. </view>
  47. <view class="item-box">
  48. <view class="seat-item" v-for="(item,index) in seatResult" :key='index'>
  49. <view class="">
  50. {{JSON.parse(item).seatNo}}
  51. </view>
  52. <van-icon name="cross" @click='remove(item)' />
  53. </view>
  54. </view>
  55. </view>
  56. <view class="price-box">
  57. <view class="left-box">
  58. 总共:{{seatResult.length}}张
  59. </view>
  60. <button v-if="seatResult.length>0" class="btn" type="default" @click="goPage(`/pages/cinema/placeorder?seatResult=${JSON.stringify(seatResult)}&showItem=${JSON.stringify(showItem)}`)">下一步</button>
  61. <button v-else class="btn" style="background: linear-gradient(90deg, #c0c0c0, #c0c0c0, #c0c0c0);" type="default">下一步</button>
  62. </view>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. import {
  68. getSeat
  69. } from '@/api/cinema.js'
  70. export default {
  71. data: () => ({
  72. showItem: null,
  73. seatList: null,
  74. rowlong: 0,
  75. collong: 0,
  76. seatResult: [],
  77. max: null,
  78. loading: true
  79. }),
  80. onLoad: function(option) {
  81. this.showItem = JSON.parse(option.showItem)
  82. },
  83. mounted() {
  84. this.init()
  85. },
  86. methods: {
  87. groupOnChange(e) {
  88. this.seatResult = e.detail
  89. },
  90. remove(item) {
  91. this.seatResult.splice(this.seatResult.indexOf(item), 1)
  92. },
  93. seatSet(row, col, list) {
  94. if (!list) {
  95. return false
  96. } else if (list[row + 1]) {
  97. if (list[row + 1][col + 1])
  98. return list[row + 1][col + 1].status
  99. }
  100. },
  101. selected(row, col, seatResult) {
  102. let flag = false
  103. seatResult.forEach((val) => {
  104. if (JSON.parse(val).columnNo == col + 1 && JSON.parse(val).rowNo == row + 1)
  105. flag = true
  106. })
  107. return flag
  108. },
  109. loveSeat(row, col, list) {
  110. return ''
  111. },
  112. async init() {
  113. let seatRes = await getSeat({
  114. showId: this.showItem.showId
  115. })
  116. console.log(seatRes)
  117. this.max = seatRes.data.data.seatData.restrictions
  118. seatRes.data.data.seatData.seats.forEach((val) => {
  119. this.seatList || (this.seatList = {})
  120. this.seatList[val.rowNo] || (this.seatList[val.rowNo] = {})
  121. // this.$set(this.seatList[val.rowNo], val.columnNo, val)
  122. if (parseInt(val.rowNo) > this.rowlong) {
  123. this.rowlong = parseInt(val.rowNo)
  124. }
  125. if (parseInt(val.columnNo) > this.collong) {
  126. this.collong = parseInt(val.columnNo)
  127. }
  128. this.seatList[val.rowNo][val.columnNo] = val
  129. })
  130. this.$nextTick(() => {
  131. this.loading = false
  132. })
  133. console.log(this.seatList)
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss">
  139. .seatSelection-box {
  140. padding: 30rpx;
  141. box-sizing: border-box;
  142. .address {
  143. font-size: 30rpx;
  144. font-weight: 400;
  145. color: #0F0404;
  146. }
  147. .seat {
  148. width: 26rpx;
  149. height: 26rpx;
  150. border: 1rpx solid #D9D9D9;
  151. border-radius: 4rpx;
  152. background: #FFFFFF;
  153. }
  154. .noneSeat {
  155. opacity: 0;
  156. }
  157. .notSelect {
  158. opacity: 1;
  159. background: #FB3D46;
  160. }
  161. .selected {
  162. opacity: 1;
  163. background: #47CB79;
  164. }
  165. .logo-box {
  166. margin-top: 43rpx;
  167. width: 50%;
  168. display: flex;
  169. justify-content: space-between;
  170. align-items: center;
  171. .item {
  172. display: flex;
  173. justify-content: center;
  174. align-items: center;
  175. }
  176. }
  177. .screen-box {
  178. position: relative;
  179. margin-top: 47rpx;
  180. .screen {
  181. width: 100%;
  182. }
  183. .screen-name {
  184. position: absolute;
  185. left: 50%;
  186. top: 30rpx;
  187. transform: translateX(-50%);
  188. white-space: nowrap;
  189. font-size: 22rpx;
  190. font-weight: 400;
  191. color: #999999;
  192. }
  193. }
  194. .seat-box {
  195. margin-top: 50rpx;
  196. width: calc(var(--col) * 30rpx);
  197. margin: auto;
  198. .col {
  199. display: flex;
  200. justify-content: space-around;
  201. align-items: center;
  202. margin-top: 15rpx;
  203. }
  204. }
  205. }
  206. .bottom-box {
  207. position: fixed;
  208. width: 100vw;
  209. bottom: 0;
  210. .buy-des {
  211. background-color: #FFFFFF;
  212. padding: 30rpx;
  213. .film-des {
  214. font-size: 26rpx;
  215. font-weight: 400;
  216. color: #666666;
  217. }
  218. .item-box {
  219. display: flex;
  220. justify-content: flex-start;
  221. flex-wrap: wrap;
  222. .seat-item {
  223. display: flex;
  224. justify-content: space-between;
  225. align-items: center;
  226. width: 200rpx;
  227. background: #E6E6E6;
  228. border-radius: 10rpx;
  229. margin: 20rpx 20rpx 0rpx 0rpx;
  230. padding: 20rpx;
  231. box-sizing: border-box;
  232. }
  233. }
  234. }
  235. .price-box {
  236. display: flex;
  237. justify-content: space-between;
  238. align-items: center;
  239. background-color: #FFFFFF;
  240. padding: 15rpx 30rpx;
  241. padding-bottom: calc(15rpx + 10px + env(safe-area-inset-bottom)/2);
  242. margin-top: 20rpx;
  243. .left-box {
  244. font-size: 26rpx;
  245. font-weight: 400;
  246. color: #0F0404;
  247. }
  248. .btn {
  249. margin: 0;
  250. width: 200rpx;
  251. height: 80rpx;
  252. background: linear-gradient(90deg, #E31818, #ED3E24, #ED4F24);
  253. border-radius: 40rpx;
  254. font-size: 30rpx;
  255. font-weight: 400;
  256. color: #FFFFFF;
  257. display: flex;
  258. justify-content: center;
  259. align-items: center;
  260. white-space: nowrap;
  261. }
  262. }
  263. }
  264. </style>