PersonalExpressDialog.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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" mode="aspectFit" />
  16. <text class="option-text">顺丰物流</text>
  17. </view>
  18. <!-- 京东选项 -->
  19. <view class="express-option jd-option" :class="{ 'selected': selectedExpress === '京东' }"
  20. @click="selectExpress('京东')">
  21. <image class="option-icon" src="/static/img/icon-logo-jd.png" mode="aspectFit" />
  22. <text class="option-text">京东物流</text>
  23. </view>
  24. </view>
  25. <!-- 取消按钮 -->
  26. <view class="popup-footer">
  27. <button class="cancel-btn" @click="handleClose">取消</button>
  28. </view>
  29. </view>
  30. </u-popup>
  31. </template>
  32. <script setup>
  33. import {
  34. ref,
  35. watch,
  36. onUnmounted
  37. } from 'vue'
  38. const props = defineProps({
  39. visible: {
  40. type: Boolean,
  41. default: false
  42. }
  43. })
  44. const emit = defineEmits(['update:visible', 'select'])
  45. const selectedExpress = ref('')
  46. // 监听弹框显示状态,控制底部 tabBar
  47. watch(() => props.visible, (newVal) => {
  48. if (newVal) {
  49. // 弹框打开:隐藏 tabBar(忽略失败回调,防止重复调用报错)
  50. uni.hideTabBar({
  51. fail: () => {}
  52. })
  53. } else {
  54. // 弹框关闭:显示 tabBar
  55. uni.showTabBar({
  56. fail: () => {}
  57. })
  58. }
  59. }, {
  60. immediate: true
  61. }) // 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://rjsd.mychery.com/jd.html" : "https://rjsd.mychery.com/sf.html")
  75. const url = encodeURIComponent(company == '京东' ? "https://rjsd.mychery.com/jd" : "https://rjsd.mychery.com/sf")
  76. uni.navigateTo({
  77. url: '/pages/webView/webView?title=个人寄件&url=' + url
  78. })
  79. return
  80. const appId = company == '京东' ? "wx73247c7819d61796" : "wxd4185d00bf7e08ac"
  81. wx.navigateToMiniProgram({
  82. appId: appId, // 必填
  83. envVersion: 'release', // 打开正式版
  84. success(res) {
  85. console.log("跳转成功", res);
  86. },
  87. fail(err) {
  88. console.error("跳转失败", err);
  89. }
  90. });
  91. selectedExpress.value = ''
  92. }, 50)
  93. }
  94. const handleClose = () => {
  95. selectedExpress.value = ''
  96. emit('update:visible', false)
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .popup-content {
  101. padding: 32rpx 16rpx 0rpx 16rpx;
  102. background-color: #fff;
  103. border-radius: 40rpx 40rpx 0rpx 0rpx;
  104. }
  105. .popup-header {
  106. display: flex;
  107. justify-content: center;
  108. align-items: center;
  109. margin-bottom: 46rpx;
  110. }
  111. .popup-title {
  112. height: 52rpx;
  113. line-height: 52rpx;
  114. font-size: 36rpx;
  115. font-weight: bold;
  116. color: #333;
  117. }
  118. .express-options {
  119. height: 204rpx;
  120. display: flex;
  121. justify-content: space-around;
  122. }
  123. .express-option {
  124. width: 200rpx;
  125. display: flex;
  126. flex-direction: column;
  127. align-items: center;
  128. justify-content: center;
  129. &.selected {
  130. width: 200rpx;
  131. height: 204rpx;
  132. background: #E9F0FF;
  133. border-radius: 32rpx;
  134. border: 2rpx solid #C1D5FF;
  135. }
  136. .option-icon {
  137. width: 88rpx;
  138. height: 88rpx;
  139. margin-bottom: 8rpx;
  140. }
  141. .option-text {
  142. font-size: 28rpx;
  143. font-weight: 500;
  144. color: #333;
  145. }
  146. }
  147. .popup-footer {
  148. margin-top: 44rpx;
  149. margin-bottom: 44rpx;
  150. .cancel-btn {
  151. width: 100%;
  152. height: 88rpx;
  153. background: #E9F0FF;
  154. border-radius: 44rpx;
  155. font-weight: 400;
  156. font-size: 32rpx;
  157. color: #2361FF;
  158. line-height: 88rpx;
  159. text-align: center;
  160. font-style: normal;
  161. text-transform: none;
  162. }
  163. }
  164. @keyframes popIn {
  165. 0% {
  166. transform: scale(0);
  167. }
  168. 70% {
  169. transform: scale(1.2);
  170. }
  171. 100% {
  172. transform: scale(1);
  173. }
  174. }
  175. </style>