index.vue
4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-09-21 18:04:48
* @FilePath: /swx/src/pages/_index/index.vue
* @Description: 文件描述
-->
<template>
<!-- <van-tabs :active="active" bind:change="onChange">
<van-tab title="标签 1">内容 2</van-tab>
<van-tab title="标签 2">内容 2</van-tab>
<van-tab title="标签 3">内容 3</van-tab>
<van-tab title="标签 4">
<van-button type="primary" @click="goTo">主要按钮</van-button>
</van-tab>
</van-tabs> -->
<!-- <van-button type="primary" @click="goTo">主要按钮</van-button> -->
<!-- <van-image width="100" height="100" src="https://img.yzcdn.cn/vant/cat.jpeg" /> -->
<!-- <view class="page-body">
<view class="page-section">
<text>时间日期选择器--无默认</text>
<view>
<timePickerData
:start-time="startTime"
:end-time="endTime"
@result="onResult"
>
<input placeholder="请选择" disabled='true' :value="time" />
</timePickerData>
</view>
</view>
</view> -->
<van-image width="100" height="100" :src="upload_img" />
<van-uploader @after-read="afterRead">
<van-button icon="photo" type="primary">上传图片</van-button>
</van-uploader>
</template>
<script setup>
import Taro from '@tarojs/taro'
import { ref } from 'vue';
import request from '../../utils/request';
import { file } from '@babel/types';
// import timePickerData from "@/components/time-picker-data/picker";
// import { AtImagePicker } from 'taro-ui-vue3'
// import 'taro-ui-vue3/dist/style/components/image-picker.scss'
// request.get('/srv/?a=kg_list')
// .then(res => {
// console.warn(res);
// })
// .catch(err => {
// console.error(err);
// })
// Taro.request({
// url: 'http://voice.onwall.cn/srv/?f=voice&a=kg_list', //仅为示例,并非真实的接口地址
// data: {
// },
// // header: {
// // 'content-type': 'application/json' // 默认值
// // },
// success: function (res) {
// console.log(res.data)
// }
// })
// const active = ref(1);
// const goTo = () => {
// Taro.navigateTo({
// url: '../demo/index?id=1'
// })
// }
</script>
<script>
import "./index.less";
export default {
name: "indexPage",
onReady() {
if (!Taro.canIUse("getUpdateManager")) {
Taro.showModal({
title: "提示",
content: "当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试",
showCancel: false,
});
return;
}
// https://developers.weixin.qq.com/miniprogram/dev/api/base/update/UpdateManager.html
const updateManager = Taro.getUpdateManager();
updateManager.onCheckForUpdate((res) => {
// 请求完新版本信息的回调
if (res.hasUpdate) {
updateManager.onUpdateReady(function () {
Taro.showModal({
title: "更新提示",
content: "新版本已经准备好,是否重启应用?",
success: function (res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate();
}
},
});
});
updateManager.onUpdateFailed(function () {
// 新版本下载失败
Taro.showModal({
title: "更新提示",
content: "新版本已上线,请删除当前小程序,重新搜索打开",
});
});
}
});
},
data() {
return {
fileList: [
// {
// url: 'https://img.yzcdn.cn/vant/leaf.jpg',
// name: '图片1',
// },
// // Uploader 根据文件后缀来判断是否为图片文件
// // 如果图片 URL 中不包含类型信息,可以添加 isImage 标记来声明
// {
// url: 'http://tmp/gcx6DzfhcgkMa6e11381f160429f0079f413cd452247.png',
// name: '图片2',
// isImage: true,
// deletable: true,
// },
],
upload_img: ''
};
},
methods: {
afterRead(event) {
const { file } = event.detail;
console.warn(file);
// this.fileList.push(file)
this.fileList.push({ name: '1', url: file.url });
console.warn(this.fileList);
this.upload_img = file.url
// 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
// wx.uploadFile({
// url: 'https://example.weixin.qq.com/upload', // 仅为示例,非真实的接口地址
// filePath: file.url,
// name: 'file',
// formData: { user: 'test' },
// success(res) {
// // 上传完成需要更新 fileList
// const { fileList = [] } = this.data;
// this.fileList.push({ ...file, url: res.data });
// this.setData({ fileList });
// },
// });
},
}
};
</script>