master
271556543@qq.com 3 years ago
parent e90d722920
commit 0f33f25daf

@ -0,0 +1,130 @@
<template>
<view>
<u-mask :show="isShow" :isBack="false">
<cpn-navbar title="拍照上传"></cpn-navbar>
<view class="content">
<view class="content__img">
<u-upload ref="uUpload" :custom-btn="true" :action="action" :auto-upload="false"
:source-type="['camera']">
<view slot="addBtn" class="slot-btn" hover-class="slot-btn__hover" hover-stay-time="150">
<u-icon name="camera" size="60" color="#c0c4cc" label="点击拍摄" label-pos="bottom"></u-icon>
</view>
</u-upload>
</view>
<view class="content__btn">
<u-button :custom-style="btnStyle1" shape="circle" type="error"
@click="$emit('update:isShow',false),clearList()">取消</u-button>
<u-button :custom-style="btnStyle2" shape="circle" type="primary" @click.stop="submit">确认</u-button>
</view>
</view>
</u-mask>
</view>
</template>
<script>
export default {
props: {
isShow: {
type: Boolean,
default: false
},
type: Number
},
data() {
return {
btnStyle1: {
letterSpacing: "4rpx",
fontWeight: "600",
width: '330rpx',
background: "linear-gradient(133deg,#ff832a 36%, #FA3534)",
filter: "drop-shadow(0 0 6rpx #FA3534) drop-shadow(0 0 10rpx #ff832a)"
},
btnStyle2: {
letterSpacing: "4rpx",
fontWeight: "600",
width: '330rpx',
background: "linear-gradient(133deg,#03d5ff 36%, #108cff)",
filter: "drop-shadow(0 0 6rpx #108cff) drop-shadow(0 0 10rpx #03d5ff)"
}
}
},
methods: {
clearList() {
this.$refs.uUpload.clear()
},
submit() {
if (!this.$refs.uUpload.lists || this.$refs.uUpload.lists.length === 0) {
uni.showToast({
icon: 'none',
title: '请选择拍摄照片'
})
return
}
let fileList = this.$refs.uUpload.lists.map(item => {
return item.url
})
this.$emit('confirm', fileList, this.type)
},
},
computed: {
},
}
</script>
<style scoped lang="scss">
.content {
height: 1410rpx;
padding: 20rpx;
position: relative;
&::before {
content: '';
width: 1800rpx;
height: 1800rpx;
border-radius: 100%;
background: rgb(250, 250, 250);
box-shadow: 0 6rpx 40rpx 6rpx #1479FF;
position: absolute;
top: -800rpx;
left: calc(375rpx - 900rpx);
}
&__btn {
display: flex;
justify-content: space-between;
position: absolute;
left: 30rpx;
right: 30rpx;
bottom: 60rpx;
}
}
.slot-btn {
width: 200rpx;
height: 200rpx;
display: flex;
justify-content: center;
align-items: center;
background: rgb(244, 245, 246);
border: 2rpx #108cff solid;
border-radius: 10rpx;
box-sizing: content-box;
filter: drop-shadow(0 0 4rpx #0fc7ff) drop-shadow(0 0 6rpx #00eaff);
animation: flame 2s ease-in-out infinite alternate;
}
.slot-btn__hover {
background-color: rgb(235, 236, 238);
}
@keyframes flame {
to {
filter: drop-shadow(0 0 2rpx #1063cf) drop-shadow(0 0 5rpx #1479FF) drop-shadow(0 0 7rpx #0fc7ff) drop-shadow(0 0 10rpx #08ffef);
}
}
</style>

@ -84,7 +84,7 @@
<!-- 打卡 -->
<view class="clock">
<view class="btn" v-if="detail.status === 1 && detail.logs_count < 3"
<view class="btn" v-if="detail.status === 1 && detail.logs_count < detail.product.process_total"
@click="$u.throttle(clockIn,1000)">
<view class="text1">过程打卡</view>
<view class="text2">{{detail.logs_count + 1}}</view>
@ -111,6 +111,8 @@
定位时间{{$u.timeFormat(location.time,'hh:MM:ss')}} {{location.address}}
</view>
</view>
<imgUpload ref="imgUpload" :isShow.sync="isShowImg" :type="type" @confirm="clock"></imgUpload>
</view>
</template>
@ -120,9 +122,15 @@
} from '@/common/config.js'
import QQMapWX from '@/libs/qqmap-wx-jssdk.js'
import imgUpload from './components/imgUpload.vue'
export default {
components: {
imgUpload
},
data() {
return {
type: 0, //,1 2 3退
isShowImg: false,
id: '',
flag: false, //()
qqmapsdk: null,
@ -233,13 +241,8 @@
},
//
async uploadImgs() {
let res = await uni.chooseImage({
sourceType: ['camera']
})
if (res[1]) {
let promiseAll = res[1].tempFilePaths.map(item => {
console.log(`${ROOTPATH}/api/nurse/upload-file`);
uploadImgs(files) {
let promiseAll = files.map(item => {
return new Promise((resolve, reject) => {
uni.uploadFile({
url: `${ROOTPATH}/api/nurse/upload-file`,
@ -259,15 +262,40 @@
})
return Promise.all(promiseAll)
} else {
return Promise.reject(res[0].errMsg)
}
// let res = await uni.chooseImage({
// sourceType: ['camera']
// })
// if (res[1]) {
// let promiseAll = res[1].tempFilePaths.map(item => {
// console.log(`${ROOTPATH}/api/nurse/upload-file`);
// return new Promise((resolve, reject) => {
// uni.uploadFile({
// url: `${ROOTPATH}/api/nurse/upload-file`,
// header: {
// Authorization: `Bearer ${this.vuex_token}`
// },
// filePath: item,
// name: 'file',
// success: (res1) => {
// resolve(res1)
// },
// fail: (err) => {
// reject(err)
// }
// })
// })
// })
// return Promise.all(promiseAll)
// } else {
// return Promise.reject(res[0].errMsg)
// }
},
//
clock(type) {
clock(files, type) {
let title;
switch (type) {
case 1:
@ -282,19 +310,20 @@
default:
title = '操作成功'
}
this.uploadImgs().then(res => {
this.uploadImgs(files).then(res => {
this.form.upload_list = res.map(item => {
return {
upload_id: JSON.parse(item.data).id
}
})
this.form.type = type
console.log(this.form);
this.$u.api.processSave(this.form).then(res => {
uni.showToast({
icon: 'success',
title
})
this.$refs['imgUpload'].clearList()
this.isShowImg = false
this.getDeatil(this.id)
}).catch(err => {
uni.showToast({
@ -333,7 +362,9 @@
//
sign() {
this.clock(1)
this.type = 1
this.isShowImg = true
//this.clock(1)
},
//
@ -353,7 +384,8 @@
return
}
this.saveSku().then(res => {
this.clock(2)
this.type = 2
this.isShowImg = true
}).catch(err => {
console.log(err);
uni.showToast({
@ -365,10 +397,10 @@
//退
signOut() {
if (this.detail.logs_count < 3) {
if (this.detail.logs_count < this.detail.product.process_total) {
uni.showToast({
icon: 'none',
title: `请先完成3次打卡,再签退。当前完成打卡次数${this.detail.logs_count}`
title: `请先完成${this.detail.product.process_total}次打卡,再签退。当前完成打卡次数${this.detail.logs_count}`
})
return
}
@ -405,7 +437,8 @@
}
this.saveSku().then(() => {
this.clock(3)
this.type = 3
this.isShowImg = true
}).catch(err => {
console.log(err);
uni.showToast({
@ -444,7 +477,7 @@
},
mounted() {
this.load()
//this.getLoaction()
this.getLoaction()
}
}
</script>

@ -1,48 +1,29 @@
<template>
<view class="u-upload" v-if="!disabled">
<view
v-if="showUploadList"
class="u-list-item u-preview-wrap"
v-for="(item, index) in lists"
:key="index"
<view v-if="showUploadList" class="u-list-item u-preview-wrap" v-for="(item, index) in lists" :key="index"
:style="{
width: $u.addUnit(width),
height: $u.addUnit(height)
}"
>
<view
v-if="deletable"
class="u-delete-icon"
@tap.stop="deleteItem(index)"
:style="{
}">
<view v-if="deletable" class="u-delete-icon" @tap.stop="deleteItem(index)" :style="{
background: delBgColor
}"
>
}">
<u-icon class="u-icon" :name="delIcon" size="20" :color="delColor"></u-icon>
</view>
<u-line-progress
v-if="showProgress && item.progress > 0 && !item.error"
:show-percent="false"
height="16"
class="u-progress"
:percent="item.progress"
></u-line-progress>
<u-line-progress v-if="showProgress && item.progress > 0 && !item.error" :show-percent="false" height="16"
class="u-progress" :percent="item.progress"></u-line-progress>
<view @tap.stop="retry(index)" v-if="item.error" class="u-error-btn"></view>
<image @tap.stop="doPreviewImage(item.url || item.path, index)" class="u-preview-image" v-if="!item.isImage" :src="item.url || item.path" :mode="imageMode"></image>
<image @tap.stop="doPreviewImage(item.url || item.path, index)" class="u-preview-image" v-if="!item.isImage"
:src="item.url || item.path" :mode="imageMode"></image>
</view>
<slot name="file" :file="lists"></slot>
<view style="display: inline-block;" @tap="selectFile" v-if="maxCount > lists.length">
<view style="display: inline-block;" @tap.stop="selectFile" v-if="maxCount > lists.length">
<slot name="addBtn"></slot>
<view
v-if="!customBtn"
class="u-list-item u-add-wrap"
hover-class="u-add-wrap__hover"
hover-stay-time="150"
<view v-if="!customBtn" class="u-list-item u-add-wrap" hover-class="u-add-wrap__hover" hover-stay-time="150"
:style="{
width: $u.addUnit(width),
height: $u.addUnit(height)
}"
>
}">
<u-icon name="plus" class="u-add-btn" size="40"></u-icon>
<view class="u-add-tips">{{ uploadText }}</view>
</view>
@ -51,7 +32,7 @@
</template>
<script>
/**
/**
* upload 图片上传
* @description 该组件用于上传图片场景
* @tutorial https://www.uviewui.com/components/upload.html
@ -90,7 +71,7 @@
* @event {Function} on-choose-complete 每次选择图片后触发只是让外部可以得知每次选择后内部的文件列表
* @example <u-upload :action="action" :file-list="fileList" ></u-upload>
*/
export default {
export default {
name: 'u-upload',
props: {
//
@ -126,14 +107,14 @@ export default {
//
header: {
type: Object,
default() {
default () {
return {};
}
},
//
formData: {
type: Object,
default() {
default () {
return {};
}
},
@ -145,13 +126,13 @@ export default {
// , original compressed
sizeType: {
type: Array,
default() {
default () {
return ['original', 'compressed'];
}
},
sourceType: {
type: Array,
default() {
default () {
return ['album', 'camera'];
}
},
@ -178,7 +159,7 @@ export default {
//
fileList: {
type: Array,
default() {
default () {
return [];
}
},
@ -243,9 +224,9 @@ export default {
default: null
},
//
limitType:{
limitType: {
type: Array,
default() {
default () {
// "image"
// https://opendocs.alipay.com/mini/api/media-image
return ['png', 'jpg', 'jpeg', 'webp', 'gif', 'image'];
@ -277,7 +258,11 @@ export default {
return val.url == value.url;
})
// (tmpfalse)
!tmp && this.lists.push({ url: value.url, error: false, progress: 100 });
!tmp && this.lists.push({
url: value.url,
error: false,
progress: 100
});
});
}
},
@ -298,7 +283,9 @@ export default {
//
selectFile() {
if (this.disabled) return;
const { name = '', maxCount, multiple, maxSize, sizeType, lists, camera, compressed, maxDuration, sourceType } = this;
const {
name = '', maxCount, multiple, maxSize, sizeType, lists, camera, compressed, maxDuration, sourceType
} = this;
let chooseFile = null;
const newMaxCount = maxCount - lists.length;
// 使 chooseImage
@ -317,7 +304,7 @@ export default {
let listOldLength = this.lists.length;
res.tempFiles.map((val, index) => {
// this.limitTypefalse
if(!this.checkFileExt(val)) return ;
if (!this.checkFileExt(val)) return;
// index1
if (!multiple && index >= 1) return;
@ -384,7 +371,7 @@ export default {
return;
}
// before-upload
if(this.beforeUpload && typeof(this.beforeUpload) === 'function') {
if (this.beforeUpload && typeof(this.beforeUpload) === 'function') {
//
// (H5)customBack()thisthis
// bind()thisthis.customBack()this
@ -400,7 +387,7 @@ export default {
// catch
return this.uploadFile(index + 1);
})
} else if(beforeResponse === false) {
} else if (beforeResponse === false) {
// false
return this.uploadFile(index + 1);
} else {
@ -423,7 +410,8 @@ export default {
header: this.header,
success: res => {
// jsonjson
let data = this.toJson && this.$u.test.jsonString(res.data) ? JSON.parse(res.data) : res.data;
let data = this.toJson && this.$u.test.jsonString(res.data) ? JSON.parse(res
.data) : res.data;
if (![200, 201, 204].includes(res.statusCode)) {
this.uploadError(index, data);
} else {
@ -468,9 +456,10 @@ export default {
if (res.confirm) {
// before-remove
// before-remove
if(this.beforeRemove && typeof(this.beforeRemove) === 'function') {
if (this.beforeRemove && typeof(this.beforeRemove) === 'function') {
// before-remove
let beforeResponse = this.beforeRemove.bind(this.$u.$parent.call(this))(index, this.lists);
let beforeResponse = this.beforeRemove.bind(this.$u.$parent.call(this))(index,
this.lists);
// promise
if (!!beforeResponse && typeof beforeResponse.then === 'function') {
await beforeResponse.then(res => {
@ -480,7 +469,7 @@ export default {
// promisereject
this.showToast('已终止移除');
})
} else if(beforeResponse === false) {
} else if (beforeResponse === false) {
// false
this.showToast('已终止移除');
} else {
@ -552,23 +541,23 @@ export default {
//
return ext.toLowerCase() === fileExt;
})
if(!noArrowExt) this.showToast(`不允许选择${fileExt}格式的文件`);
if (!noArrowExt) this.showToast(`不允许选择${fileExt}格式的文件`);
return noArrowExt;
}
}
};
};
</script>
<style lang="scss" scoped>
@import '../../libs/css/style.components.scss';
@import '../../libs/css/style.components.scss';
.u-upload {
.u-upload {
@include vue-flex;
flex-wrap: wrap;
align-items: center;
}
}
.u-list-item {
.u-list-item {
width: 200rpx;
height: 200rpx;
overflow: hidden;
@ -581,35 +570,36 @@ export default {
/* #endif */
align-items: center;
justify-content: center;
}
filter: drop-shadow(0 0 8rpx #1479FF);
}
.u-preview-wrap {
.u-preview-wrap {
border: 1px solid rgb(235, 236, 238);
}
}
.u-add-wrap {
.u-add-wrap {
flex-direction: column;
color: $u-content-color;
font-size: 26rpx;
}
}
.u-add-tips {
.u-add-tips {
margin-top: 20rpx;
line-height: 40rpx;
}
}
.u-add-wrap__hover {
.u-add-wrap__hover {
background-color: rgb(235, 236, 238);
}
}
.u-preview-image {
.u-preview-image {
display: block;
width: 100%;
height: 100%;
border-radius: 10rpx;
}
}
.u-delete-icon {
.u-delete-icon {
position: absolute;
top: 10rpx;
right: 10rpx;
@ -621,24 +611,24 @@ export default {
@include vue-flex;
align-items: center;
justify-content: center;
}
}
.u-icon {
.u-icon {
@include vue-flex;
align-items: center;
justify-content: center;
}
}
.u-progress {
.u-progress {
position: absolute;
bottom: 10rpx;
left: 8rpx;
right: 8rpx;
z-index: 9;
width: auto;
}
}
.u-error-btn {
.u-error-btn {
color: #ffffff;
background-color: $u-type-error;
font-size: 20rpx;
@ -650,5 +640,5 @@ export default {
right: 0;
z-index: 9;
line-height: 1;
}
}
</style>

Loading…
Cancel
Save