orderDetail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <div class="orderDetail">
  3. <div class="card">
  4. <div class="hotelName">{{ hotel.hotelName }}</div>
  5. <div class="address">{{ hotel.address }}</div>
  6. <div class="btnico flex_r flex_jb">
  7. <div class="btn_i" @click="openm">
  8. <span class="iconfont">&#xe8ae;</span>
  9. <div class="t">查看地图</div>
  10. </div>
  11. <div class="btn_i" @click="PhoneCall(hotel.phone)">
  12. <span class="iconfont">&#xe8ad;</span>
  13. <div class="t">联系酒店</div>
  14. </div>
  15. </div>
  16. <div class="roominfo">
  17. <div class="name">{{ roomInfo.roomName }}</div>
  18. <div class="days">
  19. <span>{{ daydate(roomInfo.checkInDate) }} - {{ daydate(roomInfo.checkOutDate) }}</span>
  20. <span class="dn">共{{ getDaysBetween(roomInfo.checkInDate,roomInfo.checkOutDate) }}晚</span>
  21. </div>
  22. <div class="tegs">
  23. <span>{{ roomInfo.windowType }}</span>
  24. <span>{{ roomInfo.breakfast }}</span>
  25. <span>{{ roomInfo.useableArea }}</span>
  26. <span>{{ roomInfo.bedType }}</span>
  27. </div>
  28. <div class="pli">
  29. <div class="label">入住人</div>
  30. <span>{{ qda.guestNames }}</span>
  31. </div>
  32. <div class="pli">
  33. <div class="label">联系手机</div>
  34. <span>{{ qda.contactMobile }}</span>
  35. </div>
  36. <div class="pli" v-if="detail.arriveTime">
  37. <div class="label">预计到店</div>
  38. <span>{{ qda.arriveTime }}</span>
  39. </div>
  40. <div class="pli" v-else>
  41. <div class="label">入住时间</div>
  42. <span>{{ qda.checkInDate + " 12:00" }}后</span>
  43. </div>
  44. </div>
  45. </div>
  46. <template v-if="detail && JSON.stringify(detail) != '{}'">
  47. <div class="card">
  48. <div class="tit">订单信息</div>
  49. <div class="pli">
  50. <div class="label">订单编号:</div>
  51. <span>{{ order.trade_no }}</span>
  52. </div>
  53. <div class="pli">
  54. <div class="label">平台编号:</div>
  55. <span>{{ detail.orderNo }}</span>
  56. </div>
  57. <div class="pli">
  58. <div class="label">下单时间:</div>
  59. <span>{{ order.create_time }}</span>
  60. </div>
  61. </div>
  62. </template>
  63. <template v-else>
  64. <div class="money card">
  65. <div class="li flex_r flex_jb">
  66. <span>消费金额</span>
  67. <span>¥{{ order.order_amount || 0 }}</span>
  68. </div>
  69. <div class="li flex_r flex_jb">
  70. <span>消费券抵扣<span class="corg">{{Integral}}%</span></span>
  71. <span class="corg">-¥{{ deduction || 0 }}</span>
  72. </div>
  73. <div class="li flex_r flex_jb">
  74. <span>实付金额</span>
  75. <span>¥{{ actuallypaid || 0 }}</span>
  76. </div>
  77. </div>
  78. <div class="money card">
  79. <div class="li flex_r flex_jb">
  80. <span>赠送贡献值</span>
  81. <span>{{ chabao || 0 }}</span>
  82. </div>
  83. </div>
  84. <div class="footbtn" @click="pay" v-if="$day().unix() < $day(order.create_time).add(15, 'm').unix() && order.status == 0">立即支付</div>
  85. </template>
  86. </div>
  87. </template>
  88. <script>
  89. import { ToPayOpre } from "@/utils/reqTools.js";
  90. let toPayOpre = new ToPayOpre();
  91. import { getDaysBetween } from "@/utils/myfun.js"
  92. import { post } from "@/request/api.js";
  93. export default {
  94. name: "orderDetail",
  95. props: {},
  96. components: {},
  97. data() {
  98. return {
  99. tradeNo: "",
  100. hotel: {},
  101. detail: {},
  102. order: {},
  103. roomInfo: {},
  104. qda: {},
  105. Integral: 0,
  106. deduction: 0,
  107. actuallypaid: 0,
  108. chabao: 0,
  109. };
  110. },
  111. methods: {
  112. getDaysBetween,
  113. daydate(va) {
  114. return this.$day(va).format("M月DD日")
  115. },
  116. daydate2(va) {
  117. return this.$day(va).format("YYYY-MM-DD")
  118. },
  119. getorderDetail(da) {
  120. post("local/ticket/orderDetail",da).then(res => {
  121. if (res.code == 0) {
  122. this.detail = res.data.detail.data
  123. this.order = res.data.order
  124. this.roomInfo = JSON.parse(res.data.order.orderGoods[0].attachment);
  125. let de = JSON.parse(res.data.order.product_detail)
  126. let { hotelID,checkInDate,checkOutDate } = de
  127. this.gethotel({ hotelID,checkInDate,checkOutDate })
  128. this.qda = de
  129. this.getIntegral()
  130. }
  131. })
  132. },
  133. gethotel(da){
  134. post("local/hotel/detail", da).then((res) => {
  135. if (res.code == 0) {
  136. this.hotel = res.data.data;
  137. }
  138. });
  139. },
  140. openm() {
  141. let latitude = this.hotel.googleLat;
  142. let longitude = this.hotel.googleLon;
  143. let name = this.hotel.hotelName;
  144. let address = this.hotel.address;
  145. uni.openLocation({
  146. latitude, longitude, scale: 18, name, address,
  147. success: function() {
  148. console.log('success');
  149. }
  150. });
  151. },
  152. PhoneCall(va){
  153. uni.makePhoneCall({ phoneNumber: va });
  154. },
  155. getIntegral() {
  156. post("local/getIntegral", { type: 4 }).then(res => {
  157. if (res.code == 0) {
  158. let i1 = res.data.integral, i2 = res.data.chabao;
  159. this.Integral = this.$h.Mul(i1, 100);
  160. this.deduction = this.$h.Mul(this.order.order_amount, i1);
  161. this.actuallypaid = this.$h.Sub(this.order.order_amount, this.deduction);
  162. this.chabao = this.$h.Mul(this.actuallypaid, i2).toFixed(2);
  163. }
  164. })
  165. },
  166. async pay() {
  167. let type = "";
  168. // #ifdef H5
  169. type = "H5";
  170. // #endif
  171. // #ifdef APP
  172. type = "app";
  173. // #endif
  174. // #ifdef MP-WEIXIN
  175. type = "jsapi";
  176. // #endif
  177. let adres = await uni.Location();
  178. post("local/goOrderPay", { trade_no: this.order.trade_no,trade_type: type,location: "+"+adres.lat+'/+'+adres.lng }).then(res => {
  179. if(res.data && res.data != 200){
  180. let data = {
  181. ...res.data,
  182. appId:res.data.app_id,
  183. nonceStr:res.data.nonce_str,
  184. package:res.data.package,
  185. signType:res.data.sign_type,
  186. paySign:res.data.pay_sign,
  187. timeStamp:res.data.time_stamp,
  188. prepayid:res.data.prepay_id
  189. }
  190. if (res.code == 0 && data.prepayid) {
  191. toPayOpre.toPay(data, (rea) => {
  192. if (!rea) {
  193. // 支付成功
  194. this.getTicket(this.pda);
  195. } else {
  196. // 支付失败
  197. }
  198. });
  199. }
  200. }
  201. })
  202. },
  203. },
  204. onLoad(da) {
  205. this.tradeNo = da.trade_no;
  206. this.getorderDetail(da);
  207. },
  208. onShow() {},
  209. mounted() {},
  210. };
  211. </script>
  212. <style scoped lang='scss'>
  213. .orderDetail{
  214. padding: 28rpx 32rpx;
  215. .hotelName{
  216. font-size: 36rpx;
  217. font-weight: 600;
  218. }
  219. .address{
  220. font-size: 25rpx;
  221. color: #555;
  222. margin-top: 10rpx;
  223. }
  224. .btnico{
  225. padding: 26rpx 36rpx;
  226. margin-bottom: 10rpx;
  227. .iconfont{
  228. font-size: 40rpx;
  229. font-weight: bold;
  230. }
  231. .btn_i{
  232. text-align: center;
  233. .t{
  234. font-size: 22rpx;
  235. margin-top: 6rpx;
  236. }
  237. }
  238. }
  239. .roominfo{
  240. margin-top: 10rpx;
  241. .name{
  242. font-size: 32rpx;
  243. font-weight: 600;
  244. }
  245. .days{
  246. margin-top: 12rpx;
  247. font-size: 28rpx;
  248. .dn{
  249. margin-left: 16rpx;
  250. }
  251. }
  252. .tegs{
  253. font-size: 26rpx;
  254. margin: 12rpx 0 36rpx;
  255. span{
  256. margin-right: 12rpx;
  257. &:last-child{
  258. margin-right: 0;
  259. }
  260. }
  261. }
  262. }
  263. .pli{
  264. margin-bottom: 10rpx;
  265. font-size: 26rpx;
  266. &:last-child{
  267. margin-bottom: 0;
  268. }
  269. .label{
  270. width: 150rpx;
  271. font-weight: 600;
  272. display: inline-block;
  273. }
  274. }
  275. .tit{
  276. font-size: 32rpx;
  277. font-weight: 600;
  278. margin-bottom: 16rpx;
  279. }
  280. }
  281. .money {
  282. .li {
  283. margin-bottom: 16rpx;
  284. &:last-child {
  285. margin-bottom: 0;
  286. }
  287. span {
  288. font-size: 30rpx;
  289. }
  290. }
  291. .corg {
  292. color: #18bb88;
  293. margin-left: 12rpx;
  294. }
  295. }
  296. .footbtn {
  297. width: calc(100% - 60rpx);
  298. height: 80rpx;
  299. background: #17bb87;
  300. border-radius: 45rpx;
  301. position: fixed;
  302. bottom: 50rpx;
  303. left: 30rpx;
  304. color: #fff;
  305. font-size: 36rpx;
  306. text-align: center;
  307. line-height: 80rpx;
  308. }
  309. .card {
  310. background-color: #fff;
  311. border-radius: 20rpx;
  312. margin-bottom: 30rpx;
  313. padding: 28rpx 30rpx;
  314. font-size: 32rpx;
  315. box-shadow: 4rpx 4rpx 8rpx 4rpx rgba(0, 0, 0, 0.12);
  316. &:last-child {
  317. margin-bottom: 0;
  318. }
  319. }
  320. </style>