Эх сурвалжийг харах

处理首页特价区CMS接口处理

Administrator 7 жил өмнө
parent
commit
e0c1243a43

+ 1 - 2
components/home/floor/Floor.vue

@@ -10,7 +10,7 @@
           <div class="floor-content">
             <p v-if="item.name" class="floor-item-name" :title="item.name">{{ item.name }}</p>
             <p v-if="item.body" v-html="item.body" class="floor-item-body"></p>
-            <p class="floor-item-price" v-if="item.size != 'large' && isDefault">{{item.currency == 'RMB' ? '¥' : '$'}}&nbsp;{{item.price}}</p>
+            <p class="floor-item-price" v-if="item.size != 'large' && isDefault">{{item.price}}</p>
           </div>
         </a>
       </li>
@@ -163,7 +163,6 @@
       &.small {
         width: 220px;
         height: 200px;
-
         a {
           img {
             margin-top: 15px;

+ 43 - 81
components/home/floor/FloorList.vue

@@ -49,11 +49,9 @@
           </li>
         </ul>
       </div>
-      <floor :floor="defaultFloors[0]" :isDefault="true" v-if="!isEmpty"></floor>
-      <floor :floor="defaultFloors[1]" :isDefault="true" v-if="!isEmpty"></floor>
-      <floor v-for="(floor, index) in floorsList" :floor="floor" :isDefault="false" :key="index"></floor>
+      <floor v-for="floor in expandList" :floor="floor" :isDefault="true"></floor>
+      <floor v-for="floor in floorsList" :floor="floor" :isDefault="false"></floor>
     </div>
-    <span v-if="expandFloors && false">floor</span>
     <say-price :current="currentSayPriceIndex"
                :purchase="purchaseManListData || {}"
                @cancelSayPriceAction="cancelSayPrice"
@@ -76,30 +74,6 @@
     },
     data () {
       return {
-        defaultFloors: [
-          {
-            items: [
-              {
-                backGroundColor: '',
-                body: '',
-                hrefUrl: '/store/33069557578d44e69bd91ad12d28a8d4',
-                pictureUrl: '/images/floor/banner01.jpg',
-                size: 'large'
-              }
-            ]
-          },
-          {
-            items: [
-              {
-                backGroundColor: '',
-                body: '',
-                hrefUrl: '/store/33069557578d44e69bd91ad12d28a8d4',
-                pictureUrl: '/images/floor/banner02.jpg',
-                size: 'large'
-              }
-            ]
-          }
-        ],
         timerIndex: 0,
         pageSize: 50,
         nowPage: 1,
@@ -141,19 +115,25 @@
     },
     computed: {
       floorsF1 () {
-        return this.$store.state.floor.listF1.data
+        return this.$store.state.floor.list_v3.data.data.home_floor_f1
       },
       floorsF2 () {
-        return this.$store.state.floor.listF2.data
+        return this.$store.state.floor.list_v3.data.data.home_floor_f2
       },
       floorsF3 () {
-        return this.$store.state.floor.listF3.data
+        return this.$store.state.floor.list_v3.data.data.home_floor_f3
       },
       floorsF4 () {
-        return this.$store.state.floor.listF4.data
+        return this.$store.state.floor.list_v3.data.data.home_floor_f4
       },
       floorsF5 () {
-        return this.$store.state.floor.listF5.data
+        return this.$store.state.floor.list_v3.data.data.home_floor_f5
+      },
+      expandF1 () {
+        return this.$store.state.floor.list_v3.data.data.home_expand_f1
+      },
+      expandF2 () {
+        return this.$store.state.floor.list_v3.data.data.home_expand_f2
       },
       floorsList () {
         let lists = []
@@ -161,11 +141,11 @@
         for (let i = 0; i < floorName.length; i++) {
           lists.push({'floorNumber': i + 1, 'name': floorName[i]})
         }
-        lists[0].items = this.floorsF1.data
-        lists[1].items = this.floorsF2.data
-        lists[2].items = this.floorsF3.data
-        lists[3].items = this.floorsF4.data
-        lists[4].items = this.floorsF5.data
+        lists[0].items = this.floorsF1
+        lists[1].items = this.floorsF2
+        lists[2].items = this.floorsF3
+        lists[3].items = this.floorsF4
+        lists[4].items = this.floorsF5
         lists.slice().forEach(function(value) {
           let lengs = value.items.length
           for (let j = 0; j < lengs; j++) {
@@ -175,55 +155,37 @@
             value.items[j].size = value.items[j].metadatas.contExp_spec
             value.items[j].hrefUrl = value.items[j].detailsLink
             value.items[j].pictureUrl = value.items[j].pictureLink
+            value.items[j].price = value.items[j].remark
+            value.items[j].isNull = value.items[j].pictureLink === null
           }
         })
         return lists
       },
-      isProd () {
-        return this.$store.state.option.url === 'http://www.usoftmall.com'
-      },
-      expandFloors () {
-        let data = this.$store.state.floor.list_expand.data
-        let _this = this
-        for (let i = 0; i < data.length; i++) {
-          let obj = {
-            backGroundColor: '',
-            body: '',
-            hrefUrl: '',
-            name: '',
-            pictureUrl: '',
-            size: '',
-            price: '',
-            currency: 'RMB'
-          }
-          if (data[i]) {
-            obj.name = data[i].code
-            obj.body = data[i].brandNameEn + '<br/>' + (data[i].kindNameCn || '其他')
-            obj.hrefUrl = '/store/productDetail/' + data[i].batchCode
-            obj.pictureUrl = '/images/floor/' + (this.isProd ? data[i].code : '2SD2704KT146') + '.png'
-            obj.currency = data[i].currencyName
-            obj.price = _this.getMinPrice(data[i].prices, data[i].currencyName)
-          } else {
-            // 如果是空数据
-            obj.isNull = true
-          }
-          obj.size = i % 3 === 0 ? 'medium' : 'small'
-          _this.defaultFloors[i < 6 ? 0 : 1].items.push(obj)
+      expandList () {
+        let lists = []
+        let floorName = ['特价1', '特价2']
+        for (let i = 0; i < floorName.length; i++) {
+          lists.push({'floorNumber': i + 1, 'name': floorName[i]})
         }
-        return data
-      },
-      isEmpty () {
-        let data = this.$store.state.floor.list_expand.data
-        if (!data.length) {
-          return true
-        } else {
-          for (let i = 0; i < data.length; i++) {
-            if (!(data[0] && data[0] !== null)) {
-              return true
-            }
+        lists[0].items = this.expandF1
+        lists[1].items = this.expandF2
+        lists.slice().forEach(function(value) {
+          let lengs = value.items.length
+          for (let j = 0; j < lengs; j++) {
+            value.items[j].backGroundColor = value.items[j].metadatas.contExp_select
+            value.items[j].body = value.items[j].metadatas.contExp_remark
+            value.items[j].name = value.items[j].metadatas.contExp_abstract
+            value.items[j].size = value.items[j].metadatas.contExp_spec
+            value.items[j].hrefUrl = value.items[j].detailsLink
+            value.items[j].pictureUrl = value.items[j].pictureLink
+            value.items[j].price = value.items[j].remark
+            value.items[j].isNull = value.items[j].pictureLink === null
           }
-        }
-        return false
+        })
+        return lists
+      },
+      isProd () {
+        return this.$store.state.option.url === 'http://www.usoftmall.com'
       },
       purchaseManListData () {
 //        let list = this.$store.state.applyPurchase.purchaseManList.purchaseManList.data

+ 2 - 59
pages/index.vue

@@ -26,39 +26,12 @@
     name: 'index',
     // middleware: 'wechatInfo',
     layout (context) {
-//      console.log(context.store.state.option.isMobile)
       return context.store.state.option.isMobile ? 'mobile' : 'main'
     },
     data () {
       return {
         isOpen: false,
-        hasNewYear: false,
-        defaultFloorsData: [
-//        'BT2018012500000141',
-//        'BT2018012500000126',
-//        'BT2018012500000131',
-//        'BT2018012500000152',
-//        'BT2018012500000124',
-//        'BT2018012500000164',
-//        'BT2018012500000167',
-//        'BT2018012500000145',
-//        'BT2018012500000151',
-//        'BT2018012500000161',
-//        'BT2018012500000149',
-//        'BT2018012500000162'
-          'BT2018012900002056',
-          'BT2018012900002056',
-          'BT2018012900002056',
-          'BT2018012900002056',
-          'BT2018012900002056',
-          'BT2018012900002056',
-          'BT2018012900002056',
-          'BT2018012900002056',
-          'BT2018012900002056',
-          'BT2018012900002056',
-          'BT2018012900002056',
-          'BT2018012900002056'
-        ]
+        hasNewYear: false
       }
     },
     components: {
@@ -79,11 +52,7 @@
       let nowMonth = today.getMonth() + 1
       let LastMonth = today.getMonth()
       return !store.state.option.isMobile ? Promise.all([
-        store.dispatch('loadNewFloorsF1'),
-        store.dispatch('loadNewFloorsF2'),
-        store.dispatch('loadNewFloorsF3'),
-        store.dispatch('loadNewFloorsF4'),
-        store.dispatch('loadNewFloorsF5'),
+        store.dispatch('loadNewFloors', {type: 'home_floor_f1,home_floor_f2,home_floor_f3,home_floor_f4,home_floor_f5,home_expand_f1,home_expand_f2'}),
         store.dispatch('loadBanners', {type: 'home_banner_carousel'}),
         store.dispatch('loadProductKinds', { id: 0 }),
         store.dispatch('loadNewsSnapshot', { page: 1, pageSize: 10 }),
@@ -92,32 +61,6 @@
         store.dispatch('loadInquirySheet', {year: nowYear, month: nowMonth}),
         store.dispatch('loadInquirySheetLast', {year: nowYear, month: LastMonth}),
         store.dispatch('provider/findSimilarStoreList', {page: 1, count: 10, type: 'ORIGINAL_FACTORY-DISTRIBUTION-AGENCY-CONSIGNMENT', keyword: ''}),
-        store.dispatch('loadBatchCommodities', {batchCodeList: store.state.option.url === 'http://www.usoftmall.com' ? [
-          'BT2018013000000043',
-          'BT2018013000000026',
-          'BT2018013000000030',
-          'BT2018013000000052',
-          'BT2018013000000025',
-          'BT2018013000000053',
-          'BT2018013000000033',
-          'BT2018013000000047',
-          'BT2018013000000057',
-          'BT2018013000000048',
-          'BT2018013000000051',
-          'BT2018013000000020'] : [
-            'BT2018012900002056',
-            'BT2018012900002056',
-            'BT2018012900002056',
-            'BT2018012900002056',
-            'BT2018012900002056',
-            'BT2018012900002056',
-            'BT2018012900002056',
-            'BT2018012900002056',
-            'BT2018012900002056',
-            'BT2018012900002056',
-            'BT2018012900002056',
-            'BT2018012900002056']
-        }),
         store.dispatch('applyPurchase/loadPurchaseManList', {pageNumber: 1, pageSize: 50, enUU: store.state.option.user.data.enterprise ? store.state.option.user.data.enterprise.uu : null}),
         store.dispatch('loadStoreStatus', { op: 'check' })
       ]) : Promise.all([

+ 0 - 84
store/floor.js

@@ -3,33 +3,9 @@ export const state = () => ({
     fetching: false,
     data: []
   },
-  listF1: {
-    fetching: false,
-    data: []
-  },
-  listF2: {
-    fetching: false,
-    data: []
-  },
-  listF3: {
-    fetching: false,
-    data: []
-  },
-  listF4: {
-    fetching: false,
-    data: []
-  },
-  listF5: {
-    fetching: false,
-    data: []
-  },
   list_v3: {
     fetching: false,
     data: []
-  },
-  list_expand: {
-    fetching: false,
-    data: []
   }
 })
 export const mutations = {
@@ -43,56 +19,6 @@ export const mutations = {
     state.list.fetching = false
     state.list.data = result
   },
-  REQUEST_LISTF1 (state) {
-    state.listF1.fetching = true
-  },
-  GET_LIST_FAILUREF1 (state) {
-    state.listF1.fetching = false
-  },
-  GET_LIST_SUCCESSF1 (state, result) {
-    state.listF1.fetching = false
-    state.listF1.data = result
-  },
-  REQUEST_LISTF2 (state) {
-    state.listF2.fetching = true
-  },
-  GET_LIST_FAILUREF2 (state) {
-    state.listF2.fetching = false
-  },
-  GET_LIST_SUCCESSF2 (state, result) {
-    state.listF2.fetching = false
-    state.listF2.data = result
-  },
-  REQUEST_LISTF3 (state) {
-    state.listF3.fetching = true
-  },
-  GET_LIST_FAILUREF3 (state) {
-    state.listF3.fetching = false
-  },
-  GET_LIST_SUCCESSF3 (state, result) {
-    state.listF3.fetching = false
-    state.listF3.data = result
-  },
-  REQUEST_LISTF4 (state) {
-    state.listF4.fetching = true
-  },
-  GET_LIST_FAILUREF4 (state) {
-    state.listF4.fetching = false
-  },
-  GET_LIST_SUCCESSF4 (state, result) {
-    state.listF4.fetching = false
-    state.listF4.data = result
-  },
-  REQUEST_LISTF5 (state) {
-    state.listF5.fetching = true
-  },
-  GET_LIST_FAILUREF5 (state) {
-    state.listF5.fetching = false
-  },
-  GET_LIST_SUCCESSF5 (state, result) {
-    state.listF5.fetching = false
-    state.listF5.data = result
-  },
   REQUEST_NEWLIST (state) {
     state.list_v3.fetching = true
   },
@@ -102,15 +28,5 @@ export const mutations = {
   GET_NEWLIST_SUCCESS (state, result) {
     state.list_v3.fetching = false
     state.list_v3.data = result
-  },
-  REQUEST_EXPANDLIST (state) {
-    state.list_expand.fetching = true
-  },
-  GET_EXPANDLIST_FAILURE (state) {
-    state.list_expand.fetching = false
-  },
-  GET_EXPANDLIST_SUCCESS (state, result) {
-    state.list_expand.fetching = false
-    state.list_expand.data = result
   }
 }

+ 4 - 63
store/index.js

@@ -112,16 +112,6 @@ export const actions = {
         commit('floor/GET_LIST_FAILURE', err)
       })
   },
-  // 批量获取产品信息
-  loadBatchCommodities({ commit }, params = {}) {
-    commit('floor/REQUEST_EXPANDLIST')
-    return axios.post('/api/commodity/detail', params.batchCodeList)
-      .then(response => {
-        commit('floor/GET_EXPANDLIST_SUCCESS', response.data)
-      }, err => {
-        commit('floor/GET_EXPANDLIST_FAILURE', err)
-      })
-  },
   // 获取轮播配置
   loadBanners({ commit }, params = {}) {
     commit('carousel/REQUEST_BANNER')
@@ -132,66 +122,17 @@ export const actions = {
         commit('carousel/GET_BANNER_FAILURE', err)
       })
   },
-  // 获取新楼层配置
-  loadNewFloors({ commit }) {
+
+  // 获取楼层配置和特价信息
+  loadNewFloors({ commit }, params = {}) {
     commit('floor/REQUEST_NEWLIST')
-    return axios.get('/api/floors/home-v3')
+    return axios.get(`/cmsApi?method=queryContentPage&module=${params.type}&orderBy=order_number%20ASC&status=normal`)
       .then(response => {
         commit('floor/GET_NEWLIST_SUCCESS', response.data)
       }, err => {
         commit('floor/GET_NEWLIST_FAILURE', err)
       })
   },
-  // 获取楼层配置f1
-  loadNewFloorsF1({ commit }) {
-    commit('floor/REQUEST_LISTF1')
-    return axios.get(`/cmsApi?method=queryContentPage&module=home_floor_f1&orderBy=order_number%20ASC`)
-      .then(response => {
-        commit('floor/GET_LIST_SUCCESSF1', response.data)
-      }, err => {
-        commit('floor/GET_LIST_FAILUREF1', err)
-      })
-  },
-  // 获取楼层配置f2
-  loadNewFloorsF2({ commit }) {
-    commit('floor/REQUEST_LISTF2')
-    return axios.get(`/cmsApi?method=queryContentPage&module=home_floor_f2&orderBy=order_number%20ASC`)
-      .then(response => {
-        commit('floor/GET_LIST_SUCCESSF2', response.data)
-      }, err => {
-        commit('floor/GET_LIST_FAILUREF2', err)
-      })
-  },
-  // 获取楼层配置f3
-  loadNewFloorsF3({ commit }) {
-    commit('floor/REQUEST_LISTF3')
-    return axios.get(`/cmsApi?method=queryContentPage&module=home_floor_f3&orderBy=order_number%20ASC`)
-      .then(response => {
-        commit('floor/GET_LIST_SUCCESSF3', response.data)
-      }, err => {
-        commit('floor/GET_LIST_FAILUREF3', err)
-      })
-  },
-  // 获取楼层配置f4
-  loadNewFloorsF4({ commit }) {
-    commit('floor/REQUEST_LISTF4')
-    return axios.get(`/cmsApi?method=queryContentPage&module=home_floor_f4&orderBy=order_number%20ASC`)
-      .then(response => {
-        commit('floor/GET_LIST_SUCCESSF4', response.data)
-      }, err => {
-        commit('floor/GET_LIST_FAILUREF4', err)
-      })
-  },
-  // 获取楼层配置f5
-  loadNewFloorsF5({ commit }) {
-    commit('floor/REQUEST_LISTF5')
-    return axios.get(`/cmsApi?method=queryContentPage&module=home_floor_f5&orderBy=order_number%20ASC`)
-      .then(response => {
-        commit('floor/GET_LIST_SUCCESSF5', response.data)
-      }, err => {
-        commit('floor/GET_LIST_FAILUREF5', err)
-      })
-  },
   // 获取子器件类目
   loadProductKinds({ commit }, params = {}) {
     let id = params.id