| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <template>
- <view class="">
- <view class="grid grid-square flex-sub margin-top-50" :class="col?'col-'+col:'col-' + count">
- <view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="viewImage(index)">
- <image :src="imgList[index]" mode="aspectFill"></image>
- <view class="cu-tag bg-red" @tap.stop="delImg(index)">
- <text class='cuIcon-close' style="font-size: 18rpx;"></text>
- </view>
- </view>
- <view class="border" @click="uploadShopPics" v-if="imgList.length< count">
- <text class="cuIcon-add"></text>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- props: {
- count: {
- type: Number,
- default: 4
- },
- col:String
- },
- data() {
- return {
- imgList: []
- };
- },
- methods: {
- changeImgList(data){
- this.imgList=data
- },
- async uploadShopPics() {
- let resp = await this.$mpi.chooseImage()
- let res=await this.$api.uploadFile(resp[0])
- this.imgList.push(res.data.data.link)
- this.$emit('click',this.imgList)
- },
- viewImage(index) {
- uni.previewImage({
- urls: this.imgList,
- current: index
- });
- },
- delImg(index) {
- let _this = this
- uni.showModal({
- title: '提示',
- content: '确定删除',
- success: (res) => {
- if (res.confirm) {
- _this.imgList.splice(index, 1)
- _this.$emit('delImg',this.imgList)
- }
- }
- })
- },
- }
- };
- </script>
- <style lang="scss" scoped>
- .border {
- border: 4rpx dashed #e1e1e1;
- position: relative;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .icon {
- width: 50rpx;
- height: 50rpx;
- position: absolute;
- left: 0;
- right: 0;
- bottom: 0;
- top: 0;
- margin: auto;
- }
- </style>
|