Bläddra i källkod

2.2web-资源商城列表页优化;

huan-jie 4 år sedan
förälder
incheckning
d5de059229

+ 142 - 3
assets/css/work_down/index.scss

@@ -17,7 +17,7 @@
             .add-works-btn {
                 position: absolute;
                 right: 20px;
-                width: 120px;
+                width: 136px;
                 height: 32px;
                 padding: 0;
                 border: none;
@@ -59,6 +59,56 @@
             width: 100%;
             padding: 0 20px;
             margin-top: 7px;
+            .search-wrapper {
+                position: absolute;
+                width: 215px;
+                height: 100%;
+                top: 10px;
+                right: 20px;
+                &:after {
+                    position: absolute;
+                    content: " ";
+                    top: 0;
+                    left: -22px;
+                    width: 1px;
+                    height: 100%;
+                    background: rgba(0,0,0,0.06);
+                }
+                .search-content {
+                    position: relative;
+                    width: 100%;
+                    height: 34px;
+                    margin-top: 10px;
+                    display: flex;
+                    align-items: center;
+                    .search-btn {
+                        position: absolute;
+                        top: 0;
+                        right: 0;
+                        width: 60px;
+                        height: 100%;
+                        padding: 0;
+                        border: none;
+                        background: #308eff;
+                        border-radius: 5px;
+                        font-size: 12px;
+                        font-family: PingFangSC, PingFangSC-Regular;
+                        text-align: center;
+                        color: #ffffff;
+                    }
+                }
+                .search-tips {
+                    margin-top: 10px;
+                    line-height: 18px;
+                    font-size: 13px;
+                    font-family: PingFangSC, PingFangSC-Regular;
+                    color: #999999;
+                    span {
+                        color: #308eff;
+                        cursor: pointer;
+                    }
+                }
+            }
             .works-expand-arrow {
                 position: absolute;
                 width: 20px;
@@ -73,13 +123,17 @@
             }
             .works-category-two-wrapper {
                 position: relative;
-                width: 900px;
+                width: 720px;
                 height: 42px;
+                min-height: 84px;
                 display: flex;
-                align-items: center;
+                // align-items: center;
                 flex-wrap: wrap;
                 overflow: hidden;
                 transition: all .3s;
+                &:after {
+                    
+                }
                 &.expand {
                     height: auto;
                 }
@@ -319,6 +373,34 @@
             }
         }
     }
+    // 筛选
+    .filter-wrapper {
+        width: 1000px;
+        height: 50px;
+        padding: 0 30px;
+        margin-top: 10px;
+        background: #ffffff;
+        border-radius: 10px;
+        backdrop-filter: blur(40px);
+        display: flex;
+        align-items: center;
+        .sort-content {
+            display: flex;
+            align-items: center;
+            cursor: pointer;
+            font-size: 14px;
+            font-family: PingFangSC, PingFangSC-Regular;
+            color: #222222;
+            img {
+                width: 18px;
+                height: 18px;
+                margin-right: 4px;
+            }
+        }
+        .price-filter {
+            margin-left: 26px;
+        }
+    }
 }
 .mobileMain {
     width: 100%;
@@ -551,3 +633,60 @@
         height: calc(100vh - 64px);
     }
 }
+// 寻找源码 modal
+.remark-title {
+    width: 100%;
+    height: 28px;
+    line-height: 28px;
+    font-size: 20px;
+    font-family: PingFangSC, PingFangSC-Semibold;
+    font-weight: 600;
+    text-align: center;
+    color: #222222;
+}
+.remark-content {
+    position: relative;
+    width: 100%;
+    .remark-description {
+        width: 100%;
+        line-height: 21px;
+        font-size: 13px;
+        color: #666666;
+    }
+    .remark-contact {
+        width: 100%;
+        line-height: 21px;
+        font-size: 13px;
+        color: #666666;
+    }
+    .action-wrapper {
+        width: 100%;
+        margin-top: 40px;
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        .confirm-btn {
+            width: 170px;
+            height: 46px;
+            background: #308eff;
+            border-radius: 6px;
+            margin-right: 12px;
+            font-size: 15px;
+            font-family: PingFangSC, PingFangSC-Medium;
+            font-weight: 500;
+            color: #ffffff;
+            border: none !important;
+        }
+        .cancel-btn {
+            width: 170px;
+            height: 46px;
+            background: #f4f5f9;
+            border-radius: 6px;
+            font-size: 15px;
+            font-family: PingFangSC, PingFangSC-Medium;
+            font-weight: 500;
+            color: #666666;
+            border: none !important;
+        }
+    }
+}

BIN
assets/img/common/filter-icon@2x.png


+ 4 - 0
components/work_down/dealSeoList.js

@@ -9,6 +9,10 @@ export default class DealSeoData {
             page: 1,
             keywords: '',
             cate_id_two: [],
+            // 价格筛选:0 全部,1 付费,2 免费
+            filter_price: 0,
+            // 排序:0 默认,1 价格从高到低,2 价格从低到高
+            sort: 0,
             // 非接口参数
             pagesize: 20,
             total: 0,

+ 222 - 15
pages/work_down/index.vue

@@ -23,12 +23,24 @@
                 </div>
                 <div class="works-category-two">
                     <!-- 展开按钮 -->
-                    <img
+                    <!-- <img
                         src="@/assets/img/works/expand-arrow@2x.png"
                         alt="expand"
                         class="works-expand-arrow"
                         :class="categoryExpanded ? 'active' : ''"
-                        @click="handleClickExpandCategory">
+                        @click="handleClickExpandCategory"> -->
+                    <!-- 关键字筛选 -->
+                    <div class="search-wrapper">
+                        <div class="search-content">
+                            <el-input
+                                v-model="pagination.keywords"
+                                @keyup.enter.native="handleKeywordSearch"
+                                class="search-input"
+                                placeholder="源码搜索"></el-input>
+                            <el-button class="search-btn" @click="handleKeywordSearch">搜索</el-button>
+                        </div>
+                        <div class="search-tips">找不到想要的源码?<span @click="handleClickRemark">请留言给我们</span></div>
+                    </div>
                     <!-- 全部二级分类 -->
                     <div
                         class="works-category-two-wrapper"
@@ -61,6 +73,22 @@
                     </div>
                 </div>
             </div>
+            <!-- 资源筛选 -->
+            <div class="filter-wrapper">
+                <!-- 价格排序 -->
+                <div class="sort-content" @click="handleClickPriceSort">
+                    <img src="@/assets/img/common/filter-icon@2x.png">
+                    <span>{{ priceSortText }}</span>
+                </div>
+                <!-- 价格筛选 -->
+                <div class="price-filter">
+                    <el-radio-group v-model="pagination.filter_price" @change="handlePriceFilterChange">
+                        <el-radio :label="0">全部</el-radio>
+                        <el-radio :label="1">付费</el-radio>
+                        <el-radio :label="2">免费</el-radio>
+                    </el-radio-group>
+                </div>
+            </div>
             <div class="works-list" v-if="worksList.length" v-loading="loadingWorksList">
                 <div
                     class="works-item"
@@ -95,7 +123,7 @@
                     </a>
                 </div>
             </div>
-            <div class="result-empty-wrapper" v-else>
+            <div class="result-empty-wrapper" style="margin-top: 10px;" v-else>
                 <img src="@/assets/img/common/empty@2x.png" alt="empty">
                 <span>暂无搜索内容</span>
             </div>
@@ -109,6 +137,45 @@
                     @current-change="handlePageChange">
                 </el-pagination>
             </div>
+            <!-- 留言 modal -->
+            <el-dialog
+                :visible.sync="isShowRemarkDialog"
+                width="520px"
+                top="10vh"
+                class="remark-modal">
+                <div class="remark-title" slot="title">寻找源码</div>
+                <div class="remark-content">
+                    <el-form
+                        ref="remarkForm"
+                        :model="remarkModel"
+                        :rules="remarkRules"
+                        class="remark-form">
+                        <el-form-item label="源码描述" prop="remarkDescription">
+                            <el-input
+                                class="remark-description"
+                                type="textarea"
+                                placeholder="请输入您要寻找的源码描述"
+                                maxlength="1000"
+                                :autosize="{ minRows: 6, maxRows: 12 }"
+                                show-word-limit
+                                v-model="remarkModel.remarkDescription"></el-input>
+                        </el-form-item>
+                        <el-form-item label="联系方式" prop="remarkContact">
+                            <el-input
+                                class="remark-contact"
+                                type="input"
+                                placeholder="请输入您的手机号,方便我们找到源码后第一时间通知您"
+                                v-model="remarkModel.remarkContact"></el-input>
+                        </el-form-item>
+                    </el-form>
+                    <div class="action-wrapper">
+                        <el-button
+                            :loading="saveRemarkIsLoading"
+                            class="confirm-btn"
+                            @click="handleSaveRemark">提交</el-button>
+                    </div>
+                </div>
+            </el-dialog>
         </div>
         <div class="works-wrapper-mobile" v-else>
             <div class="works-category">
@@ -263,6 +330,20 @@ import qs from "qs"
 
 export default {
     data () {
+        // 验证留言手机号
+        var validateContact = (rule, value, callback) => {
+            if (!value) {
+                return callback(new Error('联系方式不能为空'))
+            }
+            var reg = /^[0-9-]*$/
+            if (!reg.test(value)) {
+                callback(new Error('联系方式只能为数字'))
+            } else if (value.length > 15) {
+                callback(new Error('联系方式支持填写不超过15字符'))
+            } else {
+                callback()
+            }
+        };
         return {
             baseUrl: '',
             // categoryAll: [],
@@ -270,7 +351,7 @@ export default {
             // worksList: [],
             currentCategoryIndex: 0,
             currentDrawerCategoryIndex: 0,
-            categoryExpanded: false,
+            categoryExpanded: true,
             firstLoad: false,
             loadingWorksList: false,
             showCategoryDrawer: false,
@@ -284,7 +365,24 @@ export default {
             //     loading: true,
             //     noMore: true
             // },
-            isWeixinApp: true
+            isWeixinApp: true,
+            // 寻找源码弹窗
+            isShowRemarkDialog: false,
+            saveRemarkIsLoading: false,
+            remarkModel: {
+                remarkDescription: '', // 源码描述
+                remarkContact: '', // 联系方式
+            },
+            remarkRules: {
+                remarkDescription: [
+                    { required: true, message: '源码描述不能为空', trigger: 'blur' },
+                    { min: 5, max: 1000, message: '源码描述支持填写5-1000字符', trigger: 'blur' }
+                ],
+                remarkContact: [
+                    { required: true, message: '联系方式不能为空', trigger: 'blur' },
+                    { validator: validateContact, trigger: 'blur' }
+                ]
+            }
         }
     },
     head() {
@@ -329,6 +427,17 @@ export default {
             } else {
                 return '20px !important'
             }
+        },
+        priceSortText () {
+            let text = '价格'
+
+            if (this.pagination.sort == 1) {
+                text = '从高到低'
+            } else if (this.pagination.sort == 2) {
+                text = '从低到高'
+            }
+
+            return text
         }
     },
     async asyncData ({...params}) {
@@ -395,7 +504,9 @@ export default {
                 page: this.pagination.page,
                 keywords: this.pagination.keywords,
                 cate_id_two: this.pagination.cate_id_two.join(','),
-                root_type: this.root_type
+                root_type: this.root_type,
+                filter_price: this.pagination.filter_price,
+                sort: this.pagination.sort
             }
 
             const promise = new Promise((resolve, reject) => {
@@ -428,6 +539,28 @@ export default {
             return promise
         },
         /**
+         * 保存留言
+         */
+        _saveRemark () {
+            const self = this
+            this.saveRemarkIsLoading = true
+            const data = {
+                content: this.remarkModel.remarkDescription,
+                phone: this.remarkModel.remarkContact
+            }
+
+            this.$axios.$post('/api/UserWorks/addRemark', data).then((res) => {
+                if (Number(res.status) === 1) {
+                    self.$message.success('提交成功,请耐心等待')
+                    self.isShowRemarkDialog = false
+                } else {
+                    self.$message.error(res.info)
+                }
+            }).then(() => {
+                self.saveRemarkIsLoading = false
+            })
+        },
+        /**
          * 点击一级分类
          */
         handleClickCategoryOne (id) {
@@ -488,16 +621,16 @@ export default {
          * 分页页码改变时
          */
         handlePageChange (val) {
-            // this.pagination.page = val
+            this.pagination.page = val
 
-            // this._getWorksList()
-            let query = {
-                page: val
-            }
-            if (this.root_type && Number(this.root_type) > 0) {
-                query.root_type = this.root_type
-            }
-            window.location.href = `${window.location.origin}${window.location.pathname}?${qs.stringify(query)}`
+            this._getWorksList()
+            // let query = {
+            //     page: val
+            // }
+            // if (this.root_type && Number(this.root_type) > 0) {
+            //     query.root_type = this.root_type
+            // }
+            // window.location.href = `${window.location.origin}${window.location.pathname}?${qs.stringify(query)}`
         },
         /**
          * mobile 加载更多
@@ -562,6 +695,60 @@ export default {
          */
         handleClickCreate () {
             location.href = '/otherpage/works/create'
+        },
+        /**
+         * 回车、点击按钮:根据关键词搜索
+         */
+        handleKeywordSearch () {
+            this.pagination.page = 1
+            this._getWorksList()
+        },
+        /**
+         * 点击留言时
+         */
+        handleClickRemark () {
+            if (this.remarkModel.remarkContact == '') {
+                // 若已登录,自动填写手机号
+                if (this.userinfo && this.userinfo.login_mobile) {
+                    this.remarkModel.remarkContact = this.userinfo.login_mobile
+                }
+            }
+
+            this.isShowRemarkDialog = true
+        },
+        /**
+         * 留言点击保存时
+         */
+        handleSaveRemark () {
+            const self = this
+
+            this.$refs.remarkForm.validate((valid) => {
+                if (valid) {
+                    self._saveRemark()
+                }
+            })
+        },
+        /**
+         * 价格筛选改变时
+         */
+        handlePriceFilterChange () {
+            this.pagination.page = 1
+            this._getWorksList()
+        },
+        /**
+         * 点击价格排序时
+         */
+        handleClickPriceSort () {
+            if (this.pagination.sort == 0) {
+                this.pagination.sort = 1
+            } else if (this.pagination.sort == 1) {
+                this.pagination.sort = 2
+            } else if (this.pagination.sort == 2) {
+                this.pagination.sort = 0
+            }
+
+            this.pagination.page = 1
+            this._getWorksList()
         }
     }
 }
@@ -652,4 +839,24 @@ export default {
     position: fixed !important;
     z-index: 11 !important;
 }
+.search-input {
+    width: 100%;
+    height: 34px;
+    input {
+        width: 100%;
+        height: 34px;
+        line-height: 34px;
+        padding-left: 10px;
+        padding-right: 70px;
+    }
+}
+.remark-modal .el-dialog__body {
+    padding-top: 15px !important;
+}
+.remark-modal .el-form-item__label {
+    font-weight: 700;
+}
+.price-filter .el-radio {
+    margin-right: 18px;
+}
 </style>