orderDetails.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <view class="order">
  3. <view class="fix">
  4. <view class="top"></view>
  5. <view class="head">
  6. <span class="cuIcon-back" @click="back"></span>
  7. <view class="case"> 结算详情 </view>
  8. </view>
  9. </view>
  10. <view class="order-card">
  11. <view class="order-header">
  12. <view class="amount">{{ orderInfo.payableToMerchant }}</view>
  13. <view class="title">应收金额</view>
  14. </view>
  15. <block v-if="jumpType == 'SETTLE_TSMAIN'">
  16. <view class="order-info">
  17. <view v-for="(item, index) in serveMealFields" :key="index" class="info">
  18. <view class="label">
  19. {{ item.title }}
  20. <image v-if="item.isShowTip" src="/static/finance/status/icon-remind.png" mode="aspectFit"
  21. style="width: 33rpx; height: 33rpx; margin-left: 8rpx"
  22. @click.stop="toggleTooltip(item.key)"></image>
  23. <view class="tooltip" v-show="showTooltip === item.key"> 商户占比{{ orderInfo[item.rateField] }}%
  24. </view>
  25. </view>
  26. <view class="value">{{ orderInfo[item.valueField] }}</view>
  27. </view>
  28. </view>
  29. <!-- 备注说明 -->
  30. <view class="remark line">注:应收金额=订单金额*商品分佣占比-平台优惠券成本-金豆成本</view>
  31. <!-- 表格 -->
  32. <uni-table
  33. class="service-table"
  34. border
  35. :empty-text="'暂无数据'"
  36. v-if="orderInfo.merchantServiceOrderDetailVoList && orderInfo.merchantServiceOrderDetailVoList.length"
  37. >
  38. <uni-tr>
  39. <uni-th align="center">服务名称/数量</uni-th>
  40. <uni-th align="center">实付总价</uni-th>
  41. </uni-tr>
  42. <uni-tr
  43. v-for="(item, index) in orderInfo.merchantServiceOrderDetailVoList"
  44. :key="item.serviceOrderSubNo || index"
  45. >
  46. <uni-td align="center">
  47. <text class="service-name">{{ item.serviceName }}</text>
  48. </uni-td>
  49. <uni-td align="center">{{ formatOrderMoney(item.orderMoney) }}</uni-td>
  50. </uni-tr>
  51. </uni-table>
  52. </block>
  53. <block v-else>
  54. <view class="order-info">
  55. <view v-for="(item, index) in orderFields" :key="index" class="info">
  56. <view class="label">
  57. {{ item.title }}
  58. <image v-if="item.isShowTip" src="/static/finance/status/icon-remind.png" mode="aspectFit"
  59. style="width: 33rpx; height: 33rpx; margin-left: 8rpx"
  60. @click.stop="toggleTooltip(item.key)"></image>
  61. <view class="tooltip" v-show="showTooltip === item.key"> 商户占比{{ orderInfo[item.rateField] }}%
  62. </view>
  63. </view>
  64. <view class="value">{{ orderInfo[item.valueField] }}</view>
  65. </view>
  66. </view>
  67. <!-- 备注说明 -->
  68. <view class="remark">注:应收金额=订单金额*商品分佣占比-邀新分佣成本-优惠券成本-会员折扣成本-金豆抵扣成本-推广分佣成本</view>
  69. </block>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import api from '@/api/account';
  75. import {
  76. orderFields,
  77. serveMealFields
  78. } from './dictionary';
  79. export default {
  80. name: 'OrderDetails',
  81. data() {
  82. return {
  83. orderId: '',
  84. orderInfo: {},
  85. showTooltip: null,
  86. tooltipTimer: null,
  87. orderFields,
  88. serveMealFields,
  89. orderType: '',
  90. jumpType: ''
  91. };
  92. },
  93. mounted() {
  94. // 点击其他区域隐藏提示
  95. document.addEventListener('click', this.handleClickOutside);
  96. },
  97. beforeUnmount() {
  98. // 移除事件监听
  99. document.removeEventListener('click', this.handleClickOutside);
  100. // 清除定时器
  101. if (this.tooltipTimer) {
  102. clearTimeout(this.tooltipTimer);
  103. }
  104. },
  105. onLoad(options) {
  106. console.log('options', options)
  107. if (options.jumpType) {
  108. this.jumpType = options.jumpType;
  109. }
  110. if (options.id) {
  111. this.orderId = options.id;
  112. }
  113. if (options.orderType) {
  114. this.orderType = options.orderType;
  115. }
  116. },
  117. onShow() {
  118. this.getOrderDetails(this.orderId, this.orderType);
  119. },
  120. methods: {
  121. getOrderDetails(id, orderType) {
  122. if (this.jumpType == 'SETTLE_TSMAIN') {
  123. api.groupSeverDetail(id, orderType).then((res) => {
  124. if (res.data.code === 200) {
  125. this.orderInfo = res.data.result;
  126. }
  127. });
  128. } else {
  129. api.orderClearDetail(id, orderType).then((res) => {
  130. if (res.data.code === 200) {
  131. this.orderInfo = res.data.result;
  132. }
  133. });
  134. }
  135. },
  136. back() {
  137. uni.navigateBack({
  138. delta: 1,
  139. });
  140. },
  141. // 处理点击事件,显示提示并设置10秒自动隐藏
  142. toggleTooltip(key) {
  143. // 清除之前的定时器
  144. if (this.tooltipTimer) {
  145. clearTimeout(this.tooltipTimer);
  146. }
  147. // 显示当前提示,隐藏其他提示
  148. this.showTooltip = this.showTooltip === key ? null : key;
  149. // 如果是显示状态,设置10秒后自动隐藏
  150. if (this.showTooltip) {
  151. this.tooltipTimer = setTimeout(() => {
  152. this.showTooltip = null;
  153. }, 10000); // 10秒自动隐藏
  154. }
  155. },
  156. formatOrderMoney(money) {
  157. if (money === null || money === undefined || money === '') {
  158. return '--';
  159. }
  160. const num = Number(money);
  161. if (Number.isNaN(num)) {
  162. return '--';
  163. }
  164. return `¥ ${num.toFixed(2)}`;
  165. },
  166. // 点击其他区域隐藏提示
  167. handleClickOutside(event) {
  168. // 检查点击目标是否在提示或图片上
  169. const tooltipElements = document.querySelectorAll('.tooltip, image[src*="icon-remind.png"]');
  170. let isClickOnTooltip = false;
  171. tooltipElements.forEach((element) => {
  172. if (element.contains(event.target)) {
  173. isClickOnTooltip = true;
  174. }
  175. });
  176. // 如果点击的不是提示或图片,隐藏所有提示
  177. if (!isClickOnTooltip) {
  178. this.showTooltip = null;
  179. // 清除定时器
  180. if (this.tooltipTimer) {
  181. clearTimeout(this.tooltipTimer);
  182. }
  183. }
  184. },
  185. },
  186. };
  187. </script>
  188. <style lang="scss" scoped>
  189. .order {
  190. background: #f7f8fc;
  191. min-height: 100vh;
  192. font-family: Source Han Sans SC;
  193. font-weight: 500;
  194. .fix {
  195. position: sticky;
  196. top: 0;
  197. /*#ifdef APP-PLUS*/
  198. .top {
  199. width: 100%;
  200. height: var(--status-bar-height);
  201. background: #fff;
  202. }
  203. /*#endif*/
  204. .head {
  205. width: 100%;
  206. height: 112rpx;
  207. padding: 20rpx;
  208. display: flex;
  209. align-items: center;
  210. background: #fff;
  211. position: relative;
  212. border-bottom: 1rpx solid #eeeeee;
  213. .cuIcon-back {
  214. font-size: 40rpx;
  215. margin-right: 40rpx;
  216. }
  217. .case {
  218. position: absolute;
  219. left: 50%;
  220. transform: translateX(-50%);
  221. font-weight: 500;
  222. font-size: 38rpx;
  223. color: #333333;
  224. }
  225. }
  226. }
  227. .order-card {
  228. padding: 42rpx 31rpx 85rpx;
  229. overflow: hidden;
  230. background: #ffffff;
  231. height: 95vh;
  232. }
  233. }
  234. .order-header {
  235. display: flex;
  236. flex-direction: column;
  237. align-items: center;
  238. .amount {
  239. font-size: 63rpx;
  240. color: #1f1f1f;
  241. }
  242. .title {
  243. font-size: 28rpx;
  244. color: #666666;
  245. margin: 11rpx 0 42rpx;
  246. }
  247. }
  248. .order-info {
  249. .info {
  250. display: flex;
  251. justify-content: space-between;
  252. align-items: center;
  253. padding-bottom: 21rpx;
  254. .label {
  255. display: flex;
  256. align-items: center;
  257. font-weight: 400;
  258. font-size: 31rpx;
  259. color: #666666;
  260. position: relative;
  261. .tooltip {
  262. display: flex;
  263. align-items: center;
  264. justify-content: center;
  265. width: 158rpx;
  266. height: 42rpx;
  267. background: rgba(0, 0, 0, 0.6);
  268. border-radius: 4rpx 4rpx 4rpx 4rpx;
  269. font-family: PingFang SC;
  270. font-weight: 400;
  271. font-size: 23rpx;
  272. color: #ffffff;
  273. margin-left: 10rpx;
  274. &::after {
  275. content: '';
  276. position: absolute;
  277. right: 158rpx;
  278. bottom: 14rpx;
  279. width: 0;
  280. height: 0;
  281. border-bottom: 10rpx solid transparent;
  282. border-right: 10rpx solid rgba(0, 0, 0, 0.6);
  283. border-top: 10rpx solid transparent;
  284. border-left: 0;
  285. }
  286. }
  287. }
  288. .value {
  289. font-size: 31rpx;
  290. color: #333333;
  291. }
  292. }
  293. }
  294. .remark {
  295. font-weight: 400;
  296. font-size: 25rpx;
  297. color: #666666;
  298. margin-top: 10rpx;
  299. }
  300. .line{
  301. color: #449AFF;
  302. }
  303. .service-table {
  304. margin-top: 31rpx;
  305. border-radius: 8rpx;
  306. overflow: hidden;
  307. font-family: PingFang SC;
  308. font-weight: 400;
  309. .service-name {
  310. font-size: 27rpx;
  311. color: #666666;
  312. }
  313. }
  314. ::v-deep .service-table {
  315. .uni-table-th {
  316. height: 67rpx !important;
  317. background: #f5f7fa;
  318. font-size: 29rpx;
  319. color: #333333;
  320. }
  321. .uni-table-td {
  322. height: 54rpx !important;
  323. text-align: center !important;
  324. font-size: 27rpx !important;
  325. color: #666666 !important;
  326. }
  327. .table--border {
  328. border-color: #ebeef5 !important;
  329. }
  330. }
  331. </style>