瀏覽代碼

2025-05-14 全站搜索页

codeMan 1 年之前
父節點
當前提交
2d7f8e0889
共有 2 個文件被更改,包括 210 次插入51 次删除
  1. 155 3
      cloud/globalSearch/index.vue
  2. 55 48
      pages/index/cloud/workbench.vue

+ 155 - 3
cloud/globalSearch/index.vue

@@ -1,13 +1,165 @@
 <template>
-    <view>
-        全局搜索
+    <view class="global-search">
+        <view class="global-search_input">
+            <image class="image" src="/static/c+unselected.svg" mode="widthFix" />
+            <view style="flex:1">
+                <My_search placeholder="搜索全站关键字" @onSearch="onSearch"></My_search>
+            </view>
+        </view>
+        <view class="content">
+            <view class="type-tabs">
+                <u-tabs :scrollable="false" lineColor="#C30D23" :activeStyle="{ color: '#C30D23', fontWeight: 'bold' }" :list="types"
+                @click="changeType" :current="current" />
+            </view>
+            
+            <My_listbox ref="List" @getlist="getList" :bottomHeight="70">
+                <view class="list-box">
+                    <navigator class="item-box" :url="'/store/product/detail?id=' + item.sa_fadid"
+                    v-for="item in list" :key="item.sa_fadid"
+                    hover-class="navigator-hover">
+                        <view class="item">
+                            <u--image radius="5" :lazy-load="true" :width="tovw(100)" :height="tovw(100)" :src="item.attinfos.length ? item.attinfos[0].url : avatar">
+                                <template v-slot:loading>
+                                    <u-loading-icon color="red"></u-loading-icon>
+                                </template>
+                            </u--image>
+                            <view class="title">
+                                {{ item.title }}
+                            </view>
+                        </view>
+                        
+                    </navigator>
+                </view>
+            </My_listbox>
+        </view>
+       
     </view>
 </template>
 
 <script>
 export default {
+    data() {
+        return {
+            types: [
+                {
+                    name:'产品',
+                    value:1,
+                },
+                {
+                    name:'效果图',
+                    value:2,
+                },
+                {
+                    name:'课件',
+                    value:3,
+                },
+                {
+                    name:'资料',
+                    value:4,
+                }
+            ],
+            content: {
+                "type": 1,
+                //1:产品:来源单品、案例-电器系统
+                //2:效果图:来源效果图管理;
+                //3:课件:来源商学院授权可查看的课程中的课件;
+                //4:资料:来源装备资源库授权可查看的资料;
+                "pageNumber": 1,
+                "pageSize": 6,
+                "where": {
+                    "condition": ""
+                }
+            },
+            list:[],
+            current:0,
+            avatar:''
+        }
+    },
+    methods: {
+        onSearch (condition) {
+            this.content.where.condition = condition
+            this.getList(true)
+        },
+        changeType (type) {
+            this.current = type.index
+            this.content.type = type.value
+            this.getList(true)
+        },
+        getList(init = false) {
+            return new Promise((resolve, reject) => {
+                if (this.paging(this.content, init)) return resolve();
+                this.$Http.basic({
+                    "id": "20240513085802",
+                    content: this.content
+                }).then(res => {
+                    this.$refs.List.setHeight()
+                    this.$refs.List.RefreshToComplete()
+                    console.log("获取产品列表", res)
+                    resolve();
+                    if (this.cutoff(res.msg)) return;
+                    this.list = res.pageNumber == 1 ? res.data : this.list.concat(res.data);
+                    this.content = this.$refs.List.paging(this.content, res)
+                })
+            })
+        },
+    },
+    created() {
+        this.avatar = uni.getStorageSync("site").logo
+        this.getList()
+    },
 
 }
 </script>
 
-<style></style>
+<style lang="scss">
+.global-search {
+    .global-search_input {
+        margin: 10px;
+        display: flex;
+        align-items: center;
+        .image{
+            width: 40px;
+            height: 20px;
+            margin-right: 10px;
+        }
+    }
+    .content {
+        background: #ffffff;
+        min-height: calc(100vh - 30px);
+        .type-tabs {
+            margin-bottom: 10px;
+        }
+        .list-box {
+            .item-box{
+                padding: 0 10px;
+                .item {
+                    display: flex;
+                    align-items: center;
+                    align-content: center;
+                    border-bottom: 0.5px solid #DDDDDd;
+                    padding: 10px 0;
+                    .image-box {
+                        margin-right: 10px;
+                        width: 100px;
+                        height: 100px;
+                        padding: 18px;
+                        background: #F5F5F5;
+                        .image{
+                            width: 100%;
+                            height: 100%;
+                        }
+                    }
+                    .title{
+                        font-family: PingFang SC, PingFang SC;
+                        font-weight: 400;
+                        font-size: 14px;
+                        color: #333333;
+                        margin-left: 10px;
+                    }
+                }
+            }
+        }
+    }
+    
+}
+</style>

+ 55 - 48
pages/index/cloud/workbench.vue

@@ -2,12 +2,9 @@
     <view class="work-panel">
         <view class="work-panel_header">
             <image class="image" src="/static/c+unselected.svg" mode="widthFix" />
-            <My_search placeholder="搜索全站关键字" :value="content.where.condition" @onSearch="onSearch">
-                <view class="cancel" v-if="content.where.condition" hover-class="navigator-hover">
-                    取消
-                </view>
-                <view v-else style="width: 5px;" />
-            </My_search>
+            <view @click="onSearch" style="flex:1">
+                <My_search placeholder="搜索全站关键字" disabled></My_search>
+            </view>
         </view>
         <!-- 用户信息 -->
         <UserInfo :userInfoValue="userInfoValue"></UserInfo>
@@ -19,8 +16,8 @@
             </navigator>
         </view>
         <view class="work-panel_applist"> 
-            <template v-for="(item,index) in list" >
-                <navigator class="app" url="#" :key="index" v-if="item.path">
+            <template v-for="(item,index) in list">
+                <navigator class="app" :url="item.path" :key="index" v-if="item.path">
                     <view class="bg" :style="item.color">
                         <image class="image" :src="`/static/workbench/${item.label}.svg`" mode="widthFix"></image>
                     </view>
@@ -30,17 +27,19 @@
             
         </view>
         <view class="work-panel_options">
-            <navigator class="option" v-for="(item,index) in list2" :key="index" url="#" hover-class="navigator-hover" open-type="navigate">
-                <view class="box">
-                    <text class="left">{{ item.label }}</text>
-                    <view class="right">
-                        <!-- <view class="tag">10</view> -->
-                        
-                        <u-icon name="arrow-right" color="#999999"></u-icon>
+            <template v-for="(item,index) in list2">
+                <navigator class="option" :key="index" url="#" hover-class="navigator-hover" open-type="navigate" v-if="path">
+                    <view class="box">
+                        <text class="left">{{ item.label }}</text>
+                        <view class="right">
+                            <!-- <view class="tag">10</view> -->
+                            
+                            <u-icon name="arrow-right" color="#999999"></u-icon>
+                        </view>
                     </view>
-                </view>
-                
-            </navigator>
+                    
+                </navigator>
+            </template>
         </view>
     </view>
 </template>
@@ -99,45 +98,42 @@ export default {
             }],
             list2: [{
                 label: "我的访问店铺",
-                introduce: "电器 / 吊顶 / 墙面 / 木制品 \n渠道 / 工程",
-                itemId: "cloud"
+                itemId: "cloud",
+                name:'1'
             }, {
                 label: "我的预约",
-                introduce: "总部直通车  千万大返利",
                 itemId: "index",
                 page: "活动",
+                name:'1',
             }, {
                 label: "收货地址",
-                introduce: "电器 / 厨卫 / 阳台 / 背景墙 /顶墙",
                 itemId: "index",
                 page: "案例",
-                params: {
-                    active: '图库'
-                }
+                name:'1',
             }, {
                 label: "我的收藏",
-                introduce: "总部精选 / 实景图 / 设计图",
                 itemId: "index",
                 page: "案例",
                 params: {
                     active: '实景案例'
-                }
+                },
+                name:'1',
             }, {
                 label: "通讯录",
-                introduce: "单品 / 通知 / 介绍 / 画册 / 物料\n视频 / 说明书等",
                 itemId: "cloud",
+                name:'1',
             }, {
                 label: "考试成绩",
-                introduce: "产品 / 销售 / 管理 / 设计 / 考试等",
                 itemId: "cloud",
+                name:'1',
             }, {
                 label: "问卷调查",
-                introduce: "装修报价 / 老房改造 / 精装房焕新\n品质服务",
-                path: "/packageA/advertising/unshareable?id=505"
+                path: "/packageA/advertising/unshareable?id=505",
+                name:'1',
             }, {
                 label: "意见反馈",
-                introduce: "装修报价 / 老房改造 / 精装房焕新\n品质服务",
-                path: "/packageA/advertising/unshareable?id=505"
+                path: "/packageA/advertising/unshareable?id=505",
+                name:'1',
             }],
             colors: ['background: linear-gradient( 225deg, #81AEF3 0%, #6787E7 100%)',
                 "background: linear-gradient( 225deg, #F1AA68 0%, #EA895B 100%)",
@@ -178,25 +174,36 @@ export default {
         },
         //处理权限
         handleAppRole () {
-            let that = this
-            uni.getStorage({
-                key: 'authList',
-                success: function (res) {
-                    let keys = Object.keys(res.data.工作台)
-                    for (let index = 0; index < that.list.length; index++) {
-                        for (let index2 = 0; index2 < keys.length; index2++) {
-                            if (res.data.工作台[keys[index2]] && res.data.工作台[keys[index2]].name == that.list[index].name) {
-                                that.list[index] = Object.assign({},that.list[index],res.data.工作台[keys[index2]])
-                                break;
-                            }
-                        }
+            this.roles = uni.getStorageSync("authList")
+            let keys = Object.keys(this.roles.工作台)
+            for (let index = 0; index < this.list.length; index++) {
+                for (let index2 = 0; index2 < keys.length; index2++) {
+                    if (this.roles.工作台[keys[index2]] && this.roles.工作台[keys[index2]].name == this.list[index].name) {
+                        this.list[index] = Object.assign({},this.list[index],this.roles.工作台[keys[index2]])
+                        break;
                     }
-                    that.roles = res.data
-                    console.log(res.data,that.list,'权限');
                 }
-            })
+            }
+
+            for (let index = 0; index < this.list2.length; index++) {
+                for (let index2 = 0; index2 < keys.length; index2++) {
+                    if (this.roles.工作台[keys[index2]] && this.roles.工作台[keys[index2]].name == this.list2[index].name) {
+                        this.list2[index] = Object.assign({},this.list2[index],this.roles.工作台[keys[index2]])
+                        break;
+                    }
+                }
+            }
+            console.log(this.roles,this.list,'权限');
             
         },
+        onSearch () {
+            uni.navigateTo({
+                url: '/cloud/globalSearch/index',
+                // fail: (fail) => {
+                //     viewImage(item.attinfos[0].url)
+                // },
+            })
+        }
     },
     created () {
         this.list = this.dye(this.list, this.colors, 1)