ltx529596 4 years ago
parent
commit
e65ae20f75

+ 4 - 2
src/config/index.config.js

@@ -6,7 +6,8 @@ const CONFIG = {
         // baseUrl: 'http://192.168.100.135:83/merch',  // 后台接口请求地址
         // baseUrl: 'http://192.168.100.135:83/merch',  // 后台接口请求地址
         hostUrl: 'http://localhost:8080',        // H5地址(前端运行地址)
         hostUrl: 'http://localhost:8080',        // H5地址(前端运行地址)
         websocketUrl: '',        // websocket服务端地址
         websocketUrl: '',        // websocket服务端地址
-        weixinAppId: '' // 微信公众号appid
+        weixinAppId: '', // 微信公众号appid
+        uploadUrl: 'http://tyou.xiudo.cn/merch/common/upload/oss'
     },
     },
     //生产环境配置
     //生产环境配置
     production: {
     production: {
@@ -14,7 +15,8 @@ const CONFIG = {
         baseUrl: 'https://tyou.xiudo.cn/merch',  // 后台接口请求地址
         baseUrl: 'https://tyou.xiudo.cn/merch',  // 后台接口请求地址
         hostUrl: 'https://tyou.xiudo.cn',        // H5地址(前端运行地址)
         hostUrl: 'https://tyou.xiudo.cn',        // H5地址(前端运行地址)
         websocketUrl: '',        // websocket服务端地址
         websocketUrl: '',        // websocket服务端地址
-        weixinAppId: '' // 微信公众号appid
+        weixinAppId: '', // 微信公众号appid
+        uploadUrl: 'https://you.xiudo.cn/merch/common/upload/oss'
     }
     }
 
 
 };
 };

+ 3 - 0
src/main.js

@@ -63,6 +63,9 @@ if (process.env.NODE_ENV === 'production') {
 	Vue.config.productionTip = false;
 	Vue.config.productionTip = false;
 }
 }
 
 
+
+
+
 // 路由导航
 // 路由导航
 $mRouter.beforeEach((navType, to) => {
 $mRouter.beforeEach((navType, to) => {
 	if (to.route === undefined)
 	if (to.route === undefined)

+ 28 - 21
src/pages/index/setting/editnotice.vue

@@ -69,8 +69,12 @@
 </template>
 </template>
 
 
 <script>
 <script>
+let myCloud;
+
 import Header from '../../components/header';
 import Header from '../../components/header';
 import moment from '@/common/moment';
 import moment from '@/common/moment';
+import indexConfig from '@/config/index.config';
+
 export default {
 export default {
   name: 'editniotice',
   name: 'editniotice',
   components: {
   components: {
@@ -103,6 +107,13 @@ export default {
       },
       },
     };
     };
   },
   },
+  onReady () {
+    myCloud = uniCloud.init({
+      provider: 'aliyun',
+      spaceId: 'db8671a1-69bd-470d-ad59-ba927c88f4a4',
+      clientSecret: '8nOzV70edtpCd0El6qce3g==',
+    });
+  },
   onLoad(option) {
   onLoad(option) {
     this.newid = option.id;
     this.newid = option.id;
     this.getShopMessage();
     this.getShopMessage();
@@ -121,7 +132,6 @@ export default {
       this.storeIndex = e.detail.value;
       this.storeIndex = e.detail.value;
 			this.storeId = this.storeList[this.storeIndex].id;
 			this.storeId = this.storeList[this.storeIndex].id;
 			this.noticeMessage.sid = this.storeId
 			this.noticeMessage.sid = this.storeId
-      console.log(this.storeId);
     },
     },
     // 商家信息
     // 商家信息
     async getShopMessage() {
     async getShopMessage() {
@@ -163,9 +173,7 @@ export default {
     async getNoticeBuyId() {
     async getNoticeBuyId() {
       this.loading = true;
       this.loading = true;
       await this.$http.get('/news/getById/' + this.newid).then(async (res) => {
       await this.$http.get('/news/getById/' + this.newid).then(async (res) => {
-        console.log(res);
         if (res.code === 200) {
         if (res.code === 200) {
-					console.log(res);
           this.noticeMessage = res.data;
           this.noticeMessage = res.data;
           this.loading = false;
           this.loading = false;
         }
         }
@@ -177,12 +185,11 @@ export default {
         .createSelectorQuery()
         .createSelectorQuery()
         .select('#editor')
         .select('#editor')
         .context((res) => {
         .context((res) => {
+          console.log(this.noticeMessage.content);
           this.editorCtx = res.context;
           this.editorCtx = res.context;
-          this.editorCtx.setContents({
-            html: this.noticeMessage.content,
-          });
+          this.editorCtx.setContents({ html: this.noticeMessage.content});
         })
         })
-        .exec();
+        .exec()
     },
     },
     saveTxt(e) {
     saveTxt(e) {
       this.noticeMessage.content = e.detail.html;
       this.noticeMessage.content = e.detail.html;
@@ -213,24 +220,22 @@ export default {
         success: function (res) {
         success: function (res) {
           // 成功则返回图片的本地文件路径列表 tempFilePaths
           // 成功则返回图片的本地文件路径列表 tempFilePaths
           _self.iconUrl = res.tempFilePaths[0];
           _self.iconUrl = res.tempFilePaths[0];
-          console.log(res);
-          const uploadTask = uni.uploadFile({
-						url: 'http://tyou.xiudo.cn/merch/common/upload/oss',
+          myCloud.uploadFile({
+						url: indexConfig.uploadUrl,
             filePath: _self.iconUrl,
             filePath: _self.iconUrl,
-            header:{'content-type': 'multipart/form-data'},
+            cloudPath: _self.iconUrl,
 						name: 'file',
 						name: 'file',
 						success:(res)=>{
 						success:(res)=>{
-              let data = JSON.parse(res.data)
-							console.log(data);
-							_self.noticeMessage.icon = data.data
-						},
+              if (res.fileID) {
+                _self.noticeMessage.icon = res.fileID
+              }
+            },
+            onUploadProgress: function (progressEvent){
+              _self.progress = 1
+              _self.progress = Math.round((progressEvent.loaded * 100) / progressEvent.total);
+            }
           });
           });
-					uploadTask.onProgressUpdate((res)=>{
-						_self.progress = 1
-						setTimeout(() => {
-							_self.progress = res.progress
-						}, 500);
-					})
+				
         },
         },
         fail: function (error) {
         fail: function (error) {
           console.log(error);
           console.log(error);
@@ -244,11 +249,13 @@ export default {
 .editniotice {
 .editniotice {
   .content {
   .content {
     padding: 25upx 0;
     padding: 25upx 0;
+    height: 100vh;
   }
   }
   .content-warp {
   .content-warp {
     padding: 0 33upx 100upx;
     padding: 0 33upx 100upx;
     background-color: #fff;
     background-color: #fff;
     box-sizing: border-box;
     box-sizing: border-box;
+    height: 100%;
   }
   }
   .uni-list-cell {
   .uni-list-cell {
     border-bottom: 2px solid #f4f4f4;
     border-bottom: 2px solid #f4f4f4;

+ 1 - 0
src/pages/index/setting/notice.vue

@@ -218,6 +218,7 @@ export default {
       .delete {
       .delete {
         background-color: #ff6a5e;
         background-color: #ff6a5e;
         color: #fff;
         color: #fff;
+        border:none;
       }
       }
     }
     }
   }
   }

+ 51 - 37
src/pages/shop/shopdetail.vue

@@ -336,7 +336,7 @@
           <editor
           <editor
             id="editor"
             id="editor"
             class="ql-container"
             class="ql-container"
-            :placeholder="placeholder"
+            :placeholder="placeholderContent"
             @input="saveTxt"
             @input="saveTxt"
             @ready="onEditorReady"
             @ready="onEditorReady"
           ></editor>
           ></editor>
@@ -360,6 +360,8 @@ let _self;
 import Header from '../components/header.vue';
 import Header from '../components/header.vue';
 import uniCalendar from '@/components/uni-calendar/uni-calendar.vue';
 import uniCalendar from '@/components/uni-calendar/uni-calendar.vue';
 import moment from '@/common/moment';
 import moment from '@/common/moment';
+import indexConfig from '@/config/index.config';
+
 export default {
 export default {
   components: {
   components: {
     Header,
     Header,
@@ -372,7 +374,7 @@ export default {
       title: '商品详情',
       title: '商品详情',
       showoperat: false,
       showoperat: false,
 
 
-      placeholder: '请输入内容...',
+      placeholderContent: '请输入内容...',
       mastKnow: '',
       mastKnow: '',
 
 
       storeList: [{ name: '所属店铺', id: '', type: '' }],
       storeList: [{ name: '所属店铺', id: '', type: '' }],
@@ -404,6 +406,7 @@ export default {
       progress: 0,
       progress: 0,
       iconurl: '',
       iconurl: '',
       pickList: [],
       pickList: [],
+
       Icon: '',
       Icon: '',
       Imglist: [],
       Imglist: [],
 
 
@@ -486,7 +489,6 @@ export default {
     });
     });
   },
   },
   onLoad ( option ) {
   onLoad ( option ) {
-    
     if (option.id != 'undefined') {
     if (option.id != 'undefined') {
       this.SHOPID = option.id
       this.SHOPID = option.id
       this.getShopBuyId(option.id).then(() => {
       this.getShopBuyId(option.id).then(() => {
@@ -494,7 +496,7 @@ export default {
           this.getShopName(this.typeId, this.storeId);
           this.getShopName(this.typeId, this.storeId);
         });
         });
 
 
-        // 判断返回的是否是自营商品
+        // 数据回显
         this.price = this.shopData.salePrice / 100;
         this.price = this.shopData.salePrice / 100;
         this.rateprice = this.shopData.price / 100;
         this.rateprice = this.shopData.price / 100;
 
 
@@ -504,8 +506,21 @@ export default {
             : '请选择商品过期日期';
             : '请选择商品过期日期';
         }
         }
 
 
-        let rule = JSON.parse(this.shopData.saleRuleJson);
+        // 图标回显
+        if (this.shopData.icon) {
+          this.Icon = this.shopData.icon
+          this.iconurl = this.shopData.icon;
+        }
 
 
+        // 图册回显
+        if (this.shopData.imges) {
+          this.Imglist = JSON.parse(this.shopData.imges)
+          let urllist = JSON.parse(this.shopData.imges)
+          urllist.forEach(element => {
+            this.pickList.push(element.url)
+          });
+        }
+        let rule = JSON.parse(this.shopData.saleRuleJson);
         if (rule) {
         if (rule) {
           this.astrictDate.data.saleDay = rule.data.saleDay
           this.astrictDate.data.saleDay = rule.data.saleDay
             ? rule.data.saleDay
             ? rule.data.saleDay
@@ -551,26 +566,21 @@ export default {
         } else {
         } else {
           this.showoperat = false;
           this.showoperat = false;
         }
         }
-
-        // 图标回显
-        if (this.shopData.icon) {
-          this.iconurl = this.shopData.icon;
-        } else {
-          this.iconurl = '';
-        }
         this.loading = false;
         this.loading = false;
       });
       });
     } else {
     } else {
       this.getShopList()
       this.getShopList()
     }
     }
   },
   },
+  // onPageScroll (option) {
+  //   console.log(option);
+  // },
   methods: {
   methods: {
     // 获取单个商品信息
     // 获取单个商品信息
     async getShopBuyId (id) {
     async getShopBuyId (id) {
       this.loading = true;
       this.loading = true;
       await this.$http.get('/goods/getById/' + id).then((res) => {
       await this.$http.get('/goods/getById/' + id).then((res) => {
         if (res.code === 200 && res.msg === 'OK') {
         if (res.code === 200 && res.msg === 'OK') {
-          console.log(res);
           this.shopData = res.data;
           this.shopData = res.data;
           this.storeId = res.data.shopId;
           this.storeId = res.data.shopId;
           this.typeId = res.data.typeId;
           this.typeId = res.data.typeId;
@@ -597,7 +607,6 @@ export default {
     },
     },
     // 库存模式
     // 库存模式
     shopNumChange (e) {
     shopNumChange (e) {
-      console.log(e);
       for (let i = 0; i < this.shopNumList.length; i++) {
       for (let i = 0; i < this.shopNumList.length; i++) {
         if (this.shopNumList[i].id === e.target.value) {
         if (this.shopNumList[i].id === e.target.value) {
           this.shopNumIndex = i;
           this.shopNumIndex = i;
@@ -642,6 +651,7 @@ export default {
     },
     },
     // 初始化编辑器
     // 初始化编辑器
     onEditorReady () {
     onEditorReady () {
+      // this.placeholderContent = this.shopData.describ
       uni
       uni
         .createSelectorQuery()
         .createSelectorQuery()
         .select('#editor')
         .select('#editor')
@@ -651,6 +661,7 @@ export default {
             html: this.shopData.describ, //this.EditGoodsDetail.content为赋值内容。
             html: this.shopData.describ, //this.EditGoodsDetail.content为赋值内容。
           });
           });
         })
         })
+        .exec(-1000)
     },
     },
     // -----------------------------------------------------------------
     // -----------------------------------------------------------------
     // 跳转到管理分类页面
     // 跳转到管理分类页面
@@ -856,7 +867,7 @@ export default {
           // 成功则返回图片的本地文件路径列表 tempFilePaths
           // 成功则返回图片的本地文件路径列表 tempFilePaths
           _self.iconurl = res.tempFilePaths[0];
           _self.iconurl = res.tempFilePaths[0];
           myCloud.uploadFile({
           myCloud.uploadFile({
-            url: 'http://tyou.xiudo.cn/merch/common/upload/oss',
+            url: indexConfig.uploadUrl,
             filePath: _self.iconurl, // 要上传的文件对象
             filePath: _self.iconurl, // 要上传的文件对象
             cloudPath: _self.iconurl, // 要上传的文件对象
             cloudPath: _self.iconurl, // 要上传的文件对象
             name: 'file',
             name: 'file',
@@ -890,31 +901,27 @@ export default {
         sourceType: ['album'], // camera 使用相机   album 从相册中选
         sourceType: ['album'], // camera 使用相机   album 从相册中选
         success: function (res) {
         success: function (res) {
           // 成功则返回图片的本地文件路径列表 tempFilePaths
           // 成功则返回图片的本地文件路径列表 tempFilePaths
-          let img = [];
-          img.push(res.tempFilePaths);
           if (_self.pickList.length >= 6) {
           if (_self.pickList.length >= 6) {
             _self.$mHelper.toast('最多只可上传6张图片');
             _self.$mHelper.toast('最多只可上传6张图片');
           } else {
           } else {
-            _self.pickList = _self.pickList.concat(img);
-
-            // for (let i = 0; i < _self.pickList.length; i++) {
-            //   let element = _self.pickList[i];
-            //   myCloud.uploadFile({
-            //     url: 'http://192.168.100.135:83/merch/common/upload/oss',
-            //     filePath: element, // 要上传的文件对象
-            //     cloudPath: element,
-            //     name: 'file',
-            //     onUploadProgress: function (progressEvent) {
-            //       // 上传进度回调
-            //       let percentCompleted = Math.round(
-            //         (progressEvent.loaded * 100) / progressEvent.total
-            //       );
-            //     },
-            //     success: (res) => {
-            //     },
-            //   });
-            // }
-
+            _self.pickList = _self.pickList.concat(res.tempFilePaths).slice(0,6);
+            _self.Imglist = []
+            for (let i = 0; i < _self.pickList.length; i++) {
+              let element = _self.pickList[i];
+              myCloud.uploadFile({
+                url: indexConfig.uploadUrl,
+                filePath: element, // 要上传的文件对象
+                cloudPath: element,
+                name: 'file',
+                onUploadProgress: function (progressEvent) {
+                  // 上传进度回调
+                  let percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
+                },
+                success: (res) => {
+                  _self.Imglist.push({url:res.fileID,uid:res.filePath})
+                },
+              });
+            }
           }
           }
         },
         },
       });
       });
@@ -922,6 +929,11 @@ export default {
     // 删除图册中的图片
     // 删除图册中的图片
     deleteThisImg (index) {
     deleteThisImg (index) {
       this.pickList.splice(index, 1);
       this.pickList.splice(index, 1);
+      this.Imglist.forEach( (element,i) => {
+        if (element.uid === this.pickList[index]) {
+          this.Imglist.splice(i,1)
+        }
+      });
     },
     },
     // 富文本失去焦点保存内容
     // 富文本失去焦点保存内容
     saveTxt (e) {
     saveTxt (e) {
@@ -997,6 +1009,7 @@ export default {
           return;
           return;
         }
         }
       }
       }
+    
       this.loading = true;
       this.loading = true;
       this.$http
       this.$http
         .post('/goods/add', {
         .post('/goods/add', {
@@ -1007,6 +1020,7 @@ export default {
           customGroupId: this.lineId,
           customGroupId: this.lineId,
           describ: this.mastKnow,
           describ: this.mastKnow,
           icon: this.Icon || '',
           icon: this.Icon || '',
+          imges: JSON.stringify(this.Imglist) || '',
           del: this.shopData.del || '',
           del: this.shopData.del || '',
           upDown: this.shopData.upDown || '',
           upDown: this.shopData.upDown || '',
           saleRule: this.showoperat, // 限制购票
           saleRule: this.showoperat, // 限制购票