Browse Source

新闻页

tangxijun 6 years ago
parent
commit
8bfebca67b
1 changed files with 6 additions and 49 deletions
  1. 6 49
      wx/fortnite_wx/src/components/newsList.vue

+ 6 - 49
wx/fortnite_wx/src/components/newsList.vue

@@ -34,7 +34,10 @@
 </template>
 
 <script>
+import { client } from '@/utils/client.js'
+
 export default {
+
     props: {
         articleList: {
             type: Array,
@@ -70,56 +73,10 @@ export default {
         swiperChange (e) {
             this.currentSwiper = e.target.current
         },
-        // 判断是否存在
-        filter (storage, listItem) {
-            storage.forEach((item, index) => {
-                console.log('filter')
-                item.array.forEach((detail, deIndex) => {
-                    if (listItem.comment3Uniqid === detail.comment3Uniqid) {
-                        return false
-                    } else {
-
-                    }
-                    // if(detail[deIndex])
-                })
-            })
-        },
-        async   getNews (listItem) {
-            let storage = await wx.getStorageSync('newsRecordList')
-            console.log(wx.getStorageSync('newsRecordList'))
-            let timestamp = Date.parse(new Date())
-            timestamp = timestamp.toString().replace(/.{3}$/, '')
-
-            // 判断是否存在缓存
-            if (storage) {
-                console.log(this.filter(storage, listItem))
 
-                console.log('yes')
-                storage.forEach((item, index) => {
-                    // 判断当前是否已经存储过记录
-                    if (timestamp - storage[index].data >= 3) {
-                        let obj = {
-                            data: timestamp,
-                            array: [listItem]
-                        }
-                        storage.push(obj)
-                        return storage
-                    } else {
-                        storage[index].array.push(listItem)
-                        return storage
-                    }
-                })
-                wx.setStorageSync('newsRecordList', storage)
-            } else {
-                console.log('no')
-                let newsRecordList = [
-                    {
-                        data: timestamp,
-                        array: [listItem]
-                    }
-                ]
-                wx.setStorageSync('newsRecordList', newsRecordList)
-            }
+        // 存储在本地
+        getNews (listItem) {
+            client.getNewsSto(listItem)
         }
     },
     created () {