浏览代码

feat: 增加获取老用户、vip权限接口

zhangsiya 1 年之前
父节点
当前提交
94055f5b77
共有 1 个文件被更改,包括 63 次插入29 次删除
  1. 63 29
      apps/bigmember_pc/src/views/search/bidding/components/search-bid-filter.vue

+ 63 - 29
apps/bigmember_pc/src/views/search/bidding/components/search-bid-filter.vue

@@ -1,5 +1,5 @@
 <script setup>
-import { ref } from 'vue'
+import { ref, computed } from 'vue'
 import { SearchBidModel } from '../model/index'
 import SearchSchemaFilter from '@/views/search/components/search-schema-filter.vue'
 import SelectorWithBasePower from '@/components/filter-items/SelectorWithBasePower.vue'
@@ -9,46 +9,71 @@ import {
   createSearchBidMoreSchema
 } from '@/views/search/bidding/constant/search-filters'
 
+import { getEntSearchPower } from '@/api/modules'
+
 const {
-  isVip,
-  isOld,
   filterState,
   doQuery,
   showFilter
 } = SearchBidModel
 
-const conf = ref({
-  vipUser: isVip.value,
-  oldUser: isOld.value
+
+// 是否是VIP
+const isVip = ref(false)
+// 是否是老用户
+const isOld = ref(false)
+
+const SearchBidBaseSchema = ref([])
+const SearchBidMoreSchema = ref([])
+
+const searchBidMoreFreeSchema = ref([])
+const searchBidMoreVipSchema = ref([])
+
+const conf = computed(() => {
+  return {
+    vipUser: isVip.value,
+    oldUser: isOld.value
+  }
+})
+
+const customMoreSchema = computed(() => {
+  return {
+    commonConf: {
+      showLabel: false,
+      styleType: 'row'
+    },
+    freeConf: {
+      showRowLabel: true,
+      rowLabelText: '更多筛选:',
+      schema: searchBidMoreFreeSchema.value
+    },
+    vipConf: {
+      schema: searchBidMoreVipSchema.value
+    }
+  }
 })
-const SearchBidBaseSchema = createSearchBidBaseSchema(conf.value)
-const SearchBidMoreSchema = createSearchBidMoreSchema()
-
-const searchBidMoreFreeSchema = SearchBidMoreSchema.filter((s) => !s.vipMark)
-const searchBidMoreVipSchema = SearchBidMoreSchema.filter((s) => s.vipMark)
-
-const customMoreSchema = {
-  commonConf: {
-    showLabel: false,
-    styleType: 'row'
-  },
-  freeConf: {
-    showRowLabel: true,
-    rowLabelText: '更多筛选:',
-    schema: searchBidMoreFreeSchema
-  },
-  vipConf: {
-    schema: searchBidMoreVipSchema
+// 获取用户信息
+async function getUserPowerInfo () {
+  const { error_code: code, data } = await getEntSearchPower()
+  if (code === 0 && data) {
+    const { entniche, member, vip,  isOld: old } = data
+    isVip.value = entniche || member || vip > 0
+    isOld.value = old
+
+    SearchBidBaseSchema.value =  createSearchBidBaseSchema(conf.value)
+    SearchBidMoreSchema.value =  createSearchBidMoreSchema()
+
+    searchBidMoreFreeSchema.value = SearchBidMoreSchema.value?.filter((s) => !s.vipMark)
+    searchBidMoreVipSchema.value = SearchBidMoreSchema.value?.filter((s) => s.vipMark)
   }
 }
 
+getUserPowerInfo()
+
 function noPower() {
   $bus.$emit('search:filter:no-power')
 }
 
-console.log(SearchBidBaseSchema)
-console.log(SearchBidMoreSchema)
-
 function doChangeFilter() {
   doQuery()
 }
@@ -98,9 +123,19 @@ function doChangeFilter() {
 </template>
 
 <style lang="scss" scoped>
+.in-app {
+  .search-bid-filter {
+    .wrap-line {
+      ::v-deep {
+        .vip-module {
+          margin-left: 0;
+        }
+      }
+    }
+  }
+}
 .search-bid-filter {
   padding: 16px 32px;
-
   .wrap-line {
     ::v-deep {
       .vip-module {
@@ -108,6 +143,5 @@ function doChangeFilter() {
       }
     }
   }
-
 }
 </style>