exam-fun.wxs 979 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // 支持es4语法
  2. var filter = {
  3. numberToFixed: function(value) {
  4. return value.toFixed(2);
  5. },
  6. phoneFormat: function(value) {
  7. if( !value ) return "";
  8. if( value.length < 11){
  9. return '';
  10. }
  11. return value.substring(0, 4) +"****"+ value.substring(7,11)
  12. },
  13. trueFalseFormatter: function(question) {
  14. for (var i = 0; i < question.items.length; i++) {
  15. if (question.items[i].prefix === question.correct) {
  16. return question.items[i].content;
  17. }
  18. }
  19. return '';
  20. },
  21. indexOf: function(arg1, arg2) {
  22. return arg1.toString().indexOf(arg2.toString()) > -1 ? true : false;
  23. },
  24. numberToArray: function(number) {
  25. var array = [];
  26. for (var i = 0; i < number; i++) {
  27. array.push(i);
  28. }
  29. return array;
  30. }
  31. }
  32. // 导出对外暴露的属性
  33. module.exports = {
  34. numberToFixed: filter.numberToFixed,
  35. trueFalseFormatter: filter.trueFalseFormatter,
  36. indexOf: filter.indexOf,
  37. numberToArray: filter.numberToArray,
  38. }