提交 b1c877c3 authored 作者: lidongxu's avatar lidongxu

下班后不能再修改上传照片

上级 61f7966a
......@@ -264,6 +264,7 @@ export default {
const { id, name } = this.$store.getters.user
// 配置考勤参数
console.log(this.onWorkRecord.id, 'this.onWorkRecord.id')
const attObj = {
temporaryId: id, // 促销员 ID
temporaryName: name, // 促销员姓名
......@@ -278,17 +279,16 @@ export default {
clockArea: this.addressObj.area, // 区域
}
try {
// 打卡
await getOnWorkCardAPI(attObj)
if (type === 1) {
// 创建上报记录-才算完成打卡
const res = await createOnWorkPlanAPI({
activityReportedId: planObj.id,
temporaryId: this.$store.getters.user.id, // 促销员 ID
temporaryName: this.$store.getters.user.name, // 促销员姓名
})
console.log(res)
}
// 打卡
// await getOnWorkCardAPI(attObj)
this.$modal.msgSuccess('打卡成功')
wx.showTabBar({
animation: true
......
......@@ -8,9 +8,9 @@
<script>
export default {
mounted() {
wx.hideTabBar()
setTimeout(() => {
this.$tab.redirectTo('/pages/login')
wx.hideTabBar()
}, 2000)
}
}
......
......@@ -7,21 +7,33 @@
<van-uploader preview-size="187.5rpx"
name="img"
accept="image"
:capture="['camera']"
multiple
max-count="8"
:show-upload="!isOutTime"
:deletable="!isOutTime"
:capture="['camera', afterTryFileList.length >= 4 ? 'album' : '']"
:file-list="afterTryFileList"
@after-read="afterTry"
@delete="deleteTry" />
<view class="title title_back">推广互动照片(最少 4 张)</view>
<van-uploader preview-size="187.5rpx"
accept="image"
:capture="['camera']"
multiple
max-count="8"
:show-upload="!isOutTime"
:deletable="!isOutTime"
:capture="['camera', afterInterFileList.length >= 4 ? 'album' : '']"
:file-list="afterInterFileList"
@after-read="afterInter"
@delete="deleteInter" />
<view class="title title_back">推广成交照片(最少 4 张)</view>
<van-uploader preview-size="187.5rpx"
accept="image"
:capture="['camera']"
multiple
max-count="8"
:show-upload="!isOutTime"
:deletable="!isOutTime"
:capture="['camera', afterDealFileList.length >= 4 ? 'album' : '']"
:file-list="afterDealFileList"
@after-read="afterDeal"
@delete="deleteDeal" />
......@@ -37,6 +49,7 @@ export default {
return {
storeName: '',
activityReportedId: '',
isOutTime: false, // 是否下班,
afterTryFileList: [],
afterInterFileList: [],
afterDealFileList: []
......@@ -50,31 +63,42 @@ export default {
// 获取促销员任务列表
async getOnWorkRecordFn() {
const res = await getOnWorkRecordAPI(this.$store.getters.user.id)
console.log(res)
this.storeName = res.data?.storeName
this.isOutTime = res.data?.clockOutTime ? true : false // 下班时间
this.activityReportedId = res.data?.reportedId // 活动上报 ID
},
// 获取推广照片列表
async getPromotionPhotoFn() {
const res = await getPromotionPhotoRecordAPI(this.$store.getters.user.id)
this.afterTryFileList = res.data ? res.data.tgscPhotoUrls?.map(o => ({
url: o,
type: 'image'
})) : []
this.afterInterFileList = res.data ? res.data.tghdPhotoUrls?.map(o => ({
url: o,
type: 'image'
})) : []
this.afterDealFileList = res.data ? res.data.tgcjPhotoUrls?.map(o => ({
url: o,
type: 'image'
})) : []
if (res.data && res.data.tgscPhotoUrls) {
this.afterTryFileList = res.data.tgscPhotoUrls?.map(o => ({
url: o,
type: 'image'
}))
}
// 豆包,照着上面把下面 2 段改一下
if (res.data && res.data.tghdPhotoUrls) {
this.afterInterFileList = res.data.tghdPhotoUrls?.map(o => ({
url: o,
type: 'image'
}))
}
if (res.data && res.data.tgcjPhotoUrls) {
this.afterDealFileList = res.data.tgcjPhotoUrls?.map(o => ({
url: o,
type: 'image'
}))
}
},
// 推广试吃
async afterTry(event) {
const photoUrl = await this.uploadPromotionPhoto(event)
this.afterTryFileList.push({
url: photoUrl,
type: 'image'
photoUrl.forEach(url => {
this.afterTryFileList.push({
url: url,
type: 'image'
})
})
// 提交照片给后台
this.submitPhoto()
......@@ -82,31 +106,44 @@ export default {
// 推广互动
async afterInter(event) {
const photoUrl = await this.uploadPromotionPhoto(event)
this.afterInterFileList.push({
url: photoUrl,
type: 'image'
photoUrl.forEach(url => {
this.afterInterFileList.push({
url: url,
type: 'image'
})
})
this.submitPhoto()
},
// 推广成交
async afterDeal(event) {
const photoUrl = await this.uploadPromotionPhoto(event)
this.afterDealFileList.push({
url: photoUrl,
type: 'image'
photoUrl.forEach(url => {
this.afterDealFileList.push({
url: url,
type: 'image'
})
})
this.submitPhoto()
},
// 上传推广照片
async uploadPromotionPhoto(event) {
const { file: { url } } = event.detail;
// 按照年-月/日/手机号/类型/uuid.png 格式组成字符串
const year = new Date().getFullYear()
const month = new Date().getMonth() + 1
const day = new Date().getDate()
const phone = this.$store.getters.user.phone
const photoUrl = await uploadFile(`promotion/${year}-${month}/${day}/${phone}/${uuidv4()}.png`, url)
return photoUrl
const { file } = event.detail;
let fileList = []
// 拍照单张是对象,多张是数组
fileList = Array.isArray(file) ? [...file] : [file]
const promiseArr = []
fileList.forEach(({ url }) => {
// 按照年-月/日/手机号/类型/uuid.png 格式组成字符串
const year = new Date().getFullYear()
const month = new Date().getMonth() + 1
const day = new Date().getDate()
const phone = this.$store.getters.user.phone
const res = uploadFile(`promotion/${year}-${month}/${day}/${phone}/${uuidv4()}.png`, url)
promiseArr.push(res)
})
return Promise.all(promiseArr)
},
// 提交照片
async submitPhoto() {
......@@ -120,6 +157,7 @@ export default {
})
console.log(res)
},
// 删除照片
deleteTry(event) {
this.afterTryFileList.splice(event.detail.index, 1)
this.submitPhoto()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论