placeorder.vue 12 KB

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