index.wxs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. var containerStyle = function (urls, multipleSize, gapRow, gapColumn) {
  2. if (urls.length === 2 || urls.length === 4) {
  3. return 'width:' + (2 * multipleSize + gapRow) + 'rpx; grid-row-gap:' + gapColumn + 'rpx; grid-column-gap:' + gapRow + 'rpx;grid-template-columns:repeat(auto-fit, ' + multipleSize + 'rpx);'
  4. } else {
  5. return 'width:' + (3 * multipleSize + 2 * gapRow) + 'rpx; grid-row-gap:' + gapColumn + 'rpx; grid-column-gap:' + gapRow + 'rpx;grid-template-columns:repeat(auto-fit, ' + multipleSize + 'rpx);'
  6. }
  7. }
  8. var blockClass = function (urls, horizontalScreen) {
  9. if (urls.length === 1) {
  10. if (horizontalScreen) {
  11. return 'l-single-image-class'
  12. } else {
  13. return 'vertical l-single-image-class'
  14. }
  15. } else {
  16. return 'l-multi-image-class'
  17. }
  18. }
  19. var blockStyle = function (urls, horizontalScreen, shortSideValue, singleSize, multipleSize) {
  20. if (urls.length === 1) {
  21. if (horizontalScreen) {
  22. return 'height:' + shortSideValue + 'rpx;width:' + singleSize + 'rpx;'
  23. } else {
  24. return 'width:' + shortSideValue + 'rpx;height:' + singleSize + 'rpx;'
  25. }
  26. } else {
  27. return 'height:' + multipleSize + 'rpx;width:' + multipleSize + 'rpx;'
  28. }
  29. }
  30. var gridStyle = function (gapRow, gapColumn, multipleSize, everyRowNumber) {
  31. return 'display:inline-grid;grid-template-columns: repeat(' + everyRowNumber + ',' + multipleSize + 'rpx);grid-row-gap:' + gapRow + 'rpx;grid-column-gap:' + gapColumn + 'rpx;'
  32. }
  33. var dimBack = function (isLong, index, maxNumber, previewFullImage) {
  34. if (previewFullImage) {
  35. if (isLong) {
  36. if (index == maxNumber - 1) {
  37. return 'dimback'
  38. }
  39. }
  40. }
  41. return ''
  42. }
  43. var dim = function (isLong, index, maxNumber, previewFullImage) {
  44. if (previewFullImage) {
  45. if (isLong) {
  46. if (index == maxNumber - 1) {
  47. return 'dim'
  48. }
  49. }
  50. }
  51. return ''
  52. }
  53. var image = function (isLong, index, maxNumber, previewFullImage) {
  54. if (previewFullImage) {
  55. if (isLong) {
  56. if (index == maxNumber - 1) {
  57. return true
  58. }
  59. }
  60. }
  61. return false
  62. }
  63. module.exports = {
  64. containerStyle: containerStyle,
  65. blockClass: blockClass,
  66. blockStyle: blockStyle,
  67. gridStyle: gridStyle,
  68. dimBack: dimBack,
  69. dim: dim,
  70. image: image,
  71. }