groupMealDetails.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <view class="settle">
  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="settle-card">
  11. <view class="settle-header">
  12. <view class="amount">¥{{ settlementInfo.amountPayable }}</view>
  13. </view>
  14. <view class="settle-info">
  15. <view v-for="(item, index) in groupMealFields" :key="index" class="info">
  16. <view class="label">
  17. {{ item.title }}
  18. <image
  19. v-if="item.isShowTip"
  20. src="/static/finance/status/icon-remind.png"
  21. mode="aspectFit"
  22. style="width: 33rpx; height: 33rpx; margin-left: 8rpx"
  23. @click.stop="toggleTooltip(item.key)"
  24. ></image>
  25. <view class="tooltip" v-show="showTooltip === item.key">
  26. 商户占比{{ settlementInfo.merchantCostRatio}}%
  27. </view>
  28. </view>
  29. <view class="value">{{ settlementInfo[item.valueField] }}</view>
  30. </view>
  31. <view class="remark"> 注:应收金额=成团价*商家分佣占比-拉新分佣成本</view>
  32. </view>
  33. <!-- 订单列表 -->
  34. <view class="settle-list">
  35. <GroupMealList :list="orderList"></GroupMealList>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import api from '@/api/account';
  42. import { groupMealFields } from './dictionary';
  43. import GroupMealList from './components/group-meal-list.vue';
  44. export default {
  45. name: 'SettlementDetails',
  46. components: {
  47. GroupMealList,
  48. },
  49. data() {
  50. return {
  51. orderId: '',
  52. settleStatus: '',
  53. settlementInfo: {},
  54. orderList: [],
  55. groupMealFields,
  56. showTooltip: null,
  57. tooltipTimer: null,
  58. };
  59. },
  60. mounted() {
  61. // 点击其他区域隐藏提示
  62. document.addEventListener('click', this.handleClickOutside);
  63. },
  64. beforeUnmount() {
  65. // 移除事件监听
  66. document.removeEventListener('click', this.handleClickOutside);
  67. // 清除定时器
  68. if (this.tooltipTimer) {
  69. clearTimeout(this.tooltipTimer);
  70. }
  71. },
  72. onLoad(options) {
  73. console.log(options)
  74. if (options.id) {
  75. this.orderId = options.id;
  76. this.settleStatus = options.settleStatus;
  77. }
  78. },
  79. onShow() {
  80. this.getDetails(this.orderId, this.settleStatus);
  81. },
  82. methods: {
  83. getDetails(id, settleStatus) {
  84. console.log(id, settleStatus)
  85. api
  86. .groupOrderClearDetail( id, settleStatus)
  87. .then((res) => {
  88. if (res.data.code === 200) {
  89. this.settlementInfo = res.data.result || {};
  90. this.orderList = res.data.result.groupProductList || [];
  91. } else {
  92. uni.showToast({
  93. title: res.data.msg || '获取结算详情失败',
  94. icon: 'none',
  95. });
  96. }
  97. })
  98. .catch(() => {
  99. uni.showToast({
  100. title: '获取结算详情失败',
  101. icon: 'none',
  102. });
  103. });
  104. },
  105. // 处理点击事件,显示提示并设置10秒自动隐藏
  106. toggleTooltip(key) {
  107. // 清除之前的定时器
  108. if (this.tooltipTimer) {
  109. clearTimeout(this.tooltipTimer);
  110. }
  111. // 显示当前提示,隐藏其他提示
  112. this.showTooltip = this.showTooltip === key ? null : key;
  113. // 如果是显示状态,设置10秒后自动隐藏
  114. if (this.showTooltip) {
  115. this.tooltipTimer = setTimeout(() => {
  116. this.showTooltip = null;
  117. }, 10000); // 10秒自动隐藏
  118. }
  119. },
  120. // 点击其他区域隐藏提示
  121. handleClickOutside(event) {
  122. // 检查点击目标是否在提示或图片上
  123. const tooltipElements = document.querySelectorAll('.tooltip, image[src*="icon-remind.png"]');
  124. let isClickOnTooltip = false;
  125. tooltipElements.forEach((element) => {
  126. if (element.contains(event.target)) {
  127. isClickOnTooltip = true;
  128. }
  129. });
  130. // 如果点击的不是提示或图片,隐藏所有提示
  131. if (!isClickOnTooltip) {
  132. this.showTooltip = null;
  133. // 清除定时器
  134. if (this.tooltipTimer) {
  135. clearTimeout(this.tooltipTimer);
  136. }
  137. }
  138. },
  139. back() {
  140. uni.navigateBack({
  141. delta: 1,
  142. });
  143. },
  144. },
  145. };
  146. </script>
  147. <style lang="scss" scoped>
  148. .settle {
  149. background: #f7f8fc;
  150. min-height: 100vh;
  151. font-family: Source Han Sans SC;
  152. padding-bottom: 100rpx;
  153. font-weight: 500;
  154. .fix {
  155. position: sticky;
  156. top: 0;
  157. /*#ifdef APP-PLUS*/
  158. .top {
  159. width: 100%;
  160. height: var(--status-bar-height);
  161. background: #fff;
  162. }
  163. /*#endif*/
  164. .head {
  165. width: 100%;
  166. height: 112rpx;
  167. padding: 20rpx;
  168. display: flex;
  169. align-items: center;
  170. background: #fff;
  171. position: relative;
  172. border-bottom: 1rpx solid #eeeeee;
  173. .cuIcon-back {
  174. font-size: 40rpx;
  175. margin-right: 40rpx;
  176. }
  177. .case {
  178. position: absolute;
  179. left: 50%;
  180. transform: translateX(-50%);
  181. font-size: 38rpx;
  182. color: #333333;
  183. }
  184. }
  185. }
  186. .settle-card {
  187. background-color: #fff;
  188. padding: 30rpx 31rpx 31rpx;
  189. .settle-header {
  190. display: flex;
  191. flex-direction: column;
  192. justify-content: center;
  193. align-items: center;
  194. .amount {
  195. font-size: 63rpx;
  196. color: #1f1f1f;
  197. margin-bottom: 41rpx;
  198. }
  199. }
  200. .settle-info {
  201. background-color: #fff;
  202. margin-bottom: 20rpx;
  203. .info {
  204. display: flex;
  205. justify-content: space-between;
  206. align-items: center;
  207. padding-bottom: 21rpx;
  208. &:last-child {
  209. border-bottom: none;
  210. }
  211. .label {
  212. display: flex;
  213. align-items: center;
  214. font-weight: 400;
  215. font-size: 31rpx;
  216. color: #666666;
  217. .tooltip {
  218. display: flex;
  219. align-items: center;
  220. justify-content: center;
  221. position: relative;
  222. padding: 0 5rpx;
  223. // width: 158rpx;
  224. height: 42rpx;
  225. background: rgba(0, 0, 0, 0.6);
  226. border-radius: 4rpx 4rpx 4rpx 4rpx;
  227. font-family: PingFang SC;
  228. font-weight: 400;
  229. font-size: 23rpx;
  230. color: #ffffff;
  231. margin-left: 10rpx;
  232. &::after {
  233. content: '';
  234. position: absolute;
  235. left: 0;
  236. bottom: 0;
  237. width: 0;
  238. height: 0;
  239. transform: translate(-100%,-50%);
  240. border-bottom: 10rpx solid transparent;
  241. border-right: 10rpx solid rgba(0, 0, 0, 0.6);
  242. border-top: 10rpx solid transparent;
  243. border-left: 0;
  244. }
  245. }
  246. }
  247. .value {
  248. font-size: 31rpx;
  249. color: #333333;
  250. }
  251. }
  252. .remark {
  253. font-weight: 400;
  254. font-size: 25rpx;
  255. color: #666666;
  256. margin-top: 10rpx;
  257. }
  258. }
  259. .settle-list {
  260. margin-top: 42rpx;
  261. }
  262. }
  263. }
  264. </style>