448368749@qq.com před 4 roky
rodič
revize
e63049b447
5 změnil soubory, kde provedl 111 přidání a 23 odebrání
  1. 1 1
      src/manifest.json
  2. 4 1
      src/pages.json
  3. 12 2
      src/pages/shop/shop.vue
  4. 93 18
      src/pages/shop/shopdetail.vue
  5. 1 1
      src/utils/helper.js

+ 1 - 1
src/manifest.json

@@ -1,6 +1,6 @@
 {
     "name" : "Rageframe商城",
-    "appid" : "__UNI__8006C11",
+    "appid" : "__UNI__B6E0DB1",
     // 自行更换uniapp appid 可登录查看uniapp提供的用户统计 https://tongji.dcloud.net.cn/
     "description" : "Rageframe商城",
     "versionName" : "1.0.0",

+ 4 - 1
src/pages.json

@@ -1,5 +1,6 @@
 {
   "pages": [
+   
     {
       "path": "pages/public/login",
       "style":{
@@ -86,7 +87,9 @@
 		{
 			"path":"pages/shop/shopdetail",
 			"style":{
-				"navigationBarTitleText": "商品详情"
+        "navigationBarTitleText": "商品详情",
+        "navigationBarBackgroundColor":"#ffffff"
+        
 			}
 		},
 		{

+ 12 - 2
src/pages/shop/shop.vue

@@ -375,8 +375,18 @@ export default {
       console.log(2);
     },
     // 修改商品状态
-    async changeShopStatus(ids,state) {
-      await this.$http.postP('/goods/changeStatusOrUpDown',{id:10,upDown:1}).then( async(res)=>{
+    async changeShopStatus(ids,upordown,state) {
+      let data = {
+        id: ids,
+        upDown: upordown,
+        status: state
+      }
+      if (state) {
+        delete data.upDown
+      } else {
+        delete data.status
+      }
+      await this.$http.post('/goods/changeStatusOrUpDown',data).then( async(res)=>{
         console.log(res);
       })
     }

+ 93 - 18
src/pages/shop/shopdetail.vue

@@ -54,7 +54,7 @@
       </view>
       <!-- 商品名称 -->
       <view class="shopname detail-list">
-        <view class="menu">
+        <view class="menu" v-if="shopList.length > 1">
           <view class="uni-list-cell">
             <view class="uni-list-cell-db">
               <picker
@@ -75,6 +75,9 @@
             </view>
           </view>
         </view>
+        <view class="menu" v-else>
+          <input class="input-shopname" type="text" v-model="shopname" placeholder-style="color:#a2a8a8;font-size:30upx" placeholder="请输入商品名称">
+        </view>
       </view>
       <!-- 自定义分类 -->
       <view class="classify detail-list noborder">
@@ -163,7 +166,7 @@
             id="editor"
             class="ql-container"
             :placeholder="placeholder"
-            @blur="onEditorReady"
+            @input="saveTxt"
           ></editor>
         </view>
       </view>
@@ -184,11 +187,12 @@ export default {
       scenicId: uni.getStorageSync('scenicId'),
       title: '商品详情',
       num1: 1,
-      num2: 9999,
-      showoperat: true,
+      num2: 10,
+      showoperat: false,
       img: '',
       pickList: [],
       placeholder: '请输入内容...',
+      mastKnow: '',
       storeList: [{ name: '所属店铺', id: '' }],
       storeIndex: 0,
       storeId: '',
@@ -200,6 +204,7 @@ export default {
       shopList: [{ name: '商品名称(请先选择商品类型)', id: '' }],
       shopIndex: 0,
       shopId: '',
+      shopname: '',
 
       hasNameList: 0, // 判断是否有商品名称列表
 
@@ -214,7 +219,6 @@ export default {
   methods: {
     // 跳转到管理分类页面
     toClassify() {
-      console.log('我跳了');
       this.$mRouter.push({ route: '/pages/shop/classify' });
     },
     // 选择店铺
@@ -248,6 +252,7 @@ export default {
     },
     // 所属店铺
     async getShopList() {
+      this.storeList = [{ name: '所属店铺', id: '' }]
       await this.$http
         .get('/shop/getList', {
           mid: this.scenicId,
@@ -264,6 +269,7 @@ export default {
     },
     // 商品类型
     async getType() {
+      this.typeList = [{ name: '商品类型(请先选择所属店铺)', id: '' }]
       this.$http
         .get('/type/getTypeListByShopId', {
           id: this.storeId,
@@ -278,15 +284,17 @@ export default {
     },
     // 商品名称
     async getShopName() {
+      this.shopList = [{ name: '商品名称(请先选择商品类型)', id: '' }]
       await this.$http
         .get('/goods/getTicketGoods', {
           typeId: this.typeId,
           shopId: this.storeId,
         })
         .then(async (res) => {
+          console.log(res);
           let arr = [];
           res.data.forEach((element) => {
-            arr.push({ name: element.ticket_name, id: element.shopId });
+            arr.push({ name: element.ticket_name, id: element.ticket_no });
           });
           this.shopList = this.shopList.concat(arr);
           console.log(this.shopList);
@@ -334,7 +342,7 @@ export default {
     addDate() {
       this.num2++;
     },
-    // 图上传
+    // 图上传
     uploadImg() {
       let _self = this;
       uni.chooseImage({
@@ -343,8 +351,36 @@ export default {
         sourceType: ['album'], // camera 使用相机   album 从相册中选
         success: function (res) {
           // 成功则返回图片的本地文件路径列表 tempFilePaths
-
           _self.img = res.tempFilePaths[0];
+
+          let myCloud = uniCloud.init({
+            provider: 'aliyun',
+            spaceId: 'bc6ff3c9-ac50-449a-aa09-38ec42b68dc3',
+            clientSecret: 'i0TfgbVL3IB/nTeqtWOJbw=='
+          });
+
+          myCloud.uploadFile({
+            url: 'http://192.168.100.135:83/merch/common/upload/oss', // 是否包含baseurl???
+            filePath: _self.img, // 要上传的文件对象
+            cloudPath: _self.img,
+            name: 'file',
+            onUploadProgress: function (progressEvent) {
+              // 上传进度回调
+              console.log(progressEvent);
+              let percentCompleted = Math.round(
+                (progressEvent.loaded * 100) / progressEvent.total
+              );
+            },
+            success: (res) =>{
+              console.log(res);
+            },
+            fail:(error)=> {
+              console.log(error);
+            },
+            complete:(msg)=> {
+              console.log(msg);
+            },
+          });
         },
       });
     },
@@ -373,22 +409,57 @@ export default {
       console.log(index);
       this.pickList.splice(index, 1);
     },
-    // 保存富文本
-    onEditorReady() {
-      uni
-        .createSelectorQuery()
-        .select('#editor')
-        .context((res) => {
-          this.editorCtx = res.context;
-        })
-        .exec();
+    // 富文本失去焦点保存内容
+    saveTxt(e) {
+      this.mastKnow = e.detail.html;
     },
     // 清空富文本
     // undo() {
     //   this.editorCtx.undo();
     // },
     // 内容提交
-    submitMesage() {},
+    submitMesage() {
+      let astrictDate = {};
+      // 判断是否限制账号购买
+      if (this.showoperat) {
+        this.showoperat = '1';
+        astrictDate = {
+          data: {
+            saleDay: this.num1,
+            saleNum: this.num2,
+          },
+        };
+      } else {
+        this.showoperat = '0';
+        astrictDate = '';
+      }
+      // 判断是否可以自定义商品名称
+      let name = ''
+      if (this.shopList.length = 1) {
+        name = this.shopname
+      } else {
+        name = this.shopList[this.shopIndex].id
+      }
+      this.$http
+        .post('/goods/add', {
+          mid: this.scenicId,
+          shopId: this.storeId,
+          typeId: this.typeId,
+          name: name,
+          customGroupId: this.lineId,
+          saleRule: this.showoperat,
+          saleRuleJson: JSON.stringify(astrictDate),
+          describ: this.mastKnow,
+        })
+        .then((res) => {
+          if (res.code === 200 && res.msg === 'OK') {
+            this.$mHelper.toast('添加成功')
+            setTimeout(() => {
+              this.$mRouter.back()
+            }, 500);
+          }
+        });
+    },
   },
 };
 </script>
@@ -435,6 +506,10 @@ export default {
           color: #232828;
           font-weight: 700;
         }
+        .input-shopname {
+          width: 100%;
+          height: 100%;
+        }
         .txt {
           color: #a95cff;
           font-weight: 700;

+ 1 - 1
src/utils/helper.js

@@ -44,7 +44,7 @@ export default {
 			content: '会话已过期,是否跳转登录页面?',
 			success: (confirmRes) => {
 				if (confirmRes.confirm) {
-					mRouter.push({ route: '/pages/public/logintype' });
+					mRouter.push({ route: '/pages/public/login' });
 				}
 			}
 		});