selectseat.vue 7.0 KB

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