orderDetail.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <div class="orderDetail">
  3. <div class="Detail_con">
  4. <image :src="order.product_img" class="p_img" mode="widthFix" />
  5. <div class="p_t">{{ order.product_name }}</div>
  6. </div>
  7. <div class="money card">
  8. <div class="li flex_r flex_jb">
  9. <span>数量</span>
  10. <span>x {{ order.number }}</span>
  11. </div>
  12. <div class="li flex_r flex_jb">
  13. <span>消费金额</span>
  14. <span>¥{{ order.order_amount || 0 }}</span>
  15. </div>
  16. <div class="li flex_r flex_jb">
  17. <span>消费金抵扣<span class="corg">{{Integral}}%</span></span>
  18. <span class="corg">-¥{{ deduction || 0 }}</span>
  19. </div>
  20. <div class="li flex_r flex_jb">
  21. <span>实付金额</span>
  22. <span>¥{{ order.actually_paid || order.pay_amount }}</span>
  23. </div>
  24. </div>
  25. <div class="info card">
  26. <p>产品品牌:{{ order.restaurant_name }}</p>
  27. <p>产品名称:{{ order.product_name }}</p>
  28. <p>数量:{{ order.number }}</p>
  29. <p>手机号:{{ order.phone }}</p>
  30. <p>订单金额:¥{{ order.actually_paid || order.pay_amount }}</p>
  31. <p>订单编号:{{ order.trade_no }}</p>
  32. <p>下单时间:{{ order.create_time }}</p>
  33. </div>
  34. <div class="footbtn" v-if="$day().unix() < $day(order.create_time).add(15, 'm').unix() && order.status == 0" @click="pay">立即支付</div>
  35. </div>
  36. </template>
  37. <script>
  38. import { ToPayOpre } from "@/utils/reqTools.js";
  39. let toPayOpre = new ToPayOpre();
  40. import { post } from "@/request/api.js";
  41. export default {
  42. name: "orderDetail",
  43. props: {},
  44. data() {
  45. return {
  46. order: {},
  47. orders: [],
  48. pda: {},
  49. Integral: 0,
  50. deduction: 0,
  51. };
  52. },
  53. methods: {
  54. getOrderDetail(da) {
  55. post("local/ticket/orderDetail", da).then(res => {
  56. if (res.code == 0) {
  57. let da = res.data.order
  58. da.product_img = da.orderGoods[0].product_img;
  59. da.product_name = da.orderGoods[0].product_name;
  60. delete da.orderGoods;
  61. this.order = da;
  62. // if(res.data.detail.code == 200){
  63. // this.orders = res.data.detail.data;
  64. // }
  65. this.getIntegral()
  66. }
  67. })
  68. },
  69. getIntegral() {
  70. post("local/getIntegral", { type: 5 }).then(res => {
  71. if (res.code == 0) {
  72. let i1 = res.data.integral;
  73. this.Integral = this.$h.Mul(i1, 100);
  74. this.deduction = this.$h.Mul(this.order.order_amount, i1).toFixed(2);
  75. }
  76. })
  77. },
  78. pay() {
  79. let type = "";
  80. // #ifdef H5
  81. type = "H5";
  82. // #endif
  83. // #ifdef APP
  84. type = "app";
  85. // #endif
  86. // #ifdef MP-WEIXIN
  87. type = "jsapi";
  88. // #endif
  89. post("local/goOrderPay", { trade_no: this.order.trade_no,trade_type: type }).then(res => {
  90. if (res.code == 0 && res.data.data.prepayid) {
  91. toPayOpre.toPay(res.data.data, (rea) => {
  92. if (!rea) {
  93. // 支付成功
  94. this.getOrderDetail(this.pda);
  95. } else {
  96. // 支付失败
  97. }
  98. });
  99. }
  100. })
  101. },
  102. },
  103. onLoad(da) {
  104. this.getOrderDetail(da);
  105. this.pda = da;
  106. },
  107. onShow() {},
  108. mounted() {},
  109. };
  110. </script>
  111. <style scoped lang='scss'>
  112. .orderDetail{
  113. padding: 28rpx 30rpx;
  114. }
  115. .Detail_con{
  116. background-color: #fff;
  117. border-radius: 20rpx;
  118. padding: 28rpx 30rpx;
  119. margin-bottom: 30rpx;
  120. box-shadow: 4rpx 4rpx 8rpx 4rpx rgba(0, 0, 0, 0.12);
  121. .p_img{
  122. width: 100%;
  123. border-radius: 20rpx;
  124. }
  125. .p_t{
  126. font-size: 30rpx;
  127. font-weight: bold;
  128. }
  129. }
  130. .info{
  131. p{
  132. font-size: 28rpx;
  133. color: #666;
  134. margin-bottom: 8rpx;
  135. &:last-child {
  136. margin-bottom: 0;
  137. }
  138. }
  139. }
  140. .card {
  141. background-color: #fff;
  142. border-radius: 20rpx;
  143. margin-bottom: 30rpx;
  144. padding: 28rpx 30rpx;
  145. font-size: 32rpx;
  146. box-shadow: 4rpx 4rpx 8rpx 4rpx rgba(0, 0, 0, 0.12);
  147. &:last-child {
  148. margin-bottom: 0;
  149. }
  150. }
  151. .footbtn {
  152. width: calc(100% - 60rpx);
  153. height: 80rpx;
  154. background: #17bb87;
  155. border-radius: 45rpx;
  156. position: fixed;
  157. bottom: 50rpx;
  158. left: 30rpx;
  159. color: #fff;
  160. font-size: 36rpx;
  161. text-align: center;
  162. line-height: 80rpx;
  163. }
  164. .money{
  165. .li{
  166. margin-bottom: 16rpx;
  167. &:last-child{
  168. margin-bottom: 0;
  169. }
  170. span{
  171. font-size: 30rpx;
  172. }
  173. }
  174. .corg{
  175. color: #18bb88;
  176. margin-left: 5rpx;
  177. }
  178. }
  179. </style>