congzc 2 years ago
parent
commit
437aa9e952
2 changed files with 47 additions and 15 deletions
  1. +12
    -9
      src/api/editModel.js
  2. +35
    -6
      src/components/CutImg.vue

+ 12
- 9
src/api/editModel.js View File

@@ -1,21 +1,24 @@
import request from '@/utils/request'



// 得到声音试听文件
export function videoDetial(data) {
/**
* @description 试听MP3
* @returns id
*/
export function videoDetial(id) {
return request({
url: `/api/userVideo/videoDetial?videoId=${data}`,
url: `/api/userVideo/videoDetial?videoId=${id}`,
method: 'get',
})
}
// 得到声音试听文件
/**
* @description 上传背景图
* @returns data
*/
export function awsImgUpload(data) {
return request({
url: `/api/upload/awsImgUpload
`,
url: `/api/upload/awsImgUpload`,
method: 'post',
data:data
data
})
}

+ 35
- 6
src/components/CutImg.vue View File

@@ -47,13 +47,14 @@
left-text="取消"
right-text="选择"
@click-left="onClickLeft"
@click-right="getCropBlob"
@click-right="onClickRight"
/>
</div>
</van-popup>
</div>
</div>
</template>

<script>
import { awsImgUpload } from '@/api/editModel'
import { Toast } from 'vant'
@@ -103,16 +104,18 @@ export default {
},
methods: {
beforeRead(file) {
console.log(1)
console.log(file)
if (file.type !== 'image/jpeg' && file.type !== 'image/png') {
this.$toast('请上传 jpg/png 格式图片')
return false
}
console.log(111, file)

// console.log(111, file)
this.showCropper = true
this.imageToBase64(file)
this.imageFileName = file.name
},

imageToBase64(file) {
let reader = new FileReader()
console.log(reader)
@@ -121,22 +124,48 @@ export default {
this.option.img = reader.result
}
},
getCropBlob() {
onClickRight() {
// let formData = new FormData()
this.loadingShow = true
console.log(this.option)
// const AccessToken = localStorage.getItem
// this.$axios({
// method: 'post',
// url: `https://smapitest.malls.iformall.com/C/api/upload/awsImgUpload`,
// headers: {
// 'Content-Type': 'application/json;charset=UTF-8',
// token: AccessToken,
// 'Access-Control-Allow-Credentials': true
// },
// data: this.option.img
// }).then((res) => {
// console.log(res)
// this.loadingShow = false
// this.showCropper = false
// Toast.success('上传成功')
// })
this.pushImg({ file: this.option.img })

this.$refs.cropper.getCropBlob((data) => {
// formData.append('headFile', data, this.imageFileName)
// let blob = window.URL.createObjectURL(data)
// console.log(blob)
// formData.append('File', data, this.imageFileName)
// formData.append('id', this.$store.getters.user.userId)
console.log(data)
// console.log(formData.getAll('File'))
// console.log(data)
// this.pushImg({ file: blob })
// uploadAva(formData).then((res) => {
// this.showCropper = false
// this.$emit('update:showAta', false)
// this.$emit('update:avaUrl', res.data)
// })
})
// this.$refs.cropper.getCroppedCanvas().toBlob((blob) => {
// const formData = new FormData()
// formData.append('file', blob, 'avatar.png')

// this.pushImg({ file: blob })
// })
},
onClickLeft() {
this.loadingShow = false


Loading…
Cancel
Save