fanfan 6 months ago
commit 96b84472f7
  1. 2
      pages/cart/index.vue
  2. 45
      pages/squareDynamic/index.vue
  3. 106
      pages/squareDynamic/publish.vue
  4. BIN
      static/xls.jpeg

@ -22,7 +22,7 @@
<view class="cart-item" v-for="(item, index) in list" :key="index">
<view v-if="storeVersion == 1 && item.goods.merchant_id > 0 && item.goods.merchant" class="merchant-name" @click="toShop(item)">
<image :src="item.goods.merchant.logoImage && item.goods.merchant.logoImage[0].external_url" mode="aspectFill"></image>
<text>{{ '123456789' || item.goods.merchant.shop_name }}</text>
<text>{{ item.goods.merchant.shop_name }}</text>
<image src="@/static/arrow-right.png" mode="aspectFill"></image>
</view>
<view>

@ -24,6 +24,12 @@
<view v-if="item.imgs && item.imgs.length > 0" class="pic-list">
<image v-for="(pic, k) in item.imgs" :key="k" :src="pic.external_url" mode="aspectFill" @click="previewImages(k, item.imgs)"></image>
</view>
<view v-if="item.files && item.files.length > 0" class="file-list">
<view v-for="(file, index) in item.files" :key="index" class="file-box" @click="previewFile(file.external_url)">
<image src="/static/xls.jpeg" mode="aspectFill"></image>
<text>{{ solveFileName(file.file_name) }}</text>
</view>
</view>
<view v-if="item.goodsInfo" class="goods">
<view class="goods-box">
<image :src="item.goodsInfo.goods_image" mode="aspectFill"></image>
@ -45,10 +51,6 @@
<image src="/static/trash.png" mode="aspectFill"></image>
<view>删除文案</view>
</view>
<!-- <view class="btn" @click="previewFile(item)">
<image src="/static/trash.png" mode="aspectFill"></image>
<view>下载附件</view>
</view> -->
<view class="btn" v-if="item.imgs && item.imgs.length > 0" @click="downloadMultipleImages(item.imgs)">
<image src="/static/download.png" mode="aspectFill"></image>
<view>下载图片</view>
@ -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;

@ -6,7 +6,7 @@
<view class="upload-images">
<view v-for="(item, index) in imageList" :key="index" class="image-box">
<image :src="item" mode="aspectFill" @click="previewImage(item)"></image>
<image src="/static/delete.png" mode="aspectFill" class="delete" @click="deleteImage(index)"></image>
<image src="/static/delete.png" mode="aspectFill" class="delete" @click.stop="deleteImage(index)"></image>
</view>
<view class="upload-btn" v-if="imageList.length < 5" @click="addImage">
<image src="/static/add.png" mode="aspectFill"></image>
@ -17,6 +17,14 @@
<textarea placeholder="请输入您想发布的内容哦~" placeholder-class="textarea-placeholer" id="" cols="30" rows="10" v-model="content" maxlength="3000"></textarea>
<view class="text-num">已写<text>{{ content.length }}</text>/3000个字</view>
</view>
<view class="file-upload">
<view v-for="(file, index) in fileList" :key="index" class="file-box" @click="previewFile(file.url)">
<image src="/static/xls.jpeg" mode="aspectFill"></image>
<text>{{ file.name }}</text>
<image src="/static/delete.png" mode="aspectFill" class="delete" @click.stop="deleteFile(index)"></image>
</view>
<view class="upload-btn" @click="addFile">上传附件</view>
</view>
<view class="good">
<view class="label">关联商品:</view>
<view class="content els" :style="{ color: !good.goods_name ? '#999999' : ''}" @click="selectGood">{{ good.goods_name || '请选择' }}</view>
@ -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);
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 {

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Loading…
Cancel
Save