1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- // 支持es4语法
- var filter = {
- numberToFixed: function(value) {
- return value.toFixed(2);
- },
- phoneFormat: function(value) {
- if( !value ) return "";
- if( value.length < 11){
- return '';
- }
- return value.substring(0, 4) +"****"+ value.substring(7,11)
- },
- cardIdFormat: function(value) {
- if( !value ) return "";
- if( value.length < 18){
- return '';
- }
- return value.substring(0, 4) +"****"+ value.substring(14,18)
- },
- trueFalseFormatter: function(question) {
- for (var i = 0; i < question.items.length; i++) {
- if (question.items[i].prefix === question.correct) {
- return question.items[i].content;
- }
- }
- return '';
- },
- indexOf: function(arg1, arg2) {
- return arg1.toString().indexOf(arg2.toString()) > -1 ? true : false;
- },
- numberToArray: function(number) {
- var array = [];
- for (var i = 0; i < number; i++) {
- array.push(i);
- }
- return array;
- },
- getMultResult:function( select ){
- var prevList = ["", "A","B","C", "D", "E","F"]
- var res = []
- select=''+select
- for( var i=0; i< select.length;i++){
- var index= +select[i]
- res.push( prevList[index])
- }
- return res.join(",")
- },
- isSelect: function( index, select ){
- console.log( "select", select )
- if( index == select) return true;
- select = ""+select
- return select.indexOf( index )>-1;
- },
- isExamSelect: function( index, info ){
- if( !info.answers ) return '';
- if( index >= info.answers.length ) return '';
- var select = ""
- if( index == info.index ) select += 'cur-select';
- if( info.answers[index].select>0 ) select += ' is-select';
- return select||'un-select'
- }
- }
- // 导出对外暴露的属性
- module.exports = {
- numberToFixed: filter.numberToFixed,
- trueFalseFormatter: filter.trueFalseFormatter,
- indexOf: filter.indexOf,
- isSelect: filter.isSelect,
- phoneFormat: filter.phoneFormat,
- getMultResult:filter.getMultResult,
- cardIdFormat:filter.cardIdFormat,
- isExamSelect: filter.isExamSelect,
- numberToArray: filter.numberToArray,
- }
|