Merge branch 'release/1.6' of git.dev.yoho.cn:platform/yohobuy-portal-fe into release/1.6
Showing
8 changed files
with
141 additions
and
83 deletions
@@ -143,7 +143,7 @@ e.init(); | @@ -143,7 +143,7 @@ e.init(); | ||
143 | if(RESPONSEDATA.isAuditing!=200){ | 143 | if(RESPONSEDATA.isAuditing!=200){ |
144 | 144 | ||
145 | new common.dropDown({el:"#brandId",ajax:"brand",params:function(){ | 145 | new common.dropDown({el:"#brandId",ajax:"brand",params:function(){ |
146 | - status:1 | 146 | + return {status:1} |
147 | }}); | 147 | }}); |
148 | 148 | ||
149 | new common.dropDown({el:"#shopId",ajax:"sortbybrand",params:function(){ | 149 | new common.dropDown({el:"#shopId",ajax:"sortbybrand",params:function(){ |
@@ -416,7 +416,7 @@ e.on("validate",function(){ | @@ -416,7 +416,7 @@ e.on("validate",function(){ | ||
416 | return "同一颜色包含两组相同尺码"; | 416 | return "同一颜色包含两组相同尺码"; |
417 | } | 417 | } |
418 | if(_count1>0&&common.util.__input("supplierId")){ | 418 | if(_count1>0&&common.util.__input("supplierId")){ |
419 | - return "JIT商品条码不能重复"; | 419 | + return "GIT商品条码不能重复"; |
420 | } | 420 | } |
421 | }); | 421 | }); |
422 | e.on("validate",function(){ | 422 | e.on("validate",function(){ |
@@ -431,7 +431,7 @@ $(document).on("click","#btnReview",function(){ | @@ -431,7 +431,7 @@ $(document).on("click","#btnReview",function(){ | ||
431 | 431 | ||
432 | 432 | ||
433 | if(e.validate()){ | 433 | if(e.validate()){ |
434 | - common.dialog.confirm("温馨提示","<p>若是JIT商品,请务必选择供应商!</p><p>你确定提交吗?</p>",function(){ | 434 | + common.dialog.confirm("温馨提示","<p>若是GIT商品,请务必选择供应商!</p><p>你确定提交吗?</p>",function(){ |
435 | e.submit($("#basicForm").attr("action"),function(option){ | 435 | e.submit($("#basicForm").attr("action"),function(option){ |
436 | var select=tabTree.getAddress(); | 436 | var select=tabTree.getAddress(); |
437 | 437 |
@@ -53,13 +53,13 @@ dropDown.prototype = { | @@ -53,13 +53,13 @@ dropDown.prototype = { | ||
53 | type: 'POST', | 53 | type: 'POST', |
54 | delay: 250, | 54 | delay: 250, |
55 | data: function(params) { | 55 | data: function(params) { |
56 | + | ||
56 | var param={}; | 57 | var param={}; |
57 | if(Object.prototype.toString.call(option.params)=="[object Function]"){ | 58 | if(Object.prototype.toString.call(option.params)=="[object Function]"){ |
58 | param=option.params(); | 59 | param=option.params(); |
59 | }else{ | 60 | }else{ |
60 | param=option.params; | 61 | param=option.params; |
61 | } | 62 | } |
62 | - | ||
63 | var data = $.extend({}, { | 63 | var data = $.extend({}, { |
64 | idName: params.term | 64 | idName: params.term |
65 | }, param || {}); | 65 | }, param || {}); |
@@ -95,8 +95,6 @@ var util = { | @@ -95,8 +95,6 @@ var util = { | ||
95 | return result; | 95 | return result; |
96 | }, | 96 | }, |
97 | __template2: function(str, source) { | 97 | __template2: function(str, source) { |
98 | - // console.log(str); | ||
99 | - var result = ""; | ||
100 | var script = []; | 98 | var script = []; |
101 | script.push('var each=function(obj,fn){'); | 99 | script.push('var each=function(obj,fn){'); |
102 | script.push(' var that=this;'); | 100 | script.push(' var that=this;'); |
@@ -112,66 +110,81 @@ var util = { | @@ -112,66 +110,81 @@ var util = { | ||
112 | script.push(' }'); | 110 | script.push(' }'); |
113 | script.push(' return;'); | 111 | script.push(' return;'); |
114 | script.push(' }'); | 112 | script.push(' }'); |
115 | - script.push('}'); | ||
116 | - result = script.join('') + ";\n"; | 113 | + script.push('};'); |
117 | 114 | ||
118 | var formstr = function(code) { | 115 | var formstr = function(code) { |
119 | - return "'" + code | ||
120 | - .replace(/('|\\)/g, '\\$1') | ||
121 | - .replace(/\r/g, '\\r') | ||
122 | - .replace(/\n/g, '\\n') + "'"; | ||
123 | - } | ||
124 | - //获取参数 | ||
125 | - | ||
126 | - var params = []; | ||
127 | - | ||
128 | - | ||
129 | - var html = ""; | ||
130 | - html = str.replace(/\[\[(.*?)\]\]/igm, function(name, $1) { | ||
131 | - var trim = $1.replace(/^\s+|\s+$/, ''); | 116 | + return "'" + code |
117 | + .replace(/('|\\)/g, '\\$1') | ||
118 | + .replace(/\r/g, '\\r') | ||
119 | + .replace(/\n/g, '\\n') + "'"; | ||
120 | + } | ||
121 | + var formJs=function(code){ | ||
122 | + var trim = code.replace(/^\s+|\s+$/, ''); | ||
123 | + //each goodsSizeList as item __index | ||
132 | if (/^each/.test(trim)) { | 124 | if (/^each/.test(trim)) { |
133 | - trim = trim.replace(/^each\s+([a-zA-Z0-1.]+)\s+as\s+(\w+)\s+(\w+)/, function($0, $1, $2, $3) { | ||
134 | - params.push($1); | 125 | + return trim.replace(/^each\b([\w\W]+)\bas\b([\w\W]+)\b([\w\W]+)/, function($0, $1, $2, $3) { |
135 | return 'each\( ' + $1 + ',function(' + $3 + ',' + $2 + '){'; | 126 | return 'each\( ' + $1 + ',function(' + $3 + ',' + $2 + '){'; |
136 | }); | 127 | }); |
137 | - return "[[" + trim + "]]"; | ||
138 | - } else | ||
139 | - if (/^\/each/.test(trim)) { | ||
140 | - trim = trim.replace(/^\/each/, '});') | ||
141 | - return "[[" + trim + "]]"; | 128 | + }else if (/^\/each/.test(trim)) { |
129 | + return trim.replace(/^\/each/, '});') | ||
142 | } else if (/^if/.test(trim)) { | 130 | } else if (/^if/.test(trim)) { |
143 | - trim = trim.replace(/^if(.+)/, function($0, $1) { | ||
144 | - params.push($1); | 131 | + return trim.replace(/^if(.+)/, function($0, $1) { |
145 | return 'if(' + $1 + '){'; | 132 | return 'if(' + $1 + '){'; |
146 | }); | 133 | }); |
147 | - return "[[" + trim + "]]"; | ||
148 | } else if (/^\/if/.test(trim)) { | 134 | } else if (/^\/if/.test(trim)) { |
149 | - trim = trim.replace(/^\/if/, '};') | ||
150 | - return "[[" + trim + "]]"; | 135 | + return trim.replace(/^\/if/, '};') |
151 | } else if (/^else$/.test(trim)) { | 136 | } else if (/^else$/.test(trim)) { |
152 | - trim = trim.replace(/else/, '}else{'); | ||
153 | - return "[[" + trim + "]]"; | ||
154 | - } else { | ||
155 | - params.push(trim); | ||
156 | - return "[[+(" + trim + ")+]]"; | 137 | + return trim.replace(/else/, '}else{'); |
138 | + } else{ | ||
139 | + return code; | ||
157 | } | 140 | } |
158 | - }); | ||
159 | - // console.log(params); | ||
160 | - //.match(/(\w+)+/g) | ||
161 | - for (var i in params) { | ||
162 | - var aps = params[i].split(/\+|\-|\*|\/|\=|\!|\~|'|"|\||&/g); | ||
163 | - for (var j in aps) { | ||
164 | - var ap = aps[j].replace(/^\s+|\s+$/, ''); | ||
165 | - // console.log(":" + ap + ":"); | ||
166 | - if (!/^[0-9]+$/.test(ap) && !/^\s*$/.test(ap) && !/\./g.test(ap)) { | ||
167 | - if (!source.hasOwnProperty(ap)) { | ||
168 | - source[ap] = ""; | ||
169 | - // console.log(":" + ap + ":"); | ||
170 | - } | 141 | + } |
142 | + // var PARAMS={}; | ||
143 | + var OBJECT=/\.\w+|'.*'|".*"/g; | ||
144 | + var KEYWORDS='for,if,else,each,as'; | ||
145 | + var SPECHAR=/\W/g; | ||
146 | + var NUMBER=/^\d[^,]*|,\d[^,]*/g; | ||
147 | + var SPLIT2_RE = /^$|,+/; | ||
148 | + var REGEXKEYWORDS=new RegExp("\\b"+[KEYWORDS.replace(/,/g,'\\b|\\b')].join('|'),'g'); | ||
149 | + var getVar=function(code){ | ||
150 | + var strArr= code.replace(OBJECT,'') | ||
151 | + .replace(SPECHAR,',') | ||
152 | + .replace(REGEXKEYWORDS,'') | ||
153 | + .replace(NUMBER,'') | ||
154 | + .split(SPLIT2_RE); | ||
155 | + for(var key in strArr){ | ||
156 | + if(strArr[key]&&!source.hasOwnProperty(strArr[key])){ | ||
157 | + source[strArr[key]]=""; | ||
171 | } | 158 | } |
172 | } | 159 | } |
173 | } | 160 | } |
174 | 161 | ||
162 | + var code=[],params={}; | ||
163 | + var arr=str.split(/\[\[|\]\]/).map(function(item,index){ | ||
164 | + if(index%2){ | ||
165 | + return{ | ||
166 | + value:item, | ||
167 | + regex:true | ||
168 | + }; | ||
169 | + }else{ | ||
170 | + return{ | ||
171 | + value:item, | ||
172 | + regex:false | ||
173 | + }; | ||
174 | + } | ||
175 | + }); | ||
176 | + | ||
177 | + arr.forEach(function(item,index){ | ||
178 | + if(item.regex){ | ||
179 | + getVar(item.value); | ||
180 | + code.push(formJs(item.value)); | ||
181 | + }else{ | ||
182 | + code.push("result.push("+formstr(item.value)+");"); | ||
183 | + } | ||
184 | + }); | ||
185 | + // var header="var result=[],"; | ||
186 | + // header+=Object.keys(source).join(',')+";" | ||
187 | + | ||
175 | var keys = []; | 188 | var keys = []; |
176 | for (var key in source) { | 189 | for (var key in source) { |
177 | if (typeof source[key] == "boolean") { | 190 | if (typeof source[key] == "boolean") { |
@@ -180,27 +193,15 @@ var util = { | @@ -180,27 +193,15 @@ var util = { | ||
180 | keys.push(key + "=" + JSON.stringify(source[key])); | 193 | keys.push(key + "=" + JSON.stringify(source[key])); |
181 | } | 194 | } |
182 | } | 195 | } |
183 | - var header = "var " + keys.join(',') + ";"; | 196 | + var header = "var result=[]," + keys.join(',') + ";"; |
184 | 197 | ||
185 | - html = html.replace(/(^|\]\])(.*?)(\[\[|$)/igm, function(name, $1, $2) { | ||
186 | - var trim = $2.replace(/^\s+|\s+$/, ''); | ||
187 | - return trim ? formstr($2) : ''; | ||
188 | - }); | ||
189 | - // var result="var result='';result+="; | ||
190 | - var arr = html.split(/\n+/igm); | ||
191 | - result += "var p=[];\n"; | ||
192 | - for (var i = 0; i < arr.length; i++) { | ||
193 | - if (/^'/.test(arr[i])) { | ||
194 | - result += "p.push(" + (arr[i]) + ");\n"; | ||
195 | - } else { | ||
196 | - result += (arr[i]); | ||
197 | - } | ||
198 | - } | ||
199 | - result += "return p.join('');\n"; | ||
200 | 198 | ||
201 | - var fn = new Function(header + result); | ||
202 | - var b = fn.call(source); | ||
203 | - return b; | 199 | + |
200 | + var result=header + code.join('\n')+"return result.join('');"; | ||
201 | + // console.log(result); | ||
202 | + | ||
203 | + var fn = new Function(script.join('')+result); | ||
204 | + return fn.call(null,source); | ||
204 | }, | 205 | }, |
205 | __input: function(id) { | 206 | __input: function(id) { |
206 | return !!~$.trim($('#' + id).val()) ? $('#' + id).val() : "" | 207 | return !!~$.trim($('#' + id).val()) ? $('#' + id).val() : "" |
client/js/goods/partials/search-key.js
0 → 100644
1 | +var $ = require('jquery'), | ||
2 | + common = require('../../common/common'); | ||
3 | + | ||
4 | +var searchKeys = window.NETSALEDATA.productExtBo.searchKeys || ""; | ||
5 | + | ||
6 | +$("#searchKeys").val(searchKeys); | ||
7 | +var g = new common.grid({ | ||
8 | + el: "#search-key", | ||
9 | + hash: false, | ||
10 | + columns: [{ | ||
11 | + display: "ID", | ||
12 | + name: "id" | ||
13 | + }, { | ||
14 | + display: "内容", | ||
15 | + name: "content" | ||
16 | + }, { | ||
17 | + display: "操作", | ||
18 | + name: "", | ||
19 | + render: function(item) { | ||
20 | + return '<a class="btn btn-info add" data-index="' + item.__index + '">添加</a>'; | ||
21 | + } | ||
22 | + }] | ||
23 | +}); | ||
24 | + | ||
25 | +g.init('/netSale/queryHotSearchTerms'); | ||
26 | + | ||
27 | +$("#searchKeys").on('change', function() { | ||
28 | + searchKeys = $("#searchKeys").val(); | ||
29 | +}); | ||
30 | + | ||
31 | +$(document).on('click', '.add', function() { | ||
32 | + var item = g.rows[$(this).data("index")]; | ||
33 | + var value = $("#searchKeys").val(); | ||
34 | + if (value) value += ","; | ||
35 | + $("#searchKeys").val(value + item.content); | ||
36 | + searchKeys = $("#searchKeys").val(); | ||
37 | +}); | ||
38 | + | ||
39 | +$("#save-searchKey").on('click', function() { | ||
40 | + common.util.__ajax({ | ||
41 | + url: '/netSale/saveNetSaleSearchKeys', | ||
42 | + data: { | ||
43 | + productSkn: window.NETSALEDATA.baseProductInfo.baseProduct.productSkn, | ||
44 | + searchKeys: searchKeys | ||
45 | + } | ||
46 | + }, function(res) { | ||
47 | + | ||
48 | + }); | ||
49 | +}); |
1 | var $ = require('jquery'), | 1 | var $ = require('jquery'), |
2 | - common = require('../common/common'); | 2 | + common = require('../common/common'), |
3 | + util = require('../common/util'); | ||
3 | 4 | ||
4 | new common.dropDown({el: "#help-categoryId", "ajax": "getHelpCategory"}); | 5 | new common.dropDown({el: "#help-categoryId", "ajax": "getHelpCategory"}); |
5 | new common.dropDown({el: "#help-platform"}); | 6 | new common.dropDown({el: "#help-platform"}); |
6 | 7 | ||
7 | var ENUM = { | 8 | var ENUM = { |
8 | - id:{} | 9 | + id:[] |
9 | }; | 10 | }; |
10 | 11 | ||
11 | var g = new common.grid({ | 12 | var g = new common.grid({ |
@@ -21,7 +22,7 @@ var $ = require('jquery'), | @@ -21,7 +22,7 @@ var $ = require('jquery'), | ||
21 | {display: "编号", name: "id"}, | 22 | {display: "编号", name: "id"}, |
22 | {display: "标题", name: "title"}, | 23 | {display: "标题", name: "title"}, |
23 | {display: "分类", name: "categoryId", render: function(item) { | 24 | {display: "分类", name: "categoryId", render: function(item) { |
24 | - return ENUM.id[item.id]; | 25 | + return ENUM.id[item.categoryId]; |
25 | }}, | 26 | }}, |
26 | {display: "平台", name: "platform", render: function(item) { | 27 | {display: "平台", name: "platform", render: function(item) { |
27 | if(item.platform != null && item.platform.trim() != "") { | 28 | if(item.platform != null && item.platform.trim() != "") { |
@@ -53,9 +54,10 @@ var $ = require('jquery'), | @@ -53,9 +54,10 @@ var $ = require('jquery'), | ||
53 | for(var i = 0; i < list.length; i++) { | 54 | for(var i = 0; i < list.length; i++) { |
54 | ENUM.id[list[i].id] = list[i].categoryName; | 55 | ENUM.id[list[i].id] = list[i].categoryName; |
55 | } | 56 | } |
56 | - }); | ||
57 | - | ||
58 | - g.init('/operations/helpcontent/getAllHelpContent'); | 57 | + g.init('/operations/helpcontent/getAllHelpContent'); |
58 | + },function() { | ||
59 | + g.init('/operations/helpcontent/getAllHelpContent'); | ||
60 | + },true); | ||
59 | 61 | ||
60 | var Bll = { | 62 | var Bll = { |
61 | toast:function(url, item, hint) { | 63 | toast:function(url, item, hint) { |
@@ -65,8 +67,12 @@ var $ = require('jquery'), | @@ -65,8 +67,12 @@ var $ = require('jquery'), | ||
65 | common.util.__template($("#template").html(), item), | 67 | common.util.__template($("#template").html(), item), |
66 | function() { | 68 | function() { |
67 | e.submit(url, function (option) { | 69 | e.submit(url, function (option) { |
68 | - option.data.categoryId = item.categoryId; | ||
69 | - option.success=function() { | 70 | + option.success=function(res) { |
71 | + if(res.data.code == 200) { | ||
72 | + util.__tip(res.data.message, "success"); | ||
73 | + } else { | ||
74 | + util.__tip(res.data.message); | ||
75 | + } | ||
70 | g.reload(); | 76 | g.reload(); |
71 | }; | 77 | }; |
72 | option.error=function(){}; | 78 | option.error=function(){}; |
@@ -77,7 +83,7 @@ var $ = require('jquery'), | @@ -77,7 +83,7 @@ var $ = require('jquery'), | ||
77 | new common.dropDown({el: "#categoryId", "ajax": "getByCategoryId"}); | 83 | new common.dropDown({el: "#categoryId", "ajax": "getByCategoryId"}); |
78 | 84 | ||
79 | if(hint == "修改内容") { | 85 | if(hint == "修改内容") { |
80 | - $("#select2-categoryId-container").html(ENUM.id[item.id]); | 86 | + $("#select2-categoryId-container").html(ENUM.id[item.categoryId]); |
81 | } | 87 | } |
82 | } | 88 | } |
83 | }; | 89 | }; |
@@ -16,7 +16,9 @@ var config = { | @@ -16,7 +16,9 @@ var config = { | ||
16 | // domain: 'http://172.16.6.240:8088/platform', | 16 | // domain: 'http://172.16.6.240:8088/platform', |
17 | // domain:'http://172.16.6.240:8088/platform',//王书生 | 17 | // domain:'http://172.16.6.240:8088/platform',//王书生 |
18 | // domain: 'http://172.16.6.252:9080',//陈超 | 18 | // domain: 'http://172.16.6.252:9080',//陈超 |
19 | - //domain: 'http://172.16.6.227:8088/platform', //玛丽 | 19 | + //domain:'http://172.16.6.227:8088/platform',//玛丽 |
20 | + // domain: 'http://192.168.102.202:8088/platform', | ||
21 | + // domain:'http://172.16.9.8:8080/yohobuy-platform-web',//葛超 | ||
20 | domain: 'http://192.168.102.202:8088/platform', | 22 | domain: 'http://192.168.102.202:8088/platform', |
21 | loggers: { | 23 | loggers: { |
22 | api: { | 24 | api: { |
@@ -59,7 +59,7 @@ | @@ -59,7 +59,7 @@ | ||
59 | </div> | 59 | </div> |
60 | </div> | 60 | </div> |
61 | <div class="form-group"> | 61 | <div class="form-group"> |
62 | - <label class="col-sm-2 control-label" for="helpContent">帮助内容</label> | 62 | + <label class="col-sm-2 control-label" for="content">帮助内容</label> |
63 | <div class="col-sm-10"> | 63 | <div class="col-sm-10"> |
64 | <input type="text" value="{content}" class="form-control" id="content" required="required" /> | 64 | <input type="text" value="{content}" class="form-control" id="content" required="required" /> |
65 | </div> | 65 | </div> |
@@ -68,7 +68,7 @@ | @@ -68,7 +68,7 @@ | ||
68 | <label class="col-sm-2 control-label" for="categoryId">分类</label> | 68 | <label class="col-sm-2 control-label" for="categoryId">分类</label> |
69 | <div class="col-sm-10"> | 69 | <div class="col-sm-10"> |
70 | <select id="categoryId" style="width: 280px;" value="{categoryId}"> | 70 | <select id="categoryId" style="width: 280px;" value="{categoryId}"> |
71 | - <option value="-1">请选择分类</option> | 71 | + <option value="{categoryId}">请选择分类</option> |
72 | </select> | 72 | </select> |
73 | </div> | 73 | </div> |
74 | </div> | 74 | </div> |
-
Please register or login to post a comment