placeorder.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <template>
  2. <view>
  3. <view class="film-des">
  4. <image class="left-img" :src="filmDes.pic" mode="widthFix"></image>
  5. <view class="right-box">
  6. <view class="film-name">
  7. {{showItem.filmName}}
  8. </view>
  9. <view class="film-time">
  10. {{showItem.showTime}}<br />
  11. {{showItem.cinemaName}}<br />
  12. {{showItem.hallName}}
  13. </view>
  14. <view class="film-caveat">
  15. <view class="item">
  16. <van-icon name="clear" color='#E31818' />
  17. 不支持退票
  18. </view>
  19. <view class="item">
  20. <van-icon name="clear" color='#E31818' />
  21. 不支持改签
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="select-des">
  27. <view class="tit-text">
  28. 选择购票方式
  29. </view>
  30. <van-radio-group :value="radioType" @change="radioOnChange">
  31. <view class="options-box">
  32. <view class="left-box">
  33. <image class="img" src="https://t1-1305573081.cos.ap-shanghai.myqcloud.com/wxapp/static/imgs/%E7%89%B9%E6%83%A0%E8%B4%AD%E7%A5%A8.png"
  34. mode="widthFix"></image>
  35. <view class="text-box">
  36. <text class="top">特惠购票</text>
  37. <text class="bottom">固定折扣,快速出票</text>
  38. </view>
  39. </view>
  40. <view class="right-box">
  41. <view class="text-box">
  42. <text class="top">¥{{aPrice}}/张</text>
  43. <text class="bottom">优惠 ¥{{aDiscount}}元</text>
  44. </view>
  45. <van-radio :name="1" checked-color="#07c160"></van-radio>
  46. </view>
  47. </view>
  48. <view class="options-box">
  49. <view class="left-box">
  50. <image class="img" src="https://t1-1305573081.cos.ap-shanghai.myqcloud.com/wxapp/static/imgs/%E5%BF%AB%E9%80%9F%E8%B4%AD%E7%A5%A8.png"
  51. mode="widthFix"></image>
  52. <view class="text-box">
  53. <text class="top">快速购票</text>
  54. <text class="bottom">无需等待,即买即兑</text>
  55. </view>
  56. </view>
  57. <view class="right-box">
  58. <view class="text-box">
  59. <text class="top">¥{{(showItem.netPrice/100).toFixed(2)}}/张</text>
  60. </view>
  61. <van-radio :name="2" checked-color="#07c160"></van-radio>
  62. </view>
  63. </view>
  64. <view class="options-box">
  65. <view class="left-box">
  66. <image class="img" src="https://t1-1305573081.cos.ap-shanghai.myqcloud.com/wxapp/static/imgs/%E7%AB%9E%E4%BB%B7.png"
  67. mode="widthFix"></image>
  68. <view class="text-box">
  69. <text class="top">竞价购买</text>
  70. <text class="bottom">为您网罗最低的折扣,约耗时几分钟</text>
  71. </view>
  72. </view>
  73. <view class="right-box">
  74. <view class="text-box">
  75. <text class="top">等待竞价</text>
  76. </view>
  77. <van-radio :name="3" checked-color="#07c160" disabled></van-radio>
  78. </view>
  79. </view>
  80. </van-radio-group>
  81. </view>
  82. <view class="seat-select">
  83. <text class="tit-text">无座时接受系统调座</text>
  84. <van-switch :checked="acceptChangeSeat==1" @change="onChange" size="24px" />
  85. </view>
  86. <view class="seat-des">
  87. <view class="tit-text">
  88. 购票须知
  89. </view>
  90. <view class="seat-box">
  91. <view class="left">
  92. 座位:
  93. </view>
  94. <view class="right">
  95. <view class="item" v-for="(item,index) in seatResult" :key='index'>
  96. <text class="top">{{item.seatNo}}</text>
  97. <text class="bottom">¥{{aPrice}}</text>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. <view class="buy-des">
  103. <view class="left">
  104. <text class="one">总价:</text>
  105. <text class="two">¥{{allPrice}}</text>
  106. <text class="three">优惠¥{{allDiscount}}元</text>
  107. </view>
  108. <view class="right">
  109. <text class="text">{{seatResult.length}}张</text>
  110. <button class="btn" type="default" @click="buy">去支付</button>
  111. </view>
  112. </view>
  113. </view>
  114. </template>
  115. <script>
  116. import {
  117. prepareOrder
  118. } from '@/api/cinema.js'
  119. export default {
  120. data: () => ({
  121. showItem: {},
  122. seatResult: [],
  123. radioType: 1,
  124. acceptChangeSeat: 0,
  125. orderRes: {}
  126. }),
  127. onLoad: async function(option) {
  128. let data = await this.goPageGetData()
  129. this.showItem = data.showItem
  130. this.seatResult = data.seatResult.map((val) => {
  131. return JSON.parse(val)
  132. })
  133. },
  134. computed: {
  135. filmDes() {
  136. let des = {}
  137. this.$store.state.cinema.filmList.forEach((val) => {
  138. if (val.filmId == this.showItem.filmId) {
  139. des = val
  140. }
  141. })
  142. return des;
  143. },
  144. filmDiscount() {
  145. return this.$store.state.cinema.filmDiscount;
  146. },
  147. discountRule() {
  148. return this.$store.state.cinema.discountRule;
  149. },
  150. aPrice() {
  151. let discountRule = (this.showItem.netPrice > 3900 ? this.discountRule.upDiscountRate : this.discountRule.downDiscountRate)
  152. let filmDiscount = this.filmDiscount
  153. let netPrice = this.showItem.netPrice / 100
  154. return (netPrice * discountRule * filmDiscount).toFixed(2)
  155. },
  156. aDiscount() {
  157. let discountRule = (this.showItem.netPrice > 3900 ? this.discountRule.upDiscountRate : this.discountRule.downDiscountRate)
  158. let filmDiscount = this.filmDiscount
  159. let netPrice = this.showItem.netPrice / 100
  160. return (netPrice - netPrice * discountRule * filmDiscount).toFixed(2)
  161. },
  162. allPrice() {
  163. let discountRule = (this.showItem.netPrice > 3900 ? this.discountRule.upDiscountRate : this.discountRule.downDiscountRate)
  164. let filmDiscount = this.filmDiscount
  165. let netPrice = this.showItem.netPrice / 100
  166. if (this.radioType == 1) {
  167. return (this.seatResult.length * netPrice * discountRule * filmDiscount).toFixed(2)
  168. }
  169. if (this.radioType == 2) {
  170. return (this.seatResult.length * netPrice).toFixed(2)
  171. }
  172. },
  173. allDiscount() {
  174. let discountRule = (this.showItem.netPrice > 3900 ? this.discountRule.upDiscountRate : this.discountRule.downDiscountRate)
  175. let filmDiscount = this.filmDiscount
  176. let netPrice = this.showItem.netPrice / 100
  177. if (this.radioType == 1) {
  178. return (this.seatResult.length * (netPrice - netPrice * discountRule * filmDiscount)).toFixed(2)
  179. }
  180. if (this.radioType == 2) {
  181. return (this.seatResult.length * (netPrice - netPrice)).toFixed(2)
  182. }
  183. },
  184. },
  185. methods: {
  186. radioOnChange(e) {
  187. this.orderRes = {}
  188. this.radioType = e.detail
  189. },
  190. onChange({
  191. detail
  192. }) {
  193. // 需要手动对 checked 状态进行更新
  194. if (detail) {
  195. this.acceptChangeSeat = 1
  196. } else {
  197. this.acceptChangeSeat = 0
  198. }
  199. },
  200. async buy() {
  201. //已有订单则直接请求历史数据
  202. if (this.orderRes.code == 200) {
  203. let payRes = await wx.requestPayment(this.orderRes.data)
  204. console.log(payRes)
  205. return false
  206. }
  207. let seat = [],
  208. seatId = [],
  209. seatNo = []
  210. this.seatResult.forEach(val => {
  211. seat.push(val.seatNo)
  212. seatNo.push(val.seatNo)
  213. seatId.push(val.seatId)
  214. })
  215. prepareOrder({
  216. acceptChangeSeat: this.acceptChangeSeat,
  217. seat: seat.join(','),
  218. seatId: seatId.join('|'),
  219. seatNo: seatNo.join('|'),
  220. showId: this.showItem.showId,
  221. cinemaId: this.showItem.cinemaId,
  222. goodsPictureUrl: this.filmDes.pic,
  223. goodsType: '1',
  224. ticketType: this.radioType
  225. }).then(async res => {
  226. this.orderRes = res
  227. let payRes = await wx.requestPayment(this.orderRes.data)
  228. if (payRes.errMsg == 'requestPayment:ok') {
  229. this.goPage(`/pages/cinema/orderdes?outTradeNo=${this.orderRes.data.outTradeNo}`, 'reLaunch')
  230. }
  231. console.log(payRes)
  232. })
  233. }
  234. }
  235. }
  236. </script>
  237. <style lang="scss" scoped>
  238. .film-des {
  239. padding: 40rpx 30rpx;
  240. margin-top: 20rpx;
  241. background-color: #FFFFFF;
  242. display: flex;
  243. .left-img {
  244. width: 170rpx;
  245. height: 236rpx;
  246. margin-right: 20rpx;
  247. }
  248. .right-box {
  249. display: flex;
  250. flex-direction: column;
  251. justify-content: space-between;
  252. .film-name {
  253. font-size: 30rpx;
  254. font-weight: 400;
  255. color: #0F0404;
  256. }
  257. .film-time {
  258. font-size: 26rpx;
  259. font-weight: 400;
  260. color: #666666;
  261. line-height: 39rpx;
  262. }
  263. .film-caveat {
  264. display: flex;
  265. .item {
  266. display: flex;
  267. align-items: center;
  268. margin-right: 33rpx;
  269. font-size: 26rpx;
  270. font-weight: 400;
  271. color: #0F0404;
  272. }
  273. }
  274. }
  275. }
  276. .select-des {
  277. background-color: #FFFFFF;
  278. margin-top: 20rpx;
  279. padding-bottom: 1rpx;
  280. .tit-text {
  281. padding: 30rpx;
  282. font-size: 26rpx;
  283. font-weight: 400;
  284. color: #0F0404;
  285. border-bottom: 1rpx solid #E8E8E8;
  286. }
  287. .options-box {
  288. display: flex;
  289. justify-content: space-between;
  290. align-items: center;
  291. margin: 30rpx;
  292. .left-box {
  293. display: flex;
  294. .img {
  295. width: 66rpx;
  296. height: 66rpx;
  297. margin-right: 20rpx;
  298. }
  299. .text-box {
  300. display: flex;
  301. flex-direction: column;
  302. .top {
  303. font-size: 26rpx;
  304. font-weight: 400;
  305. color: #0F0404;
  306. }
  307. .bottom {
  308. font-size: 22rpx;
  309. font-weight: 400;
  310. color: #666666;
  311. }
  312. }
  313. }
  314. .right-box {
  315. display: flex;
  316. align-items: center;
  317. .text-box {
  318. display: flex;
  319. flex-direction: column;
  320. justify-content: space-around;
  321. align-items: flex-end;
  322. margin-right: 23rpx;
  323. .top {
  324. font-size: 26rpx;
  325. font-weight: 400;
  326. color: #E31818;
  327. }
  328. .bottom {
  329. font-size: 20rpx;
  330. font-weight: 400;
  331. color: #605A5A;
  332. }
  333. }
  334. }
  335. }
  336. }
  337. .seat-select {
  338. background-color: #FFFFFF;
  339. margin-top: 20rpx;
  340. display: flex;
  341. justify-content: space-between;
  342. align-items: center;
  343. padding: 20rpx 30rpx;
  344. .tit-text {
  345. font-size: 26rpx;
  346. font-weight: 400;
  347. color: #E31818;
  348. }
  349. }
  350. .seat-des {
  351. background-color: #FFFFFF;
  352. margin-top: 20rpx;
  353. .tit-text {
  354. font-size: 26rpx;
  355. font-weight: 400;
  356. color: #0F0404;
  357. padding: 30rpx;
  358. border-bottom: 1rpx solid #E8E8E8;
  359. }
  360. .seat-box {
  361. display: flex;
  362. justify-content: flex-start;
  363. padding: 10rpx 30rpx;
  364. .left {
  365. white-space: nowrap;
  366. height: 96rpx;
  367. margin-top: 10rpx;
  368. }
  369. .right {
  370. display: flex;
  371. flex-wrap: wrap;
  372. justify-content: flex-start;
  373. align-items: center;
  374. .item {
  375. width: 134rpx;
  376. height: 96rpx;
  377. margin: 10rpx;
  378. background: #EBEBEB;
  379. border-radius: 10rpx;
  380. display: flex;
  381. flex-direction: column;
  382. justify-content: center;
  383. align-items: center;
  384. .top {
  385. font-size: 26rpx;
  386. font-weight: 400;
  387. color: #666666;
  388. }
  389. .bottom {
  390. font-size: 22rpx;
  391. font-weight: 400;
  392. color: #E31923;
  393. }
  394. }
  395. }
  396. }
  397. }
  398. .buy-des {
  399. display: flex;
  400. justify-content: space-between;
  401. align-items: center;
  402. background-color: #FFFFFF;
  403. width: 100vw;
  404. box-sizing: border-box;
  405. position: fixed;
  406. bottom: 0;
  407. padding: 15rpx 30rpx;
  408. padding-bottom: calc(10px + env(safe-area-inset-bottom)/2);
  409. .left {
  410. display: flex;
  411. justify-content: space-between;
  412. align-items: center;
  413. width: 50%;
  414. .one {
  415. font-size: 26rpx;
  416. color: #0F0404;
  417. }
  418. .two {
  419. font-size: 36rpx;
  420. color: #E31919;
  421. }
  422. .three {
  423. font-size: 22rpx;
  424. color: #E86125;
  425. }
  426. }
  427. .right {
  428. width: 40%;
  429. display: flex;
  430. justify-content: space-between;
  431. align-items: center;
  432. .text {
  433. font-size: 26rpx;
  434. color: #0F0404;
  435. }
  436. .btn {
  437. margin: 0;
  438. width: 200rpx;
  439. height: 80rpx;
  440. background: linear-gradient(90deg, #E31818, #ED3E24, #ED4F24);
  441. border-radius: 40rpx;
  442. font-size: 30rpx;
  443. color: #FFFFFF;
  444. display: flex;
  445. justify-content: center;
  446. align-items: center;
  447. white-space: nowrap;
  448. }
  449. }
  450. }
  451. </style>