feat: 提交订单信息
This commit is contained in:
parent
b683bf60e3
commit
f436bb536f
|
|
@ -67,6 +67,12 @@ class Api {
|
|||
let url = `${config.host}/worker/order_dispatch/appointmentTime`;
|
||||
return fetch.request('postFrom', url, data, true)
|
||||
}
|
||||
|
||||
// 获取 OSS 上传文件参数
|
||||
static getOssParams(data) {
|
||||
let url = `${config.host}/worker/common/ossParams`;
|
||||
return fetch.request('postFrom', url, data, true)
|
||||
}
|
||||
}
|
||||
|
||||
export default Api
|
||||
|
|
|
|||
|
|
@ -11,7 +11,10 @@
|
|||
<view class="desc flex-l">请上传上门的打卡照片</view>
|
||||
</view>
|
||||
<view class="right flex-c">
|
||||
<view class="up-ctr flex-direction-column" hover-class="auto-mask-layer-radius4" hover-start-time="0" hover-stay-time="50">
|
||||
<view v-if="img" @click="delImg()" class="img-ctr">
|
||||
<image class="img" mode="aspectFill" :src="img"></image>
|
||||
</view>
|
||||
<view v-else @click="upload()" class="up-ctr flex-direction-column" hover-class="auto-mask-layer-radius4" hover-start-time="0" hover-stay-time="50">
|
||||
<me-icon class="icon" type="icon-upload-cloud-fill" color="var(--summaryColor)" size="36rpx"></me-icon>
|
||||
<view class="up flex-c">点击上传</view>
|
||||
</view>
|
||||
|
|
@ -31,14 +34,75 @@ import MeIcon from "../../components/me-icon/me-icon.vue";
|
|||
import MeEmptySpace from "../../components/me-empty-space/me-empty-space.vue";
|
||||
import MeButton from "../../components/me-button/me-button.vue";
|
||||
import helpers from "../../utils/helpers";
|
||||
import {ref} from 'vue'
|
||||
import {ref, computed} from 'vue'
|
||||
import {onLoad} from '@dcloudio/uni-app'
|
||||
import api from "../../api/api";
|
||||
import {throttle} from "../../utils/throttle";
|
||||
import enums from "../../utils/enums";
|
||||
|
||||
const img = ref('');
|
||||
|
||||
const upload = () => {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['original'],
|
||||
sourceType: ['camera'],
|
||||
success: (chooseImageRes) => {
|
||||
if (chooseImageRes.tempFiles[0].size / 1024 / 1024 > 10) {
|
||||
return helpers.showToast('照片不能超过10M')
|
||||
}
|
||||
|
||||
uni.showLoading({
|
||||
title: '上传中'
|
||||
});
|
||||
|
||||
let tempFilePath = chooseImageRes.tempFilePaths[0]
|
||||
api.getOssParams({name: tempFilePath}).then(res => {
|
||||
uni.uploadFile({
|
||||
url: res.cdnurl,
|
||||
filePath: tempFilePath,
|
||||
name: 'file',
|
||||
timeout: 5 * 60 * 1000,
|
||||
formData: {
|
||||
'signature': res.signature,
|
||||
'ossAccessKeyId': res.OSSAccessKeyId,
|
||||
'policy': res.policy,
|
||||
'key': res.key,
|
||||
},
|
||||
success(r) {
|
||||
if (r.statusCode === undefined || r.statusCode !== 204) {
|
||||
helpers.showToast('上传文件失败')
|
||||
return
|
||||
}
|
||||
|
||||
let fullUrl = res.cdnurl + '/' + res.key
|
||||
helpers.showToast('上传成功')
|
||||
img.value = fullUrl
|
||||
},
|
||||
fail(e) {
|
||||
helpers.showToast('上传文件失败')
|
||||
console.log(e)
|
||||
},
|
||||
complete() {
|
||||
uni.hideLoading();
|
||||
}
|
||||
});
|
||||
}).catch(() => {})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const delImg = () => {
|
||||
img.value = ''
|
||||
helpers.showToast('图片已删除')
|
||||
}
|
||||
|
||||
//预约上门时间
|
||||
const submit = throttle(() => {
|
||||
if (!img.value) {
|
||||
return helpers.showToast('请上传上门的打卡照片')
|
||||
}
|
||||
|
||||
uni.showModal({
|
||||
title: '提示信息',
|
||||
confirmText: '确认',
|
||||
|
|
@ -146,6 +210,15 @@ const init = () => {
|
|||
.right {
|
||||
width: 130rpx;
|
||||
height: 130rpx;
|
||||
.img-ctr {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
.img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
}
|
||||
.up-ctr {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
|
|
|
|||
|
|
@ -115,6 +115,11 @@ const userLocation = reactive({
|
|||
lat: null,
|
||||
})
|
||||
|
||||
const formatDistance = (lat, lng) => {
|
||||
const res = helpers.getDistances(userLocation.lat, userLocation.lng, lat, lng);
|
||||
return `${res.distance}${res.unit}`;
|
||||
}
|
||||
|
||||
//初始化
|
||||
const init = () => {
|
||||
//获取师傅当前位置
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user