111
This commit is contained in:
parent
95faa0a0a3
commit
99b9f6cbfb
1
App.vue
1
App.vue
|
|
@ -121,7 +121,6 @@ export default {
|
|||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style lang="scss">
|
||||
/*每个页面公共css */
|
||||
@import "uview-ui/index.scss";
|
||||
|
|
|
|||
66
common/qiniuUploadProgress.js
Normal file
66
common/qiniuUploadProgress.js
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import Vue from 'vue'
|
||||
|
||||
export const qiniuUploadProgressState = Vue.observable({
|
||||
visible: false,
|
||||
progress: 0,
|
||||
speedText: '0KB/s',
|
||||
sizeText: '',
|
||||
title: '上传中'
|
||||
})
|
||||
|
||||
let lastTime = 0
|
||||
let lastSent = 0
|
||||
|
||||
export function formatFileSize(bytes) {
|
||||
const n = Number(bytes) || 0
|
||||
if (n <= 0) return '0B'
|
||||
if (n < 1024) return n + 'B'
|
||||
if (n < 1024 * 1024) return (n / 1024).toFixed(1) + 'KB'
|
||||
return (n / 1024 / 1024).toFixed(2) + 'MB'
|
||||
}
|
||||
|
||||
export function formatSpeed(bytesPerSec) {
|
||||
const n = Number(bytesPerSec) || 0
|
||||
if (n <= 0) return '0KB/s'
|
||||
if (n < 1024) return n.toFixed(0) + 'B/s'
|
||||
if (n < 1024 * 1024) return (n / 1024).toFixed(1) + 'KB/s'
|
||||
return (n / 1024 / 1024).toFixed(2) + 'MB/s'
|
||||
}
|
||||
|
||||
export function resetQiniuUploadProgress() {
|
||||
qiniuUploadProgressState.progress = 0
|
||||
qiniuUploadProgressState.speedText = '0KB/s'
|
||||
qiniuUploadProgressState.sizeText = ''
|
||||
lastTime = 0
|
||||
lastSent = 0
|
||||
}
|
||||
|
||||
export function showQiniuUploadProgress(title = '上传中') {
|
||||
resetQiniuUploadProgress()
|
||||
qiniuUploadProgressState.title = title
|
||||
qiniuUploadProgressState.visible = true
|
||||
}
|
||||
|
||||
export function hideQiniuUploadProgress() {
|
||||
qiniuUploadProgressState.visible = false
|
||||
resetQiniuUploadProgress()
|
||||
}
|
||||
|
||||
export function updateQiniuUploadProgress(res) {
|
||||
const now = Date.now()
|
||||
const sent = res.totalBytesSent || 0
|
||||
const total = res.totalBytesExpectedToSend || 0
|
||||
qiniuUploadProgressState.progress = Math.min(100, Math.max(0, res.progress || 0))
|
||||
if (total > 0) {
|
||||
qiniuUploadProgressState.sizeText = formatFileSize(sent) + ' / ' + formatFileSize(total)
|
||||
}
|
||||
if (lastTime && now > lastTime) {
|
||||
const deltaBytes = sent - lastSent
|
||||
const deltaTime = (now - lastTime) / 1000
|
||||
if (deltaTime > 0 && deltaBytes >= 0) {
|
||||
qiniuUploadProgressState.speedText = formatSpeed(deltaBytes / deltaTime)
|
||||
}
|
||||
}
|
||||
lastTime = now
|
||||
lastSent = sent
|
||||
}
|
||||
202
common/qiniuUploadUtil.js
Normal file
202
common/qiniuUploadUtil.js
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
import {
|
||||
showQiniuUploadProgress,
|
||||
hideQiniuUploadProgress,
|
||||
updateQiniuUploadProgress,
|
||||
resetQiniuUploadProgress,
|
||||
qiniuUploadProgressState
|
||||
} from './qiniuUploadProgress.js'
|
||||
|
||||
export const QINIU_UPLOAD_URL = 'https://up-z2.qiniup.com'
|
||||
export const QINIU_CDN_PREFIX = 'https://api.ccttiot.com/'
|
||||
|
||||
export function fetchQiniuToken($u) {
|
||||
return $u.get('/common/qiniuToken').then((res) => {
|
||||
if (res.code == 200 && res.data) {
|
||||
return res.data
|
||||
}
|
||||
return null
|
||||
}).catch(() => null)
|
||||
}
|
||||
|
||||
export function parseQiniuUploadKey(res) {
|
||||
if (!res || res.statusCode !== 200 || res.data == null || res.data === '') {
|
||||
return ''
|
||||
}
|
||||
try {
|
||||
const body = typeof res.data === 'string' ? JSON.parse(res.data) : res.data
|
||||
if (!body || body.error) {
|
||||
return ''
|
||||
}
|
||||
const key = body.key
|
||||
if (typeof key !== 'string' || !key.trim()) {
|
||||
return ''
|
||||
}
|
||||
return key.trim()
|
||||
} catch (e) {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
export function parseQiniuUploadUrl(res, cdnPrefix = QINIU_CDN_PREFIX) {
|
||||
const key = parseQiniuUploadKey(res)
|
||||
return key ? cdnPrefix + key : ''
|
||||
}
|
||||
|
||||
/** 校验上传结果,不合法则抛错 */
|
||||
export function assertValidUploadResult(result, returnKey = false) {
|
||||
if (result == null || result === '') {
|
||||
throw new Error('upload result empty')
|
||||
}
|
||||
const value = String(result).trim()
|
||||
if (!value || value === 'undefined' || value.indexOf('undefined') !== -1) {
|
||||
throw new Error('upload result invalid')
|
||||
}
|
||||
if (returnKey) {
|
||||
return value
|
||||
}
|
||||
if (!/^https?:\/\//.test(value)) {
|
||||
throw new Error('upload url invalid')
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
function doUploadQiniuFile(options = {}) {
|
||||
const {
|
||||
filePath,
|
||||
token,
|
||||
key,
|
||||
cdnPrefix = QINIU_CDN_PREFIX,
|
||||
returnKey = false,
|
||||
onProgress
|
||||
} = options
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!filePath) {
|
||||
reject(new Error('missing filePath'))
|
||||
return
|
||||
}
|
||||
if (!token) {
|
||||
reject(new Error('missing token'))
|
||||
return
|
||||
}
|
||||
if (!key) {
|
||||
reject(new Error('missing key'))
|
||||
return
|
||||
}
|
||||
const uploadTask = uni.uploadFile({
|
||||
url: QINIU_UPLOAD_URL,
|
||||
filePath,
|
||||
name: 'file',
|
||||
formData: {
|
||||
token,
|
||||
key
|
||||
},
|
||||
success: (res) => {
|
||||
const uploadKey = parseQiniuUploadKey(res)
|
||||
if (!uploadKey) {
|
||||
reject(new Error('upload parse failed'))
|
||||
return
|
||||
}
|
||||
try {
|
||||
const result = returnKey ? uploadKey : cdnPrefix + uploadKey
|
||||
resolve(assertValidUploadResult(result, returnKey))
|
||||
} catch (e) {
|
||||
reject(e)
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(err || new Error('upload request failed'))
|
||||
}
|
||||
})
|
||||
if (uploadTask && uploadTask.onProgressUpdate && onProgress) {
|
||||
uploadTask.onProgressUpdate(onProgress)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function uploadQiniuFile(options = {}) {
|
||||
const {
|
||||
title = '上传中',
|
||||
showProgress = true
|
||||
} = options
|
||||
|
||||
if (showProgress) {
|
||||
showQiniuUploadProgress(title)
|
||||
}
|
||||
|
||||
return doUploadQiniuFile({
|
||||
...options,
|
||||
onProgress: showProgress ? updateQiniuUploadProgress : options.onProgress
|
||||
}).then((result) => {
|
||||
if (showProgress) {
|
||||
qiniuUploadProgressState.progress = 100
|
||||
qiniuUploadProgressState.speedText = '完成'
|
||||
setTimeout(() => hideQiniuUploadProgress(), 200)
|
||||
}
|
||||
return result
|
||||
}).catch((err) => {
|
||||
if (showProgress) {
|
||||
hideQiniuUploadProgress()
|
||||
}
|
||||
throw err
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 带 token 刷新与失败重试的上传(默认最多 3 次:首次 + 重试 2 次)
|
||||
* 仅在上传结果校验通过后才 resolve,调用方可放心展示
|
||||
*/
|
||||
export async function uploadQiniuFileWithRetry($u, options = {}) {
|
||||
const maxRetry = options.maxRetry != null ? options.maxRetry : 2
|
||||
const showProgress = options.showProgress !== false
|
||||
const title = options.title || '上传中'
|
||||
const returnKey = !!options.returnKey
|
||||
let token = options.token || null
|
||||
let lastError = null
|
||||
|
||||
if (showProgress) {
|
||||
showQiniuUploadProgress(title)
|
||||
}
|
||||
|
||||
for (let attempt = 0; attempt <= maxRetry; attempt++) {
|
||||
try {
|
||||
if (!token) {
|
||||
token = await fetchQiniuToken($u)
|
||||
}
|
||||
if (!token) {
|
||||
throw new Error('no token')
|
||||
}
|
||||
if (attempt > 0 && showProgress) {
|
||||
resetQiniuUploadProgress()
|
||||
qiniuUploadProgressState.title = maxRetry > 0
|
||||
? `${title}(重试 ${attempt}/${maxRetry})`
|
||||
: title
|
||||
}
|
||||
|
||||
const result = await doUploadQiniuFile({
|
||||
...options,
|
||||
token,
|
||||
onProgress: showProgress ? updateQiniuUploadProgress : options.onProgress
|
||||
})
|
||||
|
||||
const validResult = assertValidUploadResult(result, returnKey)
|
||||
if (showProgress) {
|
||||
qiniuUploadProgressState.progress = 100
|
||||
qiniuUploadProgressState.speedText = '完成'
|
||||
setTimeout(() => hideQiniuUploadProgress(), 200)
|
||||
}
|
||||
return validResult
|
||||
} catch (e) {
|
||||
lastError = e
|
||||
token = null
|
||||
if (attempt < maxRetry) {
|
||||
token = await fetchQiniuToken($u)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (showProgress) {
|
||||
hideQiniuUploadProgress()
|
||||
}
|
||||
throw lastError || new Error('upload failed')
|
||||
}
|
||||
78
components/qiniu-upload-progress/qiniu-upload-progress.vue
Normal file
78
components/qiniu-upload-progress/qiniu-upload-progress.vue
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<template>
|
||||
<view v-if="state.visible">
|
||||
<u-mask :show="state.visible" :z-index="9998" duration="0" />
|
||||
<view class="qiniu-upload-progress-panel">
|
||||
<view class="qiniu-upload-progress-title">{{ state.title }}</view>
|
||||
<view class="qiniu-upload-progress-sub">{{ state.sizeText || '正在准备上传...' }}</view>
|
||||
<view class="qiniu-upload-progress-track">
|
||||
<view class="qiniu-upload-progress-fill" :style="{ width: state.progress + '%' }"></view>
|
||||
</view>
|
||||
<view class="qiniu-upload-progress-meta">
|
||||
<text>上传速度 {{ state.speedText }}</text>
|
||||
<text>{{ state.progress }}%</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { qiniuUploadProgressState } from '@/common/qiniuUploadProgress.js'
|
||||
|
||||
export default {
|
||||
name: 'QiniuUploadProgress',
|
||||
computed: {
|
||||
state() {
|
||||
return qiniuUploadProgressState
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.qiniu-upload-progress-panel {
|
||||
position: fixed;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 9999;
|
||||
width: 620rpx;
|
||||
background: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 36rpx 30rpx 30rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.qiniu-upload-progress-title {
|
||||
font-size: 30rpx;
|
||||
color: #2E4975;
|
||||
font-weight: 600;
|
||||
text-align: center;
|
||||
}
|
||||
.qiniu-upload-progress-sub {
|
||||
margin-top: 16rpx;
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
text-align: center;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.qiniu-upload-progress-track {
|
||||
margin-top: 24rpx;
|
||||
height: 16rpx;
|
||||
background: #EEF3FA;
|
||||
border-radius: 10rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
.qiniu-upload-progress-fill {
|
||||
height: 100%;
|
||||
background: #4297F3;
|
||||
border-radius: 10rpx;
|
||||
transition: width 0.2s;
|
||||
}
|
||||
.qiniu-upload-progress-meta {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 14rpx;
|
||||
font-size: 22rpx;
|
||||
color: #7c7c7c;
|
||||
}
|
||||
</style>
|
||||
9
main.js
9
main.js
|
|
@ -13,6 +13,8 @@ import'./common/css/iconfont.css'
|
|||
|
||||
import md5 from 'js-md5'
|
||||
import {tansParams} from './common/util.js'
|
||||
import { uploadQiniuFileWithRetry, fetchQiniuToken } from './common/qiniuUploadUtil.js'
|
||||
import QiniuUploadProgress from '@/components/qiniu-upload-progress/qiniu-upload-progress.vue'
|
||||
|
||||
// 引入公共组件 tabbar
|
||||
import tabbar from '@/components/tab-bar/tab-bar.vue';
|
||||
|
|
@ -24,6 +26,13 @@ Vue.use('tab-bar',tabbar)
|
|||
Vue.use(uView);
|
||||
Vue.use(cookies);
|
||||
Vue.config.productionTip = false
|
||||
Vue.component('qiniu-upload-progress', QiniuUploadProgress)
|
||||
Vue.prototype.$uploadQiniuFile = function(options) {
|
||||
return uploadQiniuFileWithRetry(this.$u, options)
|
||||
}
|
||||
Vue.prototype.$fetchQiniuToken = function() {
|
||||
return fetchQiniuToken(this.$u)
|
||||
}
|
||||
|
||||
|
||||
Vue.prototype.$md5 = md5;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@
|
|||
// "baseurl": "http://test.com"
|
||||
// },
|
||||
"libVersion" : "latest",
|
||||
"appid" : "wxc7e95836981d11fc",
|
||||
"appid" : "wx8a05cf95418a6859",
|
||||
"setting" : {
|
||||
"urlCheck" : false,
|
||||
"es6" : true,
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
<button hover-class="app-tap-hover" style="margin-top:20rpx;" @click="onClick('save')">提交</button>
|
||||
</view>
|
||||
</view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -135,39 +136,30 @@
|
|||
})
|
||||
return
|
||||
}
|
||||
// 生成图片的临时路径
|
||||
// H5 生成的是base64
|
||||
this.tempUrl = res.tempFilePath
|
||||
console.log('临时路径', res.tempFilePath)
|
||||
uni.showLoading({
|
||||
title: '签名上传中',
|
||||
mask: 'true',
|
||||
})
|
||||
let math = 'static/' + this.$u.guid(20)
|
||||
let that = this
|
||||
wx.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
filePath: res.tempFilePath,
|
||||
formData: {
|
||||
token: that.token, //后端返回的token
|
||||
key: 'smartmeter/img/' + math
|
||||
},
|
||||
success: function(res) {
|
||||
console.log(res, 'resres');
|
||||
let str = JSON.parse(res.data)
|
||||
let tempFilePaths = 'https://api.ccttiot.com/' + str.key
|
||||
that.userInfo.signatureUrl = tempFilePaths
|
||||
console.log('签名路径', tempFilePaths, that.userInfo.signatureUrl)
|
||||
console.log('表单数据:', that.userInfo)
|
||||
uni.hideLoading()
|
||||
uni.showLoading({
|
||||
title: '正在生成协议',
|
||||
mask: 'true',
|
||||
})
|
||||
that.getsc()
|
||||
}
|
||||
})
|
||||
try {
|
||||
const url = await this.$uploadQiniuFile({
|
||||
filePath: res.tempFilePath,
|
||||
token: that.token,
|
||||
key: 'smartmeter/img/' + math,
|
||||
title: '签名上传'
|
||||
})
|
||||
that.userInfo.signatureUrl = url
|
||||
console.log('签名路径', url, that.userInfo.signatureUrl)
|
||||
console.log('表单数据:', that.userInfo)
|
||||
uni.showLoading({
|
||||
title: '正在生成协议',
|
||||
mask: true,
|
||||
})
|
||||
that.getsc()
|
||||
} catch (e) {
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
return
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
<view class="tip_txt" style="font-weight: 600;font-size: 28rpx;color: #374151;margin-top: 30rpx;line-height: 1.6;">
|
||||
保持车辆录像的完整清晰,不要随意拍摄,确保视频中车辆出境,并且出现车牌号
|
||||
</view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -43,6 +44,7 @@
|
|||
return
|
||||
}
|
||||
this.videoPath = res.tempFilePath
|
||||
this.videoUrl = ''
|
||||
this.upload()
|
||||
},
|
||||
fail: () => {
|
||||
|
|
@ -51,22 +53,17 @@
|
|||
})
|
||||
},
|
||||
upload() {
|
||||
uni.showLoading({ title: '上传中' })
|
||||
let math = 'static/' + this.$u.guid(20)
|
||||
wx.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
this.$uploadQiniuFile({
|
||||
filePath: this.videoPath,
|
||||
formData: {
|
||||
token: this.token,
|
||||
key: 'bike/video/' + math
|
||||
},
|
||||
success: (res) => {
|
||||
uni.hideLoading()
|
||||
let str = JSON.parse(res.data)
|
||||
this.videoUrl = 'https://api.ccttiot.com/' + str.key
|
||||
this.$emit('uploaded', this.videoUrl)
|
||||
}
|
||||
token: this.token,
|
||||
key: 'bike/video/' + math,
|
||||
title: '上传验车视频'
|
||||
}).then((url) => {
|
||||
this.videoUrl = url
|
||||
this.$emit('uploaded', this.videoUrl)
|
||||
}).catch(() => {
|
||||
uni.showToast({ title: '上传失败', icon: 'none', duration: 3000 })
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@
|
|||
<text v-else class="fee-ins-btn-fee">¥{{ insurancePriceDisplay }}/次</text>
|
||||
</view>
|
||||
<text v-if="hasDeposit" class="fee-ins-btn-note">
|
||||
含安心骑保障:除押金外另计保障服务费{{ insurancePriceDisplay }}元/次,总价以试算为准。
|
||||
含安心骑保障:除押金外另计保障服务费{{ insurancePriceDisplay }}元/次,总价以实际价格为准。
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@
|
|||
</scroll-view>
|
||||
</view>
|
||||
</u-popup>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -133,7 +134,6 @@
|
|||
bgc: { backgroundColor: '#F3F4F6' },
|
||||
areaId: '',
|
||||
token: '',
|
||||
qiniuLoading: false,
|
||||
insuranceId: '',
|
||||
insuranceText: '',
|
||||
insuranceList: [],
|
||||
|
|
@ -373,34 +373,16 @@
|
|||
},
|
||||
uploadToQiniu(filePath) {
|
||||
const math = 'static/' + this.$u.guid(20)
|
||||
uni.showLoading({ title: '上传中...', mask: true })
|
||||
uni.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
this.$uploadQiniuFile({
|
||||
filePath,
|
||||
name: 'file',
|
||||
formData: {
|
||||
token: this.token,
|
||||
key: 'bike/img/' + math
|
||||
},
|
||||
success: (res) => {
|
||||
try {
|
||||
const body = JSON.parse(res.data || '{}')
|
||||
if (body.key) {
|
||||
this.licensePicture = 'https://api.ccttiot.com/' + body.key
|
||||
uni.showToast({ title: '上传成功', icon: 'success' })
|
||||
} else {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
}
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
},
|
||||
complete: () => {
|
||||
uni.hideLoading()
|
||||
}
|
||||
token: this.token,
|
||||
key: 'bike/img/' + math,
|
||||
title: '上传行驶证照片'
|
||||
}).then((url) => {
|
||||
this.licensePicture = url
|
||||
uni.showToast({ title: '上传成功', icon: 'success' })
|
||||
}).catch(() => {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
})
|
||||
},
|
||||
previewLicense() {
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@
|
|||
</scroll-view>
|
||||
</view>
|
||||
</u-popup>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -344,8 +345,7 @@
|
|||
this.form.id = str(d.id)
|
||||
this.form.insuranceCode = str(d.insuranceCode)
|
||||
this.form.insuranceContent = str(d.insuranceContent)
|
||||
this.form.insuranceDepositAmount =
|
||||
d.insuranceDepositAmount != null && d.insuranceDepositAmount !== '' ? String(d.insuranceDepositAmount) : ''
|
||||
this.form.insuranceDepositAmount = d.insuranceDepositAmount != null && d.insuranceDepositAmount !== '' ? String(d.insuranceDepositAmount) : ''
|
||||
this.form.insuranceFeeRule = str(d.insuranceFeeRule)
|
||||
this.form.insuranceId = str(d.insuranceId)
|
||||
this.form.insuranceName = str(d.insuranceName)
|
||||
|
|
@ -575,34 +575,16 @@
|
|||
},
|
||||
uploadToQiniu(filePath) {
|
||||
const math = 'static/' + this.$u.guid(20)
|
||||
uni.showLoading({ title: '上传中...', mask: true })
|
||||
uni.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
this.$uploadQiniuFile({
|
||||
filePath,
|
||||
name: 'file',
|
||||
formData: {
|
||||
token: this.token,
|
||||
key: 'bike/img/' + math
|
||||
},
|
||||
success: (res) => {
|
||||
try {
|
||||
const body = JSON.parse(res.data || '{}')
|
||||
if (body.key) {
|
||||
this.form.licensePicture = 'https://api.ccttiot.com/' + body.key
|
||||
uni.showToast({ title: '上传成功', icon: 'success' })
|
||||
} else {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
}
|
||||
} catch (err) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
},
|
||||
complete: () => {
|
||||
uni.hideLoading()
|
||||
}
|
||||
token: this.token,
|
||||
key: 'bike/img/' + math,
|
||||
title: '上传行驶证照片'
|
||||
}).then((url) => {
|
||||
this.form.licensePicture = url
|
||||
uni.showToast({ title: '上传成功', icon: 'success' })
|
||||
}).catch(() => {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
})
|
||||
},
|
||||
clearLicense() {
|
||||
|
|
|
|||
|
|
@ -1063,12 +1063,13 @@
|
|||
this.$u.get("/getInfo").then(res => {
|
||||
if (res.code == 200) {
|
||||
if (res.user.isReal == false) {
|
||||
let that = this
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '您当前还未实名认证,是否前去实名认证?',
|
||||
showCancel: true,
|
||||
success: function(res) {
|
||||
if (res.confirm) uni.navigateTo({ url: '/page_user/shiming' })
|
||||
if (res.confirm) uni.navigateTo({ url: '/page_user/shiming?areaId=' + that.bikeobj.areaId })
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
|
@ -1304,9 +1305,10 @@
|
|||
this.getlogo(() => this.btnzhifu())
|
||||
} else if (resp.code == 10001) {
|
||||
uni.hideLoading()
|
||||
let that = this
|
||||
uni.showModal({
|
||||
title: '提示', content: '您当前还未实名认证,是否前去实名认证?', showCancel: true,
|
||||
success: function(res) { if (res.confirm) uni.navigateTo({ url: '/page_user/shiming' }) }
|
||||
success: function(res) { if (res.confirm) uni.navigateTo({ url: '/page_user/shiming?areaId=' + that.bikeobj.areaId }) }
|
||||
})
|
||||
} else if (resp.code == 10002) {
|
||||
uni.hideLoading()
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@
|
|||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -266,30 +267,31 @@
|
|||
|
||||
// 选择图片
|
||||
chooseImage() {
|
||||
let _this = this
|
||||
let math = 'static/' + _this.$u.guid(20)
|
||||
const math = 'static/' + this.$u.guid(20)
|
||||
uni.chooseImage({
|
||||
count: 4 - this.imglist.length,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success(res) {
|
||||
const tempFilePaths = res.tempFilePaths[0]
|
||||
wx.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
filePath: tempFilePaths,
|
||||
formData: {
|
||||
token: _this.token, //后端返回的token
|
||||
key: 'smartmeter/img/' + math
|
||||
},
|
||||
success: function(res) {
|
||||
console.log(res, 'resres');
|
||||
let str = JSON.parse(res.data)
|
||||
let tempFilePaths = 'https://api.ccttiot.com/' + str.key
|
||||
_this.imglist.push(tempFilePaths)
|
||||
console.log(_this.imglist);
|
||||
}
|
||||
})
|
||||
success: async (res) => {
|
||||
const filePath = res.tempFilePaths[0]
|
||||
if (!this.token) {
|
||||
this.token = await this.$fetchQiniuToken()
|
||||
}
|
||||
if (!this.token) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
try {
|
||||
const url = await this.$uploadQiniuFile({
|
||||
filePath,
|
||||
token: this.token,
|
||||
key: 'smartmeter/img/' + math,
|
||||
title: '上传投诉截图'
|
||||
})
|
||||
this.imglist.push(url)
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
|
|
|||
|
|
@ -228,6 +228,7 @@
|
|||
<view style="background-color: rgba(0, 0, 0, .5);width: 100%;height: 100vh;position: fixed;top: 0;left: 0;" v-if="showRefund"></view>
|
||||
|
||||
</view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
|
|
@ -449,30 +450,31 @@
|
|||
},
|
||||
// 选择图片
|
||||
pickImages() {
|
||||
let _this = this
|
||||
let math = 'static/' + _this.$u.guid(20)
|
||||
const math = 'static/' + this.$u.guid(20)
|
||||
uni.chooseImage({
|
||||
count: 4 - this.images.length,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success(res) {
|
||||
const tempFilePaths = res.tempFilePaths[0]
|
||||
wx.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
filePath: tempFilePaths,
|
||||
formData: {
|
||||
token: _this.token, //后端返回的token
|
||||
key: 'smartmeter/img/' + math
|
||||
},
|
||||
success: function(res) {
|
||||
console.log(res, 'resres');
|
||||
let str = JSON.parse(res.data)
|
||||
let tempFilePaths = 'https://api.ccttiot.com/' + str.key
|
||||
_this.images.push(tempFilePaths)
|
||||
console.log(_this.images);
|
||||
}
|
||||
})
|
||||
success: async (res) => {
|
||||
const filePath = res.tempFilePaths[0]
|
||||
if (!this.token) {
|
||||
this.token = await this.$fetchQiniuToken()
|
||||
}
|
||||
if (!this.token) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
try {
|
||||
const url = await this.$uploadQiniuFile({
|
||||
filePath,
|
||||
token: this.token,
|
||||
key: 'smartmeter/img/' + math,
|
||||
title: '上传回复配图'
|
||||
})
|
||||
this.images.push(url)
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@
|
|||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
|
|
@ -227,7 +228,7 @@
|
|||
getqiniuyun(){
|
||||
this.$u.get("/common/qiniuToken").then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.token = res.token
|
||||
this.token = res.data
|
||||
}
|
||||
})
|
||||
},
|
||||
|
|
@ -274,30 +275,31 @@
|
|||
},
|
||||
// 选择图片
|
||||
pickImages() {
|
||||
let _this = this
|
||||
let math = 'static/' + _this.$u.guid(20)
|
||||
const math = 'static/' + this.$u.guid(20)
|
||||
uni.chooseImage({
|
||||
count: 4 - this.images.length,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success(res) {
|
||||
const tempFilePaths = res.tempFilePaths[0]
|
||||
wx.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
filePath: tempFilePaths,
|
||||
formData: {
|
||||
token: _this.token, //后端返回的token
|
||||
key: 'smartmeter/img/' + math
|
||||
},
|
||||
success: function(res) {
|
||||
console.log(res, 'resres');
|
||||
let str = JSON.parse(res.data)
|
||||
let tempFilePaths = 'https://api.ccttiot.com/' + str.key
|
||||
_this.images.push(tempFilePaths)
|
||||
console.log(_this.images);
|
||||
}
|
||||
})
|
||||
success: async (res) => {
|
||||
const filePath = res.tempFilePaths[0]
|
||||
if (!this.token) {
|
||||
this.token = await this.$fetchQiniuToken()
|
||||
}
|
||||
if (!this.token) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
try {
|
||||
const url = await this.$uploadQiniuFile({
|
||||
filePath,
|
||||
token: this.token,
|
||||
key: 'smartmeter/img/' + math,
|
||||
title: '上传投诉凭证'
|
||||
})
|
||||
this.images.push(url)
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
</view> -->
|
||||
</view>
|
||||
<button hover-class="app-tap-hover" class="bc" @click="btnbc">{{ isEdit ? '保存' : '添加' }}</button>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@
|
|||
<u-button @click="goBack">取消</u-button>
|
||||
</view>
|
||||
</view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -214,44 +215,23 @@ export default {
|
|||
|
||||
// 上传图片
|
||||
uploadImage(filePath) {
|
||||
uni.showLoading({
|
||||
title: '上传中...'
|
||||
})
|
||||
|
||||
const math = 'static/' + this.$u.guid(20)
|
||||
|
||||
uni.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
filePath: filePath,
|
||||
name: 'file',
|
||||
formData: {
|
||||
token: this.token,
|
||||
key: 'bike/img/' + math
|
||||
},
|
||||
success: (res) => {
|
||||
const response = JSON.parse(res.data)
|
||||
if (response.key) {
|
||||
this.formData.picture = this.upurl + '/' + response.key
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none'
|
||||
})
|
||||
},
|
||||
complete: () => {
|
||||
uni.hideLoading()
|
||||
}
|
||||
this.$uploadQiniuFile({
|
||||
filePath,
|
||||
token: this.token,
|
||||
key: 'bike/img/' + math,
|
||||
title: '上传环境照片'
|
||||
}).then((url) => {
|
||||
this.formData.picture = url
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success'
|
||||
})
|
||||
}).catch(() => {
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none'
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -315,6 +315,7 @@
|
|||
保存
|
||||
</view>
|
||||
</view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -611,21 +612,15 @@ export default {
|
|||
type: 'image',
|
||||
success(res) {
|
||||
const tempFilePaths = res.tempFiles
|
||||
uni.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
_this.$uploadQiniuFile({
|
||||
filePath: tempFilePaths[0].path,
|
||||
formData: {
|
||||
token: _this.token, //后端返回的token
|
||||
key: 'smartmeter/img/' + math
|
||||
},
|
||||
success: function(res) {
|
||||
console.log(res, 'resres');
|
||||
let str = JSON.parse(res.data)
|
||||
console.log(str.key)
|
||||
_this.data.icon = 'https://api.ccttiot.com/' + str.key
|
||||
console.log(_this.data.icon);
|
||||
}
|
||||
token: _this.token,
|
||||
key: 'smartmeter/img/' + math,
|
||||
title: '上传车型图标'
|
||||
}).then((url) => {
|
||||
_this.data.icon = url
|
||||
}).catch(() => {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
@ -638,21 +633,15 @@ export default {
|
|||
type: 'image',
|
||||
success(res) {
|
||||
const tempFilePaths = res.tempFiles
|
||||
uni.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
_this.$uploadQiniuFile({
|
||||
filePath: tempFilePaths[0].path,
|
||||
formData: {
|
||||
token: _this.token, //后端返回的token
|
||||
key: 'smartmeter/img/' + math
|
||||
},
|
||||
success: function(res) {
|
||||
console.log(res, 'resres');
|
||||
let str = JSON.parse(res.data)
|
||||
console.log(str.key)
|
||||
_this.data.picture = 'https://api.ccttiot.com/' + str.key
|
||||
console.log(_this.data.picture);
|
||||
}
|
||||
token: _this.token,
|
||||
key: 'smartmeter/img/' + math,
|
||||
title: '上传车辆图片'
|
||||
}).then((url) => {
|
||||
_this.data.picture = url
|
||||
}).catch(() => {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -178,19 +178,7 @@
|
|||
开启后用户必须先通过驾驶证认证才可使用
|
||||
</view>
|
||||
</view>
|
||||
<view class="card_li">
|
||||
<view class="tops">
|
||||
<view class="card_left">
|
||||
换车校验位置
|
||||
</view>
|
||||
<view class="card_right">
|
||||
<u-switch v-model="form.changeCheck"></u-switch>
|
||||
</view>
|
||||
</view>
|
||||
<view class="tips">
|
||||
开启后用户换车是否需要校验位置
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card_li">
|
||||
<view class="tops">
|
||||
<view class="card_left">
|
||||
|
|
@ -204,19 +192,7 @@
|
|||
开启后用户可以进行多个订单
|
||||
</view>
|
||||
</view>
|
||||
<view class="card_li">
|
||||
<view class="tops">
|
||||
<view class="card_left">
|
||||
手机校验附近设备
|
||||
</view>
|
||||
<view class="card_right">
|
||||
<u-switch v-model="form.mobileCheckMac"></u-switch>
|
||||
</view>
|
||||
</view>
|
||||
<view class="tips">
|
||||
开启后,用户还车时会校验手机附近设备,若不匹配则视为无效定位,可以降低异地还车的风险
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card_li">
|
||||
<view class="tops">
|
||||
<view class="card_left">
|
||||
|
|
@ -345,6 +321,19 @@
|
|||
开启后当进入禁行区内将进行断电
|
||||
</view>
|
||||
</view>
|
||||
<view class="card_li" v-if="form.enableChange">
|
||||
<view class="tops">
|
||||
<view class="card_left">
|
||||
换车校验位置
|
||||
</view>
|
||||
<view class="card_right">
|
||||
<u-switch v-model="form.changeCheck"></u-switch>
|
||||
</view>
|
||||
</view>
|
||||
<view class="tips">
|
||||
开启后用户换车是否需要校验位置
|
||||
</view>
|
||||
</view>
|
||||
<view class="card_li">
|
||||
<view class="tops">
|
||||
<view class="card_left">
|
||||
|
|
@ -449,6 +438,19 @@
|
|||
<view class="biaoti">
|
||||
还车设置
|
||||
</view>
|
||||
<view class="card_li">
|
||||
<view class="tops">
|
||||
<view class="card_left">
|
||||
手机校验附近设备
|
||||
</view>
|
||||
<view class="card_right">
|
||||
<u-switch v-model="form.mobileCheckMac"></u-switch>
|
||||
</view>
|
||||
</view>
|
||||
<view class="tips">
|
||||
开启后,用户还车时会校验手机附近设备,若不匹配则视为无效定位,可以降低异地还车的风险
|
||||
</view>
|
||||
</view>
|
||||
<view class="card_li">
|
||||
<view class="tops">
|
||||
<view class="card_left">
|
||||
|
|
@ -564,6 +566,7 @@
|
|||
{{ submitting ? '保存中…' : '保存' }}
|
||||
</view>
|
||||
</view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -961,46 +964,26 @@
|
|||
})
|
||||
},
|
||||
_uploadGuideVideoToQiniu(filePath) {
|
||||
uni.showLoading({
|
||||
title: '上传中...',
|
||||
mask: true
|
||||
})
|
||||
let _this = this
|
||||
let math = 'static/' + _this.$u.guid(20) + '.mp4'
|
||||
uni.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
filePath: filePath,
|
||||
formData: {
|
||||
token: _this.qiniuToken,
|
||||
key: 'bike/video/' + math
|
||||
},
|
||||
success: function(res) {
|
||||
uni.hideLoading()
|
||||
try {
|
||||
let str = JSON.parse(res.data)
|
||||
_this.$set(_this.form, 'guideVideo', 'https://api.ccttiot.com/' + str.key)
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
})
|
||||
} catch (e) {
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: function() {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
_this.$uploadQiniuFile({
|
||||
filePath,
|
||||
token: _this.qiniuToken,
|
||||
key: 'bike/video/' + math,
|
||||
title: '上传引导视频'
|
||||
}).then((url) => {
|
||||
_this.$set(_this.form, 'guideVideo', url)
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
})
|
||||
}).catch(() => {
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
})
|
||||
},
|
||||
removeGuideVideo() {
|
||||
|
|
|
|||
|
|
@ -108,10 +108,13 @@
|
|||
</scroll-view>
|
||||
<view hover-class="app-tap-hover" class="no-picker-cancel" @click="closeNoPicker">取消</view>
|
||||
</view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { showQiniuUploadProgress, hideQiniuUploadProgress } from '@/common/qiniuUploadProgress.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
|
@ -221,6 +224,7 @@
|
|||
},
|
||||
// 上传文件
|
||||
uploadFile() {
|
||||
// #ifdef H5
|
||||
if (!this.token) {
|
||||
uni.showToast({
|
||||
title: '上传token获取失败,请重试',
|
||||
|
|
@ -229,8 +233,6 @@
|
|||
})
|
||||
return
|
||||
}
|
||||
|
||||
// #ifdef H5
|
||||
// H5使用input选择文件
|
||||
const input = document.createElement('input')
|
||||
input.type = 'file'
|
||||
|
|
@ -310,40 +312,40 @@
|
|||
},
|
||||
// 上传到七牛云
|
||||
uploadToQiniu(filePath) {
|
||||
uni.showLoading({
|
||||
title: '上传中...',
|
||||
mask: true
|
||||
})
|
||||
|
||||
let _this = this
|
||||
let math = 'static/' + _this.$u.guid(20) + '.mp3'
|
||||
|
||||
let key = 'bike/audio/' + math
|
||||
|
||||
// #ifdef H5
|
||||
// H5需要先读取文件
|
||||
// H5需要先读取文件(仍用 fetch,配合全局上传进度占位)
|
||||
const reader = new FileReader()
|
||||
reader.onload = (e) => {
|
||||
showQiniuUploadProgress('上传语音')
|
||||
const blob = e.target.result
|
||||
const formData = new FormData()
|
||||
formData.append('file', blob)
|
||||
formData.append('token', _this.token)
|
||||
formData.append('key', 'bike/audio/' + math)
|
||||
|
||||
formData.append('key', key)
|
||||
|
||||
fetch('https://up-z2.qiniup.com', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
}).then(res => res.json()).then(data => {
|
||||
if (!data || !data.key) {
|
||||
throw new Error('upload failed')
|
||||
}
|
||||
hideQiniuUploadProgress()
|
||||
_this.destroyPreviewAudio()
|
||||
_this.fileUrl = _this.upurl + '/' + data.key
|
||||
_this.fileName = filePath.name || 'audio.mp3'
|
||||
_this.preloadPreviewDuration()
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
}).catch(err => {
|
||||
uni.hideLoading()
|
||||
hideQiniuUploadProgress()
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none',
|
||||
|
|
@ -353,47 +355,33 @@
|
|||
}
|
||||
reader.readAsArrayBuffer(filePath)
|
||||
// #endif
|
||||
|
||||
|
||||
// #ifndef H5
|
||||
wx.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
filePath: filePath,
|
||||
formData: {
|
||||
token: _this.token,
|
||||
key: 'bike/audio/' + math
|
||||
},
|
||||
success: function(res) {
|
||||
try {
|
||||
let str = JSON.parse(res.data)
|
||||
_this.destroyPreviewAudio()
|
||||
_this.fileUrl = _this.upurl + '/' + str.key
|
||||
_this.fileName = 'audio.mp3'
|
||||
_this.preloadPreviewDuration()
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
} catch(e) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: function() {
|
||||
uni.hideLoading()
|
||||
;(async () => {
|
||||
try {
|
||||
const url = await _this.$uploadQiniuFile({
|
||||
filePath,
|
||||
key,
|
||||
title: '上传语音',
|
||||
showProgress: true
|
||||
})
|
||||
_this.destroyPreviewAudio()
|
||||
_this.fileUrl = url
|
||||
_this.fileName = 'audio.mp3'
|
||||
_this.preloadPreviewDuration()
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
} catch (e) {
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
})()
|
||||
// #endif
|
||||
},
|
||||
// 移除文件
|
||||
|
|
|
|||
|
|
@ -142,10 +142,13 @@
|
|||
</scroll-view>
|
||||
<view hover-class="app-tap-hover" class="no-picker-cancel" @click="closeNoPicker">取消</view>
|
||||
</view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { showQiniuUploadProgress, hideQiniuUploadProgress } from '@/common/qiniuUploadProgress.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
|
@ -312,6 +315,7 @@
|
|||
},
|
||||
// 上传文件
|
||||
uploadFile() {
|
||||
// #ifdef H5
|
||||
if (!this.token) {
|
||||
uni.showToast({
|
||||
title: '上传token获取失败,请重试',
|
||||
|
|
@ -320,8 +324,6 @@
|
|||
})
|
||||
return
|
||||
}
|
||||
|
||||
// #ifdef H5
|
||||
// H5使用input选择文件
|
||||
const input = document.createElement('input')
|
||||
input.type = 'file'
|
||||
|
|
@ -401,81 +403,39 @@
|
|||
},
|
||||
// 上传到七牛云
|
||||
uploadToQiniu(filePath) {
|
||||
uni.showLoading({
|
||||
title: '上传中...',
|
||||
mask: true
|
||||
})
|
||||
|
||||
let _this = this
|
||||
let math = 'static/' + _this.$u.guid(20) + '.mp3'
|
||||
|
||||
// #ifndef H5
|
||||
wx.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
filePath: filePath,
|
||||
formData: {
|
||||
token: _this.token,
|
||||
key: 'bike/audio/' + math
|
||||
},
|
||||
success: function(res) {
|
||||
try {
|
||||
let str = JSON.parse(res.data)
|
||||
_this.destroyPreviewAudio()
|
||||
_this.editForm.fileUrl = _this.upurl + '/' + str.key
|
||||
_this.fileName = 'audio.mp3'
|
||||
_this.preloadPreviewDuration()
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
} catch(e) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: function() {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
|
||||
let key = 'bike/audio/' + math
|
||||
|
||||
// #ifdef H5
|
||||
const reader = new FileReader()
|
||||
reader.onload = (e) => {
|
||||
showQiniuUploadProgress('上传语音')
|
||||
const blob = e.target.result
|
||||
const formData = new FormData()
|
||||
formData.append('file', blob)
|
||||
formData.append('token', _this.token)
|
||||
formData.append('key', 'bike/audio/' + math)
|
||||
|
||||
formData.append('key', key)
|
||||
|
||||
fetch('https://up-z2.qiniup.com', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
}).then(res => res.json()).then(data => {
|
||||
if (!data || !data.key) {
|
||||
throw new Error('upload failed')
|
||||
}
|
||||
hideQiniuUploadProgress()
|
||||
_this.destroyPreviewAudio()
|
||||
_this.editForm.fileUrl = _this.upurl + '/' + data.key
|
||||
_this.fileName = filePath.name || 'audio.mp3'
|
||||
_this.preloadPreviewDuration()
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
}).catch(err => {
|
||||
uni.hideLoading()
|
||||
hideQiniuUploadProgress()
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none',
|
||||
|
|
@ -485,6 +445,34 @@
|
|||
}
|
||||
reader.readAsArrayBuffer(filePath)
|
||||
// #endif
|
||||
|
||||
// #ifndef H5
|
||||
;(async () => {
|
||||
try {
|
||||
const url = await _this.$uploadQiniuFile({
|
||||
filePath,
|
||||
key,
|
||||
title: '上传语音',
|
||||
showProgress: true
|
||||
})
|
||||
_this.destroyPreviewAudio()
|
||||
_this.editForm.fileUrl = url
|
||||
_this.fileName = 'audio.mp3'
|
||||
_this.preloadPreviewDuration()
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
} catch (e) {
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})()
|
||||
// #endif
|
||||
},
|
||||
// 移除文件
|
||||
removeFile() {
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@
|
|||
<view class="container">
|
||||
<view class="scroll-text">
|
||||
<view class="scroll-item">
|
||||
{{announcements.title == null ? '暂无最新公告' : announcements.title}}
|
||||
{{announcements.title == null ? '暂无最新公告' : announcements.title}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@
|
|||
<view class="tip">操作提示</view>
|
||||
<view class="ipt_box" style="justify-content: center;">
|
||||
<view class="text" style="width: 80%;text-align: center;">
|
||||
有订单的情况下,管理员开锁当前设备有订单,请选择改开启后的车辆状态
|
||||
当前设备已有订单,开锁前请选定车辆后续状态
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@
|
|||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -154,21 +155,15 @@ export default {
|
|||
sourceType: ['album', 'camera'],
|
||||
success(res) {
|
||||
const tempFilePaths = res.tempFilePaths[0]
|
||||
wx.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
_this.$uploadQiniuFile({
|
||||
filePath: tempFilePaths,
|
||||
formData: {
|
||||
token: _this.token, //后端返回的token
|
||||
key: 'smartmeter/img/' + math
|
||||
},
|
||||
success: function(res) {
|
||||
console.log(res, 'resres');
|
||||
let str = JSON.parse(res.data)
|
||||
let tempFilePaths = 'https://api.ccttiot.com/' + str.key
|
||||
_this.imglist = tempFilePaths
|
||||
console.log(_this.imglist);
|
||||
}
|
||||
token: _this.token,
|
||||
key: 'smartmeter/img/' + math,
|
||||
title: '上传发票'
|
||||
}).then((url) => {
|
||||
_this.imglist = url
|
||||
}).catch(() => {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -669,6 +669,7 @@
|
|||
</view>
|
||||
<view style="background-color: rgba(0, 0, 0, .5);width: 100%;height: 100vh;position: fixed;top: 0;left: 0;z-index: 999;"
|
||||
v-if="showChangeBike"></view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -992,13 +993,6 @@ import ZhimaNoDepositBadge from '@/components/zhima-no-deposit-badge/zhima-no-de
|
|||
uni.showToast({ title: '请等待当前图片上传完成', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!this.qiniuToken) {
|
||||
await this.getQiniuTokenAsync()
|
||||
}
|
||||
if (!this.qiniuToken) {
|
||||
uni.showToast({ title: '获取上传凭证失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const remain = 9 - this.damageImageList.length - this.damageImageUploadingList.length
|
||||
if (remain <= 0) return
|
||||
uni.chooseImage({
|
||||
|
|
@ -1012,13 +1006,15 @@ import ZhimaNoDepositBadge from '@/components/zhima-no-deposit-badge/zhima-no-de
|
|||
paths.forEach((tempPath, i) => {
|
||||
this.damageImageUploadingList.push({ tempPath, uid: uids[i] })
|
||||
})
|
||||
uni.showLoading({ title: '上传中...', mask: true })
|
||||
try {
|
||||
const urls = await Promise.all(paths.map((p) => this.uploadVerifyDamageFile(p)))
|
||||
const valid = []
|
||||
for (let i = 0; i < paths.length; i++) {
|
||||
const url = await this.uploadVerifyDamageFile(paths[i])
|
||||
if (url) valid.push(url)
|
||||
}
|
||||
this.damageImageUploadingList = this.damageImageUploadingList.filter(
|
||||
(x) => !uids.includes(x.uid)
|
||||
)
|
||||
const valid = urls.filter(Boolean)
|
||||
this.damageImageList = this.damageImageList.concat(valid).slice(0, 9)
|
||||
if (valid.length) {
|
||||
uni.showToast({ title: '上传成功', icon: 'success' })
|
||||
|
|
@ -1030,39 +1026,22 @@ import ZhimaNoDepositBadge from '@/components/zhima-no-deposit-badge/zhima-no-de
|
|||
(x) => !uids.includes(x.uid)
|
||||
)
|
||||
uni.showToast({ title: '部分图片上传失败', icon: 'none' })
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
uploadVerifyDamageFile(filePath) {
|
||||
const _this = this
|
||||
const math = 'static/' + _this.$u.guid(20)
|
||||
return new Promise((resolve) => {
|
||||
uni.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
async uploadVerifyDamageFile(filePath) {
|
||||
const math = 'static/' + this.$u.guid(20)
|
||||
try {
|
||||
return await this.$uploadQiniuFile({
|
||||
filePath,
|
||||
name: 'file',
|
||||
formData: {
|
||||
token: _this.qiniuToken,
|
||||
key: 'bike/img/' + math
|
||||
},
|
||||
success: (upRes) => {
|
||||
try {
|
||||
const body = JSON.parse(upRes.data || '{}')
|
||||
if (body.key) {
|
||||
resolve('https://api.ccttiot.com/' + body.key)
|
||||
} else {
|
||||
resolve('')
|
||||
}
|
||||
} catch (e) {
|
||||
resolve('')
|
||||
}
|
||||
},
|
||||
fail: () => resolve('')
|
||||
key: 'bike/img/' + math,
|
||||
title: '上传车损图片',
|
||||
showProgress: true
|
||||
})
|
||||
})
|
||||
} catch (e) {
|
||||
return ''
|
||||
}
|
||||
},
|
||||
removeVerifyDamage(index) {
|
||||
this.damageImageList.splice(index, 1)
|
||||
|
|
@ -1073,14 +1052,6 @@ import ZhimaNoDepositBadge from '@/components/zhima-no-deposit-badge/zhima-no-de
|
|||
urls: this.damageImageList
|
||||
})
|
||||
},
|
||||
getQiniuTokenAsync() {
|
||||
return this.$u.get('/common/qiniuToken').then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.qiniuToken = res.data
|
||||
}
|
||||
return this.qiniuToken
|
||||
}).catch(() => '')
|
||||
},
|
||||
// 通过审核
|
||||
btnqd(){
|
||||
if (this.verifyAuditBusy) {
|
||||
|
|
@ -1558,27 +1529,18 @@ import ZhimaNoDepositBadge from '@/components/zhima-no-deposit-badge/zhima-no-de
|
|||
},
|
||||
// 上传故障图片
|
||||
uploadFaultImage() {
|
||||
if (!this.qiniuToken) {
|
||||
uni.showToast({
|
||||
title: '上传token获取失败,请重试',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
this.getQiniuToken()
|
||||
return
|
||||
}
|
||||
let _this = this
|
||||
let math = 'static/' + _this.$u.guid(20)
|
||||
const _this = this
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success(res) {
|
||||
const tempFilePaths = res.tempFilePaths[0]
|
||||
const math = 'static/' + _this.$u.guid(20)
|
||||
// 检查文件大小(5MB)
|
||||
uni.getFileInfo({
|
||||
filePath: tempFilePaths,
|
||||
success(fileInfo) {
|
||||
async success(fileInfo) {
|
||||
if (fileInfo.size > 5 * 1024 * 1024) {
|
||||
uni.showToast({
|
||||
title: '图片大小不能超过5MB',
|
||||
|
|
@ -1587,47 +1549,26 @@ import ZhimaNoDepositBadge from '@/components/zhima-no-deposit-badge/zhima-no-de
|
|||
})
|
||||
return
|
||||
}
|
||||
// 显示上传加载提示
|
||||
uni.showLoading({
|
||||
title: '图片上传中...',
|
||||
mask: true
|
||||
})
|
||||
// 上传到七牛云
|
||||
wx.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
filePath: tempFilePaths,
|
||||
formData: {
|
||||
token: _this.qiniuToken,
|
||||
key: 'bike/img/' + math
|
||||
},
|
||||
success: function(res) {
|
||||
uni.hideLoading()
|
||||
try {
|
||||
let str = JSON.parse(res.data)
|
||||
_this.faultPicture = 'https://api.ccttiot.com/' + str.key
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
})
|
||||
} catch (e) {
|
||||
uni.showToast({
|
||||
title: '上传失败,请重试',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: function(err) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '上传失败,请重试',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
try {
|
||||
const url = await _this.$uploadQiniuFile({
|
||||
filePath: tempFilePaths,
|
||||
key: 'bike/img/' + math,
|
||||
title: '上传故障图片',
|
||||
showProgress: true
|
||||
})
|
||||
_this.faultPicture = url
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
})
|
||||
} catch (e) {
|
||||
uni.showToast({
|
||||
title: '上传失败,请重试',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
|
|
|||
|
|
@ -185,12 +185,13 @@
|
|||
<view class="tips-item">4. 上传后请等待审核,审核通过后方可使用</view>
|
||||
</view>
|
||||
</view>
|
||||
<view hover-class="app-tap-hover" class="bottom-btn"
|
||||
:class="bottomBtnClass"
|
||||
@click="handleBottomBtnClick()"
|
||||
v-if="!isViewMode || normalizedStatus === 'REJECT' || (isViewMode && status)">
|
||||
<text>{{getBottomBtnText()}}</text>
|
||||
</view>
|
||||
<view hover-class="app-tap-hover" class="bottom-btn"
|
||||
:class="bottomBtnClass"
|
||||
@click="handleBottomBtnClick()"
|
||||
v-if="!isViewMode || normalizedStatus === 'REJECT' || (isViewMode && status)">
|
||||
<text>{{getBottomBtnText()}}</text>
|
||||
</view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -329,7 +330,7 @@
|
|||
return
|
||||
}
|
||||
|
||||
// uploadImage 已经开启了 loading,这里更新文字即可
|
||||
// 上传完成后由 recognizeImage 显示识别 loading
|
||||
uni.showLoading({
|
||||
title: '智能识别中...',
|
||||
mask: true
|
||||
|
|
@ -835,60 +836,26 @@
|
|||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 显示上传加载提示
|
||||
uni.showLoading({
|
||||
title: '图片上传中...',
|
||||
mask: true
|
||||
})
|
||||
|
||||
// 上传到七牛云
|
||||
wx.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
_this.$uploadQiniuFile({
|
||||
filePath: tempFilePaths,
|
||||
formData: {
|
||||
token: _this.token,
|
||||
key: 'smartmeter/img/' + math
|
||||
},
|
||||
success: function(res) {
|
||||
try {
|
||||
let str = JSON.parse(res.data)
|
||||
let imageUrl = 'https://api.ccttiot.com/' + str.key
|
||||
// 根据类型设置对应的图片
|
||||
if(type === 'face'){
|
||||
_this.legalIdCardFace = imageUrl
|
||||
} else if(type === 'national'){
|
||||
_this.legalIdCardNational = imageUrl
|
||||
} else {
|
||||
_this.licenseImage = imageUrl
|
||||
}
|
||||
// 不在这里隐藏 loading,而是转到识别
|
||||
// uni.showToast({
|
||||
// title: '上传成功',
|
||||
// icon: 'success',
|
||||
// duration:3000
|
||||
// })
|
||||
|
||||
// 触发OCR识别
|
||||
_this.recognizeImage(type, imageUrl)
|
||||
} catch(e) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '上传失败,请重试',
|
||||
icon: 'none',
|
||||
duration:3000
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: function() {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '上传失败,请重试',
|
||||
icon: 'none',
|
||||
duration:3000
|
||||
})
|
||||
token: _this.token,
|
||||
key: 'smartmeter/img/' + math,
|
||||
title: '上传图片'
|
||||
}).then((imageUrl) => {
|
||||
if(type === 'face'){
|
||||
_this.legalIdCardFace = imageUrl
|
||||
} else if(type === 'national'){
|
||||
_this.legalIdCardNational = imageUrl
|
||||
} else {
|
||||
_this.licenseImage = imageUrl
|
||||
}
|
||||
_this.recognizeImage(type, imageUrl)
|
||||
}).catch(() => {
|
||||
uni.showToast({
|
||||
title: '上传失败,请重试',
|
||||
icon: 'none',
|
||||
duration:3000
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
<view hover-class="app-tap-hover" class="sbjl" @click="btnzgjl">
|
||||
历史上报记录 <image src="https://api.ccttiot.com/smartmeter/img/static/uVbMMNz0STQy3PMImgRJ" mode=""></image>
|
||||
</view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -238,30 +239,30 @@
|
|||
})
|
||||
},
|
||||
btn() {
|
||||
let _this = this
|
||||
let math = 'static/' + _this.$u.guid(20)
|
||||
const math = 'static/' + this.$u.guid(20)
|
||||
uni.chooseImage({
|
||||
count: 9,
|
||||
type: 'all',
|
||||
success(res) {
|
||||
const tempFilePaths = res.tempFiles
|
||||
wx.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
filePath: tempFilePaths[0].path,
|
||||
formData: {
|
||||
token: _this.token, //后端返回的token
|
||||
key: 'smartmeter/img/' + math
|
||||
},
|
||||
success: function(res) {
|
||||
console.log(res, 'resres');
|
||||
let str = JSON.parse(res.data)
|
||||
console.log(str.key)
|
||||
_this.userImgs = 'https://api.ccttiot.com/' + str.key
|
||||
console.log(_this.userImgs)
|
||||
_this.imglist.push(_this.userImgs)
|
||||
}
|
||||
})
|
||||
success: async (res) => {
|
||||
const filePath = res.tempFiles[0].path
|
||||
if (!this.token) {
|
||||
this.token = await this.$fetchQiniuToken()
|
||||
}
|
||||
if (!this.token) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
try {
|
||||
const url = await this.$uploadQiniuFile({
|
||||
filePath,
|
||||
token: this.token,
|
||||
key: 'smartmeter/img/' + math,
|
||||
title: '上传故障图片'
|
||||
})
|
||||
this.imglist.push(url)
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,15 +3,18 @@
|
|||
<u-navbar title="还车" :border-bottom="false" :background="bgc" title-color='#fff' title-size='36' height='45'
|
||||
back-icon-color='#fff'></u-navbar>
|
||||
<view class="tip_box">
|
||||
请将车辆正确停放指定停车点后,环绕车拍摄视 频,押金将在审核通过后退还账户
|
||||
请将车辆正确停放指定停车点后,环绕车拍摄视频,押金将在审核通过后退还账户
|
||||
</view>
|
||||
<view class="cont">
|
||||
<view class="tip_txt">
|
||||
我们将在12小时内完成审核
|
||||
</view>
|
||||
<view class="vadio_png1">
|
||||
<image hover-class="app-tap-hover" @click="recordVideo" class="backimg" src="https://api.ccttiot.com/smartmeter/img/static/uTwV4aH6HbxqmM1ssvTs" mode="" v-if="videoUrl==''"></image>
|
||||
<video class="vad" :src="videoUrl" controls="controls" style="width: 100%;" v-if="videoUrl!=''"></video>
|
||||
<image hover-class="app-tap-hover" @click="recordVideo" class="backimg" src="https://api.ccttiot.com/smartmeter/img/static/uTwV4aH6HbxqmM1ssvTs" mode="" v-if="!videoUrl"></image>
|
||||
<view class="video-wrap" v-else>
|
||||
<video class="vad" :src="videoUrl" controls="controls"></video>
|
||||
<view hover-class="app-tap-hover" class="reupload-btn" @click.stop="recordVideo">重新上传</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="tip_txt" style="font-weight: 500;font-size: 32rpx;color: #3D3D3D;margin-top: 30rpx;">
|
||||
保持车辆录像的完整清晰,不要随意拍摄,确保视频中车辆出境,并且出现车牌号
|
||||
|
|
@ -42,6 +45,7 @@
|
|||
</view>
|
||||
</view>
|
||||
<view class="mask" v-if="fjflag"></view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -56,8 +60,6 @@
|
|||
},
|
||||
videoPath: '',
|
||||
imglist:[],
|
||||
token: '',
|
||||
upurl:'',
|
||||
orderinfo:{},
|
||||
userId:'',
|
||||
videoUrl:'',
|
||||
|
|
@ -68,7 +70,8 @@
|
|||
mac:'',
|
||||
scdevlist:[],
|
||||
endOrderRetryCount: 0, // 结束订单重试计数器
|
||||
bluetoothQValue: null // 蓝牙关锁的q值
|
||||
bluetoothQValue: null, // 蓝牙关锁的q值
|
||||
videoUploading: false,
|
||||
}
|
||||
},
|
||||
onLoad(e) {
|
||||
|
|
@ -82,9 +85,6 @@
|
|||
}
|
||||
console.log(e,this.flag);
|
||||
},
|
||||
onShow() {
|
||||
this.getQiniuToken()
|
||||
},
|
||||
methods: {
|
||||
// 点击缴纳罚金继续还车
|
||||
btnfajin(){
|
||||
|
|
@ -221,9 +221,10 @@
|
|||
mask: true
|
||||
})
|
||||
if(this.videoUrl == ''){
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '请上传还车视频',
|
||||
icon: 'success',
|
||||
icon: 'none',
|
||||
duration: 5000
|
||||
})
|
||||
return
|
||||
|
|
@ -501,24 +502,21 @@
|
|||
}
|
||||
})
|
||||
},
|
||||
getQiniuToken() {
|
||||
console.log('diaou')
|
||||
this.$u.get("/common/qiniuToken").then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.token = res.data
|
||||
}
|
||||
})
|
||||
},
|
||||
recordVideo() {
|
||||
// 调用录像API
|
||||
if (this.videoUploading) {
|
||||
uni.showToast({
|
||||
title: '正在上传中,请稍候',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
uni.chooseVideo({
|
||||
sourceType: ['camera'], // 指定使用相机录像
|
||||
camera: 'back', // 指定使用后置摄像头,可选值有front、back
|
||||
maxDuration: 15, // 最大录制时长(秒)
|
||||
sourceType: ['camera'],
|
||||
camera: 'back',
|
||||
maxDuration: 15,
|
||||
success: (res) => {
|
||||
// 获取视频录制文件的临时路径
|
||||
this.videoPath = res.tempFilePath
|
||||
console.log(res.tempFilePath)
|
||||
this.videoUrl = ''
|
||||
this.upload()
|
||||
},
|
||||
fail: (err) => {
|
||||
|
|
@ -526,29 +524,36 @@
|
|||
}
|
||||
})
|
||||
},
|
||||
upload(){
|
||||
uni.showLoading({
|
||||
title:'上传中'
|
||||
})
|
||||
let _this=this
|
||||
let math='static/'+_this.$u.guid(20)
|
||||
wx.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
filePath: this.videoPath,
|
||||
formData: {
|
||||
token: _this.token, //后端返回的token
|
||||
key:'bike/video/'+math
|
||||
},
|
||||
success: function(res) {
|
||||
uni.hideLoading()
|
||||
console.log(res,'resres');
|
||||
let str = JSON.parse(res.data)
|
||||
console.log(str.key)
|
||||
_this.videoUrl = 'https://api.ccttiot.com/' + str.key
|
||||
console.log(_this.userImgs)
|
||||
}
|
||||
})
|
||||
async upload() {
|
||||
if (!this.videoPath) {
|
||||
uni.showToast({
|
||||
title: '请先录制视频',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
const math = 'static/' + this.$u.guid(20)
|
||||
this.videoUploading = true
|
||||
try {
|
||||
const url = await this.$uploadQiniuFile({
|
||||
filePath: this.videoPath,
|
||||
key: 'bike/video/' + math,
|
||||
title: '上传还车视频',
|
||||
showProgress: true
|
||||
})
|
||||
this.videoUrl = url
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success'
|
||||
})
|
||||
} catch (e) {
|
||||
uni.showToast({
|
||||
title: '上传失败,请重试',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.videoUploading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -650,6 +655,23 @@
|
|||
width: 672rpx;
|
||||
height: 370rpx;
|
||||
}
|
||||
.video-wrap {
|
||||
position: relative;
|
||||
width: 672rpx;
|
||||
height: 370rpx;
|
||||
}
|
||||
.reupload-btn {
|
||||
position: absolute;
|
||||
right: 16rpx;
|
||||
bottom: 16rpx;
|
||||
z-index: 12;
|
||||
padding: 10rpx 24rpx;
|
||||
background: rgba(66, 151, 243, 0.92);
|
||||
border-radius: 30rpx;
|
||||
font-size: 24rpx;
|
||||
color: #fff;
|
||||
font-weight: 500;
|
||||
}
|
||||
.tip_img{
|
||||
position: absolute;
|
||||
top: 72rpx;
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@
|
|||
<view hover-class="app-tap-hover" class="btns" @click="subs()">
|
||||
提交
|
||||
</view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -167,9 +168,8 @@ export default {
|
|||
camera: 'back', // 指定使用后置摄像头,可选值有front、back
|
||||
maxDuration: 15, // 最大录制时长(秒)
|
||||
success: (res) => {
|
||||
// 获取视频录制文件的临时路径
|
||||
this.videoPath = res.tempFilePath;
|
||||
console.log(res.tempFilePath);
|
||||
this.videoUrl = '';
|
||||
this.upload()
|
||||
},
|
||||
fail: (err) => {
|
||||
|
|
@ -177,36 +177,26 @@ export default {
|
|||
}
|
||||
})
|
||||
},
|
||||
upload(){
|
||||
uni.showLoading({
|
||||
title:'上传中'
|
||||
})
|
||||
let _this = this
|
||||
let math = 'static/'+_this.$u.guid(20)
|
||||
wx.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
filePath: this.videoPath,
|
||||
formData: {
|
||||
token: _this.token, //后端返回的token
|
||||
key:'bike/video/'+math
|
||||
},
|
||||
success: function(res) {
|
||||
if(res.data){
|
||||
uni.hideLoading()
|
||||
console.log(res,'resres');
|
||||
let str = JSON.parse(res.data)
|
||||
console.log(str.key)
|
||||
_this.videoUrl = 'https://api.ccttiot.com/' + str.key
|
||||
}else{
|
||||
uni.showToast({
|
||||
title: '上传视频失败',
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
async upload() {
|
||||
const math = 'static/' + this.$u.guid(20)
|
||||
if (!this.token) {
|
||||
this.token = await this.$fetchQiniuToken()
|
||||
}
|
||||
if (!this.token) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
try {
|
||||
const url = await this.$uploadQiniuFile({
|
||||
filePath: this.videoPath,
|
||||
token: this.token,
|
||||
key: 'bike/video/' + math,
|
||||
title: '上传车辆视频'
|
||||
})
|
||||
this.videoUrl = url
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
}
|
||||
},
|
||||
// 点击进行换车
|
||||
subs(){
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
<view hover-class="app-tap-hover" class="tj" v-else @click="btntj">
|
||||
提交
|
||||
</view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -103,32 +104,34 @@
|
|||
})
|
||||
},
|
||||
btn(num) {
|
||||
let _this = this
|
||||
let math = 'static/' + _this.$u.guid(20)
|
||||
const math = 'static/' + this.$u.guid(20)
|
||||
uni.chooseImage({
|
||||
count: 9,
|
||||
type: 'all',
|
||||
success(res) {
|
||||
const tempFilePaths = res.tempFiles
|
||||
wx.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
filePath: tempFilePaths[0].path,
|
||||
formData: {
|
||||
token: _this.token, //后端返回的token
|
||||
key: 'smartmeter/img/' + math
|
||||
},
|
||||
success: function(res) {
|
||||
console.log(res, 'resres');
|
||||
let str = JSON.parse(res.data)
|
||||
console.log(str,num);
|
||||
if(num == 1){
|
||||
_this.zhengpic = 'https://api.ccttiot.com/' + str.key
|
||||
}else{
|
||||
_this.fanpic = 'https://api.ccttiot.com/' + str.key
|
||||
}
|
||||
success: async (res) => {
|
||||
const filePath = res.tempFiles[0].path
|
||||
if (!this.token) {
|
||||
this.token = await this.$fetchQiniuToken()
|
||||
}
|
||||
if (!this.token) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
try {
|
||||
const url = await this.$uploadQiniuFile({
|
||||
filePath,
|
||||
token: this.token,
|
||||
key: 'smartmeter/img/' + math,
|
||||
title: '上传驾驶证照片'
|
||||
})
|
||||
if (num == 1) {
|
||||
this.zhengpic = url
|
||||
} else {
|
||||
this.fanpic = url
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
|
|
|||
|
|
@ -380,6 +380,7 @@
|
|||
<view hover-class="app-tap-hover" class="btn confirm" @click="confirmDepositVerify">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -413,7 +414,6 @@ export default {
|
|||
depositRemark: "",
|
||||
depositItemId: "",
|
||||
isRefreshing: false,
|
||||
token: "",
|
||||
damageImageList: [],
|
||||
auditCheckVideo: "",
|
||||
auditFinishVideo: "",
|
||||
|
|
@ -423,9 +423,6 @@ export default {
|
|||
this.areaId = option.areaId;
|
||||
},
|
||||
onShow() {
|
||||
if (!this.token) {
|
||||
this.getQiniuToken();
|
||||
}
|
||||
if (this.currentTab === 0) {
|
||||
this.pageNum = 1;
|
||||
this.getlist();
|
||||
|
|
@ -650,26 +647,7 @@ export default {
|
|||
closeVideo() {
|
||||
this.videoUrl = "";
|
||||
},
|
||||
getQiniuToken() {
|
||||
return this.$u.get("/common/qiniuToken").then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.token = res.data;
|
||||
return res.data;
|
||||
}
|
||||
return "";
|
||||
});
|
||||
},
|
||||
async chooseDamageImages() {
|
||||
if (!this.token) {
|
||||
await this.getQiniuToken();
|
||||
}
|
||||
if (!this.token) {
|
||||
uni.showToast({
|
||||
title: "获取上传凭证失败",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const remain = 9 - this.damageImageList.length;
|
||||
if (remain <= 0) {
|
||||
uni.showToast({
|
||||
|
|
@ -684,15 +662,13 @@ export default {
|
|||
sourceType: ["album", "camera"],
|
||||
success: async (res) => {
|
||||
if (!res.tempFilePaths || !res.tempFilePaths.length) return;
|
||||
uni.showLoading({
|
||||
title: "上传中...",
|
||||
});
|
||||
const paths = res.tempFilePaths;
|
||||
const validUrls = [];
|
||||
try {
|
||||
const uploadTasks = res.tempFilePaths.map((path) =>
|
||||
this.uploadDamageImage(path),
|
||||
);
|
||||
const urls = await Promise.all(uploadTasks);
|
||||
const validUrls = urls.filter(Boolean);
|
||||
for (let i = 0; i < paths.length; i++) {
|
||||
const url = await this.uploadDamageImage(paths[i]);
|
||||
if (url) validUrls.push(url);
|
||||
}
|
||||
this.damageImageList = this.damageImageList
|
||||
.concat(validUrls)
|
||||
.slice(0, 9);
|
||||
|
|
@ -701,46 +677,33 @@ export default {
|
|||
title: "上传成功",
|
||||
icon: "success",
|
||||
});
|
||||
} else if (paths.length) {
|
||||
uni.showToast({
|
||||
title: "图片上传失败,请重试",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
title: "部分图片上传失败",
|
||||
icon: "none",
|
||||
});
|
||||
} finally {
|
||||
uni.hideLoading();
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
uploadDamageImage(filePath) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const math = "static/" + this.$u.guid(20);
|
||||
uni.uploadFile({
|
||||
url: "https://up-z2.qiniup.com",
|
||||
async uploadDamageImage(filePath) {
|
||||
const math = "static/" + this.$u.guid(20);
|
||||
try {
|
||||
return await this.$uploadQiniuFile({
|
||||
filePath,
|
||||
name: "file",
|
||||
formData: {
|
||||
token: this.token,
|
||||
key: "bike/img/" + math,
|
||||
},
|
||||
success: (res) => {
|
||||
try {
|
||||
const response = JSON.parse(res.data || "{}");
|
||||
if (response.key) {
|
||||
resolve("https://api.ccttiot.com/" + response.key);
|
||||
} else {
|
||||
reject(new Error("upload fail"));
|
||||
}
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(err);
|
||||
},
|
||||
key: "bike/img/" + math,
|
||||
title: "上传车损图片",
|
||||
showProgress: true,
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
removeDamageImage(index) {
|
||||
this.damageImageList.splice(index, 1);
|
||||
|
|
@ -756,9 +719,6 @@ export default {
|
|||
this.damageImageList = [];
|
||||
this.auditCheckVideo = "";
|
||||
this.auditFinishVideo = "";
|
||||
if (!this.token) {
|
||||
this.getQiniuToken();
|
||||
}
|
||||
const applyListFallback = () => {
|
||||
if (item.orderDeviceList && item.orderDeviceList.length) {
|
||||
const v = this.extractAuditVideosFromOrder(item);
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@
|
|||
<!-- <text>进入人脸识别</text> -->
|
||||
<text>提交</text>
|
||||
</view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -71,13 +72,14 @@
|
|||
smflag:true,
|
||||
docType: 'idcard', // 新增:证件类型
|
||||
passportImage: '' ,// 新增:护照照片路径
|
||||
token:''
|
||||
token:'',
|
||||
areaId:''
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
if(option.user){
|
||||
console.log(option);
|
||||
|
||||
console.log(option,'45465645645645645645645645645');
|
||||
if(option.areaId){
|
||||
this.areaId = option.areaId
|
||||
}
|
||||
this.getQiniuToken()
|
||||
},
|
||||
|
|
@ -100,29 +102,30 @@
|
|||
},
|
||||
// 上传头像
|
||||
choosePassportImage() {
|
||||
let _this = this
|
||||
let math = 'static/' + _this.$u.guid(20)
|
||||
const math = 'static/' + this.$u.guid(20)
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
type: 'all',
|
||||
success(res) {
|
||||
const tempFilePaths = res.tempFiles
|
||||
wx.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
filePath: tempFilePaths[0].path,
|
||||
formData: {
|
||||
token: _this.token, //后端返回的token
|
||||
key: 'smartmeter/img/' + math
|
||||
},
|
||||
success: function(res) {
|
||||
console.log(res, 'resres');
|
||||
let str = JSON.parse(res.data)
|
||||
console.log(str.key)
|
||||
_this.passportImage = 'https://api.ccttiot.com/' + str.key
|
||||
console.log(_this.passportImage);
|
||||
}
|
||||
})
|
||||
success: async (res) => {
|
||||
const filePath = res.tempFiles[0].path
|
||||
if (!this.token) {
|
||||
this.token = await this.$fetchQiniuToken()
|
||||
}
|
||||
if (!this.token) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
try {
|
||||
const url = await this.$uploadQiniuFile({
|
||||
filePath,
|
||||
token: this.token,
|
||||
key: 'smartmeter/img/' + math,
|
||||
title: '上传护照照片'
|
||||
})
|
||||
this.passportImage = url
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
|
@ -189,7 +192,8 @@
|
|||
return
|
||||
}
|
||||
let data = {
|
||||
url:this.passportImage
|
||||
url:this.passportImage,
|
||||
areaId:this.areaId
|
||||
}
|
||||
this.$u.put(`/app/realName/passportRealName`,data).then(res =>{
|
||||
if(res.code == 200){
|
||||
|
|
@ -218,6 +222,7 @@
|
|||
let data = {
|
||||
userName:this.name,
|
||||
idCard:this.zfzh,
|
||||
areaId:this.areaId
|
||||
}
|
||||
this.$u.put(`/app/realName/twoElementRealName`,data).then(res =>{ //二要素
|
||||
if(res.code == 200){
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@
|
|||
</u-button>
|
||||
</view>
|
||||
</view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -253,44 +254,30 @@ export default {
|
|||
})
|
||||
},
|
||||
// 上传图片
|
||||
uploadImage(filePath) {
|
||||
uni.showLoading({
|
||||
title: '上传中...'
|
||||
})
|
||||
async uploadImage(filePath) {
|
||||
const math = 'static/' + this.$u.guid(20)
|
||||
uni.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
filePath: filePath,
|
||||
name: 'file',
|
||||
formData: {
|
||||
if (!this.token) {
|
||||
this.token = await this.$fetchQiniuToken()
|
||||
}
|
||||
if (!this.token) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
try {
|
||||
const url = await this.$uploadQiniuFile({
|
||||
filePath,
|
||||
token: this.token,
|
||||
key: 'bike/img/' + math
|
||||
},
|
||||
success: (res) => {
|
||||
const response = JSON.parse(res.data)
|
||||
if (response.key) {
|
||||
this.bankForm.no = this.upurl + '/' + response.key
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none'
|
||||
})
|
||||
},
|
||||
complete: () => {
|
||||
uni.hideLoading()
|
||||
}
|
||||
})
|
||||
key: 'bike/img/' + math,
|
||||
title: '上传收款码'
|
||||
})
|
||||
this.bankForm.no = url
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success'
|
||||
})
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
}
|
||||
},
|
||||
submitForm() {
|
||||
this.bankForm.channelId = this.activeTypeid
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@
|
|||
</view>
|
||||
|
||||
<view hover-class="app-tap-hover" class="btn" @click="sub()">提交</view>
|
||||
<qiniu-upload-progress />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -185,30 +186,31 @@
|
|||
}
|
||||
},
|
||||
btn() {
|
||||
let _this = this
|
||||
let math = 'static/' + _this.$u.guid(20)
|
||||
const math = 'static/' + this.$u.guid(20)
|
||||
uni.chooseImage({
|
||||
count: 9,
|
||||
type: 'image',
|
||||
success(res) {
|
||||
const tempFilePaths = res.tempFiles
|
||||
wx.uploadFile({
|
||||
url: 'https://up-z2.qiniup.com',
|
||||
name: 'file',
|
||||
filePath: tempFilePaths[0].path,
|
||||
formData: {
|
||||
token: _this.token, //后端返回的token
|
||||
key: 'smartmeter/img/' + math
|
||||
},
|
||||
success: function(res) {
|
||||
console.log(res, 'resres')
|
||||
let str = JSON.parse(res.data)
|
||||
_this.userImgs = 'https://api.ccttiot.com/' + str.key
|
||||
console.log(_this.userImgs)
|
||||
_this.imglist.push(_this.userImgs)
|
||||
}
|
||||
})
|
||||
}
|
||||
success: async (res) => {
|
||||
const filePath = res.tempFiles[0].path
|
||||
if (!this.token) {
|
||||
this.token = await this.$fetchQiniuToken()
|
||||
}
|
||||
if (!this.token) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
try {
|
||||
const url = await this.$uploadQiniuFile({
|
||||
filePath,
|
||||
token: this.token,
|
||||
key: 'smartmeter/img/' + math,
|
||||
title: '上传反馈图片'
|
||||
})
|
||||
this.imglist.push(url)
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
// 获取上传七牛云token
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const store = new Vuex.Store({
|
|||
isLogin: false,
|
||||
userInfo: null,
|
||||
token:"",
|
||||
appid:'10',//1小鹿 6创享 2嵛山岛 7小兔 1福兴 10易达
|
||||
appid:'1',//1小鹿 6创享 2嵛山岛 7小兔 1福兴 10易达
|
||||
// 电动车图标
|
||||
iconobj:{
|
||||
tabcion:'https://api.ccttiot.com/smartmeter/img/static/uIiSizdNVb65ATEXvxfT', //底部导航栏图标
|
||||
|
|
|
|||
|
|
@ -266,48 +266,24 @@
|
|||
success: (chooseImageRes) => {
|
||||
const tempFilePaths = chooseImageRes.tempFiles[0].tempFilePath;
|
||||
let math = 'static/' + this.$u.guid(20)
|
||||
uni.uploadFile({
|
||||
url: this.photoUrl,
|
||||
this.$uploadQiniuFile({
|
||||
filePath: tempFilePaths,
|
||||
name: 'file',
|
||||
formData: {
|
||||
token: this.token, //后端返回的token
|
||||
key: 'smartmeter/img/' + math
|
||||
},
|
||||
success: (uploadFileRes) => {
|
||||
// console.log(uploadFileRes,'uploadFileResuploadFileRes');
|
||||
var obj = JSON.parse(uploadFileRes.data)
|
||||
// console.log(obj,'objpbj');
|
||||
this.img = 'https://api.ccttiot.com/' + obj.key
|
||||
console.log(this.img);
|
||||
this.editorCtx.insertImage({
|
||||
src: this.img,
|
||||
alt: '图像',
|
||||
success: function() {}
|
||||
})
|
||||
},
|
||||
fail(err) {
|
||||
console.log(err)
|
||||
uni.showToast({
|
||||
title: err.errMsg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
});
|
||||
// if (!this.api || !this.photoUrl) {
|
||||
// that.editorCtx.insertImage({
|
||||
// src: tempFilePaths,
|
||||
// alt: '图像',
|
||||
// success: function() {}
|
||||
// })
|
||||
// uni.showToast({
|
||||
// title: '未传入api字段或者photoUrl字段,此为临时图片路径',
|
||||
// duration: 3000,
|
||||
// icon: 'none'
|
||||
// })
|
||||
// } else {
|
||||
|
||||
// }
|
||||
token: this.token,
|
||||
key: 'smartmeter/img/' + math,
|
||||
title: '图片上传中'
|
||||
}).then((url) => {
|
||||
this.img = url
|
||||
this.editorCtx.insertImage({
|
||||
src: this.img,
|
||||
alt: '图像',
|
||||
success: function() {}
|
||||
})
|
||||
}).catch(() => {
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none'
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user