Ver Fonte

解决了花店端上传图像的问题

wangn há 5 anos atrás
pai
commit
24f2e6424c
2 ficheiros alterados com 46 adições e 5 exclusões
  1. 17 3
      hdApp/src/admin/shop/add.vue
  2. 29 2
      hdApp/src/components/app-uploader.vue

+ 17 - 3
hdApp/src/admin/shop/add.vue

@@ -7,6 +7,10 @@
 					<div class="tui-title required">门店名称</div>
 					<input v-model="form.shopName" placeholder-class="phcolor" class="tui-input" name="shopName" placeholder="请输入名称" maxlength="50" type="text" />
 				</tui-list-cell>
+        <tui-list-cell class="line-cell" :hover="false">
+          <div class="tui-title required" >花店头像</div>
+          <app-uploader @chooseImage="_resultData" :num="4" :prefixShow="true" :imgList="form.img"/>
+        </tui-list-cell>
 			</div>
 			<!-- <div class="prompt-text">注: 请先关注公众号,绑定后可以在移动端自动登录</div> -->
 			<!-- 登录信息 -->
@@ -58,6 +62,7 @@
 <script>
 	import TuiListCell from '@/components/plugin/list-cell'
 	import AppAvatarModule from '@/components/module/app-avatar'
+  import AppUploader from "@/components/app-uploader";
 	import SimpleAddress from '@/components/plugin/simple-address'
 	import AppAreaSel from '@/components/app-area-sel'
 	const form = require('@/utils/formValidation.js')
@@ -69,7 +74,8 @@
 			TuiListCell,
             AppAvatarModule,
             SimpleAddress,
-            AppAreaSel
+            AppAreaSel,
+            AppUploader
 		},
 		data() {
 			return {
@@ -81,7 +87,8 @@
                     floor: '',
                     openTime: '8:00 - 22:00',
                     introduction: '',
-                    mobile: ''
+                    mobile: '',
+                    img: []
 				},
 				// 详细地址
 				showRegion: false,
@@ -91,7 +98,8 @@
 				},
                 // 省市联动
                 regionData: [],
-				cityPickerValueDefault: [0, 0]
+				cityPickerValueDefault: [0, 0],
+        img: []
 			}
 		},
 		onLoad() {
@@ -115,6 +123,7 @@
 			// api
 			_getDet() {
 				let data = uni.getStorageSync('modifyShopB')
+        console.log('data===>', data)
 				if (this.$util.isEmpty(data)) return
 				Object.keys(this.form).forEach((i, index) => {
 					// if (i != 'password') {
@@ -131,6 +140,11 @@
 				}
 				this.showRegion = true
 			},
+      _resultData(val) {
+        console.log(val)
+        this.form.img = val;
+        // this.form.upImgList = item
+      },
 			changeAreaFn(e) {
 				console.log('changeAreaFn', e)
 				this.form.address = e.address

+ 29 - 2
hdApp/src/components/app-uploader.vue

@@ -21,6 +21,14 @@
               @click="viewImg(item)"
               :style="{ width: size + 'rpx', height: size + 'rpx' }"
               :mode="imgMode"
+              v-if="!prefixShow"
+            />
+            <img
+              :src="`${constant.imgUrl}/${item}`"
+              @click="viewImg(item)"
+              :style="{ width: size + 'rpx', height: size + 'rpx' }"
+              :mode="imgMode"
+              v-if="prefixShow"
             />
           </li>
           <li
@@ -114,10 +122,16 @@ export default {
     isStorage: {
       type: Boolean,
       default: false
+    },
+    // 是否需要拼接路径  true 需要 false 不需要
+    prefixShow: {
+      type: Boolean,
+      default: false
     }
   },
   data() {
     return {
+      constant: this.$constant,
       resultData: {},
       showImgList: [],
       base64ImgList: [],
@@ -187,8 +201,13 @@ export default {
           picAdd({
             ...params
           }).then(res => {
+            let imgArr
             if (res.code === 1) {
-              let imgArr = [res.data.url];
+              if(this.prefixShow) {
+                imgArr = [res.data.shortUrl]
+              } else {
+                imgArr = [res.data.url];
+              }
               that.showImgList = [...that.showImgList, ...imgArr];
               that.resultData = res.data;
               this.$emit("currentUpload", imgArr);
@@ -202,9 +221,17 @@ export default {
           uploadPic({
             ...params
           }).then(res => {
+            let imgArr
+            console.log(this.prefixShow)
             if (res.code === 1) {
-              let imgArr = [res.data.url];
+              if(this.prefixShow) {
+                console.log(11111, res.data.shortUrl)
+                imgArr = [res.data.shortUrl]
+              } else {
+                imgArr = [res.data.url];
+              }
               that.showImgList = [...that.showImgList, ...imgArr];
+              console.log(222, that.showImgList)
               that.resultData = res.data;
               this.$emit("currentUpload", imgArr);
               this.$emit("getResult", that.showImgList);