orderDetail.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. getOrderPayState
  91. } from '@/request/api/workark.js'
  92. import processItem from '@/subPages/indexPage/components/processItem.vue';
  93. import config from '@/config';
  94. export default {
  95. components: {
  96. processItem
  97. },
  98. data() {
  99. return {
  100. orderId: '',
  101. orderNo: '',
  102. orderData: {},
  103. operationBtn: [],
  104. contractNode: {},
  105. current: 0,
  106. contractProcessList: []
  107. };
  108. },
  109. onLoad(body) {
  110. this.orderId = body.orderId;
  111. this.orderNo = body.orderNo;
  112. this.init();
  113. },
  114. methods: {
  115. async init() {
  116. this.operationBtn = [];
  117. let orderData = {};
  118. if (this.orderId) {
  119. orderData = await getOrderDetail(this.orderId);
  120. } else if (this.orderNo) {
  121. orderData = await getOrderDetailByOrderNo(this.orderNo);
  122. }
  123. if (!orderData.state) return;
  124. this.orderData = orderData.data;
  125. this.current = this.returnCurrent();
  126. this.initProcessData();
  127. if (this.orderData.contractId) this.initBindContract();
  128. if (this.orderData.orderStatus === '未支付') this.operationBtn = [{
  129. id: 4,
  130. type: 'primary',
  131. name: '立即支付'
  132. }]
  133. },
  134. async initBindContract() {
  135. let contractNode = await getBindContract(this.orderData.contractId);
  136. if (!contractNode.state) return;
  137. this.contractNode = contractNode.data;
  138. },
  139. async initProcessData() {
  140. let contractProcess = await getProcessData(this.orderData.id);
  141. if (!contractProcess.state) return;
  142. this.contractProcessList = contractProcess.data;
  143. this.updateParentStatus(this.contractProcessList);
  144. },
  145. logout() {
  146. this.$chat.disConnect();
  147. uni.removeStorageSync('token');
  148. uni.removeStorageSync('chatToken');
  149. uni.removeStorageSync('vuex_state');
  150. this.$store.dispatch('app/changeOrganization', {});
  151. this.$store.dispatch('app/changeUser', {});
  152. uni.removeTabBarBadge({
  153. index: 3
  154. })
  155. },
  156. async operation(item) {
  157. if (item.id === 4) {
  158. if (!uni.getStorageSync('openId')) {
  159. this.$toast('未获取到OpenId,请重新登录');
  160. this.logout();
  161. setTimeout(() => {
  162. uni.navigateTo({
  163. url: '/pages/login/login'
  164. });
  165. }, 400)
  166. return;
  167. }
  168. uni.showLoading({
  169. title: '订单支付中...'
  170. })
  171. let wxConfig = await getWxPay(this.orderData.orderNo, uni.getStorageSync('openId'));
  172. uni.requestPayment({
  173. provider: 'wxpay',
  174. timeStamp: wxConfig.data.timeStamp,
  175. nonceStr: wxConfig.data.nonceStr,
  176. package: wxConfig.data.prepayId,
  177. signType: wxConfig.data.signType,
  178. paySign: wxConfig.data.paySign,
  179. success: async (res) => {
  180. let payStatus = await getOrderPayState(this.orderData.orderNo);
  181. if (payStatus.state) {
  182. this.init();
  183. uni.hideLoading();
  184. }
  185. },
  186. fail: err => {
  187. uni.hideLoading();
  188. }
  189. });
  190. }
  191. },
  192. returnCurrent() {
  193. if (!this.orderData.contractId) return 0;
  194. if (this.orderData.contractStatus === 0) return 1;
  195. if (this.orderData.contractStatus === 1) return 2;
  196. if (this.orderData.contractStatus === 2) return 3;
  197. if (this.orderData.contractStatus === 3) return 5;
  198. },
  199. lookContract() {
  200. let url = `${config.baseUrl}/file/workarkContract/pdf/show/${this.orderData.contractId}`;
  201. this.$navigateTo('/pages/pdf/pdf?fileUrl=' + url + '&titleName=' + this.contractNode.contractName);
  202. },
  203. updateParentStatus(nodes) {
  204. nodes.forEach(node => {
  205. if (node.type !== 3) {
  206. // 递归处理子节点
  207. let children = !node.children ? [] : node.children.filter(item => item.type != 3);
  208. if (children.length > 0) {
  209. this.updateParentStatus(node.children); // 先处理子节点
  210. // 获取所有子节点的 status
  211. const childStatusList = node.children.map(child => child.status);
  212. // 判断条件优先级:4 > 1/2 > 3
  213. if (childStatusList.some(status => status === 4)) {
  214. node.status = 4;
  215. } else if (childStatusList.some(status => status === 1 || status === 2)) {
  216. node.status = 1;
  217. } else if (childStatusList.every(status => status === 3)) {
  218. node.status = 3;
  219. } else if (childStatusList.some(status => status === 3)) {
  220. node.status = 1;
  221. }
  222. }
  223. }
  224. });
  225. }
  226. }
  227. }
  228. </script>
  229. <style lang="scss" scoped>
  230. </style>