Commit bf5c95540fc730c579f6e8456c6c221c11d04572
1 parent
36262af8
日期的显示格式
Showing
1 changed file
with
16 additions
and
14 deletions
utils/util.js
... | ... | @@ -236,13 +236,13 @@ function check_mobile(phoneMobile){ |
236 | 236 | var ob={code:1}; |
237 | 237 | if (phoneMobile.length === 0) { |
238 | 238 | ob.title='输入的手机号为空'; |
239 | - ob.code=-1; | |
239 | + ob.code=-1; | |
240 | 240 | } else if (phoneMobile.length < 11) { |
241 | 241 | ob.title ='手机号长度有误!'; |
242 | - ob.code = -1; | |
242 | + ob.code = -1; | |
243 | 243 | } else if (!myreg.test(phoneMobile)) { |
244 | 244 | ob.title = '手机号格式有误!'; |
245 | - ob.code = -1; | |
245 | + ob.code = -1; | |
246 | 246 | } |
247 | 247 | return ob; |
248 | 248 | } |
... | ... | @@ -280,31 +280,31 @@ function draw_randon_rect(ctx,x,y,r,w,h){ |
280 | 280 | // ctx.setStrokeStyle('transparent') |
281 | 281 | // 左上角 |
282 | 282 | ctx.arc(x + r, y + r, r, Math.PI, Math.PI * 1.5) |
283 | - | |
283 | + | |
284 | 284 | // border-top |
285 | 285 | ctx.moveTo(x + r, y) |
286 | 286 | ctx.lineTo(x + w - r, y) |
287 | 287 | ctx.lineTo(x + w, y + r) |
288 | 288 | // 右上角 |
289 | 289 | ctx.arc(x + w - r, y + r, r, Math.PI * 1.5, Math.PI * 2) |
290 | - | |
290 | + | |
291 | 291 | // border-right |
292 | 292 | ctx.lineTo(x + w, y + h - r) |
293 | 293 | ctx.lineTo(x + w - r, y + h) |
294 | 294 | // 右下角 |
295 | 295 | ctx.arc(x + w - r, y + h - r, r, 0, Math.PI * 0.5) |
296 | - | |
296 | + | |
297 | 297 | // border-bottom |
298 | 298 | ctx.lineTo(x + r, y + h) |
299 | 299 | ctx.lineTo(x, y + h - r) |
300 | 300 | // 左下角 |
301 | 301 | ctx.arc(x + r, y + h - r, r, Math.PI * 0.5, Math.PI) |
302 | - | |
302 | + | |
303 | 303 | // border-left |
304 | 304 | ctx.lineTo(x, y + r) |
305 | - ctx.lineTo(x + r, y) | |
305 | + ctx.lineTo(x + r, y) | |
306 | 306 | // 这里是使用 fill 还是 stroke都可以,二选一即可,但是需要与上面对应 |
307 | - ctx.fill(); | |
307 | + ctx.fill(); | |
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
... | ... | @@ -324,7 +324,7 @@ function get_box_arr(num,x,y,sp,r){ |
324 | 324 | |
325 | 325 | /** |
326 | 326 | * @param {Object} ctx 画图句柄 |
327 | - * @param {Object} x x坐标 | |
327 | + * @param {Object} x x坐标 | |
328 | 328 | * @param {Object} y y坐标 |
329 | 329 | * @param {Object} img 画的图片 |
330 | 330 | * @param {Object} color 边框的颜色 |
... | ... | @@ -345,7 +345,7 @@ function draw_circle(ctx,x,y,r,img,color,unit){ |
345 | 345 | |
346 | 346 | |
347 | 347 | function null_promise(){ |
348 | - var promise=new Promise(function(resolve, reject){ var ob={code:-1,data:null}; resolve(ob); }); return promise; | |
348 | + var promise=new Promise(function(resolve, reject){ var ob={code:-1,data:null}; resolve(ob); }); return promise; | |
349 | 349 | } |
350 | 350 | |
351 | 351 | module.exports = { |
... | ... | @@ -371,9 +371,11 @@ module.exports = { |
371 | 371 | for (var o in n) new RegExp("(" + o + ")").test(r) && (r = r.replace(RegExp.$1, 1 == RegExp.$1.length ? n[o] : ("00" + n[o]).substr(("" + n[o]).length))); |
372 | 372 | return r; |
373 | 373 | }, |
374 | - formar_no_full(e){ | |
374 | + formar_no_full(e,char){ | |
375 | 375 | var t= new Date(1e3 * e); |
376 | - return t.getFullYear() +"-"+(t.getMonth() + 1)+"-"+t.getDate(); | |
376 | + var c="-"; | |
377 | + if(char) c=char; | |
378 | + return t.getFullYear() +c+(t.getMonth() + 1)+c+t.getDate(); | |
377 | 379 | }, |
378 | 380 | |
379 | 381 | json2Form: function(e) { |
... | ... | @@ -442,7 +444,7 @@ module.exports = { |
442 | 444 | sub_last: sub_last,//去掉末尾一个字符 |
443 | 445 | measureText: measureText,//画布需要的函数 |
444 | 446 | check_mobile: check_mobile,//验证手机 |
445 | - get_rand_item:get_rand_item, //随机获取元素 | |
447 | + get_rand_item:get_rand_item, //随机获取元素 | |
446 | 448 | getDistance:getDistance, //获取俩个经纬网度之间的距离 |
447 | 449 | draw_randon_rect:draw_randon_rect ,//画图画圆角矩形 |
448 | 450 | null_promise:null_promise,//返回空的promise | ... | ... |