Bläddra i källkod

供货商小程序添加门店头像

wangning 5 år sedan
förälder
incheckning
13054d9acc

+ 14 - 2
ghsApp/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> -->
 			<!-- 登录信息 -->
@@ -60,6 +64,7 @@
 	import AppAvatarModule from '@/components/module/app-avatar'
 	import SimpleAddress from '@/components/plugin/simple-address'
 	import AppAreaSel from '@/components/app-area-sel'
+  import AppUploader from "@/components/app-uploader";
 	const form = require('@/utils/formValidation.js')
 	// api
     import { updateShop as update, addShop as add } from '@/api/shop'
@@ -70,7 +75,8 @@
 			TuiListCell,
             AppAvatarModule,
             SimpleAddress,
-            AppAreaSel
+            AppAreaSel,
+            AppUploader
 		},
 		data() {
 			return {
@@ -82,7 +88,8 @@
                     floor: '',
                     openTime: '8:00 - 22:00',
                     introduction: '',
-                    mobile: ''
+                    mobile: '',
+                    img: []
 				},
 				// 详细地址
 				showRegion: false,
@@ -114,6 +121,11 @@
 			init() {
                 this._getDet()
 			},
+       _resultData(val) {
+        console.log(val)
+        this.form.img = val;
+        // this.form.upImgList = item
+      },
 			// api
 			_getDet() {
 				let data = uni.getStorageSync('modifyShopB')

+ 26 - 3
ghsApp/src/components/app-uploader.vue

@@ -21,7 +21,15 @@
               @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
             v-if="showImgList.length < num && (multiple || showImgList.length == 0)"
@@ -114,7 +122,12 @@ export default {
     isStorage: {
       type: Boolean,
       default: false
-    }
+    },
+    // 是否需要拼接路径  true 需要 false 不需要
+     prefixShow: {
+      type: Boolean,
+      default: false
+     }
   },
   data() {
     return {
@@ -187,8 +200,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,8 +220,13 @@ export default {
           uploadPic({
             ...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);

+ 4 - 2
ghsApp/src/components/module/app-commodity.vue

@@ -43,11 +43,13 @@ import animationMins from "@/mixins/animation";
 
 import allSelectInput from "@/components/module/allSelectInput";
 import allSelectInputMins from "@/mixins/allSelectInput";
-import easyLoadimage from '@/components/easy-loadimage/easy-loadimage.vue'
+// import easyLoadimage from '@/components/easy-loadimage/easy-loadimage.vue'
 export default {
 	name: "Commodity",
 	components: {
-		AppImg,allSelectInput,easyLoadimage
+		AppImg,
+    allSelectInput,
+    // easyLoadimage
 	},
 	mixins: [animationMins,allSelectInputMins],
 	props: {