mall-detail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. <template>
  2. <view class="detail-container">
  3. <!-- 商品轮播图 -->
  4. <view class="swiper-container">
  5. <swiper class="goods-swiper" :indicator-dots="true" :autoplay="true" :circular="true">
  6. <swiper-item v-for="(image, index) in goodsImages" :key="index">
  7. <image class="swiper-image" :src="image" mode="aspectFill"></image>
  8. </swiper-item>
  9. </swiper>
  10. </view>
  11. <!-- 商品基本信息 -->
  12. <view class="goods-basic-info">
  13. <view class="goods-title">{{ goodsDetail.title }}</view>
  14. <view class="goods-subtitle">{{ goodsDetail.description }}</view>
  15. <view class="price-container">
  16. <text class="current-price">¥{{ goodsDetail.price }}</text>
  17. <text class="price-unit">/{{ goodsDetail.unit }}</text>
  18. <text class="original-price" v-if="goodsDetail.originalPrice">¥{{ goodsDetail.originalPrice }}</text>
  19. </view>
  20. <view class="specs-info">
  21. <text class="specs-label">规格:</text>
  22. <text class="specs-value">{{ goodsDetail.specifications }}</text>
  23. </view>
  24. </view>
  25. <!-- 商品详情介绍 -->
  26. <view class="goods-detail-info">
  27. <view class="detail-title">商品详情</view>
  28. <!-- 产品特点 -->
  29. <view class="detail-section">
  30. <view class="section-title">产品特点</view>
  31. <view class="feature-list">
  32. <view
  33. class="feature-item"
  34. v-for="(feature, index) in goodsDetail.features"
  35. :key="index"
  36. >
  37. <view class="feature-icon">✓</view>
  38. <text class="feature-text">{{ feature }}</text>
  39. </view>
  40. </view>
  41. </view>
  42. <!-- 使用说明 -->
  43. <view class="detail-section">
  44. <view class="section-title">使用说明</view>
  45. <view class="usage-content">
  46. <text>{{ goodsDetail.usage }}</text>
  47. </view>
  48. </view>
  49. <!-- 产品图片展示 -->
  50. <view class="detail-section">
  51. <view class="section-title">产品展示</view>
  52. <view class="detail-images">
  53. <image
  54. class="detail-image"
  55. v-for="(image, index) in goodsDetail.detailImages"
  56. :key="index"
  57. :src="image"
  58. mode="widthFix"
  59. @click="previewImage(image, goodsDetail.detailImages)"
  60. ></image>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- 底部操作栏 -->
  65. <view class="bottom-actions">
  66. <view class="action-btn consult-btn" @click="handleConsult">
  67. 立即咨询
  68. </view>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. export default {
  74. data() {
  75. return {
  76. goodsId: '',
  77. goodsDetail: {
  78. title: '高产玉米种子',
  79. description: '优质杂交种,抗病性强,适应性广',
  80. price: '68',
  81. originalPrice: '88',
  82. unit: '袋',
  83. specifications: '500g/袋,发芽率≥95%',
  84. features: [
  85. '高产稳产,比普通品种增产15-20%',
  86. '抗病性强,抗大小斑病、丝黑穗病',
  87. '适应性广,适合多种土壤和气候条件',
  88. '株型紧凑,抗倒伏能力强',
  89. '籽粒饱满,商品性好'
  90. ],
  91. usage: '播种前先进行种子处理,选择肥沃、排水良好的土壤,按照每亩3-4千粒的密度播种。播种深度2-3厘米,播种后及时覆土镇压。生长期注意水肥管理,适时中耕除草。',
  92. detailImages: [
  93. '/static/images/products/corn-seeds-new.jpg',
  94. '/static/images/products/seeds-packets.jpg',
  95. '/static/images/products/agriculture-tools.jpg'
  96. ]
  97. },
  98. goodsImages: [
  99. '/static/images/products/corn-seeds-new.jpg',
  100. '/static/images/products/fertilizer.jpg',
  101. '/static/images/products/organic-fertilizer-new.jpg',
  102. '/static/images/products/greenhouse-film.jpg'
  103. ]
  104. }
  105. },
  106. onLoad(options) {
  107. if (options.id) {
  108. this.goodsId = options.id;
  109. this.loadGoodsDetail();
  110. }
  111. if (options.title) {
  112. uni.setNavigationBarTitle({
  113. title: decodeURIComponent(options.title)
  114. });
  115. }
  116. },
  117. methods: {
  118. // 加载商品详情
  119. loadGoodsDetail() {
  120. // 这里可以根据goodsId从后端获取商品详情
  121. // 目前使用模拟数据
  122. const goodsData = {
  123. 1: {
  124. title: '高产玉米种子',
  125. description: '优质杂交种,抗病性强,适应性广',
  126. price: '68',
  127. originalPrice: '88',
  128. unit: '袋',
  129. specifications: '500g/袋,发芽率≥95%',
  130. features: [
  131. '高产稳产,比普通品种增产15-20%',
  132. '抗病性强,抗大小斑病、丝黑穗病',
  133. '适应性广,适合多种土壤和气候条件',
  134. '株型紧凑,抗倒伏能力强',
  135. '籽粒饱满,商品性好'
  136. ],
  137. usage: '播种前先进行种子处理,选择肥沃、排水良好的土壤,按照每亩3-4千粒的密度播种。播种深度2-3厘米,播种后及时覆土镇压。生长期注意水肥管理,适时中耕除草。',
  138. detailImages: [
  139. '/static/images/products/corn-seeds-new.jpg',
  140. '/static/images/products/seeds-packets.jpg',
  141. '/static/images/products/agriculture-tools.jpg'
  142. ]
  143. },
  144. 2: {
  145. title: '复合肥料NPK',
  146. description: '15-15-15配比,全营养均衡',
  147. price: '120',
  148. originalPrice: '150',
  149. unit: '袋',
  150. specifications: '40kg/袋,NPK含量≥45%',
  151. features: [
  152. '营养全面,氮磷钾配比科学',
  153. '速效持效相结合,肥效持久',
  154. '提高作物产量和品质',
  155. '改善土壤结构,增强保肥能力',
  156. '适用于多种作物和土壤类型'
  157. ],
  158. usage: '基肥:每亩施用20-30kg,在耕地时均匀撒施并翻入土中。追肥:根据作物生长情况,在关键生长期追施10-15kg。注意避免与种子直接接触,施肥后及时浇水。',
  159. detailImages: [
  160. '/static/images/products/fertilizer.jpg',
  161. '/static/images/products/organic-fertilizer-new.jpg',
  162. '/static/images/products/soil-test.jpg'
  163. ]
  164. },
  165. 3: {
  166. title: '植物保护剂',
  167. description: '广谱除草,效果持久',
  168. price: '45',
  169. originalPrice: '58',
  170. unit: '瓶',
  171. specifications: '500ml/瓶,有效成分≥98%',
  172. features: [
  173. '广谱高效,对多种杂草有效',
  174. '低毒环保,对作物安全',
  175. '持效期长,减少施药次数',
  176. '易于使用,省时省力',
  177. '成本经济,性价比高'
  178. ],
  179. usage: '在杂草3-5叶期施药效果最佳。每亩用药量15-20ml,兑水30-45kg均匀喷雾。避免在风力较大时施药,施药后6小时内遇雨需重新施药。',
  180. detailImages: [
  181. '/static/images/products/plant-protection.jpg',
  182. '/static/images/products/agriculture-tools.jpg',
  183. '/static/images/products/pesticide.jpg'
  184. ]
  185. },
  186. 4: {
  187. title: '优质水稻种子',
  188. description: '高产稳产,米质优良',
  189. price: '85',
  190. originalPrice: '105',
  191. unit: '袋',
  192. specifications: '25kg/袋,发芽率≥95%',
  193. features: [
  194. '优质品种,口感佳产量高',
  195. '抗病性强,适应性广',
  196. '生育期适中,便于管理',
  197. '籽粒饱满,商品性好',
  198. '耐储存,发芽率稳定'
  199. ],
  200. usage: '播种前进行晒种、选种处理。育秧密度适宜,秧龄25-30天移栽。合理密植,一般每亩1.8-2.2万穴。科学施肥,注意水分管理。',
  201. detailImages: [
  202. '/static/images/products/seeds-packets.jpg',
  203. '/static/images/products/rice-seeds.jpg',
  204. '/static/images/products/corn-seeds-new.jpg'
  205. ]
  206. }
  207. };
  208. if (goodsData[this.goodsId]) {
  209. this.goodsDetail = goodsData[this.goodsId];
  210. // 根据商品类型设置轮播图
  211. this.setGoodsImages(this.goodsId);
  212. }
  213. },
  214. // 设置商品轮播图
  215. setGoodsImages(goodsId) {
  216. const imageMap = {
  217. '1': [ // 玉米种子
  218. '/static/images/products/corn-seeds-new.jpg',
  219. '/static/images/products/seeds-packets.jpg',
  220. '/static/images/products/agriculture-tools.jpg',
  221. '/static/images/products/wheat-seeds.jpg'
  222. ],
  223. '2': [ // 复合肥料
  224. '/static/images/products/fertilizer.jpg',
  225. '/static/images/products/organic-fertilizer-new.jpg',
  226. '/static/images/products/soil-test.jpg',
  227. '/static/images/products/greenhouse-film.jpg'
  228. ],
  229. '3': [ // 植物保护剂
  230. '/static/images/products/plant-protection.jpg',
  231. '/static/images/products/agriculture-tools.jpg',
  232. '/static/images/products/pesticide.jpg',
  233. '/static/images/products/insecticide.jpg'
  234. ],
  235. '4': [ // 水稻种子
  236. '/static/images/products/seeds-packets.jpg',
  237. '/static/images/products/rice-seeds.jpg',
  238. '/static/images/products/corn-seeds-new.jpg',
  239. '/static/images/products/wheat-seeds.jpg'
  240. ]
  241. };
  242. if (imageMap[goodsId]) {
  243. this.goodsImages = imageMap[goodsId];
  244. }
  245. },
  246. // 预览图片
  247. previewImage(current, urls) {
  248. uni.previewImage({
  249. current: current,
  250. urls: urls
  251. });
  252. },
  253. // 立即咨询
  254. handleConsult() {
  255. uni.showModal({
  256. title: '咨询服务',
  257. content: '您可以通过以下方式联系我们:\n1. 拨打客服热线:400-xxx-xxxx\n2. 在线客服(工作时间:9:00-18:00)',
  258. confirmText: '拨打电话',
  259. cancelText: '取消',
  260. success: (res) => {
  261. if (res.confirm) {
  262. uni.makePhoneCall({
  263. phoneNumber: '400-xxx-xxxx'
  264. });
  265. }
  266. }
  267. });
  268. }
  269. }
  270. }
  271. </script>
  272. <style lang="scss">
  273. .detail-container {
  274. min-height: 100vh;
  275. background-color: #f5f5f5;
  276. padding-bottom: 120rpx; // 为底部操作栏留出空间
  277. }
  278. .swiper-container {
  279. width: 100%;
  280. height: 600rpx;
  281. background-color: #fff;
  282. }
  283. .goods-swiper {
  284. width: 100%;
  285. height: 100%;
  286. }
  287. .swiper-image {
  288. width: 100%;
  289. height: 100%;
  290. }
  291. .goods-basic-info {
  292. background-color: #fff;
  293. padding: 30rpx;
  294. margin-bottom: 20rpx;
  295. }
  296. .goods-title {
  297. font-size: 36rpx;
  298. font-weight: bold;
  299. color: #333;
  300. line-height: 1.4;
  301. margin-bottom: 16rpx;
  302. }
  303. .goods-subtitle {
  304. font-size: 28rpx;
  305. color: #666;
  306. line-height: 1.5;
  307. margin-bottom: 24rpx;
  308. }
  309. .price-container {
  310. display: flex;
  311. align-items: baseline;
  312. margin-bottom: 24rpx;
  313. }
  314. .current-price {
  315. font-size: 40rpx;
  316. font-weight: bold;
  317. color: #4CAF50;
  318. }
  319. .price-unit {
  320. font-size: 28rpx;
  321. color: #999;
  322. margin-left: 8rpx;
  323. margin-right: 16rpx;
  324. }
  325. .original-price {
  326. font-size: 28rpx;
  327. color: #999;
  328. text-decoration: line-through;
  329. }
  330. .specs-info {
  331. display: flex;
  332. align-items: center;
  333. }
  334. .specs-label {
  335. font-size: 28rpx;
  336. color: #666;
  337. }
  338. .specs-value {
  339. font-size: 28rpx;
  340. color: #333;
  341. }
  342. .goods-detail-info {
  343. background-color: #fff;
  344. padding: 30rpx;
  345. }
  346. .detail-title {
  347. font-size: 32rpx;
  348. font-weight: bold;
  349. color: #333;
  350. margin-bottom: 30rpx;
  351. text-align: center;
  352. }
  353. .detail-section {
  354. margin-bottom: 40rpx;
  355. &:last-child {
  356. margin-bottom: 0;
  357. }
  358. }
  359. .section-title {
  360. font-size: 30rpx;
  361. font-weight: bold;
  362. color: #333;
  363. margin-bottom: 20rpx;
  364. padding-left: 20rpx;
  365. position: relative;
  366. &::before {
  367. content: '';
  368. position: absolute;
  369. left: 0;
  370. top: 50%;
  371. transform: translateY(-50%);
  372. width: 8rpx;
  373. height: 32rpx;
  374. background-color: #4CAF50;
  375. border-radius: 4rpx;
  376. }
  377. }
  378. .feature-list {
  379. .feature-item {
  380. display: flex;
  381. align-items: center;
  382. margin-bottom: 16rpx;
  383. .feature-icon {
  384. width: 32rpx;
  385. height: 32rpx;
  386. background-color: #4CAF50;
  387. color: #fff;
  388. border-radius: 50%;
  389. display: flex;
  390. align-items: center;
  391. justify-content: center;
  392. font-size: 20rpx;
  393. font-weight: bold;
  394. margin-right: 16rpx;
  395. flex-shrink: 0;
  396. }
  397. .feature-text {
  398. font-size: 28rpx;
  399. color: #666;
  400. line-height: 1.5;
  401. }
  402. }
  403. }
  404. .usage-content {
  405. font-size: 28rpx;
  406. color: #666;
  407. line-height: 1.6;
  408. padding: 20rpx;
  409. background-color: #f8f8f8;
  410. border-radius: 12rpx;
  411. }
  412. .detail-images {
  413. display: flex;
  414. flex-direction: column;
  415. gap: 20rpx;
  416. }
  417. .detail-image {
  418. width: 100%;
  419. border-radius: 12rpx;
  420. }
  421. .bottom-actions {
  422. position: fixed;
  423. bottom: 0;
  424. left: 0;
  425. right: 0;
  426. background-color: #fff;
  427. padding: 20rpx 30rpx;
  428. border-top: 1rpx solid #f0f0f0;
  429. z-index: 1000;
  430. }
  431. .action-btn {
  432. text-align: center;
  433. padding: 24rpx 0;
  434. border-radius: 12rpx;
  435. font-size: 32rpx;
  436. font-weight: bold;
  437. }
  438. .consult-btn {
  439. background-color: #4CAF50;
  440. color: #fff;
  441. }
  442. </style>