Forráskód Böngészése

还在商品管理模块瞎摸摸

ltx529596 4 éve
szülő
commit
8e2061e05d

+ 1 - 1
src/components/uni-load-more/uni-load-more.vue

@@ -92,7 +92,7 @@
 		// #ifndef APP-NVUE
 		computed:{
 			iconSnowWidth(){
-				console.log((Math.floor(this.iconSize/24)||1)*2);
+				// console.log((Math.floor(this.iconSize/24)||1)*2);
 				return (Math.floor(this.iconSize/24)||1)*2
 			}
 		},

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

@@ -2,8 +2,8 @@ const CONFIG = {
     //开发环境配置
     development: {
         assetsPath: '/static', // 静态资源路径
-        baseUrl: 'http://tyou.xiudo.cn/merch',  // 后台接口请求地址
-        // baseUrl: 'http://192.168.100.135:83/merch',  // 后台接口请求地址
+        // baseUrl: 'http://tyou.xiudo.cn/merch',  // 后台接口请求地址
+        baseUrl: 'http://192.168.100.135:83/merch',  // 后台接口请求地址
         hostUrl: 'http://localhost:8080',        // H5地址(前端运行地址)
         websocketUrl: '',        // websocket服务端地址
         weixinAppId: '' // 微信公众号appid

+ 2 - 0
src/pages/index/index.vue

@@ -485,6 +485,7 @@ export default {
 
     // 获取店铺列表
     async getShopList() {
+      this.loading = true
       await this.$http.get('/homePage/getShopByMerId').then((res) => {
         if (res.data && res.code === 200) {
           let newarr = [{ name: '全部', id: 0 }];
@@ -495,6 +496,7 @@ export default {
           this.shopSellMoneyTrend();
           this.futureDayData();
           this.shopSellData();
+          this.loading = false
         }
       })
     },

+ 259 - 165
src/pages/shop/shopdetail.vue

@@ -28,7 +28,7 @@
         </view>
       </view>
       <!-- 商品类型 -->
-      <view class="shoptype detail-list ">
+      <view class="shoptype detail-list">
         <view class="menu">
           <view class="uni-list-cell">
             <view class="uni-list-cell-db">
@@ -301,7 +301,10 @@
       <view class="iconcontent">
         <image class="shopLogo" :src="iconurl" v-if="iconurl"></image>
         <text class="icon" @tap="uploadImg">点击上传</text>
-        <text class="per">{{  uploadtxt  }} {{ progress=== 0 ? '' : progress }} <text v-if="progress!=0">%</text></text>
+        <text class="per"
+          >{{ uploadtxt }} {{ progress === 0 ? '' : progress }}
+          <text v-if="progress != 0">%</text></text
+        >
       </view>
       <view class="shopicon">商品图册</view>
       <view class="uploading">
@@ -352,7 +355,7 @@
 
 <script>
 let myCloud;
-let shopData;
+let _self;
 import Header from '../components/header.vue';
 import uniCalendar from '@/components/uni-calendar/uni-calendar.vue';
 import moment from '@/common/moment';
@@ -379,7 +382,7 @@ export default {
 
       typeList: [{ name: '商品类型(请先选择所属店铺)', id: '' }],
       typeIndex: 0,
-      typeId: '',
+      typeId: '1',
       typeDisabled: true,
 
       shopList: [{ name: '商品名称(请先选择商品类型)', id: '' }],
@@ -408,7 +411,7 @@ export default {
       // -------------- 编辑分界线 ------------------------------------
 
       SHOPID: 0,
-      // shopData: {},
+      shopData: {},
 
       expirationDate: '请选择商品过期日期',
       // 销售属性
@@ -473,11 +476,11 @@ export default {
     uni.removeStorageSync('Id');
   },
   onShow() {
-    if (this.storeId != '') {
-      this.getLine()
-    }
+    // if (this.storeId != '') {
+    //   this.getLine(this.storeId)
+    // }
   },
-  onReady (){
+  onReady() {
     myCloud = uniCloud.init({
       provider: 'aliyun',
       spaceId: 'db8671a1-69bd-470d-ad59-ba927c88f4a4',
@@ -485,18 +488,165 @@ export default {
     });
   },
   onLoad() {
-
     this.SHOPID = uni.getStorageSync('Id');
+
     if (this.SHOPID) {
-      this.getShopBuyId();
+      this.getShopBuyId(this.SHOPID).then( () => {
+        this.getShopList().then(()=>{
+          this.getShopName(this.typeId, this.storeId);
+        })
+
+        setTimeout(() => {
+          // 判断返回的是否是自营商品
+          this.price = this.shopData.salePrice / 100;
+          this.rateprice = this.shopData.price / 100;
+
+          if (this.shopData.expiredTime) {
+            this.expirationDate = this.shopData.expiredTime.slice(0, 10)
+              ? this.shopData.expiredTime.slice(0, 10)
+              : '请选择商品过期日期';
+          }
+
+          let rule = JSON.parse(this.shopData.saleRuleJson);
+
+          if (rule) {
+            this.astrictDate.data.saleDay = rule.data.saleDay
+              ? rule.data.saleDay
+              : 0;
+            this.astrictDate.data.saleNum = rule.data.saleNum
+              ? rule.data.saleNum
+              : 0;
+            // 有效期模式
+            this.astrictDate.dateSetting = rule.data.dateSetting;
+            this.patterIndex = +rule.data.dateSetting;
+            // 库存模式
+            this.astrictDate.goodsStockFlag = rule.data.goodsStockFlag;
+            this.shopNumIndex = +rule.data.goodsStockFlag;
+
+            if (this.shopNumIndex === 1) {
+              this.dateInventory = this.shopData.inventory;
+            } else if (this.shopNumIndex === 2) {
+              this.sunInventory = this.shopData.inventory;
+            }
+            // 预订数量
+            this.astrictDate.data.bookRule = rule.data.bookRule;
+            // 实名制
+            if (rule.data.isRealName === '0') {
+              this.trueNme = true;
+            } else {
+              this.trueNme = false;
+            }
+            this.astrictDate.data.isRealName = rule.data.isRealName;
+            // 可退规则
+            this.bookingIndex = +rule.data.usubscribeRule;
+            this.astrictDate.usubscribeRule = rule.data.usubscribeRule;
+            // 二维码
+            if (rule.data.isShowQrcode === '0') {
+              this.codeShow = true;
+            } else {
+              this.codeShow = false;
+            }
+            this.astrictDate.data.isShowQrcode = rule.data.isShowQrcode;
+          }
+          // 限制购票回显
+          if (this.shopData.saleRule === '1') {
+            this.showoperat = true;
+          } else {
+            this.showoperat = false;
+          }
+
+          // 图标回显
+          if (this.shopData.icon) {
+            this.iconurl = this.shopData.icon;
+          } else {
+            this.iconurl = '';
+          }
+          this.loading = false;
+        }, 1);
+      })
     }
 
-    this.getShopList();
-    this.getType();
-    this.getShopName();
-    this.getLine();
+    // this.getShopList();
   },
   methods: {
+    // 获取单个商品信息
+    async getShopBuyId(id) {
+      this.loading = true;
+      await this.$http.get('/goods/getById/' + id).then((res) => {
+        if (res.code === 200 && res.msg === 'OK') {
+          this.shopData = res.data;
+          this.storeId = res.data.shopId;
+          this.typeId = res.data.typeId;
+          this.loading = false;
+          // setTimeout(() => {
+          //   this.price = this.shopData.salePrice / 100;
+          //   this.rateprice = this.shopData.price / 100;
+
+          //   if (this.shopData.expiredTime) {
+          //     this.expirationDate = this.shopData.expiredTime.slice(0, 10)
+          //       ? this.shopData.expiredTime.slice(0, 10)
+          //       : '请选择商品过期日期';
+          //   }
+
+          //   let rule = JSON.parse(this.shopData.saleRuleJson);
+
+          //   if (rule) {
+          //     this.astrictDate.data.saleDay = rule.data.saleDay
+          //       ? rule.data.saleDay
+          //       : 0;
+          //     this.astrictDate.data.saleNum = rule.data.saleNum
+          //       ? rule.data.saleNum
+          //       : 0;
+          //     // 有效期模式
+          //     this.astrictDate.dateSetting = rule.data.dateSetting;
+          //     this.patterIndex = +rule.data.dateSetting;
+          //     // 库存模式
+          //     this.astrictDate.goodsStockFlag = rule.data.goodsStockFlag;
+          //     this.shopNumIndex = +rule.data.goodsStockFlag;
+
+          //     if (this.shopNumIndex === 1) {
+          //       this.dateInventory = this.shopData.inventory;
+          //     } else if (this.shopNumIndex === 2) {
+          //       this.sunInventory = this.shopData.inventory;
+          //     }
+          //     // 预订数量
+          //     this.astrictDate.data.bookRule = rule.data.bookRule;
+          //     // 实名制
+          //     if (rule.data.isRealName === '0') {
+          //       this.trueNme = true;
+          //     } else {
+          //       this.trueNme = false;
+          //     }
+          //     this.astrictDate.data.isRealName = rule.data.isRealName;
+          //     // 可退规则
+          //     this.bookingIndex = +rule.data.usubscribeRule;
+          //     this.astrictDate.usubscribeRule = rule.data.usubscribeRule;
+          //     // 二维码
+          //     if (rule.data.isShowQrcode === '0') {
+          //       this.codeShow = true;
+          //     } else {
+          //       this.codeShow = false;
+          //     }
+          //     this.astrictDate.data.isShowQrcode = rule.data.isShowQrcode;
+          //   }
+          //   // 限制购票回显
+          //   if (this.shopData.saleRule === '1') {
+          //     this.showoperat = true;
+          //   } else {
+          //     this.showoperat = false;
+          //   }
+
+          //   // 图标回显
+          //   if (this.shopData.icon) {
+          //     this.iconurl = this.shopData.icon;
+          //   } else {
+          //     this.iconurl = '';
+          //   }
+          //   this.loading = false;
+          // }, 500);
+        }
+      });
+    },
     // 打开日历
     openTime() {
       this.$refs.calendar.open();
@@ -504,8 +654,8 @@ export default {
     confirm(e) {
       this.expirationDate = e.fulldate;
     },
-    // 单选自定义属性
-    radioChange (evt) {
+    // 自定义属性
+    radioChange(evt) {
       for (let i = 0; i < this.patterList.length; i++) {
         if (this.patterList[i].id === evt.target.value) {
           this.patterIndex = i;
@@ -514,7 +664,7 @@ export default {
       }
       this.astrictDate.data.dateSetting = evt.detail.value;
     },
-    // 单选库存模式
+    // 库存模式
     shopNumChange(e) {
       for (let i = 0; i < this.shopNumList.length; i++) {
         if (this.shopNumList[i].id === e.target.value) {
@@ -531,7 +681,7 @@ export default {
       }
       this.astrictDate.data.goodsStockFlag = e.detail.value;
     },
-    // 单选可退模式
+    // 可退模式
     bookingChange(e) {
       for (let i = 0; i < this.bookingList.length; i++) {
         if (this.bookingList[i].id === e.target.value) {
@@ -557,88 +707,6 @@ export default {
         this.astrictDate.data.isShowQrcode = '1';
       }
     },
-    // 获取单个商品信息
-    getShopBuyId() {
-      this.loading = true;
-      if (!this.SHOPID) return;
-      this.$http
-        .get('/goods/getById/' + this.SHOPID)
-        .then((res) => {
-          if (res.code === 200 && res.msg === 'OK') {
-
-            shopData = res.data;
-            console.log(shopData);
-
-            setTimeout(() => {
-              // 判断返回的是否是自营商品
-              this.price = shopData.salePrice / 100;
-              this.rateprice = shopData.price / 100;
-
-              if (shopData.expiredTime) {
-                this.expirationDate = shopData.expiredTime.slice(0, 10)
-                  ? shopData.expiredTime.slice(0, 10)
-                  : '请选择商品过期日期';
-              }
-
-              let rule = JSON.parse(shopData.saleRuleJson);
-
-              if (rule) {
-                this.astrictDate.data.saleDay = rule.data.saleDay
-                  ? rule.data.saleDay
-                  : 0;
-                this.astrictDate.data.saleNum = rule.data.saleNum
-                  ? rule.data.saleNum
-                  : 0;
-                // 有效期模式
-                this.astrictDate.dateSetting = rule.data.dateSetting;
-                this.patterIndex = +rule.data.dateSetting;
-                // 库存模式
-                this.astrictDate.goodsStockFlag = rule.data.goodsStockFlag;
-                this.shopNumIndex = +rule.data.goodsStockFlag;
-                if (this.shopNumIndex === 1) {
-                  this.dateInventory = shopData.inventory;
-                } else if (this.shopNumIndex === 2) {
-                  this.sunInventory = shopData.inventory;
-                }
-                // 预订数量
-                this.astrictDate.data.bookRule = rule.data.bookRule;
-                // 实名制
-                if (rule.data.isRealName === '0') {
-                  this.trueNme = true;
-                } else {
-                  this.trueNme = false;
-                }
-                this.astrictDate.data.isRealName = rule.data.isRealName;
-                // 可退规则
-                this.bookingIndex = +rule.data.usubscribeRule;
-                this.astrictDate.usubscribeRule = rule.data.usubscribeRule;
-                // 二维码
-                if (rule.data.isShowQrcode === '0') {
-                  this.codeShow = true;
-                } else {
-                  this.codeShow = false;
-                }
-                this.astrictDate.data.isShowQrcode = rule.data.isShowQrcode;
-              }
-              // 限制购票回显
-              if (shopData.saleRule === '1') {
-                this.showoperat = true;
-              } else {
-                this.showoperat = false;
-              }
-
-              // 图标回显
-              if (shopData.icon) {
-                this.iconurl = shopData.icon;
-              } else {
-                this.iconurl = '';
-              }
-              this.loading = false;
-            }, 500);
-          }
-        });
-    },
-
     // 初始化编辑器
     onEditorReady() {
       uni
@@ -647,14 +715,12 @@ export default {
         .context((res) => {
           this.editorCtx = res.context;
           this.editorCtx.setContents({
-            html: shopData.describ, //this.EditGoodsDetail.content为赋值内容。
+            html: this.shopData.describ, //this.EditGoodsDetail.content为赋值内容。
           });
         })
         .exec();
     },
-
     // -----------------------------------------------------------------
-
     // 跳转到管理分类页面
     toClassify() {
       if (this.storeId) {
@@ -689,69 +755,72 @@ export default {
     async getShopList() {
       this.storeList = [{ name: '所属店铺', id: '', type: '' }];
       await this.$http
-        .get('/shop/getList', {
-          mid: this.scenicId,
-        })
-        .then(async (res) => {
+        .get('/shop/getList', { mid: this.scenicId })
+        .then((res) => {
           if (res.data) {
             let arr = [];
-            res.data.forEach((element) => {
+            res.data.forEach((element) =>
               arr.push({
                 name: element.name,
                 id: element.id,
-                type: element.shopFrom   // 是否是分销店铺
-              });
-            });
+                type: element.shopFrom,
+              })
+            );
             this.storeList = this.storeList.concat(arr);
             this.storeDisable = false;
-
             // 所属店铺回显
-            if (shopData.shopId) {
+            if (this.shopData.shopId) {
               this.storeDisable = true;
               this.storeList.forEach((item, index) => {
-                if (shopData.shopId === item.id) {
+                if (this.shopData.shopId === item.id) {
                   this.storeIndex = index;
                 }
               });
               this.storeId = this.storeList[this.storeIndex].id;
               this.typeProperty = this.storeList[this.storeIndex].type;
+
+              this.getType(this.storeId);
+              this.getLine(this.storeId);
             }
           }
         });
     },
     // 商品类型
-    async getType() {
+    async getType(storeId) {
       this.typeList = [{ name: '商品类型(请先选择所属店铺)', id: '' }];
-      this.$http.get('/type/getTypeListByShopId', {
-        id: this.storeId || shopData.shopId
-      }).then((res) => {
-        let arr = [];
-        res.data[0].children.forEach((element) => {
-          arr.push({ name: element.name, id: element.id });
-        });
-        this.typeList = this.typeList.concat(arr);
-        this.typeDisabled = false;
-
-        // 商品类型回显
-        if (shopData.typeId) {
-          this.typeDisabled = true;
-          this.typeList.forEach((item, index) => {
-            if (shopData.typeId === item.id) {
-              this.typeIndex = index;
-            }
+      this.$http
+        .get('/type/getTypeListByShopId', {
+          id: storeId,
+        })
+        .then((res) => {
+          let arr = [];
+          res.data[0].children.forEach((element) => {
+            arr.push({ name: element.name, id: element.id });
           });
-          this.typeId = this.typeList[this.typeIndex].id;
-          this.shopname = shopData.name;
-        }
-      });
+          this.typeList = this.typeList.concat(arr);
+          this.typeDisabled = false;
+
+          // 商品类型回显
+          if (this.shopData.typeId) {
+            this.typeDisabled = true;
+            this.typeList.forEach((item, index) => {
+              if (this.shopData.typeId === item.id) {
+                this.typeIndex = index;
+              }
+            });
+            this.typeId = this.typeList[this.typeIndex].id;
+            this.shopname = this.shopData.name;
+          }
+        });
     },
     // 商品名称
-    async getShopName() {
+    async getShopName(typeId, storeId) {
+      this.loading = true
       this.shopList = [{ name: '商品名称(请先选择商品类型)', id: '' }];
       await this.$http
         .get('/goods/getTicketGoods', {
-          typeId: this.typeId || shopData.typeId,
-          shopId: this.storeId  || shopData.shopId
+          typeId: typeId,
+          shopId: storeId,
         })
         .then(async (res) => {
           if (res.code === 200) {
@@ -760,29 +829,42 @@ export default {
               arr.push({ name: element.ticket_name, id: element.ticket_no });
             });
             this.shopList = this.shopList.concat(arr);
+            this.loading = false
 
             // 回显名称
-            if (shopData.name) {
-              this.shopList[0] = {name: shopData.name,id: shopData.ticketNo}
+            if (this.shopData.name) {
+              this.loading = true
+              if (this.shopData.ticketNo) {
+                // 分销没有ticketNo
+                this.shopList[0] = {
+                  name: this.shopData.name,
+                  id: this.shopData.ticketNo,
+                };
+              } else {
+                // 自营商品直接赋值
+                this.shopname = this.shopname.name;
+              }
               this.shopList.forEach((item, index) => {
-                if (shopData.name === item.name) {
+                if (this.shopData.name === item.name) {
                   // this.shopList[0] = { name: '商品名称(请先选择商品类型)', id: '' }
                   this.shopIndex = index;
                 } else {
-                  this.shopIndex = 0
+                  this.shopIndex = 0;
                 }
               });
               this.shopId = this.shopList[this.shopIndex].id;
+              this.loading = false
             }
           }
         });
     },
     // 线路分配
-    async getLine() {
+    async getLine(storeId) {
+      this.loading = true
       this.lineList = [{ name: '分类(请先选择所属商品)', id: '' }];
       await this.$http
         .get('/goods/getCustomGroupList', {
-          shopId: this.storeId || shopData.shopId,
+          shopId: storeId,
         })
         .then(async (res) => {
           let arr = [];
@@ -792,15 +874,18 @@ export default {
           });
           this.lineList = this.lineList.concat(arr);
           this.lineDidsable = false;
+          this.loading = false
 
           // 分类回显
-          if (shopData.customGroupId) {
+          if (this.shopData.customGroupId) {
+            this.loading = true
             this.lineList.forEach((item, index) => {
-              if (shopData.customGroupId === item.id) {
+              if (this.shopData.customGroupId === item.id) {
                 this.lineIndex = index;
               }
             });
             this.lineId = this.lineList[this.lineIndex].id;
+            this.loading = false
           }
         });
     },
@@ -833,8 +918,8 @@ export default {
     // 图标上传
     uploadImg() {
       let _self = this;
-      _self.uploadtxt = '上传中...'
-      _self.progress = 0
+      _self.uploadtxt = '上传中...';
+      _self.progress = 0;
       uni.chooseImage({
         count: 1,
         sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
@@ -852,19 +937,20 @@ export default {
                 _self.Icon = res.fileID;
               }
             },
-            fail: function (msg) {
-            },
+            fail: function (msg) {},
             onUploadProgress: function (progressEvent) {
-              _self.progress = Math.round((progressEvent.loaded * 100) / progressEvent.total);
-              if ( _self.progress === 100) {
-                _self.uploadtxt = '上传成功'
+              _self.progress = Math.round(
+                (progressEvent.loaded * 100) / progressEvent.total
+              );
+              if (_self.progress === 100) {
+                _self.uploadtxt = '上传成功';
               }
             },
           });
         },
         fail: function (error) {
-          _self.uploadtxt = '已取消上传'
-        }
+          _self.uploadtxt = '已取消上传';
+        },
       });
     },
     // 图册上传
@@ -924,12 +1010,17 @@ export default {
       }
 
       let name = '';
-      if (this.typeProperty === '1' ) {
-        name = this.shopList[this.shopIndex].id
-      } else if (this.typeProperty === '0') {
+      console.log('是否自营');
+      console.log(this.typeProperty);
+      if (this.typeProperty === 1) {
+        name = this.shopList[this.shopIndex].id;
+      } else if (this.typeProperty === 0) {
         name = this.shopname;
       }
 
+      console.log(name);
+
+      return;
       if (!this.storeId) {
         this.$mHelper.toast('请选择所属商铺!');
         return;
@@ -986,28 +1077,31 @@ export default {
       this.loading = true;
       this.$http
         .post('/goods/add', {
-          id: shopData.id || '',
+          id: this.shopData.id || '',
           mid: this.scenicId,
           shopId: this.storeId,
           typeId: this.typeId,
           customGroupId: this.lineId,
           describ: this.mastKnow,
           icon: this.Icon || '',
-          del: shopData.del || '',
-          upDown: shopData.upDown || '',
+          del: this.shopData.del || '',
+          upDown: this.shopData.upDown || '',
           saleRule: this.showoperat, // 限制购票
           saleRuleJson: JSON.stringify(this.astrictDate),
           //  自营
           name: name,
           salePrice: this.price * 100 || null,
           price: this.rateprice * 100 || null,
-          expiredTime: this.expirationDate === '请选择商品过期日期' ? '' : this.expirationDate,
+          expiredTime:
+            this.expirationDate === '请选择商品过期日期'
+              ? ''
+              : this.expirationDate,
           inventory: this.inventory,
         })
         .then((res) => {
           if (res.code === 200 && res.msg === 'OK') {
             this.loading = false;
-            if (shopData.id) {
+            if (this.shopData.id) {
               this.$mHelper.toast('保存成功,请联系管理员进行审核');
             } else {
               this.$mHelper.toast('添加成功');