Authored by dongjunjie

提交

<%include '__ui/header'%>
<app></app>
<%include '__ui/footer'%>
\ No newline at end of file
... ...
<template>
addadasdasdasd
</template>
<script>
</script>
\ No newline at end of file
... ...
var Vue = require("vue");
Vue.use(require('vue-resource'));
new Vue({
el: 'body',
components: {
app:require("./app.vue")
}
});
... ...
module.exports = function (app){
app.get("/shop/shopCategory/index", "shop.ShopCategory.Index", function (req,res){
app.get("/shop/shopCategory/index222", "shop.ShopCategory.Index", function (req,res){
this.$extend={
moduleName:"店铺管理",
pageName:"店铺销售类目管理"
}
});
app.get("/shop/shopCategory/info", "shop.ShopCategory.Info", function (rs,req,res){
app.vue("/shop/shopCategory/index", "shop.ShopCategory", function (req,res){
this.$extend={
moduleName:"店铺管理",
pageName:"店铺销售类目管理"
}
});
app.get("/shop/shopCategory/add", "shop.ShopCategory.Info", function (rs,req,res){
this.$extend={
moduleName:"店铺管理",
pageName:"店铺销售类目管理",
subPageName:"新增店铺销售类目"
}
});
app.get("/shop/shopCategory/info/:shopId", "shop.ShopCategory.Info", function (rs,req,res){
this.$extend={
moduleName:"店铺管理",
pageName:"店铺销售类目管理",
... ... @@ -14,7 +29,7 @@ module.exports = function (app){
}
});
app.get("/shop/shopCategory/edit", "shop.ShopCategory.Edit", function (rs,req,res){
app.get("/shop/shopCategory/edit/:shopId", "shop.ShopCategory.Edit", function (rs,req,res){
this.$extend={
moduleName:"店铺管理",
pageName:"店铺销售类目管理",
... ...
... ... @@ -2,21 +2,65 @@
<%include '../../../common/views/__partail/ListHeader'%>
<div class="contentpanel">
<div style="margin-bottom: 20px">
<div class="form-group">
<select id="shop-select" name="shop-select" style="width: 300px;" class="form-control">
<option value="-1">请选择店铺</option>
</select>
<div class="panel">
<div class="selectShop">
<div class="form-group" style="float: left">
<select id="shop-select" name="shop-select" style="width: 320px;" class="form-control">
<option value="-1">请选择店铺</option>
</select>
</div>
<div id="shopInfo" style="font-family:'microsoft yahei';font-size: 18px;line-height: 40px;float: left;margin-left: 40px">
<span id="shopId"><font color="#999">店铺ID:</font><b>--</b></span>
<span id="shopName" style="margin-left: 20px"><font color="#999">店铺名称:</font><b>--</b></span>
</div>
<div class="clearfix"></div>
</div>
</div>
<div style="margin-bottom: 20px">
<a class="add btn btn-success"><i class="fa fa-plus"></i> 新增销售类目</a>
</div>
<div style="margin-bottom: 20px">
<div class="panel-body" style="background: #eeeeee">
<div id="showCategory" style="display: none"></div>
<h1 id="initCategory" style="height: 500px;text-align: center;line-height: 500px;color: #999999">请先选择相关店铺!</h1>
</div>
</div>
</div>
<script type="text/template" id="listTemplate">
<div class="addCategory" style="margin-bottom: 20px">
<a class="btn btn-success addBtn"><i class="fa fa-plus"></i> 新增销售类目</a>
<span style="float: right;font-size: 16px;line-height:37px;font-family:'simhei'">
当前店铺共有:<b style="color: #5cb85c;font-size: 20px">[[data.length]]</b>&nbsp;条销售类目,<font color="#f0ad4e">最多可以添加20条</font>
</span>
</div>
<table class="table table-striped table-bordered responsive dataTable no-footer" style="text-align: center">
<thead>
<tr>
<th style="text-align: center">类目ID</th>
<th style="text-align: center">类目名称</th>
<th style="text-align: center">创建时间</th>
<th style="text-align: center">已关联商品数量</th>
<th style="text-align: center">操作</th>
</tr>
</thead>
<tbody style="line-height: 27px">
[[if data.length > 0]]
[[each data as item _index]]
<tr>
<td style="line-height: 27px">[[item.id]]</td>
<td style="line-height: 27px">[[item.name]]</td>
<td style="line-height: 27px">[[item.date]]</td>
<td style="line-height: 27px">[[item.num]]</td>
<td style="line-height: 27px">
<a href='/shop/shopCategory/edit/[[item.id]]' class='btn btn-xs btn-primary'>编辑</a>
<a href='/shop/shopCategory/info/[[item.id]]' class='btn btn-xs btn-info'>查看</a>
<a href='javascript:' class='btn btn-xs btn-danger deleteBtn' data-index='"+_index+"'>删除</a>
</td>
</tr>
[[/each]]
[[else]]
<tr><td colspan="6">当前店铺暂无销售类目!</td></tr>
[[/if]]
</tbody>
</table>
</script>
<%include '../../../common/views/__ui/footer'%>
\ No newline at end of file
... ...
<template>
<div class="pageheader">
<ul class="breadcrumb">
<li><a href=""><i class="glyphicon glyphicon-home"></i></a></li>
<li><a href="">{{title}}</a></li>
<li>{{subTitle}}</li>
</ul>
<div class="media">
<div class="pageicon pull-left">
<i class="fa fa-th-list"></i>
</div>
<div class="media-body" style="font-family: 'microsoft yahei'">
<ul class="breadcrumb">
<li><a href=""><i class="glyphicon glyphicon-home"></i></a></li>
<li><a href="">{{moduleName}}</a></li>
<li>{{pageName}}</li>
</ul>
<div style="margin-top: 4px">
<h4 v-if="subPageName" style="line-height: 30px;font-size: 24px">{{subPageName}}</h4>
<h4 v-else style="line-height: 30px;font-size: 24px">{{pageName}}</h4>
</div>
</div>
</div>
</div>
</template>
<script>
export default{
props:{
title:{type:String, default:""},
subTitle:{type:String, default:""}
moduleName:{type:String, default:""},
pageName:{type:String, default:""},
subPageName:{type:String, default:""}
}
}
</script>
<style>
.pageheader{ margin-bottom: 8px}
.pageheader .breadcrumb {font-family: 'microsoft yahei'}
</style>
\ No newline at end of file
</script>
\ No newline at end of file
... ...
... ... @@ -234,4 +234,4 @@ gulp.task('vue',["vue-gulp"], function (cb) {
});
gulp.task("default",["jquery","assets","sass"]);
gulp.task('start', ["default", "static", "server"]);//"vue"
\ No newline at end of file
gulp.task('start', ["default", "static", "server", "vue"]);//"vue"
\ No newline at end of file
... ...
... ... @@ -26,7 +26,7 @@ Controller.prototype.__parseReq=function(req){
}
}
Controller.prototype.__define=function(method,router,view,apis,callback,clientmodel){
Controller.prototype.__define=function(method,router,view,apis,callback,clientmodel,clientsrc){
var me=this,isObj=false;
if(typeof apis=="string"){
apis=[apis];
... ... @@ -34,34 +34,34 @@ Controller.prototype.__define=function(method,router,view,apis,callback,clientmo
}
/*参数验证*/
var guid=md5(router+":"+method)
me.on(guid,function(){
var args=[].slice.call(arguments, 0);
var req = args[0], res = args[1];
var req = args[0], res = args[1];
var local = { __session__: req.session, $extend: {} };
var local = { __session__: req.session, $extend: {} };
/*如果接口不存在 就实现express 原来的方法*/
if(!apis.length){
var model={};
if(callback){
model=callback.apply(local, args);
model=callback.apply(local, args);
}
if(view){
res.render(view,local,me.client(res,view,model,clientmodel));
res.render(view,local,me.client(res,clientsrc,model,clientmodel));
}
return;
}
args.push(function (err, interfaces, names){
if (err) {
res.json({code:500,message:"接口异常"});
return;
}
args.push(function (err, interfaces, names){
if (err) {
res.json({code:500,message:err.message||'接口异常'});
return;
}
//callback
var model={};
if (typeof callback == "function") {
if (typeof callback == "function") {
model=callback.apply(local,interfaces.concat(args));
}else{
interfaces.forEach(function(item,index){
... ... @@ -70,18 +70,18 @@ Controller.prototype.__define=function(method,router,view,apis,callback,clientmo
}else{
model[names[index]]=item;
}
});
}
if(res.__complete__){
return;
}
if (model&&model.readable) {
model.pipe(res);
}else if (view && method == "get" && !req.xhr) {
res.render(view, local, me.client(res, view, model,clientmodel));
} else {
res.json(model);
}
});
}
if(res.__complete__){
return;
}
if (model&&model.readable) {
model.pipe(res);
}else if (view && method == "get" && !req.xhr) {
res.render(view, local, me.client(res, clientsrc, model,clientmodel));
} else {
res.json(model);
}
});
//调用接口获取数据
me.interfaces.require.apply(me.interfaces,[apis].concat(args));
... ... @@ -91,8 +91,8 @@ Controller.prototype.__define=function(method,router,view,apis,callback,clientmo
guid:guid,
url:router,
method:method
});
//console.log(me.routers);
});
//console.log(me.routers);
}
Controller.prototype.vue=function(router,views,apis,callback){
var me=this;
... ... @@ -106,7 +106,7 @@ Controller.prototype.vue=function(router,views,apis,callback){
apis=[];
}
apis=apis||[];
me.__define("get",router,views,apis,callback,"vue");
me.__define("get",router,"common.Vue",apis,callback,"vue",views);
}
Controller.prototype.get=function(router,views,apis,callback){
var me=this;
... ... @@ -120,7 +120,7 @@ Controller.prototype.get=function(router,views,apis,callback){
apis=[];
}
apis=apis||[];
me.__define("get",router,views,apis,callback,"jquery");
me.__define("get",router,views,apis,callback,"jquery",views);
}
Controller.prototype.post=function(router,apis,callback){
var me=this;
... ...
... ... @@ -2,7 +2,92 @@
var $ = require('jquery'),
common = require('../../../common/common');
var loadModal = null,
currentShopId = -1,
currentShopCategoryNum = 0;
new common.dropDown({
hash:true,
el: "#shop-select",
ajax: "shopsRest"
});
var Bill = {
//初始化页面
init: function () {
currentShopId = -1;
currentShopCategoryNum = 0;
$('#shopId b').text('--');
$('#shopName b').text('--');
$('#showCategory').hide();
$('#initCategory').show();
},
//展示销售类目列表
showList: function (shopId,isLoading) {
if(isLoading==1) loadModal = common.dialog.load();
common.util.__ajax({
url:'',
data: {shopId:shopId}
}, function (res) {
if(isLoading==1 && loadModal) loadModal.close();
var data = res.data;
currentShopCategoryNum = data.length;
$('#initCategory').hide();
$('#showCategory').html(common.util.__template2($("#listTemplate").html(),data)).show();
},true)
},
//删除销售类目
deleteCategory: function (shopId,categoryId) {
common.util.__ajax({
url:'',
data: {
shopId:shopId,
categoryId:categoryId
}
}, function (res) {
this.showList(shopId,0);
})
}
};
//选择店铺
$(document).on('change', '#shop-select', function () {
var shopId = $(this).val();
if(shopId > 0){
currentShopId = shopId;
var shopName = this.options[this.selectedIndex].text;
$('#shopId b').text(shopId);
$('#shopName b').text(shopName);
//Bill.showList(shopId,1);
$('#initCategory').hide();
$('#showCategory').html(common.util.__template2($("#listTemplate").html(),{data:[{id:'1',name:'dada',date:'ff',num:'23'}]})).show();
}else{
Bill.init();
}
});
//新增类目
$(document).on('click', '.addBtn', function () {
if(currentShopCategoryNum < 20){
location.href = '/shop/shopCategory/add';
}else {
common.util.__tip('店铺最多添加只能添加20个销售类目!');
}
});
//删除类目
$(document).on('click', '.deleteBtn', function () {
var categoryName = $(this).parent().parent().find('td').eq(1).text();
common.dialog.confirm(
"删除店铺销售类目",
"你确定<b style='color: #ff0000'>&nbsp;删除&nbsp;</b>销售类目<b style='color:#428bca'>&nbsp;"+categoryName+"&nbsp;</b>么?",
function () {
Bill.deleteCategory();
}
)
});
\ No newline at end of file
... ...
... ... @@ -3,69 +3,66 @@
* 默认依赖
*/
'use strict';
var $ = require('jquery');
var isMenuShow = false;
var localStorage = window.localStorage;
/**
* 左侧导航
*/
$('#sidebar .nav .has-sub>a').click(function() {
var child = $(this).parent().find('.sub-menu');
/*左侧导航*/
$('.leftpanel .nav .parent>a').click(function() {
var parent = $(this).parent(),
child = parent.find('.children');
$('#sidebar .nav .has-sub>a').each(function() {
$(this).find('.sub-menu').slideUp('fast');
$(this).removeClass('active');
});
parent.siblings('.active').find('.children').removeClass("active").slideUp('fast');
parent.siblings('.active').removeClass("active");
if (!child.is(':visible')) {
child.slideDown('fast');
if (!child.parent().hasClass('active'))
child.parent().addClass('active');
} else {
child.slideUp('fast');
child.parent().removeClass('active');
if(parent.hasClass('active')){
$(".parent ").removeClass("active");
$('.children').removeClass("active").slideUp('fast');
isMenuShow = false;
}else{
$(this).parent(".parent ").addClass("active");
child.slideDown('fast').addClass("active");
isMenuShow = true;
}
isMenuShow = true;
return false;
});
$("#sidebar .nav .sub-menu a").each(function() {
/*菜单*/
$(".leftpanel .nav .children a").each(function() {
var attr = $(this).attr('href');
if (!isMenuShow && attr == window.location.pathname + window.location.search) {
$(this).parents(".sub-menu").show();
$(this).parents(".children").show();
$(this).parent("li").addClass("active");
$(this).parents(".has-sub ").addClass("active");
$(this).parents(".parent").addClass("active");
localStorage.setItem("router", attr);
localStorage.getItem("router");
isMenuShow = true;
}
});
/**
* 左侧最小化
*/
$(".sidebar-minify-btn").click(function(){
$("#page-container").toggleClass("page-sidebar-minified");
});
$(".dropdown").hover(function () {
$(".dropdown-menu").show();
}, function () {
$(".dropdown-menu").hide();
});
if (!isMenuShow && localStorage.getItem("router")) {
$(".leftpanel .nav .children a").each(function() {
var attr = $(this).attr('href');
/**
* 切换店铺
*/
$('.shops_id').click(function (){
var shop_id = $(this).attr('data-shopid');
$.getJSON('/index/ajaxshop?shops_id='+shop_id, function (data){
if(data.code == 200){
window.location.href="/";
}else{
alert(data.message);
if (localStorage.getItem("router") == attr) {
$(this).parents(".children").show();
$(this).parent("li").addClass("active");
$(this).parents(".parent").addClass("active");
isMenuShow = true;
}
})
});
}
// LocalStorage.setItem("router",);
$('.panel-heading').hover(function() {
$(this).find('.panel-btns').fadeIn('fast');
}, function() {
$(this).find('.panel-btns').fadeOut('fast');
});
$('.panel .panel-close').click(function() {
$(this).closest('.panel').fadeOut(200);
return false;
});
\ No newline at end of file
... ...
... ... @@ -11,9 +11,7 @@ module.exports = {
resolve: {
alias: {
jquery: path.resolve(baseName, './jquery.js'),
vue: path.resolve(baseName, './vue.min.js'),
echarts:path.resolve(baseName, './echarts.simple.min.js'),
util:path.resolve(baseName, './util.js')
vue: path.resolve(baseName, './vue.min.js')
},
extensions: ['', '.js', '.vue', '.scss']
},
... ...