ylbtech-杂项-TMod:常见错误 |
1.返回顶部 |
1、
1.1、
{Template Error} TypeError: dateDiff is not a function at Array.<anonymous> (http://localhost:8023/y/js/template.js:1616:15)
1.2、
2、
2.1、
2.返回顶部 |
3.返回顶部 |
4.返回顶部 |
5.返回顶部 |
6.返回顶部 |
7.返回顶部 |
8.返回顶部 |
9.返回顶部 |
10.返回顶部 |
11.返回顶部 |
1、helpers/help.js
var formatDate = function (date, fmt) { if (!date) return ""; if (!(date instanceof Date)) { try { date = new Date(date); } catch (ex) { return date; } finally { } } var o = { "M+": date.getMonth() + 1, //月份 "d+": date.getDate(), //日 "h+": date.getHours() % 12 === 0 ? 12 : date.getHours() % 12, //小时 "H+": date.getHours(), //小时 "m+": date.getMinutes(), //分 "s+": date.getSeconds(), //秒 "q+": Math.floor((date.getMonth() + 3) / 3), //季度 "S": date.getMilliseconds() //毫秒 }; var week = { "0": "/u65e5", "1": "/u4e00", "2": "/u4e8c", "3": "/u4e09", "4": "/u56db", "5": "/u4e94", "6": "/u516d" }; if (!fmt) { fmt = "yyyy-MM-dd HH:mm:ss"; } if (/(y+)/.test(fmt)) { fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length)); } if (/(E+)/.test(fmt)) { fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "/u661f/u671f" : "/u5468") : "") + week[date.getDay() + ""]); } for (var k in o) { if (o.hasOwnProperty(k)) { if (new RegExp("(" + k + ")").test(fmt)) { fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); } } } return fmt; }; var utcToLocal = function (ticks, format) { if (!ticks) { return ""; } var t = new Date(ticks); var utc = new Date(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate(), t.getUTCHours(), t.getUTCMinutes(), t.getUTCSeconds()); if (!format) { format = "yyyy-MM-dd HH:mm:ss"; } try { return formatDate(utc, format); } catch (e) { return "Invalid Date"; } }; template.helper("dateFormat", utcToLocal); var dateDiff = function (timestamp) { var minute = 1000 * 60; var hour = minute * 60; var day = hour * 24; var now = new Date().getTime(); var diffValue = now - timestamp; // 如果本地时间反而小于变量时间 if (diffValue < 0) { //return '不久前'; return '刚刚'; } // 计算差异时间的量级 var dayC = diffValue / day; var hourC = diffValue / hour; var minC = diffValue / minute; //一分钟之内显示为刚刚,例如:刚刚,1分钟前、2分钟前...... 、一小时前、两小时前、一天前等;超过3天以上的显示为发布日期,如11月19日、11月18日; // 使用 if (dayC >= 1 && dayC <= 3) { return parseInt(dayC) + "天前"; } else if (hourC >= 1 && hourC < 24) { return parseInt(hourC) + "小时前"; } else if (minC >= 1 && minC < 60) { return parseInt(minC) + "分钟前"; } else if (minC < 1) { return '刚刚'; } else { return utcToLocal(timestamp, "MM-dd"); } }; template.helper("dateDiff", dateDiff); template.helper("getAllMoney", function (money) { return (money + money * 0.002).toFixed(2); }); template.helper("getChangeMoney", function (money) { return (money * 0.002).toFixed(2); }); template.helper("fmtImgPath", function (faceUrl) { if (!faceUrl) return "/img/none.gif"; return faceUrl;//.replace("/bgimg/", "/x_bgimg/"); }); template.helper("fmtCustomerIdentity", function (Identity) { switch (Identity) { default: case 0: { return "先生"; } case 1: { return "太太"; } case 2: { return "爷爷"; } case 3: { return "奶奶"; } case 4: { return "给父母请(不同住)"; } case 5: { return "帮朋友请"; } } }); template.helper("fmtMarriage", function (Marriage) { switch (Marriage) { default: case 1: { return "已婚"; } case 2: { return "未婚"; } case 3: { return "离异"; } } }); template.helper("fmtEducation", function (Education) { switch (Education) { default: case 1: { return "小学"; } case 2: { return "初中"; } case 3: { return "高中"; } case 4: { return "高中以上"; } } }); template.helper("fmtPolitical", function (Political) { switch (Political) { default: return "群众"; case 1: { return "团员"; } case 2: { return "党员"; } case 3: { return "入党积极分子"; } } }); template.helper('getSkill', function (num) { switch (num) { case 1: return '一般'; case 2: return '精细'; case 3: return '完美'; } }); template.helper('getSFH', function (num) { if (!num) return ""; var result = []; if (num.CleanRoom) result.push('打扫房间'); if (num.Cook) result.push('餐食制作'); if (num.Laundry) result.push('洗涤熨烫'); if (num.Plant) result.push('植卉养护'); if (num.OldPeople) result.push('照护老人'); if (num.Child) result.push('照护小孩'); if (num.Patient) result.push('照护病人'); if (num.Pet) result.push('照顾宠物'); return result.join('、'); }); template.helper('getJYW', function (num) { if (!num) return ""; if (num.Experience == 0) { return "新手"; } else if (num.Experience == 1) { return "熟练(2年- 5年)"; } else if (num.Experience == 2) { return "资深(5年以上)"; } }); template.helper('getJGS', function (num) { if (!num) return ""; if (num.NativePlace == 0) { return "周边人"; } else if (num.NativePlace == 1) { return "南方人"; } else if (num.NativePlace == 2) { return "北方人"; } else if (num.NativePlace == 3) { return "东北人"; } else if (num.NativePlace == 4) { return "西北人"; } else if (num.NativePlace == 5) { return "西南人"; } else if (num.NativePlace == 6) { return "沿海人"; } }); template.helper('getSFP', function (num) { if (!num) return ""; var result = []; if (num.Cat) result.push('猫'); if (num.Puppy) result.push('小狗'); if (num.SmallDogs) result.push('小型犬'); if (num.GoldFish) result.push('金鱼'); if (num.Bird) result.push('鸟'); return result.join('、'); }); template.helper('getJYF', function (num) { if (!num) return ""; var result = []; if (num.Oversee) result.push('监控'); if (num.InFected) result.push('传染病人'); if (num.Basement) result.push('住地下室'); return result.join('、'); }); template.helper('getYYH', function (num) { if (!num) return ""; var result = []; if (num.English) result.push('简单英语口语'); return result.join('、'); }); template.helper('getTCY', function (num) { if (!num) return ""; var result = []; if (num.Delicious) result.push('做饭好吃'); if (num.Pasta) result.push('擅长面食'); if (num.WesternFood) result.push('西餐制作'); if (num.GoodLaundry) result.push('洗涤熨烫'); if (num.Neat) result.push('干净利落'); if (num.Positive) result.push('阳光心态'); if (num.LikeChild) result.push('喜欢小孩'); if (num.Filial) result.push('恭顺老人'); if (num.Temper) result.push('好脾气'); if (num.LikeAnimal) result.push('喜欢小动物'); return result.join('、'); }); template.helper('getXYW', function (num) { if (!num) return ""; var result = []; if (num.Buddhism) result.push('信仰佛'); if (num.Catholicism) result.push('信仰天主'); if (num.Christianity) result.push('信仰基督'); if (num.Ala) result.push('信仰阿拉'); if (num.GoodRepay) result.push('信仰好人好报'); return result.join('、'); }); template.helper('getCYBZ', function (num) { if (!num) return ""; var result = []; if (num.Chinese) result.push('普通话标准'); if (num.Face) result.push('五官端正无残疾'); if (num.Smell) result.push('无狐臭口臭'); if (num.Mental) result.push('无精神病倾向'); return result.join('、'); }); template.helper('getSFBZ', function (num) { if (!num) return ""; var result = []; if (num.IDCard) result.push('身份证(包括:姓名、年龄、籍贯、身份证号码)'); if (num.Communicate) result.push('沟通(包括:文化程度、婚姻状况、政治面貌)'); return result.join('、'); }); template.helper('getJKBZ', function (num) { if (!num) return ""; var result = []; if (num.PhysicalExam) result.push('体检证明(包括:无传染性疾病、体检日期、体检项目)'); return result.join('、'); }); template.helper('getPXBZ', function (num) { if (!num) return ""; var result = []; if (num.Certificate) result.push('荣誉与证书(包括:获得时间、鉴定单位、有无钢印)'); return result.join('、'); }); template.helper('getFKBZ', function (num) { if (!num) return ""; var result = []; if (num.Insurance) result.push('职业责任险(包括:有效日期)'); return result.join('、'); }); template.helper('getClean', function (num) { var result = []; if (num.Clean) result.push('打扫房间'); if (num.Mark) result.push('餐食制作'); if (num.Wash) result.push('洗涤熨烫'); if (num.CuringPlant) result.push('植卉养护'); if (num.CaringOld) result.push('照护老人'); if (num.CaringSmall) result.push('照护小孩'); if (num.CaringDisease) result.push('照护病人'); if (num.CaringPet) result.push('恭顺老人'); if (num.LikePet) result.push('照护宠物'); if (num.ServicesOther) result.push(num.ServicesOther); if (num.ServicesOthers) result.push(num.ServicesOthers); return result.join('、'); }); template.helper('getCat', function (num) { var result = []; if (num.Cat) result.push('猫'); if (num.Pup) result.push('小狗'); if (num.LargeDog) result.push('大型犬'); if (num.GoldFish) result.push('金鱼'); if (num.Bird) result.push('鸟'); if (num.OtherPet) result.push(num.OtherPet); if (num.OtherPets) result.push(num.OtherPets); return result.join('、'); }); template.helper('getCookingGood', function (num) { var result = []; if (num.CookingGood) result.push('做饭好吃'); if (num.GoodPasta) result.push('擅长面食'); if (num.WesternFoodMark) result.push('西餐制作'); if (num.Ironing) result.push('洗涤熨烫'); if (num.Smooth) result.push('干净利落'); if (num.SunshineMentality) result.push('阳光心态'); if (num.Likekid) result.push('喜欢小孩'); if (num.PoorOld) result.push('恭顺老人'); if (num.LikePet) result.push('喜欢小动物'); return result.join('、'); }); template.helper('getSimpleEnglish', function (num) { var result = []; if (num.SimpleEnglish) result.push('会简单英语口语'); if (num.HandWash) result.push('手洗特殊内衣'); if (num.Wipe) result.push('手持抹布擦地'); if (num.OtherSpecial) result.push(num.OtherSpecial); return result.join('、'); }); template.helper('getMonitor', function (num) { var result = []; if (num.Monitor) result.push('监控'); if (num.InfectiousPatients) result.push('传染病人'); if (num.MentalDisease) result.push('精神不太正常家属'); if (num.Basement) result.push('住地下室'); if (num.Roommate) result.push('陪同性雇主同室住'); if (num.WithSleep) result.push('幼儿带睡'); return result.join('、'); }); template.helper('getHealthConditioning', function (num) { var result = []; if (num.HealthConditioning) result.push('健康调理'); if (num.TeaCeremony) result.push('茶艺'); if (num.Flowering) result.push('插花'); if (num.PanHead) result.push('盘头'); if (num.Cosmetology) result.push('美容'); if (num.OtherNeed) result.push(num.OtherNeed); if (num.OtherNeeds) result.push(num.OtherNeeds); return result.join('、'); }); template.helper('getWorkHours', function (num) { switch (num) { case 0: return ''; case 1: return '平均每天有效工作'; } }); template.helper('getDifferentPlaces', function (num) { switch (num) { case 0: return ''; case 1: return '工作地点在两个不同的地方'; } }); template.helper('getMembers', function (num) { switch (num) { case 1: return '三口之家'; case 2: return '婆媳同住'; case 3: return '三代同堂'; case 4: return '单身'; case 5: return '丁克家族'; } }); template.helper('getFooding', function (num) { switch (num) { case 1: return '普通'; case 2: return '偏肉'; case 3: return '偏素'; case 4: return '全素'; } }); template.helper('getFlavor', function (num) { switch (num) { case 1: return '偏重'; case 2: return '偏甜'; case 3: return '清淡'; case 4: return '喜辣'; case 5: return '不吃辣椒'; } }); template.helper('getHabit', function (num) { switch (num) { case 1: return '早睡早起'; case 2: return '夜猫子'; case 3: return '不坐班'; } }); template.helper('getEducation', function (s) { switch (s) { case 0: return '专科'; case 1: return '本科'; case 2: return '硕士'; case 3: return '博士'; } }); template.helper('getExperience', function (num) { switch (num) { case 0: return '一年以下'; case 1: return '一年到三年'; case 2: return '三年到五年'; case 3: return '五年以上'; } }); template.helper("parseimg", function (s) { if (!s) return ""; return s.replace(/\< *[img][^\>]*[src] *= *[\"\']{0,1}([^\"\'\ >]*)/ig, function (cap1, cap2) { var tag1 = cap1.replace(/\/bgimg\//ig, '/x_bgimg/').replace(/src=/ig, 'src='); var tag2 = cap2.replace(/\/bgimg\//ig, '/bgimg/'); return '' + tag1 + '" data-preview-src="' + tag2 }); });
2、
12.返回顶部 |
13.返回顶部 |
1、/GruntFile.js
module.exports = function (grunt) { grunt.initConfig({ useminPrepare: { html: ['**/*.html', '!js/**/*.html', '!dist/**/*.html', '!node_modules/**/*.html', '!unpackage/**/*.html', '!g/tmp/**/*.html', '!m/js/tmp/**/*.html', '!s/tmp/**/*.html', '!y/js/tpl/**/*.html'], options: { dest: 'dist' } }, usemin: { html: ['dist/**/*.html'], options: { assetsDirs: ['dist'], blockReplacements: { MaxPrestaJSBuild: function (block) { return '<script src="/js/vendor.min.js"></script>'; } } } }, copy: { dist: { files: [ { expand: true, cwd: 'fonts', src: '**', dest: 'dist/fonts/' }, { expand: true, cwd: 'bin', src: '*.dll', dest: 'dist/bin/' }, { expand: true, cwd: 'img', src: '**', dest: 'dist/img/' }, { expand: true, cwd: 'js/ueditor', src: '**', dest: 'dist/js/ueditor/' }, { expand: true, src: ['**/*.html', '!js/**/*.html', '!dist/**/*.html', '!node_modules/**/*.html', '!unpackage/**/*.html', '!g/tmp/**/*.html', '!m/js/tmp/**/*.html', '!s/tmp/**/*.html', '!y/js/tpl/**/*.html'], dest: 'dist/' }, { src: 'Global.asax', dest: 'dist/Global.asax' }, { src: 'NLog.config', dest: 'dist/NLog.config' }, { src: 'css/mlibs.appvendor.min.css', dest: 'dist/css/mlibs.appvendor.min.css' }, { src: 'js/mlibs.appvendor.min.js', dest: 'dist/js/mlibs.appvendor.min.js' }, { src: 'js/video/video-js.css', dest: 'dist/js/video/video-js.css' }, { src: 'js/video/video.6.0.js', dest: 'dist/js/video/video.6.0.js' }, { src: 'js/jquery.cxselect.min.js', dest: 'dist/js/jquery.cxselect.min.js' }, { src: 'js/cityData.min.json', dest: 'dist/js/cityData.min.json' }, { expand: true, cwd: 'js/my97datepicker', src: '**', dest: 'dist/g' }, { src:['*.aspx','*.aspx.cs','*.ashx'],dest:'dist/'} ] }, js: { files: [] } }, htmlmin: { dist: { options: { removeComments: true, collapseWhitespace: true }, files: [ { expand: true, cwd: 'dist/', src: ['**/*.html', '!g/tmp/**/*.html', '!m/js/tmp/**/*.html', '!s/tmp/**/*.html', '!y/js/tpl/**/*.html'], dest: 'dist/' } ] } }, filerev: { options: { encoding: 'utf8', algorithm: 'md5', length: 8 }, js: { src: ['dist/js/**/m.*.min.js'], dest: 'dist/js' }, css: { src: ['dist/css/**/m.*.min.css'], dest: 'dist/css' } }, compress: { main: { options: { archive: function () { return 'dist/jfb-' + (new Date()).getTime() + '.tgz' }, pretty: true, mode: 'tgz' }, expand: true, cwd: 'dist/', src: ['**/*'], dest: '/' } }, exec: { genGTmpl: { cmd: 'tmod g/tmp --no-watch' }, genMTmpl: { cmd: 'tmod m/js/tmp --no-watch' }, genSTmpl: { cmd: 'tmod s/tmp --no-watch' }, genYTmpl: { cmd: 'tmod y/js/tpl --no-watch' } }, clean: { dist: { src: ['dist/'] }, tmp: { src: ['.tmp/'] }, build: { src: [ 'dist/m/js/**/m.*.min.js', 'dist/m/css/**/m.*.min.css', ] } } }); grunt.loadNpmTasks('grunt-usemin'); grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-htmlmin'); grunt.loadNpmTasks('grunt-contrib-compress'); grunt.loadNpmTasks('grunt-assemble'); grunt.loadNpmTasks('grunt-filerev'); grunt.loadNpmTasks('grunt-exec'); grunt.registerTask('build', [ 'clean:dist', 'exec:genGTmpl', 'exec:genMTmpl', 'exec:genSTmpl', 'exec:genYTmpl', 'copy', 'useminPrepare', 'concat:generated', 'cssmin:generated', 'uglify:generated', 'filerev', 'usemin', 'htmlmin', 'clean:tmp', 'copy:js', 'clean:build', 'compress:main' ]); };
2、
14.返回顶部 |
15.返回顶部 |
16.返回顶部 |
作者:ylbtech 出处:http://ylbtech.cnblogs.com/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。 |