detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. <template>
  2. <Theme>
  3. <view class="wrap">
  4. <Navbar fixed leftIconColor="var(--black)">
  5. <template #center>
  6. <view class="nav_title">
  7. {{ shopInfo.name || "店铺详情" }}
  8. </view>
  9. </template>
  10. <template #right>
  11. <view class="nav_right" @click="toggleFavorite">
  12. <i
  13. class="icon-font"
  14. :class="isFavorite ? 'icon-heart-fill' : 'icon-heart'"
  15. ></i>
  16. </view>
  17. </template>
  18. </Navbar>
  19. <!-- 店铺头部信息 -->
  20. <view class="shop-header">
  21. <view class="shop-avatar">
  22. <image :src="shopInfo.avatar" class="avatar-img" />
  23. <view class="shop-status" :class="shopInfo.status">
  24. {{ shopInfo.status === "online" ? "营业中" : "休息中" }}
  25. </view>
  26. </view>
  27. <view class="shop-info">
  28. <view class="shop-name">{{ shopInfo.name }}</view>
  29. <view class="shop-desc">{{ shopInfo.description }}</view>
  30. <view class="shop-stats">
  31. <view class="stat-item">
  32. <text class="stat-label">评分:</text>
  33. <text class="stat-value">{{ shopInfo.rating }}</text>
  34. <text class="stat-unit">分</text>
  35. </view>
  36. <view class="stat-item">
  37. <text class="stat-label">销量:</text>
  38. <text class="stat-value">{{ shopInfo.sales }}</text>
  39. <text class="stat-unit">件</text>
  40. </view>
  41. <view class="stat-item">
  42. <text class="stat-label">距离:</text>
  43. <text class="stat-value">{{ shopInfo.distance }}</text>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <!-- 店铺标签 -->
  49. <view class="shop-tags">
  50. <text class="tag" v-for="tag in shopInfo.tags" :key="tag">
  51. {{ tag }}
  52. </text>
  53. </view>
  54. <!-- 店铺功能按钮 -->
  55. <view class="shop-actions">
  56. <view class="action-btn" @click="contactShop">
  57. <i class="icon-font icon-chat"></i>
  58. <text>联系店铺</text>
  59. </view>
  60. <view class="action-btn" @click="viewLocation">
  61. <i class="icon-font icon-location"></i>
  62. <text>查看位置</text>
  63. </view>
  64. <view class="action-btn" @click="shareShop">
  65. <i class="icon-font icon-share"></i>
  66. <text>分享店铺</text>
  67. </view>
  68. </view>
  69. <!-- 商品分类 -->
  70. <view class="category-section">
  71. <view class="section-title">商品分类</view>
  72. <view class="category-list">
  73. <view
  74. class="category-item"
  75. v-for="category in categories"
  76. :key="category.id"
  77. @click="selectCategory(category)"
  78. :class="{ active: selectedCategory === category.id }"
  79. >
  80. <image :src="category.icon" class="category-icon" />
  81. <text class="category-name">{{ category.name }}</text>
  82. </view>
  83. </view>
  84. </view>
  85. <!-- 商品列表 -->
  86. <view class="products-section">
  87. <view class="section-title">热销商品</view>
  88. <view class="products-grid">
  89. <view
  90. class="product-item"
  91. v-for="product in products"
  92. :key="product.id"
  93. @click="toProductDetail(product)"
  94. >
  95. <image :src="product.image" class="product-image" />
  96. <view class="product-info">
  97. <text class="product-name">{{ product.name }}</text>
  98. <view class="product-price">
  99. <text class="current-price"
  100. >{{ symbol.symbol }}{{ product.price }}</text
  101. >
  102. <text class="original-price" v-if="product.originalPrice"
  103. >{{ symbol.symbol }}{{ product.originalPrice }}</text
  104. >
  105. </view>
  106. <view class="product-sales">已售{{ product.sales }}件</view>
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. </Theme>
  113. </template>
  114. <script setup>
  115. import { ref, computed, onMounted } from "vue";
  116. import Navbar from "@/components/navbar";
  117. import { useSystemStore } from "@/store";
  118. import { t } from "@/locale";
  119. import { onLoad } from "@dcloudio/uni-app";
  120. const useSystem = useSystemStore();
  121. const symbol = computed(() => useSystem.getSymbol);
  122. // 店铺信息
  123. const shopInfo = ref({
  124. id: 1,
  125. name: "时尚潮流店",
  126. description: "专注时尚潮流服饰,品质保证,为您提供最优质的商品和服务",
  127. avatar: "/static/shop/shop1.png",
  128. rating: 4.8,
  129. sales: 1234,
  130. distance: "1.2km",
  131. status: "online",
  132. tags: ["时尚", "潮流", "品质", "正品"],
  133. });
  134. // 是否收藏
  135. const isFavorite = ref(false);
  136. // 选中的分类
  137. const selectedCategory = ref(1);
  138. // 商品分类
  139. const categories = ref([
  140. { id: 1, name: "全部", icon: "/static/shop/category_all.png" },
  141. { id: 2, name: "上衣", icon: "/static/shop/category_top.png" },
  142. { id: 3, name: "裤子", icon: "/static/shop/category_pants.png" },
  143. { id: 4, name: "鞋子", icon: "/static/shop/category_shoes.png" },
  144. { id: 5, name: "配饰", icon: "/static/shop/category_accessories.png" },
  145. ]);
  146. // 商品列表
  147. const products = ref([
  148. {
  149. id: 1,
  150. name: "时尚T恤",
  151. image: "/static/shop/product1.png",
  152. price: "99.00",
  153. originalPrice: "129.00",
  154. sales: 234,
  155. },
  156. {
  157. id: 2,
  158. name: "休闲牛仔裤",
  159. image: "/static/shop/product2.png",
  160. price: "199.00",
  161. originalPrice: "259.00",
  162. sales: 156,
  163. },
  164. {
  165. id: 3,
  166. name: "运动鞋",
  167. image: "/static/shop/product3.png",
  168. price: "299.00",
  169. originalPrice: "399.00",
  170. sales: 89,
  171. },
  172. {
  173. id: 4,
  174. name: "时尚帽子",
  175. image: "/static/shop/product4.png",
  176. price: "59.00",
  177. originalPrice: "79.00",
  178. sales: 67,
  179. },
  180. ]);
  181. // 切换收藏状态
  182. const toggleFavorite = () => {
  183. isFavorite.value = !isFavorite.value;
  184. uni.showToast({
  185. title: isFavorite.value ? "已收藏" : "已取消收藏",
  186. icon: "none",
  187. });
  188. };
  189. // 联系店铺
  190. const contactShop = () => {
  191. uni.showToast({
  192. title: "联系店铺功能开发中",
  193. icon: "none",
  194. });
  195. };
  196. // 查看位置
  197. const viewLocation = () => {
  198. uni.showToast({
  199. title: "查看位置功能开发中",
  200. icon: "none",
  201. });
  202. };
  203. // 分享店铺
  204. const shareShop = () => {
  205. uni.showToast({
  206. title: "分享店铺功能开发中",
  207. icon: "none",
  208. });
  209. };
  210. // 选择分类
  211. const selectCategory = (category) => {
  212. selectedCategory.value = category.id;
  213. // 这里可以根据分类筛选商品
  214. console.log("选择分类:", category.name);
  215. };
  216. // 跳转到商品详情
  217. const toProductDetail = (product) => {
  218. uni.navigateTo({
  219. url: `/pagesBuyer/shop/product?id=${product.id}`,
  220. });
  221. };
  222. onLoad((options) => {
  223. // 从页面参数获取店铺信息
  224. if (options.id) {
  225. shopInfo.value.id = options.id;
  226. }
  227. if (options.name) {
  228. shopInfo.value.name = decodeURIComponent(options.name);
  229. }
  230. });
  231. onMounted(() => {
  232. // 页面加载完成后的逻辑
  233. });
  234. </script>
  235. <style lang="less" scoped>
  236. @import url("@/style.less");
  237. .wrap {
  238. min-height: 100vh;
  239. background: var(--bg);
  240. padding-bottom: 30rpx;
  241. .nav_title {
  242. color: var(--black);
  243. font-size: 36rpx;
  244. font-weight: bold;
  245. }
  246. .nav_right {
  247. color: var(--primary);
  248. font-size: 40rpx;
  249. }
  250. .shop-header {
  251. display: flex;
  252. align-items: center;
  253. background: var(--light);
  254. padding: 30rpx;
  255. margin-bottom: 20rpx;
  256. .shop-avatar {
  257. position: relative;
  258. margin-right: 24rpx;
  259. .avatar-img {
  260. width: 120rpx;
  261. height: 120rpx;
  262. border-radius: 20rpx;
  263. }
  264. .shop-status {
  265. position: absolute;
  266. bottom: -8rpx;
  267. left: 50%;
  268. transform: translateX(-50%);
  269. font-size: 20rpx;
  270. padding: 4rpx 12rpx;
  271. border-radius: 20rpx;
  272. color: var(--light);
  273. &.online {
  274. background: var(--success);
  275. }
  276. &.offline {
  277. background: var(--text-01);
  278. }
  279. }
  280. }
  281. .shop-info {
  282. flex: 1;
  283. .shop-name {
  284. font-size: 36rpx;
  285. font-weight: bold;
  286. color: var(--black);
  287. margin-bottom: 8rpx;
  288. }
  289. .shop-desc {
  290. font-size: 24rpx;
  291. color: var(--text-01);
  292. margin-bottom: 16rpx;
  293. line-height: 1.4;
  294. }
  295. .shop-stats {
  296. display: flex;
  297. gap: 24rpx;
  298. .stat-item {
  299. display: flex;
  300. align-items: center;
  301. .stat-label {
  302. font-size: 22rpx;
  303. color: var(--text-01);
  304. margin-right: 4rpx;
  305. }
  306. .stat-value {
  307. font-size: 24rpx;
  308. color: var(--black);
  309. font-weight: bold;
  310. margin-right: 4rpx;
  311. }
  312. .stat-unit {
  313. font-size: 20rpx;
  314. color: var(--text-01);
  315. }
  316. }
  317. }
  318. }
  319. }
  320. .shop-tags {
  321. padding: 0 30rpx 20rpx;
  322. display: flex;
  323. gap: 12rpx;
  324. flex-wrap: wrap;
  325. .tag {
  326. font-size: 22rpx;
  327. color: var(--primary);
  328. background: rgba(255, 107, 107, 0.1);
  329. padding: 8rpx 16rpx;
  330. border-radius: 20rpx;
  331. }
  332. }
  333. .shop-actions {
  334. display: flex;
  335. padding: 0 30rpx 30rpx;
  336. gap: 20rpx;
  337. .action-btn {
  338. flex: 1;
  339. display: flex;
  340. flex-direction: column;
  341. align-items: center;
  342. background: var(--light);
  343. padding: 24rpx 16rpx;
  344. border-radius: 16rpx;
  345. .icon-font {
  346. font-size: 40rpx;
  347. color: var(--primary);
  348. margin-bottom: 8rpx;
  349. }
  350. text {
  351. font-size: 24rpx;
  352. color: var(--black);
  353. }
  354. }
  355. }
  356. .category-section,
  357. .products-section {
  358. padding: 0 30rpx 30rpx;
  359. .section-title {
  360. font-size: 32rpx;
  361. font-weight: bold;
  362. color: var(--black);
  363. margin-bottom: 20rpx;
  364. }
  365. }
  366. .category-list {
  367. display: flex;
  368. gap: 20rpx;
  369. overflow-x: auto;
  370. padding-bottom: 10rpx;
  371. .category-item {
  372. display: flex;
  373. flex-direction: column;
  374. align-items: center;
  375. min-width: 120rpx;
  376. padding: 20rpx 16rpx;
  377. background: var(--light);
  378. border-radius: 16rpx;
  379. border: 2rpx solid transparent;
  380. &.active {
  381. border-color: var(--primary);
  382. background: rgba(255, 107, 107, 0.05);
  383. }
  384. .category-icon {
  385. width: 48rpx;
  386. height: 48rpx;
  387. margin-bottom: 8rpx;
  388. }
  389. .category-name {
  390. font-size: 22rpx;
  391. color: var(--black);
  392. text-align: center;
  393. }
  394. }
  395. }
  396. .products-grid {
  397. display: grid;
  398. grid-template-columns: repeat(2, 1fr);
  399. gap: 20rpx;
  400. .product-item {
  401. background: var(--light);
  402. border-radius: 16rpx;
  403. overflow: hidden;
  404. .product-image {
  405. width: 100%;
  406. height: 200rpx;
  407. object-fit: cover;
  408. }
  409. .product-info {
  410. padding: 16rpx;
  411. .product-name {
  412. font-size: 24rpx;
  413. color: var(--black);
  414. margin-bottom: 8rpx;
  415. display: -webkit-box;
  416. -webkit-line-clamp: 2;
  417. line-clamp: 2;
  418. -webkit-box-orient: vertical;
  419. overflow: hidden;
  420. }
  421. .product-price {
  422. display: flex;
  423. align-items: center;
  424. margin-bottom: 8rpx;
  425. .current-price {
  426. font-size: 28rpx;
  427. font-weight: bold;
  428. color: var(--red);
  429. margin-right: 8rpx;
  430. }
  431. .original-price {
  432. font-size: 20rpx;
  433. color: var(--text-01);
  434. text-decoration: line-through;
  435. }
  436. }
  437. .product-sales {
  438. font-size: 20rpx;
  439. color: var(--text-01);
  440. }
  441. }
  442. }
  443. }
  444. }
  445. </style>