Browse Source

1.上传文件优化 2.新增解决方案入口 3.部分bug修改

xinfeng 6 years ago
parent
commit
43e605e87d
6 changed files with 85 additions and 14 deletions
  1. 1 1
      assets/css/kaifain/kaifainAdd.scss
  2. 12 0
      components/header.vue
  3. 13 3
      mixins/uploadFile.js
  4. 1 0
      nuxt.config.js
  5. 27 8
      pages/kaifain/add.vue
  6. 31 2
      pages/kaifain/index.vue

+ 1 - 1
assets/css/kaifain/kaifainAdd.scss

@@ -80,7 +80,7 @@
         color: rgba(16, 185, 106, 1);
         line-height: 20px;
       }
-      &:none {
+      &.none {
         background: rgba(235, 235, 235, 1);
         border: none;
         border-radius: 3px;

+ 12 - 0
components/header.vue

@@ -49,6 +49,18 @@
               />技术信用
             </a>
           </el-dropdown-item>
+          <el-dropdown-item>
+            <a
+              class="workstation"
+              href="/kaifain"
+              style="display: flex; align-items: center;"
+            >
+              <img
+                src="@/assets/img/header/partners.png"
+                style="width: 24px;height: 24px;margin-right: 5px;"
+              />解决方案
+            </a>
+          </el-dropdown-item>
         </el-dropdown-menu>
       </el-dropdown>
       <div>

+ 13 - 3
mixins/uploadFile.js

@@ -9,6 +9,7 @@ export default {
         auto: true,
         compress: null,
       },
+      upload_id: '',
       file: null,
       post_url: ''
     }
@@ -24,6 +25,7 @@ export default {
       }).then( (data) => {
         this.uploadInfo = data.data.data.post_params;
         this.post_url = data.data.data.post_url;
+        this.upload_id = data.data.data.upload_id;
         this.apiSend(file, cb)
       })
       return uploadInfo;
@@ -36,13 +38,21 @@ export default {
         console.log('key', key)
         formData.append(key, this.uploadInfo[key])
       }
-      console.log(formData)
       this.$axios.$post(this.options.server, formData, {
         headers: { "Content-Type": "multipart/form-data" }
       }).then(res=>{
-        cb && cb(res, this.post_url)
+        this.returnData = res.data
+        this.uploadCb(cb)
+      })
+    },
+    uploadCb(cb) {
+      let p = {
+        upload_id: this.upload_id,
+        return_data: JSON.stringify(this.returnData)
+      }
+      this.$axios.post('/file/uploadCallback', p).then(res=>{
+        cb && cb(res)
       })
     }
-    
   }
 }

+ 1 - 0
nuxt.config.js

@@ -101,6 +101,7 @@ module.exports = {
     [ '/api', { target: 'https://dev.test.proginn.com', changeOrigin: true } ],
     [ '/file/proxyUpload', { target: 'https://dev.test.proginn.com', changeOrigin: true } ],
     [ '/file/prepareUpload', { target: 'https://dev.test.proginn.com', changeOrigin: true } ],
+    [ '/file/uploadCallback', { target: 'https://dev.test.proginn.com', changeOrigin: true } ],
     [ '/programmerinnfile', { target: 'https://v0.api.upyun.com', changeOrigin: true } ],
     [ '/upload_image', { target: 'https://dev.test-jishuin.proginn.com', changeOrigin: true } ],
     [ '/image', { target: 'https://stacdn.proginn.com', changeOrigin: true } ]

+ 27 - 8
pages/kaifain/add.vue

@@ -13,8 +13,8 @@
       </div>
     </div>
     <div class="bodyArea">
-      <div class="statusBox" :class="{none: true}">
-        <p>{{'已入驻'}}</p>
+      <div class="statusBox" :class="{none: !(statusObj.isOk)}">
+        <p>{{statusObj.name}}</p>
       </div>
 
       <div class="nameBox">
@@ -244,6 +244,17 @@
       this.getDraftInfo()
       this.getTypeList()
     },
+    computed: {
+      statusObj() {
+        let status = Number(this.data.status || 0)
+        let nameList = ['未申请', '审核中', '已入驻', '拒绝']
+        let o = {
+          isOk: status === 2,
+          name: nameList[status]
+        }
+        return o
+      }
+    },
     async mounted() {
     },
     methods: {
@@ -308,10 +319,13 @@
         formData.append("file", file);
         formData.append("original_filename", file.name);
         this.uploading = true;
-        this.apiPrepareUpload(file, (res, baseUrl)=>{
-          if (res.code === 200) {
-            this.dataItem.file = baseUrl + res.url
-            this.fileList = [{name:file.name, url: this.dataItem.file}]
+        this.apiPrepareUpload(file, (res)=>{
+          if (res.data && res.data.status === 1) {
+            let url = res.data.data.url
+            this.dataItem.file = url
+            this.fileList = [{name:file.name, url: url}]
+          } else {
+            this.$message.error('上传失败')
           }
         })
         return false
@@ -382,7 +396,7 @@
           }
         }
         p.provider_id = this.data.id
-
+        console.log("添加案例", this.dataItem, p)
         let isEdit = !!p.id
         if (!p.title || p.title.length < 2 || p.title.length > 20) {
           this.$message.warning('请填写2-20字符的案例名称!')
@@ -404,7 +418,11 @@
         this.$axios.post(url, p).then(res => {
           if (Number(res.data.status) === 1) {
             this.dataItem.id = 4
-            this.data.successful_case.push(this.dataItem)
+            if (!isEdit) {
+              this.data.successful_case.push(this.dataItem)
+            } else {
+              this.getDraftInfo()
+            }
             this.dataItem = {
               provider_id: 0, title: '', logo: '', description: '', file: '',
             }
@@ -468,6 +486,7 @@
               this.$message.success('保存成功')
             } else {
               this.$message.success('发布成功')
+              location.href = "/wo/" + this.$store.state.userinfo.uid
             }
           }
         })

+ 31 - 2
pages/kaifain/index.vue

@@ -23,7 +23,7 @@
               <p>{{item.name}}</p>
             </div>
           </div>
-          <div class="more" @click="changeExpansion(key)">
+          <div class="more" @click="changeExpansion(key)" v-if="typeList[key].list.length > 8">
             {{expansion[key] ? "收起" : "展开"}}
           </div>
         </div>
@@ -42,7 +42,7 @@
               <div class="top">
                 <div class="titleA">
                   <div class="title">{{item.title}}</div>
-                  <div class="tips">{{item.tech_type}}</div>
+                  <div class="tips">{{getTechTypeName(item)}}</div>
                 </div>
                 <div class="intro">
                   <p class="tt">介绍:</p>
@@ -170,6 +170,16 @@
         this.selected[key] = item.id
         this.getList()
       },
+      getTechTypeName(item1) {
+        try {
+          console.log(item1)
+          let d = this.typeList.techType.list.filter(item => Number(item1.tech_type) == Number(item.id))[0] || {}
+          return d.name
+        } catch (e) {
+          console.log('e', e)
+          return ''
+        }
+      },
       changeExpansion(key) {
         this.expansion[key] = !this.expansion[key]
       },
@@ -218,6 +228,25 @@
         this.getList()
       },
       handleApplyBtnClick() {
+        const {userinfo} = this.$store.state || {}
+        //检查登录
+        if (!userinfo || !userinfo.uid) {
+          this.$message.info('请先登录!')
+          location.href = '/?loginbox=show'
+          return
+        }
+        // //去绑定手机号
+        // if (!userinfo.mobile) {
+        //   this.$message.info('请先绑定手机号')
+        //   window.open('/setting/user', '__black')
+        //   return
+        // }
+        // //判断是否是首次入驻
+        // if (!userinfo.is_first_join) {
+        //   location.href = "/wo/" + userinfo.uid
+        //   return
+        // }
+
         location.href = "/kaifain/add";
       },