surOrder.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view class="sure-order">
  3. <view class="order-detail">
  4. <view class="order-title">
  5. <uv-text text="订单详情" :customStyle="{
  6. fontWeight:'bold'
  7. }" size="32"></uv-text>
  8. </view>
  9. <view class="order-content">
  10. <uv-image :src="imageUrl(orderData.rotatingImages) || ''" width="180" height="180" radius="16">
  11. </uv-image>
  12. <view class="order-content-detail">
  13. <uv-text :text="orderData.name" :lines="2" size="28"></uv-text>
  14. <uv-text text="x1" type="content" size="28" :customStyle="{
  15. background:'#eee',
  16. padding:'2rpx 16rpx',
  17. borderRadius:'4rpx',
  18. margin:'10rpx 0'
  19. }"></uv-text>
  20. <uv-text :text="orderData.price" type="error" size="32" mode="price"></uv-text>
  21. </view>
  22. </view>
  23. <view class="order-item">
  24. <uv-text text="优惠券" size="28"></uv-text>
  25. <view class="text-flex"
  26. @tap="$navigateTo('/subPages/workarkPage/coupon/coupon?productLevelId=' + orderData.productLevelId + '&price=' + orderData.price)">
  27. <text class="order-item-icon">-</text>
  28. <uv-text :text="minus" type="error" size="28" mode="price"></uv-text>
  29. <uv-icon name="arrow-right" size="32"></uv-icon>
  30. </view>
  31. </view>
  32. <view class="order-count">
  33. <view class="text-flex">
  34. <uv-text text="合计:" size="28"></uv-text>
  35. <uv-text :text="countPriceData.totalFee" type="error" size="28" mode="price"></uv-text>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="hui-button-box">
  40. <view class="button-flex">
  41. <uv-text :text="countPriceData.totalFee" type="error" size="28" mode="price"></uv-text>
  42. <view class="text-flex">
  43. <uv-text text="-" type="error" size="24"></uv-text>
  44. <uv-text :text="minus" type="error" size="24" mode="price"></uv-text>
  45. </view>
  46. </view>
  47. <uv-button type="primary" text="立即支付" @tap="payment" :disabled="isCount"></uv-button>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import {
  53. getServeById,
  54. countPriceAPI
  55. } from '@/request/api/workark.js'
  56. export default {
  57. data() {
  58. return {
  59. orderId: '',
  60. orderData: {
  61. price: 0
  62. },
  63. countPriceData: {
  64. productCoupon: [],
  65. totalFee: 0
  66. },
  67. isCount: false,
  68. couponChecked: []
  69. };
  70. },
  71. onLoad(body) {
  72. this.orderId = body.orderId;
  73. uni.$on('changeCoupon', this.changeCoupon);
  74. if (this.orderId) this.init();
  75. },
  76. computed: {
  77. minus() {
  78. let data = this.countPriceData.productCoupon || [];
  79. let num = 0;
  80. for (var i = 0; i < data.length; i++) {
  81. num += data[i].minus
  82. }
  83. return num;
  84. }
  85. },
  86. methods: {
  87. async init() {
  88. let orderData = await getServeById(this.orderId);
  89. if (!orderData.state) return;
  90. this.orderData = orderData.data;
  91. this.countPrice();
  92. },
  93. imageUrl(data) {
  94. if (!data) return '';
  95. let imgData = JSON.parse(data)[0];
  96. if (!imgData) return '';
  97. return imgData.url;
  98. },
  99. async countPrice() {
  100. this.isCount = true;
  101. let couponIds = this.couponChecked.map(node => node.id).join(',') || -1;
  102. let countPriceData = await countPriceAPI(this.orderData.id, couponIds);
  103. this.isCount = false;
  104. if (!countPriceData.state) return;
  105. this.countPriceData = countPriceData.data;
  106. },
  107. changeCoupon(data) {
  108. this.couponChecked = data;
  109. this.countPrice();
  110. },
  111. payment() {
  112. uni.requestPayment({
  113. provider: 'wxpay',
  114. timeStamp: String(Date.now()),
  115. nonceStr: 'BOSSHAND',
  116. package: 'prepay_id=wx3c006d364161d240',
  117. signType: 'MD5',
  118. paySign: '',
  119. success: function(res) {
  120. console.log('success:' + JSON.stringify(res));
  121. },
  122. fail: function(err) {
  123. console.log('fail:' + JSON.stringify(err));
  124. }
  125. });
  126. }
  127. },
  128. }
  129. </script>
  130. <style lang="scss">
  131. .sure-order {
  132. padding: 30rpx;
  133. }
  134. .order-detail {
  135. background: #fff;
  136. padding: 30rpx;
  137. border-radius: 16rpx;
  138. }
  139. .order-title {
  140. padding-bottom: 30rpx;
  141. }
  142. .order-content {
  143. display: flex;
  144. }
  145. .order-content-detail {
  146. flex: 1;
  147. width: 0;
  148. margin-left: 30rpx;
  149. }
  150. .order-item {
  151. display: flex;
  152. justify-content: space-between;
  153. align-items: center;
  154. height: 88rpx;
  155. border-bottom: 1px solid $uv-border-color;
  156. margin-bottom: 30rpx;
  157. }
  158. .order-item-icon {
  159. color: $uv-error;
  160. }
  161. .order-count {
  162. display: flex;
  163. justify-content: flex-end;
  164. }
  165. .button-flex {
  166. margin-right: 20rpx;
  167. }
  168. </style>