index.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. function getDateString(date = new Date) {
  2. return {
  3. year: date.getFullYear() + '',
  4. month: date.getMonth() + '',
  5. day: date.getDate() + '',
  6. hour: date.getHours() + '',
  7. minute: date.getMinutes() + '',
  8. }
  9. }
  10. const { year, month, day, hour, minute } = getDateString()
  11. import ad from '../index/ad'
  12. ad({
  13. data: {
  14. value1: [year, month, day, hour, minute],
  15. value2: [year, month, day],
  16. value3: [year],
  17. value4: [year, month],
  18. value5: [hour, minute],
  19. value6: [year, month, day, hour, minute, '1'],
  20. value7: [hour, minute, '1'],
  21. value8: [],
  22. value9: [],
  23. displayValue1: '请选择',
  24. displayValue2: '请选择',
  25. displayValue3: '请选择',
  26. displayValue4: '请选择',
  27. displayValue5: '请选择',
  28. displayValue6: '请选择',
  29. displayValue7: '请选择',
  30. displayValue8: '请选择',
  31. displayValue9: '请选择',
  32. lang: 'zh_CN',
  33. },
  34. onChange(e) {
  35. console.log(e)
  36. const { key, values } = e.detail
  37. const lang = values[key]
  38. this.setData({
  39. lang,
  40. })
  41. },
  42. setValue(values, key, mode) {
  43. this.setData({
  44. [`value${key}`]: values.value,
  45. [`displayValue${key}`]: values.label,
  46. // [`displayValue${key}`]: values.displayValue.join(' '),
  47. })
  48. },
  49. onConfirm(e) {
  50. const { index, mode } = e.currentTarget.dataset
  51. this.setValue(e.detail, index, mode)
  52. console.log(`onConfirm${index}`, e.detail)
  53. },
  54. onVisibleChange(e) {
  55. this.setData({ visible: e.detail.visible })
  56. },
  57. onClick() {
  58. this.setData({ visible: true })
  59. },
  60. })