app-send-time.vue 2.4 KB

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