ソースを参照

图标上传传,分类管理列表,商品列表优化

ltx529596 4 年 前
コミット
bbb554bc1d

+ 7 - 1
src/pages.json

@@ -93,7 +93,13 @@
 			"style":{
         "navigationBarTitleText": "商品详情",
         "navigationBarBackgroundColor":"#ffffff"
-        
+			}
+		},
+		{
+			"path":"pages/shop/editclassify",
+			"style":{
+        "navigationBarTitleText": "新增自定义分类",
+        "navigationBarBackgroundColor":"#ffffff"
 			}
 		},
 		{

+ 17 - 26
src/pages/shop/classify.vue

@@ -16,9 +16,15 @@
             >分组标识:<text class="name">{{ item.code }}</text></view
           >
           <view class="bar"
-            >一级分类:<text class="name">{{ item.typeId | grade }}</text></view
+            >一级分类:<text class="name">{{
+              item.typeName ? item.typeName : 'none'
+            }}</text></view
+          >
+          <view class="bar"
+            >所属店铺:<text class="name">{{
+              item.shopName ? item.shopName : 'none'
+            }}</text></view
           >
-          <view class="bar">所属店铺:<text class="name">西线推荐</text></view>
         </view>
         <view class="warp-bottom">
           <view class="btn edtil" @tap="compile(item.id)">编辑</view>
@@ -26,11 +32,12 @@
         </view>
       </view>
     </view>
+
+    <rf-loading v-if="loading"></rf-loading>
   </view>
 </template>
 
 <script>
-let gradeList;
 import Header from '../components/header';
 export default {
   name: 'classify',
@@ -38,38 +45,31 @@ export default {
   data() {
     //这里存放数据
     return {
+      loading: true,
       title: '管理自定义分类',
       storeId: uni.getStorageSync('shopid'),
       lineList: [],
+      gradeList: [],
     };
   },
   filters: {
     grade(val) {
-      console.log(val);
       if (!val) {
         return '无';
-      } 
-      gradeList.forEach(element => {
-        if (val === element.id) {
-          console.log(val === element.id);
-          console.log(element.name);
-          val = element.name
-          return  val
-        } 
-      });
+      }
     },
   },
   onLoad() {
     this.getCustomList();
-    this.getOneClassList();
   },
   //方法集合
   methods: {
     addClass() {
-      console.log(1);
+      this.$mRouter.push({ route: '/pages/shop/editclassify' });
     },
     // 自定义分类列表
     async getCustomList() {
+      this.loading = true;
       await this.$http
         .get('/goods/getCustomGroupList', {
           shopId: this.storeId,
@@ -77,19 +77,10 @@ export default {
         .then(async (res) => {
           if (res.code === 200) {
             this.lineList = res.data.customGroupList;
+            this.loading = false;
           }
         });
     },
-    // 一级分类
-    async getOneClassList() {
-      await this.$http.get('/type/getParentList', {}).then(async (res) => {
-        if (res.code === 200 && res.msg === 'OK') {
-          gradeList = res.data;
-        }
-      });
-    },
-    // 处理分类
-
 
     // 编辑
     compile(id) {
@@ -118,7 +109,7 @@ export default {
   }
   .content {
     width: 100%;
-    padding: 24upx 32upx 0;
+    padding: 24upx 32upx 100upx;
     .item-warp {
       width: 100%;
       padding: 28upx 31upx 0;

+ 33 - 0
src/pages/shop/editclassify.vue

@@ -0,0 +1,33 @@
+<!-- editclassify -->
+<template>
+  <view class="editclassify">
+    <Header :title="title" />
+    <view style="height:94upx"></view>
+    <view class="content">
+      五百年了,UI还没来
+    </view>
+  </view>
+</template>
+
+<script>
+import Header from '../components/header'
+export default {
+  name: 'editclassify',
+  components: {
+    Header
+  },
+  data() {
+    //这里存放数据
+    return {
+      title: '新增自定义分类'
+    };
+  },
+  //方法集合
+  methods: {}
+};
+</script>
+<style lang='scss' scoped>
+.editclassify {
+  background-color: pink;
+}
+</style>

+ 11 - 5
src/pages/shop/shop.vue

@@ -93,7 +93,7 @@
           >
         </view>
         <view class="operate">
-          <view class="btn stick" id="one" @tap="sticktop($event)">置顶</view>
+          <view class="btn stick" id="one" @tap="sticktop(item.id)">置顶</view>
           <view class="btn sold" @tap="passGet(item.id)">审核</view>
           <view class="btn compile" @tap="topage">编辑</view>
           <view class="btn delete">删除</view>
@@ -126,7 +126,7 @@
           >
         </view>
         <view class="operate">
-          <view class="btn stick" id="one" @tap="sticktop($event)">置顶</view>
+          <view class="btn stick" id="one" @tap="sticktop(item.id)">置顶</view>
           <view class="btn sold" @tap="shopPutDown(item.id)">下架</view>
           <view class="btn compile" @tap="topage">编辑</view>
           <view class="btn delete">删除</view>
@@ -153,7 +153,7 @@
           <view class="right">¥<text class="price">{{ item.price }}</text></view>
         </view>
         <view class="operate">
-          <view class="btn stick" id="one" @tap="sticktop($event)">置顶</view>
+          <view class="btn stick" id="one" @tap="sticktop(item.id)">置顶</view>
           <view class="btn sold" @tap="shopPutUp(item.id)">上架</view>
           <view class="btn compile" @tap="topage">编辑</view>
           <view class="btn delete" @tap="deleteshop(item.id)">删除</view>
@@ -310,8 +310,14 @@ export default {
       this.getTicketShopList();
     },
     // 置顶
-    sticktop(e) {
-      console.log(e.target);
+    sticktop(id) {
+      console.log(id);
+      this.$http.put('/goods/changeSort',{
+        id: id,
+        sort: -1
+      }).then(res=>{
+        console.log(res);
+      })
     },
     // 跳转详情
     topage() {

+ 79 - 48
src/pages/shop/shopdetail.vue

@@ -76,7 +76,13 @@
           </view>
         </view>
         <view class="menu" v-if="hasNameList === 0">
-          <input class="input-shopname" type="text" v-model="shopname" placeholder-style="color:#a2a8a8;font-size:30upx" placeholder="请输入商品名称">
+          <input
+            class="input-shopname"
+            type="text"
+            v-model="shopname"
+            placeholder-style="color:#a2a8a8;font-size:30upx"
+            placeholder="请输入商品名称"
+          />
         </view>
       </view>
       <!-- 自定义分类 -->
@@ -133,7 +139,7 @@
       <!-- 商品图标 -->
       <view class="shopicon">商品图标</view>
       <view class="iconcontent">
-        <image class="shopLogo" :src="img" v-if="img"></image>
+        <image class="shopLogo" :src="iconurl" v-if="iconurl"></image>
         <text class="icon" @tap="uploadImg">点击上传</text>
       </view>
       <view class="shopicon">商品图册</view>
@@ -172,11 +178,13 @@
       </view>
 
       <view class="btn" @tap="submitMesage">确认</view>
+      <rf-loading v-if="loading"></rf-loading>
     </view>
   </view>
 </template>
 
 <script>
+let myCloud;
 import Header from '../components/header.vue';
 export default {
   components: {
@@ -184,13 +192,13 @@ export default {
   },
   data() {
     return {
+      loading: false,
       scenicId: uni.getStorageSync('scenicId'),
       title: '商品详情',
       num1: 1,
       num2: 10,
       showoperat: false,
-      img: '',
-      pickList: [],
+
       placeholder: '请输入内容...',
       mastKnow: '',
       storeList: [{ name: '所属店铺', id: '' }],
@@ -211,26 +219,38 @@ export default {
       lineList: [{ name: '分类(请先选择所属商品)', id: '' }],
       lineIndex: 0,
       lineId: '',
+
+      // 图标上传
+      iconurl: '',
+      pickList: [],
+      Icon: '',
+      Imglist: [],
     };
   },
   onLoad() {
+    // 初始化阿里云
+    myCloud = uniCloud.init({
+      provider: 'aliyun',
+      spaceId: 'db8671a1-69bd-470d-ad59-ba927c88f4a4',
+      clientSecret: '8nOzV70edtpCd0El6qce3g==',
+    });
     this.getShopList();
   },
   methods: {
     // 跳转到管理分类页面
     toClassify() {
       if (this.storeId) {
-        uni.setStorageSync('shopid',this.storeId)
+        uni.setStorageSync('shopid', this.storeId);
         this.$mRouter.push({ route: '/pages/shop/classify' });
       } else {
-        this.$mHelper.toast('请选择所属店铺后再进行自定义分类管理')
+        this.$mHelper.toast('请选择所属店铺后再进行自定义分类管理');
       }
     },
     // 选择店铺
     changeStore(e) {
       this.storeIndex = e.detail.value;
       this.storeId = this.storeList[this.storeIndex].id;
-      
+
       // 未选择商铺不能进行商铺类型选择
       if (this.storeId != '') {
         this.getType();
@@ -257,7 +277,7 @@ export default {
     },
     // 所属店铺
     async getShopList() {
-      this.storeList = [{ name: '所属店铺', id: '' }]
+      this.storeList = [{ name: '所属店铺', id: '' }];
       await this.$http
         .get('/shop/getList', {
           mid: this.scenicId,
@@ -274,7 +294,7 @@ export default {
     },
     // 商品类型
     async getType() {
-      this.typeList = [{ name: '商品类型(请先选择所属店铺)', id: '' }]
+      this.typeList = [{ name: '商品类型(请先选择所属店铺)', id: '' }];
       this.$http
         .get('/type/getTypeListByShopId', {
           id: this.storeId,
@@ -289,7 +309,7 @@ export default {
     },
     // 商品名称
     async getShopName() {
-      this.shopList = [{ name: '商品名称(请先选择商品类型)', id: '' }]
+      this.shopList = [{ name: '商品名称(请先选择商品类型)', id: '' }];
       await this.$http
         .get('/goods/getTicketGoods', {
           typeId: this.typeId,
@@ -357,34 +377,27 @@ export default {
         sourceType: ['album'], // camera 使用相机   album 从相册中选
         success: function (res) {
           // 成功则返回图片的本地文件路径列表 tempFilePaths
-          _self.img = res.tempFilePaths[0];
+          _self.iconurl = res.tempFilePaths[0];
 
-          let myCloud = uniCloud.init({
-            provider: 'aliyun',
-            spaceId: 'bc6ff3c9-ac50-449a-aa09-38ec42b68dc3',
-            clientSecret: 'i0TfgbVL3IB/nTeqtWOJbw=='
-          });
+          console.log(_self.iconurl);
 
           myCloud.uploadFile({
-            url: 'http://192.168.100.135:83/merch/common/upload/oss', // 是否包含baseurl???
-            filePath: _self.img, // 要上传的文件对象
-            cloudPath: _self.img,
+            url: 'http://192.168.100.135:83/merch/common/upload/oss',
+            filePath: _self.iconurl, // 要上传的文件对象
+            cloudPath: _self.iconurl,
             name: 'file',
             onUploadProgress: function (progressEvent) {
               // 上传进度回调
-              console.log(progressEvent);
               let percentCompleted = Math.round(
                 (progressEvent.loaded * 100) / progressEvent.total
               );
+              console.log(percentCompleted);
             },
-            success: (res) =>{
-              console.log(res);
-            },
-            fail:(error)=> {
-              console.log(error);
-            },
-            complete:(msg)=> {
-              console.log(msg);
+            success: (res) => {
+              if (res.fileID) {
+                _self.Icon = res.fileID;
+                console.log(_self.Icon);
+              }
             },
           });
         },
@@ -399,20 +412,37 @@ export default {
         sourceType: ['album'], // camera 使用相机   album 从相册中选
         success: function (res) {
           // 成功则返回图片的本地文件路径列表 tempFilePaths
-          console.log(res.tempFilePaths);
           let img = [];
           img.push(res.tempFilePaths);
           if (_self.pickList.length >= 6) {
             _self.$mHelper.toast('最多只可上传6张图片');
           } 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
+            //       );
+            //       console.log(percentCompleted);
+            //     },
+            //     success: (res) => {
+            //       console.log(res);
+            //     },
+            //   });
+            // }
           }
         },
       });
     },
     // 删除图册中的图片
     deleteThisImg(index) {
-      console.log(index);
       this.pickList.splice(index, 1);
     },
     // 富文本失去焦点保存内容
@@ -425,6 +455,8 @@ export default {
     // },
     // 内容提交
     submitMesage() {
+      let _this = this;
+      this.loading = true;
       let astrictDate = {};
       // 判断是否限制账号购买
       if (this.showoperat) {
@@ -440,31 +472,28 @@ export default {
         astrictDate = '';
       }
       // 判断是否可以自定义商品名称
-      let name = ''
-      if (this.shopList.length = 1) {
-        name = this.shopname
+      let name = '';
+      if ((this.shopList.length = 1)) {
+        name = this.shopname;
       } else {
-        name = this.shopList[this.shopIndex].id
+        name = this.shopList[this.shopIndex].id;
       }
-
-      console.log(this.storeId);
-      console.log(this.typeId);
-      console.log(name);
-
       if (!this.storeId) {
-        this.$mHelper.toast('请选择所属商铺')
-        return
+        this.$mHelper.toast('请选择所属商铺');
+        this.loading = false;
+        return;
       }
       if (!this.typeId) {
-        this.$mHelper.toast('请选择商品类型')
-        return
+        this.$mHelper.toast('请选择商品类型');
+        this.loading = false;
+        return;
       }
       if (!name) {
-        this.$mHelper.toast('请选择商品名称或者输入商品名称')
-        return
+        this.$mHelper.toast('请选择商品名称或者输入商品名称');
+        this.loading = false;
+        return;
       }
 
-      return
       this.$http
         .post('/goods/add', {
           mid: this.scenicId,
@@ -475,12 +504,14 @@ export default {
           saleRule: this.showoperat,
           saleRuleJson: JSON.stringify(astrictDate),
           describ: this.mastKnow,
+          icon: this.Icon || '',
         })
         .then((res) => {
           if (res.code === 200 && res.msg === 'OK') {
-            this.$mHelper.toast('添加成功')
+            this.$mHelper.toast('添加成功');
+            this.loading = false;
             setTimeout(() => {
-              this.$mRouter.back()
+              this.$mRouter.back();
             }, 500);
           }
         });

+ 1 - 0
src/utils/request/request.js

@@ -223,6 +223,7 @@ export default class Request {
 
   // #endif
 
+
   // #ifdef APP-PLUS || H5 || MP-WEIXIN || MP-BAIDU
   delete (url, data, options = {}) {
     return this.request({