品优购-秒杀详细页
3.1 需求分析
商品详细页显示秒杀商品信息。
3.2 显示详细页信息
3.2.1 后端代码
修改 pinyougou-seckill-interface 的 SeckillGoodsService
/**
* 根据 ID 获取实体(从缓存中读取)
*/
public TbSeckillGoods findOneFromRedis(Long id);
修改 pinyougou-seckill-service 的 SeckillGoodsServiceImpl.java
@Override
public TbSeckillGoods findOneFromRedis(Long id) {
return (TbSeckillGoods)redisTemplate.boundHashOps("seckillGoods").get(id);
}
修改 pinyougou-seckill-web 的 SeckillGoodsController
@RequestMapping("/findOneFromRedis")
public TbSeckillGoods findOneFromRedis(Long id){
return seckillGoodsService.findOneFromRedis(id);
}
增加超时时间设置
@Reference(timeout=10000)
private SeckillGoodsService seckillGoodsService;
前端代码
pinyougou-seckill-web 的 seckillGoodsService.js
this.findOne=function(id){
return $http.get('seckillGoods/findOneFromRedis.do?id='+id);
}
pinyougou-seckill-web 的 seckillGoodsController.js ,引入$location 服务
//查询实体
$scope.findOne=function(){
seckillGoodsService.findOne($location.search()['id']).success(
function(response){
$scope.entity= response;
}
);
}
修改 seckill-item.html ,引入 js
<script type="text/javascript" src="plugins/angularjs/angular.min.js"> </script>
<script type="text/javascript" src="js/base.js"> </script>
<script type="text/javascript" src="js/service/seckillGoodsService.js"> </script>
<script src="js/controller/seckillGoodsController.js"> </script>
指令
<body ng-app="pinyougou" ng-controller="seckillGoodsController" ng-init="findOne()">
用表达式显示标题
<h4>{{entity.title}}</h4>
图片
<span class="jqzoom"><img jqimg="{{entity.smallPic}}" src="{{entity.smallPic}}"
width="400px" height="400px" /></span>
价格
<div class="fl price"><i>¥</i>
<em>{{entity.costPrice}}</em>
<span>原价:{{entity.price}}</span>
</div>
介绍
<div class="intro-detail">{{entity.introduction}}</div>
剩余库存
剩余库存:{{entity.stockCount}}