爱简收旧衣按件回收前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

265 lines
6.8 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="byc-container" :style="{paddingTop: 'calc(150rpx + ' + statusBarHeight + 'px)'}">
  3. <!-- 顶部导航栏 -->
  4. <view class="nav-bar" :style="{paddingTop: statusBarHeight + 'px'}">
  5. <view class="back" @tap="goBack">
  6. <uni-icons type="left" size="20" color="#fff"></uni-icons>
  7. </view>
  8. <text class="nav-title">包邮服务城市</text>
  9. <view class="nav-icons">
  10. <!-- 占位元素保持布局对称 -->
  11. </view>
  12. </view>
  13. <!-- 蓝色banner卡片 -->
  14. <view class="byc-banner">
  15. <image
  16. class="byc-banner-img"
  17. :src="myCityImage"
  18. mode="widthFix"
  19. @error="onImageError"
  20. @load="onImageLoad"
  21. />
  22. <!-- 备用背景 -->
  23. <view v-if="!myCityImage || imageLoadError" class="byc-banner-fallback">
  24. <view class="byc-banner-title">包邮服务城市</view>
  25. <view class="byc-banner-desc">已开通包邮服务的城市列表</view>
  26. </view>
  27. </view>
  28. <!-- 主内容卡片 -->
  29. <view class="byc-main-card">
  30. <view class="byc-main-title">已开通包邮服务的城市</view>
  31. <view class="byc-main-desc">
  32. 我们很高兴为以下城市的用户提供一键包邮的便捷服务进一步简化旧衣回收流程降低参与环保行动的门槛期待未来能将这一服务拓展至更多地区邀请全国人民共同投身于旧衣回收的环保事业中
  33. </view>
  34. <view class="byc-dashed-line"></view>
  35. <view class="byc-province-list">
  36. <view class="byc-province-item" v-for="(province, idx) in cityList" :key="province.id">
  37. <view class="byc-province-name">{{ province.name }}</view>
  38. <view class="byc-city-group" v-for="(city, cidx) in (province.children || [])" :key="city.id">
  39. <view class="byc-city-name">{{ city.name }}</view>
  40. <view class="byc-district-list" v-if="city.children && city.children.length > 0">
  41. <text v-for="(district, didx) in city.children" :key="district.id" class="byc-district">
  42. <text v-if="didx !== 0" class="byc-dot">·</text>{{ district.name }}
  43. </text>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. data() {
  54. return {
  55. statusBarHeight: 0,
  56. navBarHeight: 88, // 默认
  57. menuButtonInfo: null,
  58. cityList: [],
  59. bannerTop: 0, // banner距离顶部距离
  60. imageLoadError: false // 图片加载错误标志
  61. }
  62. },
  63. onLoad() {
  64. const sysInfo = uni.getSystemInfoSync()
  65. this.statusBarHeight = sysInfo.statusBarHeight
  66. let menuButtonInfo = null
  67. try {
  68. menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  69. } catch (e) {}
  70. this.menuButtonInfo = menuButtonInfo
  71. if (menuButtonInfo && menuButtonInfo.height) {
  72. // 导航栏高度 = 胶囊 bottom + top - 状态栏高度
  73. this.navBarHeight = menuButtonInfo.bottom + menuButtonInfo.top - sysInfo.statusBarHeight
  74. } else {
  75. this.navBarHeight = 88 // 兜底
  76. }
  77. this.bannerTop = this.statusBarHeight + this.navBarHeight
  78. this.$api('getFreeCityList', {}, res => {
  79. if (res && res.success && Array.isArray(res.result)) {
  80. this.cityList = res.result.filter(item => item.open === 'Y');
  81. // console.log(this.cityList);
  82. }
  83. });
  84. },
  85. computed: {
  86. city_desc() {
  87. const item = getApp().globalData.configData.find(i => i.keyName === 'city_desc')
  88. return item ? item.keyContent : ''
  89. },
  90. myCityImage() {
  91. const item = getApp().globalData.configData.find(i => i.keyName === 'city_banner')
  92. console.log(item);
  93. return item ? item.keyContent : ''
  94. },
  95. },
  96. methods: {
  97. goBack() {
  98. uni.navigateBack()
  99. },
  100. // 图片加载错误处理
  101. onImageError(e) {
  102. console.error('包邮城市背景图加载失败:', e);
  103. this.imageLoadError = true;
  104. // 可以在这里添加上报逻辑
  105. },
  106. // 图片加载成功处理
  107. onImageLoad(e) {
  108. console.log('包邮城市背景图加载成功');
  109. this.imageLoadError = false;
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss" scoped>
  115. .byc-container {
  116. min-height: 100vh;
  117. background: #f8f8f8;
  118. padding-bottom: env(safe-area-inset-bottom);
  119. }
  120. .nav-bar {
  121. display: flex;
  122. align-items: center;
  123. height: calc(150rpx + var(--status-bar-height));
  124. padding: 0 32rpx;
  125. background: #2486f6;
  126. position: fixed;
  127. top: 0;
  128. left: 0;
  129. right: 0;
  130. z-index: 999;
  131. box-sizing: border-box;
  132. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.03);
  133. .back {
  134. padding: 20rpx;
  135. margin-left: -20rpx;
  136. }
  137. .nav-title {
  138. flex: 1;
  139. text-align: center;
  140. font-size: 32rpx;
  141. font-weight: 500;
  142. color: #fff;
  143. }
  144. .nav-icons {
  145. display: flex;
  146. align-items: center;
  147. gap: 12px;
  148. }
  149. }
  150. .byc-banner {
  151. margin: -60rpx 0 0 0;
  152. overflow: hidden;
  153. box-shadow: 0 4rpx 24rpx rgba(60, 167, 250, 0.10);
  154. background: none;
  155. position: relative;
  156. z-index: 1;
  157. max-height: 400rpx;
  158. }
  159. .byc-banner-left {
  160. flex: 1;
  161. }
  162. .byc-banner-title {
  163. color: #fff;
  164. font-size: 44rpx;
  165. font-weight: bold;
  166. margin-bottom: 16rpx;
  167. text-shadow: 0 4rpx 12rpx rgba(0,0,0,0.12);
  168. }
  169. .byc-banner-desc {
  170. color: #e3f2fd;
  171. font-size: 28rpx;
  172. margin-top: 4rpx;
  173. }
  174. .byc-banner-img {
  175. width: 100%;
  176. height: 100%;
  177. max-height: 400rpx;
  178. display: block;
  179. object-fit: cover;
  180. }
  181. .byc-banner-fallback {
  182. position: absolute;
  183. top: 0;
  184. left: 0;
  185. right: 0;
  186. bottom: 0;
  187. background: linear-gradient(135deg, #2486f6 0%, #4a9eff 100%);
  188. display: flex;
  189. flex-direction: column;
  190. justify-content: center;
  191. align-items: center;
  192. padding: 40rpx;
  193. box-sizing: border-box;
  194. }
  195. .byc-main-card {
  196. background: #fff;
  197. border-radius: 36rpx;
  198. margin: -40rpx 0 0 0;
  199. box-shadow: 0 8rpx 32rpx rgba(60, 167, 250, 0.08);
  200. padding: 48rpx 32rpx 32rpx 32rpx;
  201. position: relative;
  202. z-index: 2;
  203. }
  204. .byc-main-title {
  205. font-size: 36rpx;
  206. font-weight: bold;
  207. color: #222;
  208. margin-bottom: 24rpx;
  209. }
  210. .byc-main-desc {
  211. color: #888;
  212. font-size: 28rpx;
  213. line-height: 1.7;
  214. margin-bottom: 32rpx;
  215. }
  216. .byc-dashed-line {
  217. border-bottom: 2rpx dashed #e5e5e5;
  218. margin-bottom: 32rpx;
  219. }
  220. .byc-province-list {
  221. .byc-province-item {
  222. margin-bottom: 36rpx;
  223. &:last-child { margin-bottom: 0; }
  224. }
  225. .byc-province-name {
  226. font-size: 32rpx;
  227. font-weight: bold;
  228. color: #222;
  229. margin-bottom: 12rpx;
  230. }
  231. .byc-city-group {
  232. margin-bottom: 20rpx;
  233. padding-left: 16rpx;
  234. border-left: 3rpx solid #e5e5e5;
  235. &:last-child { margin-bottom: 0; }
  236. }
  237. .byc-city-name {
  238. font-size: 30rpx;
  239. font-weight: 600;
  240. color: #333;
  241. margin-bottom: 8rpx;
  242. }
  243. .byc-district-list {
  244. display: flex;
  245. flex-wrap: wrap;
  246. font-size: 26rpx;
  247. color: #666;
  248. line-height: 1.6;
  249. padding-left: 20rpx;
  250. }
  251. .byc-district {
  252. margin-right: 16rpx;
  253. margin-bottom: 6rpx;
  254. display: flex;
  255. align-items: center;
  256. }
  257. .byc-dot {
  258. margin-right: 6rpx;
  259. color: #bbb;
  260. font-size: 24rpx;
  261. }
  262. }
  263. </style>