zhuxinbo 5 år sedan
förälder
incheckning
af5c7f58c6
2 ändrade filer med 44 tillägg och 40 borttagningar
  1. 30 23
      src/views/modules/video/video.vue
  2. 14 17
      src/views/template/creative/modules/material.vue

+ 30 - 23
src/views/modules/video/video.vue

@@ -148,6 +148,7 @@
 import ARow from 'ant-design-vue/es/grid/Row'
 import ACol from 'ant-design-vue/es/grid/Col'
 import axios from 'axios'
+var interval
 import {
   getLoginQr,
   getUserList,
@@ -190,6 +191,7 @@ export default {
     handleChange(value) {
       this.ksid = value
       this.dataShow = []
+      clearInterval(interval)
       this.getVideoList(value, null)
       //   this.getTest()
     },
@@ -222,6 +224,7 @@ export default {
     },
     getVideoList(ksid, pcursor) {
       var that = this
+
       getVideoList({ ksid: ksid, pcursor: pcursor }).then(res => {
         if (res.code == 0) {
           var data = res.result.data.publicFeeds.list.map(item => {
@@ -233,25 +236,29 @@ export default {
           this.pcursor = res.result.data.publicFeeds.pcursor
           this.dataShow.push(...data)
           var i = 0
-          //   for (let i = 0; i < data.length; i++) {
-          setInterval(() => {
-            if (i < that.dataShow.length) {
-              setTimeout(
-                that.getCommentList(ksid, that.dataShow[i].photoId).then(dataOne => {
-                  console.log(dataOne)
-                  if (dataOne) {
-                    that.dataShow[i].commentList = dataOne
-                  }
-                  //   commentList
+          interval = setInterval(() => {
+            if (i <= that.dataShow.length) {
+              ;(function(a) {
+                setTimeout(function() {
+                  that.getCommentList(ksid, that.dataShow[a].photoId).then(dataOne => {
+                    if (dataOne && that.dataShow[a]) {
+                      that.dataShow[a].commentList = dataOne.commentList
+                    } else {
+                      that.dataShow[a].commentList = []
+                    }
+                  })
+                }, 0)
+                if (that.dataShow.length == 0) {
+                  clearInterval(interval)
+                  i = 0
+                } else {
                   i++
-                }),
-                0
-              )
+                }
+              })(i)
             } else {
+              clearInterval(interval)
             }
-          }, 3000)
-
-          //   }
+          }, 10000)
         }
       })
     },
@@ -259,7 +266,7 @@ export default {
       return new Promise(function(resolve) {
         getCommentList({ ksid: ksid, photoId: photoId, pcursor: null }).then(res => {
           if (res.code == 0) {
-            resolve(res.result.data.shortVideoCommentList.commentList)
+            resolve(res.result.data.shortVideoCommentList)
           }
         })
       })
@@ -268,12 +275,12 @@ export default {
       return new Promise(resolve => setTimeout(resolve, d))
     },
     remove(allItem, item, index) {
-      console.log(allItem, item)
-      allItem.commentList.splice(index, 1)
-      //   String ksid,String photoId,Long commentId
-      commentDelete({ ksid: this.ksid, photoId: allItem.photoId, commentId: item.commentId }).then(res => {
-        console.log(res)
-      })
+      //   console.log(allItem, item)
+      //   allItem.commentList.splice(index, 1)
+      //   //   String ksid,String photoId,Long commentId
+      //   commentDelete({ ksid: this.ksid, photoId: allItem.photoId, commentId: item.commentId }).then(res => {
+      //     console.log(res)
+      //   })
     },
     getScrollTop: function() {
       var scrollTop = 0,

+ 14 - 17
src/views/template/creative/modules/material.vue

@@ -139,7 +139,7 @@
       <a-button @click="addTitle">添加创意标题</a-button>
       <br />
       <div v-for="(item,index) of titleData" :key="index">
-        <a-input style="width:55%" v-model="item.text" class="rending-all"></a-input>
+        <a-input style="width:55%" v-model="item.text" class="rending-all" @change="judge(item)"></a-input>
         <a-icon
           type="delete"
           style="margin-left:20px;cursor: pointer;"
@@ -163,7 +163,6 @@ import { postAction, getAction, getPackage } from '@/api/manage'
 import moment from 'moment'
 import AFormItem from 'ant-design-vue/es/form/FormItem'
 import $ from 'jquery'
-
 export default {
   name: 'BaseForm',
   props: {
@@ -233,25 +232,23 @@ export default {
   },
   methods: {
     judge(item) {
-      var left = item.text.split('{')
-      var right = item.text.split('}')
-      console.log(left)
-      if (item.countTag == 0) {
-        return
-      } else {
-        if (left.length != 3 && right.lenght != 3) {
-          item.countTag -= 1
-        }
+      var re = /{(.*?)}/g
+      var array = []
+      var temp
+      while ((temp = re.exec(item.text))) {
+        array.push(temp[1])
       }
+      console.log(array)
+      item.countTag = array.length
     },
     getChange(item, tag, index) {
-      item.countTag++
+      this.judge(item)
       if (item.text == '') {
         item.countTag = 0
       }
       if (item.countTag >= 2) {
         this.$message.error('最多插入两条词包')
-        item.countTag = 2
+        // item.countTag = 2
         return
       }
       var node = document.getElementsByClassName('rending')[index]
@@ -283,13 +280,13 @@ export default {
       }
     },
     getChangeAllTitle(item, tag, index) {
-      item.titleMany++
+      this.judge(item)
       if (item.text == '') {
-        item.titleMany = 0
+        item.countTag = 0
       }
-      if (item.titleMany >= 2) {
+      if (item.countTag >= 2) {
         this.$message.error('最多插入两条词包')
-        item.titleMany = 2
+        // item.countTag = 2
         return
       }
       var node = document.getElementsByClassName('rending-all')[index]