爱简收旧衣按件回收前端代码仓库
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.

263 lines
6.0 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
  1. <template>
  2. <view class="container">
  3. <!-- 顶部导航 -->
  4. <view class="nav-bar">
  5. <view class="back" @tap="goBack">
  6. <uni-icons type="left" size="20"></uni-icons>
  7. </view>
  8. <text class="title">查看品牌</text>
  9. </view>
  10. <!-- 品牌标题 -->
  11. <view class="brand-title">
  12. <text>品牌羽绒服</text>
  13. </view>
  14. <!-- 品牌列表 -->
  15. <view class="brand-grid">
  16. <view
  17. class="brand-item"
  18. v-for="(item, index) in brandItems"
  19. :key="index"
  20. :class="{ active: item.selected }"
  21. @tap="selectItem(index)"
  22. >
  23. <image :src="item.image" mode="aspectFit"></image>
  24. <text class="name">{{ item.name }}</text>
  25. <text class="price">¥ {{ item.price }} /{{item.unit}}</text>
  26. </view>
  27. </view>
  28. <!-- 底部按钮 -->
  29. <view class="bottom-bar">
  30. <button class="submit-btn" @tap="goToPickup">去预约上门取件</button>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import pullRefreshMixin from '@/pages/mixins/pullRefreshMixin.js'
  36. export default {
  37. mixins: [pullRefreshMixin],
  38. data() {
  39. return {
  40. brandItems: [
  41. {
  42. name: 'MONCLER GENIUS Maya 70 By Palm A',
  43. image: '/static/brand/moncler.png',
  44. price: '3-10',
  45. selected: false
  46. },
  47. {
  48. name: '加拿大鹅 Wyndham系列羽绒服 冬季 男装',
  49. image: '/static/brand/canada-goose.png',
  50. price: '3-10',
  51. selected: false
  52. },
  53. {
  54. name: 'THE NORTH FACE 1992 Nupse 填充夹克',
  55. image: '/static/brand/tnf-1992.png',
  56. price: '3-10',
  57. selected: false
  58. },
  59. {
  60. name: 'THE NORTH FACE M\'S 1996 Novelty',
  61. image: '/static/brand/tnf-1996.png',
  62. price: '3-10',
  63. selected: false
  64. },
  65. {
  66. name: 'THE NORTH FACE 1996 系列 FW23',
  67. image: '/static/brand/tnf-fw23.png',
  68. price: '3-10',
  69. selected: false
  70. },
  71. {
  72. name: 'THE NORTH FACE 城市户外系列羽绒服',
  73. image: '/static/brand/tnf-urban.png',
  74. price: '3-10',
  75. selected: false
  76. },
  77. {
  78. name: 'THE NORTH FACE 城市户外系列羽绒服 红色',
  79. image: '/static/brand/tnf-red.png',
  80. price: '3-10',
  81. selected: false
  82. },
  83. {
  84. name: 'THE NORTH FACE 韩国男款 1996 Nov',
  85. image: '/static/brand/tnf-korea.png',
  86. price: '3-10',
  87. selected: false
  88. }
  89. ],
  90. selectedFromRecycle: []
  91. }
  92. },
  93. onLoad(options) {
  94. // 接收从recycle页面传来的已选中衣物数据
  95. if (options.selectedItems) {
  96. try {
  97. this.selectedFromRecycle = JSON.parse(decodeURIComponent(options.selectedItems))
  98. // 根据recycle页面选中的衣物,设置对应品牌衣物的选中状态
  99. this.syncSelectionWithRecycle()
  100. } catch (e) {
  101. console.error('解析选中衣物数据失败:', e)
  102. }
  103. }
  104. },
  105. methods: {
  106. async onRefresh() {
  107. // 模拟刷新数据
  108. await new Promise(resolve => setTimeout(resolve, 1000))
  109. uni.stopPullRefresh()
  110. },
  111. goBack() {
  112. uni.navigateBack()
  113. },
  114. // 同步recycle页面选中的衣物到品牌页面
  115. syncSelectionWithRecycle() {
  116. const brandSelected = this.selectedFromRecycle.find(item => item.showBrandCheck)
  117. if (brandSelected) {
  118. // 如果recycle页面选中了品牌衣物,这里默认选中第一个品牌衣物
  119. this.brandItems[0].selected = true
  120. }
  121. },
  122. selectItem(index) {
  123. this.brandItems[index].selected = !this.brandItems[index].selected
  124. },
  125. goToPickup() {
  126. // 获取所有选中的品牌衣物
  127. const selectedBrandItems = this.brandItems
  128. .filter(item => item.selected)
  129. .map(item => ({
  130. name: item.name,
  131. icon: item.image,
  132. quantity: 1,
  133. unitPrice: item.price.split('-')[0],
  134. desc: '品牌羽绒服,状态良好'
  135. }))
  136. // 将选中的衣物信息转换为字符串
  137. const itemsStr = encodeURIComponent(JSON.stringify([
  138. ...this.selectedFromRecycle,
  139. ...selectedBrandItems
  140. ]))
  141. // 跳转到预约页面
  142. uni.navigateTo({
  143. url: `/pages/component/pickup?fromRecycle=true&items=${itemsStr}`
  144. })
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss" scoped>
  150. .container {
  151. min-height: 100vh;
  152. background: #fff;
  153. padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
  154. }
  155. .nav-bar {
  156. display: flex;
  157. align-items: center;
  158. height: 88rpx;
  159. padding: 0 30rpx;
  160. background: #fff;
  161. .back {
  162. padding: 20rpx;
  163. margin-left: -20rpx;
  164. }
  165. .title {
  166. flex: 1;
  167. text-align: center;
  168. font-size: 34rpx;
  169. font-weight: 500;
  170. }
  171. }
  172. .brand-title {
  173. padding: 30rpx;
  174. font-size: 40rpx;
  175. font-weight: bold;
  176. color: #333;
  177. }
  178. .brand-grid {
  179. padding: 0 20rpx;
  180. display: grid;
  181. grid-template-columns: repeat(2, 1fr);
  182. gap: 20rpx;
  183. }
  184. .brand-item {
  185. background: #FFF9F2;
  186. border-radius: 16rpx;
  187. padding: 30rpx;
  188. display: flex;
  189. flex-direction: column;
  190. align-items: center;
  191. transition: all 0.3s;
  192. &.active {
  193. background: #FFE4CC;
  194. }
  195. image {
  196. width: 240rpx;
  197. height: 240rpx;
  198. margin-bottom: 20rpx;
  199. }
  200. .name {
  201. font-size: 28rpx;
  202. color: #333;
  203. text-align: center;
  204. margin-bottom: 10rpx;
  205. display: -webkit-box;
  206. -webkit-line-clamp: 2;
  207. -webkit-box-orient: vertical;
  208. overflow: hidden;
  209. }
  210. .price {
  211. font-size: 26rpx;
  212. color: #FF9500;
  213. }
  214. }
  215. .bottom-bar {
  216. position: fixed;
  217. bottom: 0;
  218. left: 0;
  219. right: 0;
  220. padding: 20rpx 30rpx calc(20rpx + env(safe-area-inset-bottom));
  221. background: #fff;
  222. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  223. .submit-btn {
  224. width: 100%;
  225. height: 80rpx;
  226. background: #FFB74D;
  227. color: #fff;
  228. font-size: 28rpx;
  229. border-radius: 40rpx;
  230. display: flex;
  231. align-items: center;
  232. justify-content: center;
  233. border: none;
  234. &::after {
  235. border: none;
  236. }
  237. &:active {
  238. opacity: 0.9;
  239. }
  240. }
  241. }
  242. </style>