Authored by 姜敏

Merge branch 'yohobuy-shop-dev-4.6-20160606' of http://git.yoho.cn/fe/yohobuy-sh…

…op-fe2 into yohobuy-shop-dev-4.6-20160606
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 </template> 3 </template>
4 4
5 <script> 5 <script>
6 - import multilevel from '../../../../components/multilevel/index'; 6 + import multilevel from '../../../../components/sort/index';
7 7
8 export default { 8 export default {
9 components:{ 9 components:{
1 var Vue = require("vue"); 1 var Vue = require("vue");
  2 +Vue.use(require('vue-resource'));
2 3
3 new Vue({ 4 new Vue({
4 el: 'body', 5 el: 'body',
5 components: { 6 components: {
6 - app:require("./app1.vue") 7 + app:require("./app.vue")
7 } 8 }
8 }); 9 });
1 -<style>  
2 - .multilevel{position: relative; font-family: 'microsoft yahei'; font-size:14px; color: #585858}  
3 - .multilevel a,.multilevel span{cursor: pointer; text-decoration: none; color:#585858}  
4 -  
5 - .picker-data{display: inline-block; width: 250px; height: 34px; border: 1px solid #ccd0d4; padding:6px 12px; position: relative; border-radius: 3px}  
6 - .placeholder{display: block}  
7 - .select-item a:hover{background: #CCCCCC}  
8 - .select-item i{margin: 0 2px}  
9 - .arrow{position: absolute; top: 50%; right: 8px; width: 10px; margin-top: -3px; height: 5px; background: url(./drop-arrow.png) -10px -25px no-repeat}  
10 -  
11 - .picker-dropdown{position: absolute; top: 34px; left: 1px;}  
12 - .select-wrap{box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5); border-radius: 4px; width: 300px}  
13 -  
14 - .select-tab{background: #f0f0f0; border-bottom: 1px solid #ccc;}  
15 - .select-tab a{display: inline-block; padding: 8px 15px; border-left: 1px solid #ccc; border-bottom: 1px solid transparent; margin-bottom: -1px}  
16 - .select-tab a:first-child { border-left: none}  
17 - .select-tab a.active{background: #FFFFFF; border-bottom: 1px solid #FFFFFF;}  
18 -  
19 - .select-content{background: #FFFFFF;}  
20 - .levelContent{clear: both; list-style: none; margin: 0; padding: 10px;}  
21 - .levelContent li{display: inline-block; padding: 5px 10px;}  
22 -</style>  
23 -  
24 -<template>  
25 - <div class="multilevel">  
26 - <span class="picker-data">  
27 - <span v-show="dataList.length==0" class="placeholder" @click="showDropdown">请选择类目</span>  
28 - <span v-show="dataList.length>0" class="data">  
29 - <span class="select-item" v-for="data in dataList">  
30 - <i v-if="$index>0">/</i>  
31 - <a href="javascript:" @click="selectTab($index)">{{data}}</a>  
32 - </span>  
33 - </span>  
34 - <div class="arrow"></div>  
35 - </span>  
36 -  
37 - <div class="picker-dropdown" v-show="isShowDropdown">  
38 - <div class="select-wrap">  
39 - <div class="select-tab">  
40 - <a v-for="tab in levelContent" class="level {{$index==activeTab?'active':''}}" @click="selectTab($index)">{{tab.name}}</a>  
41 - </div>  
42 - <div class="select-content">  
43 - <ul v-for="content in levelContent" class="levelContent" v-show="activeTab==$index">  
44 - <li v-for="item in content.list"><a href="javascript:" @click="selectItem(item)">{{item}}</a></li>  
45 - </ul>  
46 - </div>  
47 - </div>  
48 - </div>  
49 - </div>  
50 -</template>  
51 -  
52 -<script>  
53 - export default {  
54 - data() {  
55 - return {  
56 - levelContent:[  
57 - {name:"一级目录", list:["a1","a2","a3"]},  
58 - {name:"二级目录", list:["b1","b2","b3"]},  
59 - {name:"三级目录", list:["c1","c2","c3"]}  
60 - ],  
61 - isShowDropdown:false,  
62 - activeTab:0,  
63 - maxTab:2,  
64 - dataList:[]  
65 - }  
66 - },  
67 - computed:{  
68 - dataArray(){  
69 - console.log(this.dataList);  
70 - return this.dataList.join('/');  
71 - }  
72 - },  
73 - methods: {  
74 - showDropdown(){  
75 - if(this.isShowDropdown){  
76 - this.isShowDropdown = false;  
77 - }else{  
78 - this.isShowDropdown = true;  
79 - }  
80 - },  
81 -  
82 - selectTab(index){  
83 - this.isShowDropdown = true;  
84 - this.activeTab = index;  
85 - },  
86 -  
87 - selectItem(item){  
88 - this.dataList.$set(this.activeTab,item);  
89 - this.dataList.splice(this.activeTab+1, this.dataList.length-this.activeTab-1);  
90 -  
91 - if(this.activeTab < this.maxTab){  
92 - this.activeTab ++;  
93 - }else{  
94 - this.activeTab = 0;  
95 - this.isShowDropdown = false;  
96 - }  
97 - }  
98 - }  
99 - }  
100 -</script>  
  1 +<style>
  2 + .multilevel{position: relative; font-family: 'microsoft yahei'; font-size:14px; color: #585858}
  3 + .multilevel a,.multilevel span{cursor: pointer; text-decoration: none; color:#585858; display: inline-block;}
  4 +
  5 + .picker-data{display: inline-block; height: 34px; border: 1px solid #ccd0d4; padding:6px 12px; position: relative; border-radius: 3px}
  6 + .placeholder,.data{display: inline-block; width: 200px; text-overflow:ellipsis; white-space:nowrap; overflow:hidden;}
  7 + .placeholder{font-size: 14px; color: #9d9d9d}
  8 + .data a{font-size: 12px}
  9 + .select-item a{padding: 0 2px}
  10 + .select-item a:hover{background: #CCCCCC}
  11 + .clearData{display: inline-block; width: 30px; margin-left: 10px; text-overflow:ellipsis; white-space:nowrap; overflow:hidden;}
  12 + .clearData em{color: #999999; font-size: 12px; }
  13 +
  14 + .picker-dropdown{position: absolute; top: 34px; left: 1px;}
  15 + .select-wrap{box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5); border-radius: 4px; width: 350px}
  16 +
  17 + .select-tab{background: #f0f0f0; border-bottom: 1px solid #ccc;}
  18 + .select-tab a{display: inline-block; font-size: 12px; padding: 8px 15px; border-left: 1px solid #ccc; border-bottom: 1px solid transparent; margin-bottom: -1px}
  19 + .select-tab a:first-child {border-left: none}
  20 + .select-tab a:last-child {border-right: 1px solid #ccc}
  21 + .select-tab a.active{background: #FFFFFF; border-bottom: 1px solid #FFFFFF;}
  22 +
  23 + .select-content{background: #FFFFFF;}
  24 + .levelContent,.noSort{clear: both; list-style: none; margin: 0; padding: 10px;}
  25 + .levelContent li,.noSort li{display: inline-block; padding: 5px 10px;}
  26 + .levelContent li.active{background: #5bc0de; border-radius: 4px}
  27 + .levelContent li.active a{color:#FFFFFF}
  28 + .noSort li span{color: #ff0000}
  29 +</style>
  30 +
1 <template> 31 <template>
2 - <div class="region-picker">  
3 - <!-- <label class="province">  
4 - <slot name="province"></slot>  
5 - <select class="province-select" v-model="provinceSelected" :required="required" :disabled="disabled">  
6 - <option value="" v-text="placeholder.province"></option>  
7 - <option v-for="item in provinces" :value="item" v-text="item[1]"></option>  
8 - </select>  
9 - </label> -->  
10 - <template v-for="row in rows">  
11 -  
12 - </template> 32 + <div class="multilevel">
  33 + <span class="picker-data">
  34 + <span v-show="dataList.length==0" class="placeholder" @click="showDropdown">请选择类目</span>
  35 +
  36 + <span v-show="dataList.length>0" class="data" @click="showDropdown">
  37 + <span class="select-item" v-for="data in dataList">
  38 + <i v-if="$index>0">-</i>
  39 + <a href="javascript:" @click="selectTab($index)">{{data.sortName}}</a>
  40 + </span>
  41 + </span>
  42 +
  43 + <span class="clearData" @click="destroy">
  44 + <em v-show="dataList.length>0">清空</em>
  45 + </span>
  46 + </span>
  47 +
  48 + <div class="picker-dropdown" v-show="isShowDropdown">
  49 + <div class="select-wrap">
  50 + <div class="select-tab">
  51 + <a v-for="tab in tabList" class="level {{$index==activeTab?'active':''}}" @click="selectTab($index)">{{tab}}</a>
  52 + </div>
  53 +
  54 + <div class="select-content">
  55 + <ul v-for="(index,content) in levelContent" class="levelContent" v-show="activeTab==index">
  56 + <li v-for="(key,item) in content" class="{{item.id==dataList[index].id?'active':''}}">
  57 + <a href="javascript:" @click="selectItem(item)">{{item.sortName}}</a>
  58 + </li>
  59 + </ul>
  60 +
  61 + <ul v-show="activeTab>=levelContent.length" class="noSort">
  62 + <li><span>请选择上级类目!</span></li>
  63 + </ul>
  64 + </div>
  65 + </div>
  66 + </div>
13 </div> 67 </div>
14 </template> 68 </template>
15 69
16 <script> 70 <script>
17 export default { 71 export default {
18 - name:'yoho-sort',  
19 props:{ 72 props:{
20 - rows:{  
21 - type:Array,  
22 - default:[] 73 + dataList: {type: Array, default: []}
  74 + },
  75 + data() {
  76 + return {
  77 + tabList:["一级目录","二级目录","三级目录","四级目录"],
  78 + levelContent:[],
  79 + isShowDropdown:false,
  80 + activeTab:0,
  81 + maxTab:3
  82 + }
  83 + },
  84 + ready() {
  85 + this.fetchAllSortList();
  86 + },
  87 + methods: {
  88 + showDropdown(){
  89 + this.isShowDropdown = true;
  90 + },
  91 +
  92 + closeDropdown(){
  93 + this.activeTab = 0;
  94 + this.isShowDropdown = false;
  95 + },
  96 +
  97 + selectTab(index){
  98 + this.showDropdown();
  99 + this.activeTab = index;
  100 + },
  101 +
  102 + selectItem(item){
  103 + this.dataList.$set(this.activeTab,item);
  104 + this.dataList.splice(this.activeTab+1, this.dataList.length-this.activeTab-1);
  105 +
  106 + if(this.activeTab < this.maxTab){
  107 + this.activeTab ++;
  108 + this.fetchSubSortList(item.id);
  109 + }else{
  110 + this.closeDropdown();
  111 + }
  112 + },
  113 +
  114 + destroy(){
  115 + this.dataList.splice(0,this.dataList.length);
  116 + this.activeTab = 0;
  117 + this.levelContent.splice(1, this.levelContent.length-1);
  118 + },
  119 +
  120 + fetchAllSortList(){
  121 + this.$http.post("/product/class/queryAllProductSortList").then(function (response) {
  122 + var rs = response.data;
  123 + this.levelContent.$set(0,rs.data);
  124 + }, function (response) {
  125 + var rs = response.data;
  126 + console.log(rs.message);
  127 + });
  128 + },
  129 +
  130 + fetchSubSortList(sortId){
  131 + this.$http.post("/product/class/queryProductSortList",{
  132 + param:sortId
  133 + }).then(function (response) {
  134 + var rs = response.data;
  135 + if(rs.data.length>0){
  136 + this.levelContent.$set(this.activeTab,rs.data);
  137 + }else{
  138 + this.closeDropdown();
  139 + }
  140 + }, function (response) {
  141 + var rs = response.data;
  142 + console.log(rs.message);
  143 + });
23 } 144 }
24 } 145 }
25 } 146 }
@@ -78,15 +78,15 @@ if(process.env.NODE_ENV!=='development'){ @@ -78,15 +78,15 @@ if(process.env.NODE_ENV!=='development'){
78 apiCofig.log.src="/Data/logsnode/yohobuy-portal-log/" 78 apiCofig.log.src="/Data/logsnode/yohobuy-portal-log/"
79 } 79 }
80 /*环境配置*/ 80 /*环境配置*/
81 -// if(process.env.NODE_ENV==="test"){ 81 +if(process.env.NODE_ENV==="test"){
82 82
83 -// apiCofig.MVC={  
84 -// Interfacer:path.join(__dirname,"interfaces/0.js").replace(/0/g,'*'),  
85 -// Controller:path.join(__dirname,"controllers/0.js").replace(/0/g,'*'),  
86 -// filters: path.join(__dirname, "filters.js"),  
87 -// views: path.resolve(__dirname,"views", "0", "1")  
88 -// }  
89 -// apiCofig.EnvConst.domain="http://10.66.100.6:8088/platform";  
90 -// apiCofig.EnvConst.bigdata="http://10.66.100.7:8091/bigdata";  
91 -// } 83 + apiCofig.MVC={
  84 + Interfacer:path.join(__dirname,"interfaces/0.js").replace(/0/g,'*'),
  85 + Controller:path.join(__dirname,"controllers/0.js").replace(/0/g,'*'),
  86 + filters: path.join(__dirname, "filters.js"),
  87 + views: path.resolve(__dirname,"views", "0", "1")
  88 + }
  89 + apiCofig.EnvConst.domain="http://10.66.100.6:8088/platform";
  90 + apiCofig.EnvConst.bigdata="http://10.66.100.7:8091/bigdata";
  91 +}
92 module.exports = require('./libs/App')(apiCofig); 92 module.exports = require('./libs/App')(apiCofig);
@@ -4,6 +4,8 @@ var md5 = require('md5'); @@ -4,6 +4,8 @@ var md5 = require('md5');
4 var Emitter=require('events'); 4 var Emitter=require('events');
5 /*重写控制器*/ 5 /*重写控制器*/
6 var _ = require('lodash'); 6 var _ = require('lodash');
  7 +var fs=require('fs');
  8 +var config = JSON.parse(fs.readFileSync('./package.json').toString());
7 9
8 10
9 var toString= Object.prototype.toString; 11 var toString= Object.prototype.toString;
@@ -135,8 +137,16 @@ Controller.prototype.client=function(res,views,model,clientmodel){ @@ -135,8 +137,16 @@ Controller.prototype.client=function(res,views,model,clientmodel){
135 model={}; 137 model={};
136 } 138 }
137 ViewModel="<script>var ViewModel="+JSON.stringify(model)+";</script>"; 139 ViewModel="<script>var ViewModel="+JSON.stringify(model)+";</script>";
138 - var script=['<script type="text/javascript" src="/static/'+clientmodel+'/libs.js"></script>',  
139 - '<script type="text/javascript" src="/static/'+clientmodel+'/'+ views+'.js"></script>']; 140 + var src="";
  141 +
  142 + if(process.env.NODE_ENV==="production"){
  143 + src="http://cdn.yoho.cn/yohobuy-shops-fe/"+config.version;
  144 + html.replace(/\/static\/index\.min\.css/g,function($1){
  145 + return src+$1;
  146 + })
  147 + }
  148 + var script=['<script type="text/javascript" src="'+src+'/static/'+clientmodel+'/libs.js"></script>',
  149 + '<script type="text/javascript" src="'+src+'/static/'+clientmodel+'/'+ views+'.js"></script>'];
140 res.send(html+ViewModel+script.join('')); 150 res.send(html+ViewModel+script.join(''));
141 } 151 }
142 } 152 }
@@ -42,7 +42,7 @@ var Iaccount = { @@ -42,7 +42,7 @@ var Iaccount = {
42 var apiCofig = { 42 var apiCofig = {
43 //root:__dirname, 43 //root:__dirname,
44 EnvConst:{ 44 EnvConst:{
45 - domain:"http://192.168.102.202:8088/platform", 45 + domain:"http://192.168.102.210:8088/platform",
46 //bigdata:"http://172.16.6.189:8080/bigdata",//李建 46 //bigdata:"http://172.16.6.189:8080/bigdata",//李建
47 bigdata:"http://192.168.102.210:8091/bigdata", 47 bigdata:"http://192.168.102.210:8091/bigdata",
48 //bigdata:"http://172.16.6.110:8080",//钟文 48 //bigdata:"http://172.16.6.110:8080",//钟文
@@ -78,15 +78,15 @@ if(process.env.NODE_ENV!=='development'){ @@ -78,15 +78,15 @@ if(process.env.NODE_ENV!=='development'){
78 apiCofig.log.src="/Data/logsnode/yohobuy-portal-log/" 78 apiCofig.log.src="/Data/logsnode/yohobuy-portal-log/"
79 } 79 }
80 /*环境配置*/ 80 /*环境配置*/
81 -// if(process.env.NODE_ENV==="test"){ 81 +if(process.env.NODE_ENV==="test"){
82 82
83 -// apiCofig.MVC={  
84 -// Interfacer:path.join(__dirname,"interfaces/0.js").replace(/0/g,'*'),  
85 -// Controller:path.join(__dirname,"controllers/0.js").replace(/0/g,'*'),  
86 -// filters: path.join(__dirname, "filters.js"),  
87 -// views: path.resolve(__dirname,"views", "0", "1")  
88 -// }  
89 -// apiCofig.EnvConst.domain="http://10.66.100.6:8088/platform";  
90 -// apiCofig.EnvConst.bigdata="http://10.66.100.7:8091/bigdata";  
91 -// } 83 + apiCofig.MVC={
  84 + Interfacer:path.join(__dirname,"interfaces/0.js").replace(/0/g,'*'),
  85 + Controller:path.join(__dirname,"controllers/0.js").replace(/0/g,'*'),
  86 + filters: path.join(__dirname, "filters.js"),
  87 + views: path.resolve(__dirname,"views", "0", "1")
  88 + }
  89 + apiCofig.EnvConst.domain="http://10.66.100.6:8088/platform";
  90 + apiCofig.EnvConst.bigdata="http://10.66.100.7:8091/bigdata";
  91 +}
92 module.exports = require('./libs/App')(apiCofig); 92 module.exports = require('./libs/App')(apiCofig);
@@ -37,8 +37,8 @@ module.exports={ @@ -37,8 +37,8 @@ module.exports={
37 namespace:"common", 37 namespace:"common",
38 apis:{ 38 apis:{
39 login:function(req,callback){ 39 login:function(req,callback){
40 - var user = req.body.user||'wxtest1';  
41 - var password = req.body.password||'yoho9646abcdef'; 40 + var user = req.body.user;
  41 + var password = req.body.password;
42 var userInfo = {},result={code:400,message:"登录失败"}; 42 var userInfo = {},result={code:400,message:"登录失败"};
43 //调用登陆 43 //调用登陆
44 console.log(Iaccount.login); 44 console.log(Iaccount.login);
@@ -4,6 +4,8 @@ var md5 = require('md5'); @@ -4,6 +4,8 @@ var md5 = require('md5');
4 var Emitter=require('events'); 4 var Emitter=require('events');
5 /*重写控制器*/ 5 /*重写控制器*/
6 var _ = require('lodash'); 6 var _ = require('lodash');
  7 +var fs=require('fs');
  8 +var config = JSON.parse(fs.readFileSync('./package.json').toString());
7 9
8 10
9 var toString= Object.prototype.toString; 11 var toString= Object.prototype.toString;
@@ -135,8 +137,16 @@ Controller.prototype.client=function(res,views,model,clientmodel){ @@ -135,8 +137,16 @@ Controller.prototype.client=function(res,views,model,clientmodel){
135 model={}; 137 model={};
136 } 138 }
137 ViewModel="<script>var ViewModel="+JSON.stringify(model)+";</script>"; 139 ViewModel="<script>var ViewModel="+JSON.stringify(model)+";</script>";
138 - var script=['<script type="text/javascript" src="/static/'+clientmodel+'/libs.js"></script>',  
139 - '<script type="text/javascript" src="/static/'+clientmodel+'/'+ views+'.js"></script>']; 140 + var src="";
  141 +
  142 + if(process.env.NODE_ENV==="production"){
  143 + src="http://cdn.yoho.cn/yohobuy-shops-fe/"+config.version;
  144 + html.replace(/\/static\/index\.min\.css/g,function($1){
  145 + return src+$1;
  146 + })
  147 + }
  148 + var script=['<script type="text/javascript" src="'+src+'/static/'+clientmodel+'/libs.js"></script>',
  149 + '<script type="text/javascript" src="'+src+'/static/'+clientmodel+'/'+ views+'.js"></script>'];
140 res.send(html+ViewModel+script.join('')); 150 res.send(html+ViewModel+script.join(''));
141 } 151 }
142 } 152 }