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