A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

本帖最后由 谷粒姐姐 于 2018-8-28 15:34 编辑

2.1 读取商品介绍(富文本编辑器)
修改前端代码 goodsController
[AppleScript] 纯文本查看 复制代码
//查询实体

$scope.findOne=function(){


.................


goodsService.findOne(id).success(


function(response){


$scope.entity=  response;

//向富文本编辑器添加商品介绍editor.html($scope.entity.goodsDesc.introduction);

}


);


}
2.1 显示商品图片列表
修改 goodsController.js ,在 dataLogic 方法添加代码,将图片列表由字符串转换为 json 集合对象
[AppleScript] 纯文本查看 复制代码
//查询实体

$scope.findOne=function(){

..............

//如果有 ID,则查询实体goodsService.findOne(id).success(

function(response){

$scope.entity=  response;

//向富文本编辑器添加商品介绍editor.html($scope.entity.goodsDesc.introduction);
//显示图片列表

$scope.entity.goodsDesc.itemImages= JSON.parse($scope.entity.goodsDesc.itemImages);
}

);

}
2.1 读取商品扩展属性
修改 goodsController.js
[AppleScript] 纯文本查看 复制代码
//查询实体

$scope.findOne=function(){
.........


goodsService.findOne(id).success(


function(response){


.......................

//显示扩展属性

$scope.entity.goodsDesc.customAttributeItems= JSON.parse($scope.entity.goodsDesc.customAttributeItems);

}


);


}
经过测试,我们发现扩展属性值并没有读取出来,这是因为与下列代码发生冲突
1535441587(1).jpg
我们读取出来的值被覆盖了,我们需要改写代码, 添加判断,当用户没有传递 id 参数时再执行此逻辑
[AppleScript] 纯文本查看 复制代码
//监控模板 ID ,读取品牌列表

$scope.$watch('entity.goods.typeTemplateId',function(newValue,oldValue){

//读取品牌列表和扩展属性typeTemplateService.findOne(newValue).success(

function(response){

.......
//如果没有 ID,则加载模板中的扩展数据

if($location.search()['id']==null){

$scope.entity.goodsDesc.customAttributeItems  = JSON.parse($scope.typeTemplate.customAttributeItems);//扩展属性

}

}

);

.......

});

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马