diff --git a/pages/cart/index.vue b/pages/cart/index.vue index 7b74fb1..407e337 100644 --- a/pages/cart/index.vue +++ b/pages/cart/index.vue @@ -22,7 +22,7 @@ - {{ '123456789' || item.goods.merchant.shop_name }} + {{ item.goods.merchant.shop_name }} diff --git a/pages/squareDynamic/index.vue b/pages/squareDynamic/index.vue index 97e165f..a14db9c 100644 --- a/pages/squareDynamic/index.vue +++ b/pages/squareDynamic/index.vue @@ -24,6 +24,12 @@ + + + + {{ solveFileName(file.file_name) }} + + @@ -45,10 +51,6 @@ 删除文案 - 下载图片 @@ -307,6 +309,12 @@       }     }) }, + solveFileName(name) { + if (name.indexOf('.xls')) { + return name.replace('.xls', ''); + } + return name.replace('.xlsx', ''); + }, togggleLike(item, index) { Api.dynamicLike({ id: item.square_id, @@ -557,6 +565,35 @@ } } } + .file-list { + display: block; + padding: 30rpx 0; + height: fit-content; + .file-box { + border-bottom: 1px solid #ddd; + display: flex; + align-items: center; + position: relative; + padding: 10rpx 20rpx; + height: 80rpx; + margin-bottom: 20rpx; + &:last-child { + border-bottom: none; + } + >image { + width: 60rpx; + height: 60rpx; + margin: 0 10rpx 0 0; + flex-shrink: 0; + } + >text { + width: calc(100% - 70rpx); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + } + } .goods { background: #f5f5f5; padding: 20rpx; diff --git a/pages/squareDynamic/publish.vue b/pages/squareDynamic/publish.vue index 785c226..7384366 100644 --- a/pages/squareDynamic/publish.vue +++ b/pages/squareDynamic/publish.vue @@ -6,7 +6,7 @@ - + @@ -17,6 +17,14 @@ 已写{{ content.length }}/3000个字 + + + + {{ file.name }} + + + 上传附件 + 关联商品: {{ good.goods_name || '请选择' }} @@ -57,16 +65,10 @@ import * as Api from '@/api/squareDynamic/index.js' isPublish: false, loading: false, good: {}, + fileList: [], + uploadFiles: [], }; }, - watch: { - good: { - deep: true, - handler() { - console.log(this.good.goods_name); - }, - }, - }, methods: { addImage() { const that = this; @@ -79,11 +81,11 @@ import * as Api from '@/api/squareDynamic/index.js' }) { console.log(that.imageList, tempFiles); that.imageList.push(tempFiles[0].path) - that.upload(tempFiles[0]) + that.upload(tempFiles[0], 'image') } }); }, - async upload(path) { + async upload(path, type) { const that = this; // 批量上传 return new Promise((resolve, reject) => { @@ -91,7 +93,11 @@ import * as Api from '@/api/squareDynamic/index.js' UploadApi.image([path]) .then(fileIds => { console.log(fileIds); - that.uploadImages.push(fileIds[0]); + if (type === 'image') { + that.uploadImages.push(fileIds[0]); + } else { + that.uploadFiles.push(fileIds[0]) + } resolve(fileIds) }) .catch(reject) @@ -109,6 +115,39 @@ import * as Api from '@/api/squareDynamic/index.js' urls:this.imageList, }); }, + addFile() { + const that = this; + uni.chooseMessageFile({ + count: 1, + success({ + tempFiles + }) { + const nameArr = tempFiles[0].name.split('.'); + const fileType = nameArr[nameArr.length - 1]; + if (!['xls', 'xlsx'].includes(fileType)) { + uni.showToast({ + icon: 'error', + title: '文件格式错误' + }); + } + console.log(tempFiles); + that.fileList.push({ url: tempFiles[0].path, name: tempFiles[0].name.replace(`.${fileType}`, '') }); + that.upload(tempFiles[0], 'file'); + }, + fail(e) { + console.log(e); + } + }); + }, + deleteFile(index) { + this.fileList.splice(index, 1); + this.uploadFiles.splice(index, 1); + }, + previewFile(url) { + uni.openDocument({ + filePath: url, + }); + }, changePicker(e) { console.log(e); this.cateIndex = e.detail.value; @@ -135,6 +174,7 @@ import * as Api from '@/api/squareDynamic/index.js' content: this.content, cate: this.cateList[this.cateIndex], goods_id: this.good.goods_id, + files: this.uploadFiles.join(',') }) .then(res => { console.log(res); @@ -244,7 +284,7 @@ import * as Api from '@/api/squareDynamic/index.js' } } } - .cate, .good { + .cate, .good, .file-upload { margin-top: 20rpx; display: flex; justify-content: space-between; @@ -269,6 +309,48 @@ import * as Api from '@/api/squareDynamic/index.js' height: 100%; } } + .file-upload { + display: block; + padding: 30rpx; + height: fit-content; + .file-box { + border-bottom: 1px solid #ddd; + display: flex; + align-items: center; + position: relative; + padding: 10rpx 20rpx; + height: 80rpx; + margin-bottom: 20rpx; + &:last-child { + border-bottom: none; + } + >image { + &:first-child { + width: 60rpx; + height: 60rpx; + margin: 0 10rpx 0 0; + } + } + >text { + width: calc(100% - 120rpx); + } + .delete { + width: 30rpx; + height: 30rpx; + margin-left: 20rpx; + } + } + .upload-btn { + width: 160rpx; + height: 60rpx; + line-height: 60rpx; + background: #4680ff; + border-radius: 30rpx; + color: #fff; + font-size: 28rpx; + text-align: center; + } + } .good { height: fit-content; .content { diff --git a/static/xls.jpeg b/static/xls.jpeg new file mode 100644 index 0000000..52ec089 Binary files /dev/null and b/static/xls.jpeg differ