PersonalExpressDialog.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <!-- 使用 u-popup 组件 -->
  3. <u-popup :show="visible" mode="bottom" :round="30" :closeable="false" :closeOnClickOverlay="true"
  4. @close="handleClose">
  5. <view class="popup-content">
  6. <!-- 标题 -->
  7. <view class="popup-header">
  8. <text class="popup-title">个人寄件</text>
  9. </view>
  10. <!-- 物流选项 -->
  11. <view class="express-options">
  12. <!-- 顺丰选项 -->
  13. <view class="express-option sf-option" :class="{ 'selected': selectedExpress === '顺丰' }"
  14. @click="selectExpress('顺丰')">
  15. <image class="option-icon" src="/static/img/icon-logo-sf.png"
  16. mode="aspectFit" />
  17. <text class="option-text">顺丰物流</text>
  18. </view>
  19. <!-- 京东选项 -->
  20. <view class="express-option jd-option" :class="{ 'selected': selectedExpress === '京东' }"
  21. @click="selectExpress('京东')">
  22. <image class="option-icon" src="/static/img/icon-logo-jd.png"
  23. mode="aspectFit" />
  24. <text class="option-text">京东物流</text>
  25. </view>
  26. </view>
  27. <!-- 取消按钮 -->
  28. <view class="popup-footer">
  29. <button class="cancel-btn" @click="handleClose">取消</button>
  30. </view>
  31. </view>
  32. </u-popup>
  33. </template>
  34. <script setup>
  35. import {
  36. ref,
  37. watch,
  38. onUnmounted
  39. } from 'vue'
  40. const props = defineProps({
  41. visible: {
  42. type: Boolean,
  43. default: false
  44. }
  45. })
  46. const emit = defineEmits(['update:visible', 'select'])
  47. const selectedExpress = ref('')
  48. // 监听弹框显示状态,控制底部 tabBar
  49. watch(() => props.visible, (newVal) => {
  50. if (newVal) {
  51. // 弹框打开:隐藏 tabBar(忽略失败回调,防止重复调用报错)
  52. uni.hideTabBar({
  53. fail: () => {}
  54. })
  55. } else {
  56. // 弹框关闭:显示 tabBar
  57. uni.showTabBar({
  58. fail: () => {}
  59. })
  60. }
  61. }, { immediate: true }) // immediate 确保组件初始化时如果 visible 为 true 也能正确隐藏
  62. // 组件卸载时恢复 tabBar 显示(避免状态残留)
  63. onUnmounted(() => {
  64. uni.showTabBar({
  65. fail: () => {}
  66. })
  67. })
  68. const selectExpress = (company) => {
  69. selectedExpress.value = company
  70. emit('select', company)
  71. emit('update:visible', false)
  72. // 延时关闭并传递选择结果
  73. setTimeout(() => {
  74. const url = encodeURIComponent(company == '京东' ? "https://www.jdl.com/" : "https://www.sf-express.com/chn/sc")
  75. uni.navigateTo({
  76. url: '/pages/webView/webView?title=个人寄件&url=' + url
  77. })
  78. selectedExpress.value = ''
  79. }, 50)
  80. }
  81. const handleClose = () => {
  82. selectedExpress.value = ''
  83. emit('update:visible', false)
  84. }
  85. </script>
  86. <style lang="scss" scoped>
  87. .popup-content {
  88. padding: 32rpx 16rpx 0rpx 16rpx;
  89. background-color: #fff;
  90. border-radius: 40rpx 40rpx 0rpx 0rpx;
  91. }
  92. .popup-header {
  93. display: flex;
  94. justify-content: center;
  95. align-items: center;
  96. margin-bottom: 46rpx;
  97. }
  98. .popup-title {
  99. height: 52rpx;
  100. line-height: 52rpx;
  101. font-size: 36rpx;
  102. font-weight: bold;
  103. color: #333;
  104. }
  105. .express-options {
  106. height: 204rpx;
  107. display: flex;
  108. justify-content: space-around;
  109. }
  110. .express-option {
  111. width: 200rpx;
  112. display: flex;
  113. flex-direction: column;
  114. align-items: center;
  115. justify-content: center;
  116. &.selected {
  117. width: 200rpx;
  118. height: 204rpx;
  119. background: #E9F0FF;
  120. border-radius: 32rpx;
  121. border: 2rpx solid #C1D5FF;
  122. }
  123. .option-icon {
  124. width: 88rpx;
  125. height: 88rpx;
  126. margin-bottom: 8rpx;
  127. }
  128. .option-text {
  129. font-size: 28rpx;
  130. font-weight: 500;
  131. color: #333;
  132. }
  133. }
  134. .popup-footer {
  135. margin-top: 44rpx;
  136. .cancel-btn {
  137. width: 100%;
  138. height: 88rpx;
  139. background: #E9F0FF;
  140. border-radius: 44rpx;
  141. font-weight: 400;
  142. font-size: 32rpx;
  143. color: #2361FF;
  144. line-height: 88rpx;
  145. text-align: center;
  146. font-style: normal;
  147. text-transform: none;
  148. }
  149. }
  150. @keyframes popIn {
  151. 0% {
  152. transform: scale(0);
  153. }
  154. 70% {
  155. transform: scale(1.2);
  156. }
  157. 100% {
  158. transform: scale(1);
  159. }
  160. }
  161. </style>