orderDetail.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <view class="order-detail">
  3. <view class="hui-detail">
  4. <view class="detail-box">
  5. <view class="title-box">
  6. <view class="title">{{orderData.title||'-'}}</view>
  7. <view class="date">{{orderData.createTime || '-'}}</view>
  8. <view class="title-icon">
  9. <uni-icons type="icon-hetongwendang" custom-prefix="iconfont" color="#fff" size="18">
  10. </uni-icons>
  11. </view>
  12. </view>
  13. <view class="other">
  14. <view class="item">
  15. <view class="label">订单编号</view>
  16. <view class="value"> {{orderData.orderNo ||'-'}}</view>
  17. </view>
  18. <view class="item">
  19. <view class="label">价格(元)</view>
  20. <view class="value color-error">{{orderData.totalFee || '-'}}</view>
  21. </view>
  22. </view>
  23. <view class="state">
  24. <view></view>
  25. <view class="tag">
  26. <view class="status-tag" :class="{
  27. 'warning':orderData.orderStatus === '未支付',
  28. 'success':orderData.orderStatus === '支付成功',
  29. 'error':orderData.orderStatus === '超时已关闭'
  30. }">
  31. {{orderData.orderStatus}}
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="detail-box" v-if="orderData.contractId">
  37. <view class="sub-title file-box">
  38. <uni-icons type="map-filled" class="inherit-icons" size="24" color="#08979c"></uni-icons>
  39. <text class="sub-label">订单合同</text>
  40. </view>
  41. <view class="other">
  42. <view class="item" v-if="orderData.contractId">
  43. <view class="label">合同编号</view>
  44. <view class="value">{{contractNode.contractNo}}</view>
  45. </view>
  46. <view class="item" v-if="orderData.contractId">
  47. <view class="label">合同内容</view>
  48. <view class="value">
  49. <text class="color-primary" @tap="lookContract">查看合同</text>
  50. </view>
  51. </view>
  52. <view class="item">
  53. <view class="label">合同状态</view>
  54. <view class="value">
  55. <uv-steps :current="current" direction="column" dot>
  56. <uv-steps-item title="服务商上传合同" :desc="contractNode.createDate"></uv-steps-item>
  57. <uv-steps-item title="客户确认" :desc="contractNode.confirmDate"></uv-steps-item>
  58. <uv-steps-item title="服务商盖章" :desc="contractNode.processDate"></uv-steps-item>
  59. <uv-steps-item title="客户盖章" :desc="contractNode.updateDate"></uv-steps-item>
  60. <uv-steps-item title="签约成功" :desc="contractNode.updateDate"></uv-steps-item>
  61. </uv-steps>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="detail-box" v-if="contractProcessList.length > 0">
  67. <view class="sub-title file-box">
  68. <uni-icons type="map-filled" class="inherit-icons" size="24" color="#08979c"></uni-icons>
  69. <text class="sub-label">订单过程</text>
  70. </view>
  71. <view class="other process-box">
  72. <process-item :list="contractProcessList"></process-item>
  73. </view>
  74. </view>
  75. </view>
  76. <view class="hui-button-box" v-if="operationBtn.length>0">
  77. <view class="hui-button" v-for="(item,index) in operationBtn" :key="index" @click="operation(item)">
  78. {{item.name}}
  79. </view>
  80. </view>
  81. </view>
  82. </template>
  83. <script>
  84. import {
  85. getOrderDetail,
  86. getBindContract,
  87. getProcessData,
  88. getOrderDetailByOrderNo,
  89. getWxPay
  90. } from '@/request/api/workark.js'
  91. import processItem from '@/subPages/indexPage/components/processItem.vue';
  92. import config from '@/config';
  93. export default {
  94. components: {
  95. processItem
  96. },
  97. data() {
  98. return {
  99. orderId: '',
  100. orderNo: '',
  101. orderData: {},
  102. operationBtn: [],
  103. contractNode: {},
  104. current: 0,
  105. contractProcessList: []
  106. };
  107. },
  108. onLoad(body) {
  109. this.orderId = body.orderId;
  110. this.orderNo = body.orderNo;
  111. this.init();
  112. },
  113. methods: {
  114. async init() {
  115. this.operationBtn = [];
  116. let orderData = {};
  117. if (this.orderId) {
  118. orderData = await getOrderDetail(this.orderId);
  119. } else if (this.orderNo) {
  120. orderData = await getOrderDetailByOrderNo(this.orderNo);
  121. }
  122. if (!orderData.state) return;
  123. this.orderData = orderData.data;
  124. this.current = this.returnCurrent();
  125. this.initProcessData();
  126. if (this.orderData.contractId) this.initBindContract();
  127. if (this.orderData.orderStatus === '未支付') this.operationBtn = [{
  128. id: 4,
  129. type: 'primary',
  130. name: '立即支付'
  131. }]
  132. },
  133. async initBindContract() {
  134. let contractNode = await getBindContract(this.orderData.contractId);
  135. if (!contractNode.state) return;
  136. this.contractNode = contractNode.data;
  137. },
  138. async initProcessData() {
  139. let contractProcess = await getProcessData(this.orderData.id);
  140. if (!contractProcess.state) return;
  141. this.contractProcessList = contractProcess.data;
  142. this.updateParentStatus(this.contractProcessList);
  143. },
  144. async operation(item) {
  145. if (item.id === 4) {
  146. uni.showLoading({
  147. title: '订单支付中...'
  148. })
  149. let wxConfig = await getWxPay(this.orderData.orderNo, uni.getStorageSync('openId'));
  150. uni.requestPayment({
  151. provider: 'wxpay',
  152. timeStamp: wxConfig.data.timeStamp,
  153. nonceStr: wxConfig.data.nonceStr,
  154. package: wxConfig.data.prepayId,
  155. signType: wxConfig.data.signType,
  156. paySign: wxConfig.data.paySign,
  157. success: res => {
  158. this.init();
  159. uni.hideLoading();
  160. },
  161. fail: err => {
  162. uni.hideLoading();
  163. }
  164. });
  165. }
  166. },
  167. returnCurrent() {
  168. if (!this.orderData.contractId) return 0;
  169. if (this.orderData.contractStatus === 0) return 1;
  170. if (this.orderData.contractStatus === 1) return 2;
  171. if (this.orderData.contractStatus === 2) return 3;
  172. if (this.orderData.contractStatus === 3) return 5;
  173. },
  174. lookContract() {
  175. let url = `${config.baseUrl}/file/workarkContract/pdf/show/${this.orderData.contractId}`;
  176. this.$navigateTo('/pages/pdf/pdf?fileUrl=' + url + '&titleName=' + this.contractNode.contractName);
  177. },
  178. updateParentStatus(nodes) {
  179. nodes.forEach(node => {
  180. if (node.type !== 3) {
  181. // 递归处理子节点
  182. let children = !node.children ? [] : node.children.filter(item => item.type != 3);
  183. if (children.length > 0) {
  184. this.updateParentStatus(node.children); // 先处理子节点
  185. // 获取所有子节点的 status
  186. const childStatusList = node.children.map(child => child.status);
  187. // 判断条件优先级:4 > 1/2 > 3
  188. if (childStatusList.some(status => status === 4)) {
  189. node.status = 4;
  190. } else if (childStatusList.some(status => status === 1 || status === 2)) {
  191. node.status = 1;
  192. } else if (childStatusList.every(status => status === 3)) {
  193. node.status = 3;
  194. } else if (childStatusList.some(status => status === 3)) {
  195. node.status = 1;
  196. }
  197. }
  198. }
  199. });
  200. }
  201. }
  202. }
  203. </script>
  204. <style lang="scss" scoped>
  205. </style>