app-send-time.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <view>
  3. <tui-list-cell class="line-cell" :hover="false" :arrow="true">
  4. <div class="tui-title">{{ timeLabel }}</div>
  5. <picker style="width: 100%"
  6. mode="multiSelector"
  7. :range="timeList"
  8. :value="timeValue"
  9. @change="changeTimeFn"
  10. class="inp-select"
  11. >
  12. <div v-if="sendTime">{{ sendTime }}</div>
  13. <div class="tui-placeholder" v-else>{{ placeholder }}</div>
  14. </picker>
  15. </tui-list-cell>
  16. </view>
  17. </template>
  18. <script>
  19. import TuiListCell from "@/components/plugin/list-cell";
  20. export default {
  21. name: "AppSendTime",
  22. components: {
  23. TuiListCell
  24. },
  25. props: {
  26. sendDate: {
  27. type: String,
  28. default: ""
  29. },
  30. sendTime: {
  31. type: String,
  32. default: ""
  33. },
  34. dateLabel: {
  35. type: String,
  36. default: "配送日期"
  37. },
  38. timeLabel: {
  39. type: String,
  40. default: "配送时间"
  41. },
  42. placeholder: {
  43. type: String,
  44. default: "请选择具体时间"
  45. }
  46. },
  47. data() {
  48. return {
  49. timeList: [
  50. [
  51. "01",
  52. "02",
  53. "03",
  54. "04",
  55. "05",
  56. "06",
  57. "07",
  58. "08",
  59. "09",
  60. "10",
  61. "11",
  62. "12",
  63. "13",
  64. "14",
  65. "15",
  66. "16",
  67. "17",
  68. "18",
  69. "19",
  70. "20",
  71. "21",
  72. "22",
  73. "23",
  74. "24"
  75. ],
  76. ["00", "10", "20", "30", "40", "50"]
  77. ],
  78. timeValue: [0, 0]
  79. };
  80. },
  81. created() {
  82. let nowDate = new Date();
  83. this.$emit("update:sendDate", nowDate.Format("yyyy-MM-dd"));
  84. },
  85. methods: {
  86. changeTimeFn(e) {
  87. console.log(e);
  88. let oneIndex = e.detail.value[0] || 0;
  89. let twoIndex = e.detail.value[1] || 0;
  90. this.timeValue = e.detail.value;
  91. this.$emit(
  92. "update:sendTime",
  93. this.timeList[0][oneIndex] + ":" + this.timeList[1][twoIndex]
  94. );
  95. this.$emit("alterTime")
  96. }
  97. },
  98. watch: {
  99. sendTime(val) {
  100. if (val) {
  101. let indexList = val.split(":");
  102. let oneIndex = indexList[0] || 0;
  103. let twoIndex = indexList[1] || 0;
  104. this.timeValue = [oneIndex, twoIndex];
  105. }
  106. }
  107. }
  108. };
  109. </script>
  110. <style lang="scss" scoped></style>