placeorder.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  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: function(option) {
  128. this.seatResult = JSON.parse(option.seatResult).map((val) => {
  129. return JSON.parse(val)
  130. })
  131. this.showItem = JSON.parse(option.showItem);
  132. },
  133. computed: {
  134. filmDes() {
  135. let des = {}
  136. this.$store.state.cinema.filmList.forEach((val) => {
  137. if (val.filmId == this.showItem.filmId) {
  138. des = val
  139. }
  140. })
  141. return des;
  142. },
  143. filmDiscount() {
  144. return this.$store.state.cinema.filmDiscount;
  145. },
  146. discountRule() {
  147. return this.$store.state.cinema.discountRule;
  148. },
  149. aPrice() {
  150. let discountRule = (this.showItem.netPrice > 3900 ? this.discountRule.upDiscountRate : this.discountRule.downDiscountRate)
  151. let filmDiscount = this.filmDiscount
  152. let netPrice = this.showItem.netPrice / 100
  153. return (netPrice * discountRule * filmDiscount).toFixed(2)
  154. },
  155. aDiscount() {
  156. let discountRule = (this.showItem.netPrice > 3900 ? this.discountRule.upDiscountRate : this.discountRule.downDiscountRate)
  157. let filmDiscount = this.filmDiscount
  158. let netPrice = this.showItem.netPrice / 100
  159. return (netPrice - netPrice * discountRule * filmDiscount).toFixed(2)
  160. },
  161. allPrice() {
  162. let discountRule = (this.showItem.netPrice > 3900 ? this.discountRule.upDiscountRate : this.discountRule.downDiscountRate)
  163. let filmDiscount = this.filmDiscount
  164. let netPrice = this.showItem.netPrice / 100
  165. if(this.radioType==1){
  166. return (this.seatResult.length * netPrice * discountRule * filmDiscount).toFixed(2)
  167. }
  168. if(this.radioType==2){
  169. return (this.seatResult.length * netPrice).toFixed(2)
  170. }
  171. },
  172. allDiscount() {
  173. let discountRule = (this.showItem.netPrice > 3900 ? this.discountRule.upDiscountRate : this.discountRule.downDiscountRate)
  174. let filmDiscount = this.filmDiscount
  175. let netPrice = this.showItem.netPrice / 100
  176. if(this.radioType==1){
  177. return (this.seatResult.length * (netPrice - netPrice * discountRule * filmDiscount)).toFixed(2)
  178. }
  179. if(this.radioType==2){
  180. return (this.seatResult.length * (netPrice - netPrice)).toFixed(2)
  181. }
  182. },
  183. },
  184. methods: {
  185. radioOnChange(e) {
  186. this.orderRes = {}
  187. this.radioType = e.detail
  188. },
  189. onChange({
  190. detail
  191. }) {
  192. // 需要手动对 checked 状态进行更新
  193. if (detail) {
  194. this.acceptChangeSeat = 1
  195. } else {
  196. this.acceptChangeSeat = 0
  197. }
  198. },
  199. async buy() {
  200. //已有订单则直接请求历史数据
  201. if (this.orderRes.code == 200) {
  202. let payRes = await wx.requestPayment(this.orderRes.data)
  203. console.log(payRes)
  204. return false
  205. }
  206. let seat = [],
  207. seatId = [],
  208. seatNo = []
  209. this.seatResult.forEach(val => {
  210. seat.push(val.seatNo)
  211. seatNo.push(val.seatNo)
  212. seatId.push(val.seatId)
  213. })
  214. prepareOrder({
  215. acceptChangeSeat: this.acceptChangeSeat,
  216. seat: seat.join(','),
  217. seatId: seatId.join('|'),
  218. seatNo: seatNo.join('|'),
  219. showId: this.showItem.showId,
  220. cinemaId: this.showItem.cinemaId,
  221. goodsPictureUrl: this.filmDes.pic,
  222. goodsType: '1',
  223. ticketType: this.radioType
  224. }).then(async res => {
  225. this.orderRes = res
  226. let payRes = await wx.requestPayment(this.orderRes.data)
  227. if (payRes.errMsg == 'requestPayment:ok') {
  228. this.goPage(`/pages/cinema/orderdes?outTradeNo=${this.orderRes.data.outTradeNo}`, 'reLaunch')
  229. }
  230. console.log(payRes)
  231. })
  232. }
  233. }
  234. }
  235. </script>
  236. <style lang="scss" scoped>
  237. .film-des {
  238. padding: 40rpx 30rpx;
  239. margin-top: 20rpx;
  240. background-color: #FFFFFF;
  241. display: flex;
  242. .left-img {
  243. width: 170rpx;
  244. height: 236rpx;
  245. margin-right: 20rpx;
  246. }
  247. .right-box {
  248. display: flex;
  249. flex-direction: column;
  250. justify-content: space-between;
  251. .film-name {
  252. font-size: 30rpx;
  253. font-weight: 400;
  254. color: #0F0404;
  255. }
  256. .film-time {
  257. font-size: 26rpx;
  258. font-weight: 400;
  259. color: #666666;
  260. line-height: 39rpx;
  261. }
  262. .film-caveat {
  263. display: flex;
  264. .item {
  265. display: flex;
  266. align-items: center;
  267. margin-right: 33rpx;
  268. font-size: 26rpx;
  269. font-weight: 400;
  270. color: #0F0404;
  271. }
  272. }
  273. }
  274. }
  275. .select-des {
  276. background-color: #FFFFFF;
  277. margin-top: 20rpx;
  278. padding-bottom: 1rpx;
  279. .tit-text {
  280. padding: 30rpx;
  281. font-size: 26rpx;
  282. font-weight: 400;
  283. color: #0F0404;
  284. border-bottom: 1rpx solid #E8E8E8;
  285. }
  286. .options-box {
  287. display: flex;
  288. justify-content: space-between;
  289. align-items: center;
  290. margin: 30rpx;
  291. .left-box {
  292. display: flex;
  293. .img {
  294. width: 66rpx;
  295. height: 66rpx;
  296. margin-right: 20rpx;
  297. }
  298. .text-box {
  299. display: flex;
  300. flex-direction: column;
  301. .top {
  302. font-size: 26rpx;
  303. font-weight: 400;
  304. color: #0F0404;
  305. }
  306. .bottom {
  307. font-size: 22rpx;
  308. font-weight: 400;
  309. color: #666666;
  310. }
  311. }
  312. }
  313. .right-box {
  314. display: flex;
  315. align-items: center;
  316. .text-box {
  317. display: flex;
  318. flex-direction: column;
  319. justify-content: space-around;
  320. align-items: flex-end;
  321. margin-right: 23rpx;
  322. .top {
  323. font-size: 26rpx;
  324. font-weight: 400;
  325. color: #E31818;
  326. }
  327. .bottom {
  328. font-size: 20rpx;
  329. font-weight: 400;
  330. color: #605A5A;
  331. }
  332. }
  333. }
  334. }
  335. }
  336. .seat-select {
  337. background-color: #FFFFFF;
  338. margin-top: 20rpx;
  339. display: flex;
  340. justify-content: space-between;
  341. align-items: center;
  342. padding: 20rpx 30rpx;
  343. .tit-text {
  344. font-size: 26rpx;
  345. font-weight: 400;
  346. color: #E31818;
  347. }
  348. }
  349. .seat-des {
  350. background-color: #FFFFFF;
  351. margin-top: 20rpx;
  352. .tit-text {
  353. font-size: 26rpx;
  354. font-weight: 400;
  355. color: #0F0404;
  356. padding: 30rpx;
  357. border-bottom: 1rpx solid #E8E8E8;
  358. }
  359. .seat-box {
  360. display: flex;
  361. justify-content: flex-start;
  362. padding: 10rpx 30rpx;
  363. .left {
  364. white-space: nowrap;
  365. height: 96rpx;
  366. margin-top: 10rpx;
  367. }
  368. .right {
  369. display: flex;
  370. flex-wrap: wrap;
  371. justify-content: flex-start;
  372. align-items: center;
  373. .item {
  374. width: 134rpx;
  375. height: 96rpx;
  376. margin: 10rpx;
  377. background: #EBEBEB;
  378. border-radius: 10rpx;
  379. display: flex;
  380. flex-direction: column;
  381. justify-content: center;
  382. align-items: center;
  383. .top {
  384. font-size: 26rpx;
  385. font-weight: 400;
  386. color: #666666;
  387. }
  388. .bottom {
  389. font-size: 22rpx;
  390. font-weight: 400;
  391. color: #E31923;
  392. }
  393. }
  394. }
  395. }
  396. }
  397. .buy-des {
  398. display: flex;
  399. justify-content: space-between;
  400. align-items: center;
  401. background-color: #FFFFFF;
  402. width: 100vw;
  403. box-sizing: border-box;
  404. position: fixed;
  405. bottom: 0;
  406. padding: 15rpx 30rpx;
  407. padding-bottom: calc(10px + env(safe-area-inset-bottom)/2);
  408. .left {
  409. display: flex;
  410. justify-content: space-between;
  411. align-items: center;
  412. width: 50%;
  413. .one {
  414. font-size: 26rpx;
  415. color: #0F0404;
  416. }
  417. .two {
  418. font-size: 36rpx;
  419. color: #E31919;
  420. }
  421. .three {
  422. font-size: 22rpx;
  423. color: #E86125;
  424. }
  425. }
  426. .right {
  427. width: 40%;
  428. display: flex;
  429. justify-content: space-between;
  430. align-items: center;
  431. .text {
  432. font-size: 26rpx;
  433. color: #0F0404;
  434. }
  435. .btn {
  436. margin: 0;
  437. width: 200rpx;
  438. height: 80rpx;
  439. background: linear-gradient(90deg, #E31818, #ED3E24, #ED4F24);
  440. border-radius: 40rpx;
  441. font-size: 30rpx;
  442. color: #FFFFFF;
  443. display: flex;
  444. justify-content: center;
  445. align-items: center;
  446. white-space: nowrap;
  447. }
  448. }
  449. }
  450. </style>