Skip to content

Commit

Permalink
积分商品的属性
Browse files Browse the repository at this point in the history
  • Loading branch information
shirne committed Sep 10, 2024
1 parent 8366034 commit 1122dbb
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 10 deletions.
1 change: 1 addition & 0 deletions dbscript/update_credit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ CREATE TABLE `sa_goods_category` (
`name` varchar(50) DEFAULT NULL COMMENT '分类别名',
`icon` varchar(100) DEFAULT NULL COMMENT '图标',
`image` varchar(100) DEFAULT NULL COMMENT '大图',
`props` TEXT COMMENT '绑定属性',
`sort` int(11) DEFAULT NULL COMMENT '排序',
`keywords` varchar(255) DEFAULT NULL COMMENT '分类关键词',
`description` varchar(255) DEFAULT NULL COMMENT '分类描述',
Expand Down
7 changes: 7 additions & 0 deletions src/application/admin/view/credit/category/edit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@
{/if}
</div>
</div>
<div class="form-group">
<label for="description">产品属性</label>
<div class="form-control">
<input type="text" class="taginput" value="{$model.props|default=''|implode_cmp}"
placeholder="填写多个值以,分割" />
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
Expand Down
55 changes: 45 additions & 10 deletions src/application/admin/view/credit/goods/edit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
<div class="input-group-prepend"><span class="input-group-text">商品分类</span> </div>
<select name="cate_id" id="goods-cate" class="form-control">
{foreach $category as $key => $v}
<option value="{$v.id}" {$goods['cate_id']==$v['id']?'selected':""}>{$v.html} {$v.title}
<option value="{$v.id}" {$goods['cate_id']==$v['id']?'selected':""}
data-props="{$v['props']}">{$v.html} {$v.title}
</option>
{/foreach}
</select>
Expand Down Expand Up @@ -203,15 +204,6 @@
zIndex: 100
});
jQuery(function ($) {
$('.addpropbtn').click(function (e) {
$('.prop-groups').append('<div class="input-group mb-2" >\n' +
' <input type="text" class="form-control" style="max-width:120px;" name="prop_data[keys][]" />\n' +
' <input type="text" class="form-control" name="prop_data[values][]" />\n' +
' <div class="input-group-append delete"><a href="javascript:" class="btn btn-outline-secondary"><i class="ion-md-trash"></i> </a> </div>\n' +
' </div>');
});
$('.taginput').each(function () {
$(this).tags('spec_data[' + $(this).data('spec_id') + '][data][]', resetSkus);
});
Expand All @@ -221,6 +213,49 @@
self.parents('.input-group').remove();
})
});
function addProp(key, value) {
$('.prop-groups').append('<div class="input-group mb-2" >\n' +
' <input type="text" class="form-control" style="max-width:120px;" name="prop_data[keys][]" value="' + (key ? key : '') + '" />\n' +
' <input type="text" class="form-control" name="prop_data[values][]" value="' + (value ? value : '') + '" />\n' +
' <div class="input-group-append delete"><a href="javascript:" class="btn btn-outline-secondary"><i class="ion-md-trash"></i> </a> </div>\n' +
' </div>');
}
$('.addpropbtn').click(function (e) {
addProp();
});
function changeCategory(select, force) {
var option = $(select).find('option:selected');
var curProps = [];
var cid = $(option).val();
var props = $(option).data('props') || [];
$('.prop-groups .input-group').each(function () {
var input = $(this).find('input');
var prop = input.val().trim();
if (input.eq(1).val().trim() === '') {
if (props.indexOf(prop) < 0) {
$(this).remove();
} else {
curProps.push(prop);
}
} else {
curProps.push(prop);
}
});
for (var i = 0; i < props.length; i++) {
if (curProps.indexOf(props[i]) < 0) {
addProp(props[i]);
}
}
}
$('#goods-cate').change(function (e) {
changeCategory(this);
});
if ('add' === "{$goods['id']?'':'add'}") {
changeCategory($('#goods-cate'), true);
}
});
</script>
Expand Down

0 comments on commit 1122dbb

Please sign in to comment.