123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- <template>
- <div style="display: inline-block;">
- <view class="bank-license" v-for="item,index in Fimages" :key='index'>
- <block v-if="item">
- <img class="license-pic" :src="item" alt="" />
- <u-icon v-if="!flag" name="close" class='del-icon' size='30' @click.stop="handleRemove(item, index)">
- </u-icon>
- </block>
- </view>
- <view class="bank-license" @click="uploadAva">
- <text>+</text>
- </view>
-
- </div>
- </template>
- <script>
- import webUrl from '@/config.js';
- import qiniuUploader from './qiniuUploader.js';
- import {
- getEnToken
- } from '@/access/common.js';
- export default {
- data() {
- return {
- Fimages: []
- };
- },
- props: {
- images: {
-
- default: () => {
- return [];
- }
- },
- flag: {
- type: Boolean,
- default: false
- },
- },
- watch: {
- images(val) {
- this.Fimages = val;
- }
- },
- created() {
- this.Fimages = this.images;
- },
- methods: {
-
- uploadAva() {
- uni.chooseImage({
- success: async res => {
- const imgPath = res.tempFilePaths[0];
- const imgName = imgPath
- .split('.')
- .slice(-2)
- .join('.');
- const key = `${getEnToken()}/${imgName}`;
- this.$u.api.uploadToken({
- bucket: webUrl.QINIU_KEY,
- key: key
- }).then(data => {
- this.uploadtoken = data.data;
-
- let domain = webUrl.QINIU_UP;
- let token = data.data;
- let filePath = imgPath;
- uni.showLoading();
- qiniuUploader.upload(
- filePath,
- res => {
- uni.hideLoading();
-
-
- const imgData = {
- ...res,
- key: res.key
- };
- const uploadPicUrl = `${webUrl.QINIU_URL}/${res.key}`;
- this.$emit('uploadSuccess', imgData, uploadPicUrl);
- },
- error => {
- uni.hideLoading();
-
- }, {
- region: 'SCN',
- domain: domain,
- key: key,
-
- uptoken: token
- },
- res => {
-
- uni.hideLoading();
- if (res.progress === 100) {
-
- }
- }
- );
- });
- }
- });
- },
-
- handleRemove(url, index) {
- this.Fimages.splice(index, 1);
- this.$emit('handleRemove', this.Fimages);
- }
- }
- };
- </script>
- <style scoped lang="scss">
- .bank-license {
- width: 124upx;
- height: 124upx;
- border-radius: 8upx;
- border: 2upx #999999 dashed;
- margin: 32upx 10rpx;
- background: #eee;
- text-align: center;
- line-height: 100upx;
- color: #666;
- font-size: 100rpx;
- font-weight: 300;
- display: inline-block;
- vertical-align: middle;
- position: relative;
- .license-pic {
- width: 120upx;
- height: 120upx;
- display: block;
- }
- .del-icon {
- box-sizing: border-box;
- padding-left: 7rpx;
- position: absolute;
- color: #fff;
- right: -12rpx;
- top: -20upx;
- background-color: #FD463E;
- width: 40rpx;
- height: 40rpx;
- border-radius: 100%;
- line-height: 40rpx;
- }
- }
- </style>
|