hookehuyr

fix

1 <!-- 1 <!--
2 - * @Author: hookehuyr hookehuyr@gmail.com 2 + * @Date: 2022-09-19 14:11:06
3 - * @Date: 2022-05-27 15:57:59
4 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
5 - * @LastEditTime: 2022-06-06 19:18:14 4 + * @LastEditTime: 2022-09-19 17:21:39
6 - * @FilePath: /taro-vant-weapp/src/pages/index/index.vue 5 + * @FilePath: /swx/src/pages/index/index.vue
7 - * @Description: 6 + * @Description: 文件描述
8 --> 7 -->
9 <template> 8 <template>
10 <!-- <van-tabs :active="active" bind:change="onChange"> 9 <!-- <van-tabs :active="active" bind:change="onChange">
...@@ -17,12 +16,27 @@ ...@@ -17,12 +16,27 @@
17 </van-tabs> --> 16 </van-tabs> -->
18 <van-button type="primary" @click="goTo">主要按钮</van-button> 17 <van-button type="primary" @click="goTo">主要按钮</van-button>
19 <van-image width="100" height="100" src="https://img.yzcdn.cn/vant/cat.jpeg" /> 18 <van-image width="100" height="100" src="https://img.yzcdn.cn/vant/cat.jpeg" />
19 + <view class="page-body">
20 + <view class="page-section">
21 + <text>时间日期选择器--无默认</text>
22 + <view>
23 + <timePickerData
24 + :start-time="startTime"
25 + :end-time="endTime"
26 + @result="onResult"
27 + >
28 + <input placeholder="请选择" disabled='true' :value="time" />
29 + </timePickerData>
30 + </view>
31 + </view>
32 + </view>
20 </template> 33 </template>
21 34
22 <script setup> 35 <script setup>
23 import Taro from '@tarojs/taro' 36 import Taro from '@tarojs/taro'
24 import { ref } from 'vue'; 37 import { ref } from 'vue';
25 import request from '../../utils/request'; 38 import request from '../../utils/request';
39 +import timePickerData from "@/components/time-picker-data/picker";
26 40
27 request.get('/srv/?a=kg_list') 41 request.get('/srv/?a=kg_list')
28 .then(res => { 42 .then(res => {
...@@ -94,5 +108,36 @@ export default { ...@@ -94,5 +108,36 @@ export default {
94 } 108 }
95 }); 109 });
96 }, 110 },
111 + data() {
112 + return {
113 + time:'',
114 + startTime: new Date(),
115 + default:new Date(),
116 + };
117 + },
118 + created(){
119 + this.startTime = this.getTime("min", 1);
120 + this.endTime = this.getTime("year", 2);
121 + },
122 + methods: {
123 + getTime(key, number, date) {
124 + let _date = date ? new Date(date) : new Date();
125 + if (key === "min") {
126 + _date.setMinutes(_date.getMinutes() + number);
127 + }
128 + if (key === "hour") {
129 + _date.setHours(_date.getHours() + number);
130 + }
131 + if (key === "year") {
132 + _date.setFullYear(_date.getFullYear() + number);
133 + }
134 + return _date;
135 + },
136 + onResult(arr) {
137 + let time =
138 + arr[0] + "-" + arr[1] + "-" + arr[2] + " " + arr[3] + ":" + arr[4];
139 + this.time = time;
140 + },
141 + },
97 }; 142 };
98 </script> 143 </script>
......