Browse Source

H5 商城

yuhaitao14 7 years ago
parent
commit
a9284c8f93

+ 103 - 0
shop/src/main/java/com/zskk/shop/controller/h5/H5IndexController.java

@@ -0,0 +1,103 @@
+/**
+* @版权信息 (@copyright Copyright 2017-XXXX JDJR.COM All Right Reserved);
+* @see
+* @author 于海涛 京东金融【技术研发部-证券及营销平台研发部-营销平台研发部】
+* @version 1.0
+* @date 2018年6月26日
+*/
+
+package com.zskk.shop.controller.h5;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import com.zskk.shop.controller.AbstractController;
+import com.zskk.shop.controller.bean.GoodBean;
+import com.zskk.shop.dao.entry.Banner;
+import com.zskk.shop.dao.entry.GoodAd;
+import com.zskk.shop.dao.entry.GoodBase;
+import com.zskk.shop.dao.entry.GoodDescribe;
+import com.zskk.shop.dao.entry.GoodPrice;
+import com.zskk.shop.dao.entry.SysLabel;
+import com.zskk.shop.service.BannerService;
+import com.zskk.shop.service.GoodService;
+import com.zskk.shop.service.SysLabelService;
+import com.zskk.shop.service.TJCenterService;
+
+@Controller
+@RequestMapping("/h5")
+public class H5IndexController extends AbstractController {
+
+	@Autowired
+	private GoodService goodService;
+	
+	@Autowired
+	private TJCenterService tjCenterService;
+	
+	@Autowired
+	private SysLabelService sysLabelService;
+	
+	@Autowired
+	private BannerService  bannerService;
+	
+	@RequestMapping("/index")
+	public String index(Model model, @RequestParam(name="label", required=false) Integer label){
+		List<GoodBean> beans 		= this.getGoodList(label);
+		List<SysLabel> labels		= this.queryAllSysLabel();
+		List<Banner> banners		= bannerService.queryAllOnline();
+		
+		model.addAttribute("beans", beans);
+		model.addAttribute("labels", labels);
+		model.addAttribute("banners", banners);
+		
+		return "/h5/index";
+	}
+	
+	@RequestMapping("/detail/{gid}")
+	public String detail(Model model, @PathVariable("gid") Integer gid){
+		GoodBase base 					= goodService.queryOneGoodBase(gid);
+		GoodPrice price 				= goodService.queryGoodPrice(gid);
+		List<GoodAd> ads 				= goodService.queryGoodAds(gid);
+		List<GoodDescribe> describes 	= goodService.queryGoodDescribes(gid);
+		List<String> tjCheckList		= tjCenterService.getDJDetail(base.getPackageid());
+
+		
+		GoodBean bean = goodService.toDetailGoodBean(base, price, ads, describes);
+		model.addAttribute("good", bean);
+		model.addAttribute("checklist", tjCheckList);
+		this.initUser(model);
+		return "/h5/detail";
+	}
+	
+	private List<GoodBean> getGoodList(Integer lid){
+		List<GoodBase> goodList = null;
+		if (lid == null){
+			goodList = goodService.queryGoodBases(null, GoodService.GOOD_ONLINE, 1, 10);
+		}else{
+			List<Integer> gids = sysLabelService.queryLabelGoods(lid).stream().map(obj -> obj.getGid()).collect(Collectors.toList());
+			if (gids.isEmpty()){
+				goodList = new ArrayList<>();
+			}else{
+				goodList = goodService.queryGoodBases(gids, GoodService.GOOD_ONLINE);
+			}
+		}
+		List<GoodBean> beans = new ArrayList<>();
+		for (GoodBase base: goodList){
+			GoodPrice price = goodService.queryGoodPrice(base.getGid());
+			beans.add(goodService.toSimpleGoodBean(base, price));
+		}
+		return beans;
+	}
+	
+	private List<SysLabel> queryAllSysLabel(){
+		return sysLabelService.queryLabels();
+	}
+}

+ 65 - 0
shop/src/main/resource/templates/h5/detail.html

@@ -0,0 +1,65 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title th:text="${good.name}"></title>
+<meta name="viewport"
+	content="width=device-width, initial-scale=1.0, user-scalable=no" />
+<link href="/h5/style/style.css" rel="stylesheet" />
+</head>
+
+<body>
+	<img th:attr="src=${good.icon}" class="v-banner" />
+	<div class="v-v">
+		<h1 th:text="${good.name}"></h1>
+		<h3 th:text="${good.describe}"></h3>
+		<div class="price">
+			<em>¥</em><span class="new" th:text="${good.price.discountPrice}"></span><span
+				class="old" th:text="'¥' + ${good.price.price}"></span>
+		</div>
+		<div class="line-1-EEE mt10"></div>
+		<div class="tag">
+			<span class="sstk">随时退款</span> <span class="ksyy">快速预约</span>
+		</div>
+	</div>
+	<div class="line-10-EEE"></div>
+	<a class="v-tel" href="#"><div>400-899-9999</div></a>
+	<div class="line-10-EEE"></div>
+	<div class="v-title mt10">
+		<span>详细介绍</span>
+	</div>
+	<div>
+		<img th:each="desc : ${good.describes}"
+			th:attr="src=${desc.content},title=${desc.title}" style="width: 100%"/>
+	</div>
+	<div class="v-title mt10">
+		<span>体检内容</span>
+	</div>
+	<div class="v-view">
+		<table>
+			<tr th:each="item,stat : ${checklist}">
+				<td class="bgGray c666" th:if="${stat.index}%2 == 0"
+					th:text="${item}" style="text-align: center;"></td>
+				<td class="c999" th:if="${stat.index}%2 == 1" th:text="${item}"
+					style="text-align: center;"></td>
+			</tr>
+		</table>
+	</div>
+	<div class="v-title mt10">
+		<span>注意事项</span>
+	</div>
+	<p class="v-tips">
+		1. 体检前24小时避免辛辣油腻食品、饮酒及过度劳累。<br />2. 体检当日晨应禁食、水,抽血不宜超过上午10:30
+	</p>
+	<div class="v-title mt10">
+		<span>服务承诺</span>
+	</div>
+	<p class="v-tips">专业医生为您体检,购买后可随时退款</p>
+	<div style="height: 60px;"></div>
+	<div class="v-bottom">
+		<div>
+			<button>立即预约</button>
+		</div>
+	</div>
+</body>
+</html>

+ 64 - 0
shop/src/main/resource/templates/h5/index.html

@@ -0,0 +1,64 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>昆仑医疗</title>
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
+<link href="/h5/style/style.css" rel="stylesheet" />
+<script src="/h5/js/jquery-2.1.1.min.js"></script>
+<script src="/h5/js/nav.js"></script>
+</head>
+
+<body>
+	<!--顶部-->
+	<div class="index-top">
+    	<button class="l left"></button>
+        <div class="txt"><input name="" type="search" placeholder="搜索商品" /></div>
+    </div>
+    <div class="bgDiv"></div>
+    <div class="leftNav">
+    	<h3>商品分类</h3>
+        <a href="/h5/index">全部</a>
+        <a th:each="label : ${labels}" th:attr="href='/h5/index?label=' + ${label.id}" th:text="${label.name}"></a>
+    </div>
+	<!--轮播-->
+    <img src="images/test.jpg" width="100%" height="180" style="margin-top:46px;" />
+	<!--公告-->
+	<!-- 
+    <a href="#" class="notice">新春放假通知</a>
+     -->
+    <div class="line-1-EEE ml10 mr10"></div>
+	<!--入口-->
+    <ul class="nav ml10 mr10">
+    	<li><a href="##"><img src="style/index-tj-icon.png" /><p>体检套餐</p></a></li>
+        <li><a href="##"><img src="style/index-yx-icon.png" /><p>影像检查</p></a></li>
+        <li><a href="##"><img src="style/index-bg-icon.png" /><p>报告查询</p></a></li>
+        <li><a href="##"><img src="style/index-yy-icon.png" /><p>我的预约</p></a></li>
+    </ul>
+    <div class="line-10-EEE"></div>
+	<!--热销-->
+    <div class="v-list">
+        <div class="t">热销体检套餐</div>
+        <a th:each="bean : ${beans}" th:attr="href='/h5/detail/' + ${bean.gid}">
+            <div class="img l mr10"><img th:attr="src=${bean.icon}"/></div>
+            <dl>
+                <dt th:text="${bean.name}"></dt>
+                <dd th:text="${bean.describe}"></dd>
+                <span class="price-new l">
+                	<em>¥</em>
+                	<span th:text="${bean.price.discountPrice}"></span>
+                </span>
+            </dl>
+        </a>
+    </div>
+	<!--底部-->
+    <div style="height:60px; "></div>
+	<table class="n-tab">
+    	<tr>
+        	<td><a href="#" class="n-1-c">首页</a></td>
+            <td><a href="#" class="n-2">报告</a></td>
+            <td><a href="#" class="n-3">我的</a></td>
+        </tr>
+    </table>
+</body>
+</html>

+ 2 - 2
shop/static/h5/style/style.css

@@ -45,8 +45,8 @@ a{ text-decoration:none; }
 .v-list dl{ display:block; }
 .v-list dt{ font-size:1rem; color:#333; margin-bottom:5px; white-space:nowrap; }
 .v-list dd{ height:2rem; font-size:.8rem; color:#999; margin-bottom:5px; line-height:1rem; text-align:justify; text-justify:inter-ideograph; }
-.v-list .img{ width:100px; overflow:hidden; }
-.v-list .img img{ width:100px; height:70px; }
+.v-list .img{ width:70px; overflow:hidden; }
+.v-list .img img{ width:70px; height:70px; }
 .v-list .price-new{ color:#D83F31; font-size:1rem; margin-right:20px; line-height:1rem; }
 .v-list em{ font-size:.7rem; margin-right:4px; }
 /*页脚*/