orderdes.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <view>
  3. <loadSke :loading='loading'>
  4. <view class="remind">请到影院现场柜台或取票机取票</view>
  5. <view class="des-box">
  6. <loadSke :loading='qrcodeLoading'>
  7. <view v-if="ticketType==2">
  8. <view v-if="orderDes.orderDataJson.filmMcpData" class="code-box">
  9. <view class="code">
  10. <text>取票码</text>
  11. <text>{{orderDes.orderDataJson.filmMcpData.ticket.slice(4)}}</text>
  12. </view>
  13. <image class="qrcode" :src="filmDes.qrcode" mode="widthFix"></image>
  14. </view>
  15. <view v-else class="code-box">
  16. <image src="https://t1-1305573081.cos.ap-shanghai.myqcloud.com/wxapp/static/imgs/%E8%AE%A2%E5%8D%95%E5%85%B3%E9%97%AD.png"
  17. class="qrcode-loading" mode="widthFix"></image>
  18. </view>
  19. </view>
  20. <view v-else-if="ticketType!=2">
  21. <view v-if="filmDes.orderStatus < 4" class="code-box">
  22. <image src="https://t1-1305573081.cos.ap-shanghai.myqcloud.com/wxapp/static/imgs/%E7%94%B5%E5%BD%B1%E7%A5%A8%E7%AD%89%E5%BE%85.png"
  23. class="qrcode-loading" mode="widthFix"></image>
  24. </view>
  25. <view v-else-if="filmDes.orderStatus != 10" class="code-box" v-for="(item,index) in filmDes.qrcode" :key='index'>
  26. <view class="code">
  27. <text>取票码</text>
  28. <text>{{item.code}}</text>
  29. </view>
  30. <image class="qrcode" :src="item.qrcode" mode="widthFix"></image>
  31. </view>
  32. <view v-else class="code-box">
  33. <image src="https://t1-1305573081.cos.ap-shanghai.myqcloud.com/wxapp/static/imgs/%E8%AE%A2%E5%8D%95%E5%85%B3%E9%97%AD.png"
  34. class="qrcode-loading" mode="widthFix"></image>
  35. </view>
  36. </view>
  37. </loadSke>
  38. <view class="order-num">
  39. <text>订单号:{{orderDes.outTradeNo}}</text>
  40. <text>{{filmDes.orderStatusStr}}</text>
  41. </view>
  42. <view class="des">
  43. <text class="film-name">{{orderDes.orderDataJson.cinemaData.filmName}}</text>
  44. <view class="film-time">
  45. <text>时间</text>
  46. <text>{{orderDes.orderDataJson.cinemaData.showTime}}</text>
  47. </view>
  48. <view class="film-address">
  49. <text>影院</text>
  50. <text>{{orderDes.orderDataJson.cinemaData.cinemaName}}</text>
  51. </view>
  52. <view class="film-video">
  53. <text>影厅</text>
  54. <text>{{orderDes.orderDataJson.cinemaData.hallName}}</text>
  55. </view>
  56. <view class="film-seat">
  57. <text>座位</text>
  58. <view class="seat-box">
  59. <text v-for="(item,index) in seatList" :key='index'>{{item}}</text>
  60. </view>
  61. </view>
  62. </view>
  63. <view class="price">
  64. <text>总价</text>
  65. <text>¥{{orderDes.total/100}}</text>
  66. </view>
  67. </view>
  68. </loadSke>
  69. </view>
  70. </template>
  71. <script>
  72. import {
  73. getWxOrder
  74. } from '@/api/order.js'
  75. import {
  76. orderQuery
  77. } from '@/api/cinema.js'
  78. import QRCode from 'qrcode'
  79. export default {
  80. data: () => ({
  81. orderDes: {},
  82. seatList: [],
  83. outTradeNo: null,
  84. loading: true,
  85. pollingTiemId: null,
  86. filmDes: {},
  87. qrcode: null,
  88. qrcodeLoading: true,
  89. ticketType: null
  90. }),
  91. onLoad: function(option) {
  92. this.outTradeNo = option.outTradeNo
  93. },
  94. mounted() {
  95. this.init()
  96. },
  97. computed: {},
  98. methods: {
  99. async init() {
  100. let orderRes = await getWxOrder(this.outTradeNo)
  101. orderRes.data.orderDataJson = JSON.parse(orderRes.data.orderDataJson)
  102. this.orderDes = orderRes.data
  103. this.seatList = this.orderDes.orderDataJson.wxOrderCreateDTO.seat.split(',')
  104. this.ticketType = this.orderDes.orderDataJson.wxOrderCreateDTO.ticketType
  105. if (this.ticketType == 2) {
  106. if (this.orderDes.orderDataJson.filmMcpData) {
  107. this.qrcode = await this.qrcodeGenerate(this.orderDes.orderDataJson.filmMcpData.ticket.slice(4))
  108. }
  109. }
  110. if (this.ticketType != 2) {
  111. let filmRes = await orderQuery({
  112. thirdOrderId: this.outTradeNo
  113. })
  114. this.filmDes = filmRes.data.data
  115. if (this.filmDes.orderStatus < 4) {
  116. this.polling()
  117. } else if (this.filmDes.orderStatus < 10) {
  118. this.qrcodeShow()
  119. }
  120. }
  121. this.loading = false
  122. this.qrcodeLoading = false
  123. },
  124. polling() {
  125. this.pollingTiemId = setInterval(async () => {
  126. let filmRes = await orderQuery({
  127. thirdOrderId: this.outTradeNo
  128. })
  129. this.filmDes = filmRes.data.data
  130. if (this.filmDes.orderStatus == 4 || this.filmDes.orderStatus == 5) {
  131. clearInterval(this.pollingTiemId)
  132. this.qrcodeShow()
  133. }
  134. }, 3000)
  135. },
  136. qrcodeShow() {
  137. let qrcode = []
  138. this.filmDes.ticketCode.forEach(async val => {
  139. if (val.type == 1) {
  140. let qr = await this.qrcodeGenerate(val.code)
  141. qrcode.push({
  142. qrcode: qr,
  143. code: val.code
  144. })
  145. }
  146. })
  147. this.$set(this.filmDes, 'qrcode', qrcode)
  148. },
  149. async qrcodeGenerate(data) {
  150. let qrcodeRes = await QRCode.toString(data, {
  151. margin: 0,
  152. errorCorrectionLevel: 'H'
  153. });
  154. return 'data:image/svg+xml;base64,' + Buffer(qrcodeRes).toString('base64');
  155. }
  156. },
  157. beforeDestroy() {
  158. clearInterval(this.pollingTiemId)
  159. }
  160. }
  161. </script>
  162. <style lang="scss">
  163. .remind {
  164. margin-top: 36rpx;
  165. font-size: 26rpx;
  166. font-weight: 400;
  167. color: #0F0404;
  168. text-align: center;
  169. }
  170. .des-box {
  171. width: 564rpx;
  172. background: #FFFFFF;
  173. border-radius: 20rpx;
  174. margin: auto;
  175. margin-top: 30rpx;
  176. .code-box {
  177. display: flex;
  178. flex-direction: column;
  179. align-items: center;
  180. padding-bottom: 38rpx;
  181. .code {
  182. margin-top: 43rpx;
  183. text {
  184. font-size: 26rpx;
  185. font-weight: 400;
  186. color: #666666;
  187. margin-right: 20rpx;
  188. &:nth-child(2) {
  189. color: #0F0404;
  190. }
  191. }
  192. }
  193. .qrcode {
  194. margin-top: 43rpx;
  195. width: 260rpx;
  196. height: 260rpx;
  197. }
  198. .qrcode-loading {
  199. margin-top: 43rpx;
  200. width: 100%;
  201. }
  202. }
  203. .order-num {
  204. display: flex;
  205. justify-content: space-between;
  206. align-items: center;
  207. padding: 34rpx 31rpx;
  208. border-top: 1rpx dashed #D9D9D9;
  209. border-bottom: 1rpx dashed #D9D9D9;
  210. position: relative;
  211. &::after {
  212. content: '';
  213. width: 24rpx;
  214. height: 24rpx;
  215. border-radius: 50%;
  216. background-color: #F1F1F1;
  217. position: absolute;
  218. top: 0;
  219. left: 0;
  220. transform: translate(-50%, -50%);
  221. }
  222. &::before {
  223. content: '';
  224. width: 24rpx;
  225. height: 24rpx;
  226. border-radius: 50%;
  227. background-color: #F1F1F1;
  228. position: absolute;
  229. top: 0;
  230. right: 0;
  231. transform: translate(50%, -50%);
  232. }
  233. text {
  234. &:nth-child(1) {
  235. width: 60%;
  236. word-break: break-all;
  237. font-size: 26rpx;
  238. font-weight: 400;
  239. color: #666666;
  240. }
  241. &:nth-child(2) {
  242. padding: 10rpx;
  243. display: flex;
  244. justify-content: center;
  245. align-items: center;
  246. background: #FFE5E5;
  247. border: 1rpx solid #E31818;
  248. border-radius: 20rpx;
  249. font-size: 20rpx;
  250. font-weight: 400;
  251. color: #E31818;
  252. }
  253. }
  254. }
  255. .des {
  256. padding: 45rpx 30rpx;
  257. border-bottom: 1rpx dashed #D9D9D9;
  258. display: flex;
  259. flex-direction: column;
  260. .film-name {
  261. font-size: 30rpx;
  262. font-weight: 400;
  263. color: #0F0404;
  264. }
  265. text {
  266. font-size: 26rpx;
  267. font-weight: 400;
  268. color: #666666;
  269. margin-right: 20rpx;
  270. white-space: nowrap;
  271. }
  272. .film-time {
  273. text:nth-child(2) {
  274. color: #999999;
  275. }
  276. }
  277. .film-address {
  278. text:nth-child(2) {
  279. color: #999999;
  280. }
  281. }
  282. .film-video {
  283. text:nth-child(2) {
  284. color: #999999;
  285. }
  286. }
  287. .film-seat {
  288. display: flex;
  289. justify-content: flex-start;
  290. align-items: stretch;
  291. margin-top: 10rpx;
  292. .seat-box {
  293. display: flex;
  294. flex-wrap: wrap;
  295. text {
  296. height: 40rpx;
  297. padding: 4rpx 15rpx;
  298. margin-bottom: 10rpx;
  299. background: #EBEBEB;
  300. border-radius: 4rpx;
  301. color: #999999;
  302. }
  303. }
  304. }
  305. }
  306. .price {
  307. padding: 40rpx 30rpx;
  308. text {
  309. font-size: 26rpx;
  310. font-weight: 400;
  311. color: #666666;
  312. margin-right: 20rpx;
  313. &:nth-child(2) {
  314. color: #E31818;
  315. }
  316. }
  317. }
  318. }
  319. </style>