Переглянути джерело

Merge remote-tracking branch 'origin/dev4.4' into dev4.4

wangkaiyue 4 роки тому
батько
коміт
d94f840996

+ 213 - 0
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/vip_entSearch.js

@@ -0,0 +1,213 @@
+var vNode = {
+  delimiters: ['${', '}'],
+  el: '#ent-search',
+  data: {
+      sessStorageKey: '$data-ent_follow',
+      searchEntName: '',
+      conf: {
+          // 我关注的企业最大个数
+          maxLength: 500,
+          showAllInfo: true,
+          powerLoaded: false
+      },
+      listInfo: {
+          // 首次请求是否完成
+          firstLoaded: false,
+          loading: false,
+          finished: false,
+          refreshing: false,
+          pageNum: 0,
+          pageSize: 10,
+          scrollTop: 0
+      },
+      entList: [],
+      entFollowList: []
+  },
+  created: function () {
+      var recover = this.recover()
+      if (!recover) {
+          this.getPowerInfo()
+      }
+  },
+  mounted: function () {
+      $(this.$refs.jList).scrollTop(this.listInfo.scrollTop)
+      // this.adjustAddButtonPadding()
+  },
+  methods: {
+      recover: function () {
+          var excludeKey = ['sessStorageKey']
+          var $data = sessionStorage.getItem(this.sessStorageKey)
+          if ($data) {
+              $data = JSON.parse($data)
+              for (var key in $data) {
+                  if (excludeKey.indexOf(key) !== -1) {
+                      continue
+                  }
+                  this.$data[key] = $data[key]
+              }
+              sessionStorage.removeItem(this.sessStorageKey)
+          }
+          return !!$data
+      },
+      // 获取权限信息
+      getPowerInfo: function () {
+          var _this = this
+          $.ajax({
+              type: 'GET',
+              url: '/bigmember/use/isAdd',
+              success: function (res) {
+                  if (res.error_code == 0) {
+                      _this.conf.powerLoaded = true
+                      // if (res.data && res.data.memberStatus > 0) {
+                      //     _this.conf.showAllInfo = true
+                      // }
+                  } else {
+                      _this.$toast(res.error_msg)
+                  }
+              },
+              error: function (error) {
+                  console.log(error)
+              }
+          })
+      },
+      // 搜索联想
+      searchEnt: utils.debounce(function () {
+        var _this = this
+        var searchEntName = this.searchEntName.replace(/\s+/g, '')
+
+        if (!searchEntName) {
+          this.entList = []
+          return
+        }
+        $.ajax({
+            type: 'POST',
+            url: '/bigmember/follow/ent/association',
+            data: {
+                entName: searchEntName
+            },
+            success: function (res) {
+                if (res.error_code == 0) {
+                    if (res.data) {
+                        _this.entList = res.data
+                        // for (var index in res.data) {
+                        //     var item = res.data[index]
+                        //     _this.entList.push({
+                        //         entId: item.entId,
+                        //         entName: item.entName,
+                        //         follow: !!item.isFollow
+                        //     })
+                        // }
+                    }
+                } else {
+                    _this.$toast(res.error_msg)
+                }
+            },
+            error: function (error) {
+                console.log(error)
+                _this.$toast('请求失败')
+            }
+        })
+      }, 600),
+      // 关键字高亮
+      highlightText: function (str) {
+        return utils.replaceKeyword(str, this.searchEntName, '<span class="highlight-text">' + this.searchEntName + '</span>')
+      },
+      getEntFollowList: function () {
+          var _this = this
+          $.ajax({
+              type: 'POST',
+              url: '/bigmember/entinfo/bynames?t=' + new Date().getTime(),
+              data: {
+                  pageNum: _this.listInfo.pageNum,
+                  pageSize: _this.listInfo.pageSize,
+              },
+              success: function (res) {
+                  if (_this.listInfo.pageNum === 0) {
+                      _this.listInfo.firstLoaded = true
+                      _this.entFollowList = []
+                  }
+                  if (res && res.length > 0) {
+                    // 判断是否为刷新
+                    if (_this.listInfo.refreshing) {
+                        _this.entFollowList = []
+                        _this.listInfo.refreshing = false
+                    }
+
+                    // 加载状态结束
+                    _this.listInfo.loading = false
+                    // if (res.data.followMax) {
+                    //     _this.conf.maxLength = res.data.followMax
+                    // }
+
+                    // 列表赋值
+                    _this.entFollowList = _this.entFollowList.concat(res)
+                    _this.listInfo.finished = true
+                  }
+              },
+              error: function (error) {
+                  console.log(error)
+              }
+          })
+      },
+      onRefresh: function () {
+          // 重置数据
+          this.listInfo.pageNum = 0
+          // 解除加载完成状态
+          this.listInfo.finished = false
+          // 重新加载数据
+          // 将 loading 设置为 true,表示处于加载状态
+          this.listInfo.loading = true
+          // 请求数据
+          this.getEntFollowList()
+      },
+      connectEnt: function (phone) {
+          try {
+              JyObj.callPhone(phone)
+          } catch (error) {
+              console.log(error)
+          }
+      },
+      leavePage: function (item) {
+        console.log(item)
+          var scrollTop = $(this.$refs.jList).scrollTop()
+          // 如果滚动高度为0,或者entList长度为0,则不缓存数据(即返回刷新)
+          if (scrollTop == 0 || this.entFollowList.length === 0) {
+              // do something
+          } else {
+              this.listInfo.scrollTop = $(this.$refs.jList).scrollTop()
+              sessionStorage.setItem(this.sessStorageKey, JSON.stringify(this.$data))
+          }
+          location.href = './ent_portrait?eId=' + encodeURIComponent(item.entId)
+
+      },
+      formatArea: function (item) {
+          var s = []
+          if (item.company_area) {
+              s.push(item.company_area)
+          }
+          if (item.company_city) {
+              s.push(item.company_city)
+          }
+          if (s.length === 0) {
+              return '-'
+          } else {
+              return s.join(' ')
+          }
+      },
+      toEntDetail: function (item) {
+        sessionStorage.setItem(this.sessStorageKey, JSON.stringify(this.$data))
+        location.href = './ent_portrait?eId=' + encodeURIComponent(item.entId)
+      },
+      // 调整列表底部到按钮距离
+      // adjustAddButtonPadding: function () {
+      //     var refs = this.$refs
+      //     var keyListUl = $(refs.jList).find('.follow-list')
+      //     if (this.entFollowList.length < this.conf.maxLength) {
+      //         keyListUl.css({
+      //             'padding-bottom': '2.2rem'
+      //         })
+      //     }
+      // },
+  }
+}
+var vueComponent = new Vue(vNode)

+ 172 - 0
src/jfw/modules/app/src/web/templates/vipsubscribe/vip_entSearch.html

@@ -0,0 +1,172 @@
+<!DOCTYPE html>
+<html lang="zh-CN" style="font-size: 50px;">
+<head>
+    <title>企业查询</title>
+
+    <!--引入公共资源头部-->
+    {{include "/big-member/meta.html"}}
+
+    <!--S-当前页必定需要预加载的资源-->
+    <link rel="preload" as="style" href=//cdn.jsdelivr.net/npm/reset-css@4.0.1/reset.min.css />
+    <link rel="preload" as="style" href=//cdn.jsdelivr.net/npm/vant@2.8.2/lib/index.css />
+    <link rel="preload" as="style" href=//cdn.jsdelivr.net/npm/vant@2.8.2/lib/icon/local.css />
+    <!--E-当前页必定需要预加载的资源-->
+
+    <!--S-当前页面的css资源-->
+    <link rel="stylesheet" href=//cdn.jsdelivr.net/npm/reset-css@4.0.1/reset.min.css />
+    <link rel="stylesheet" href=//cdn.jsdelivr.net/npm/vant@2.8.2/lib/index.css />
+    <link rel="stylesheet" href=//cdn.jsdelivr.net/npm/vant@2.8.2/lib/icon/local.css />
+    <link rel="stylesheet" href='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/big-member/css/ent_follow.css?v={{Msg "seo" "mod_version"}}' />
+    <!--E-当前页面的css资源-->
+</head>
+<style>
+  #ent-search .search-container{
+    position: relative;
+  }
+  #ent-search .ent-list-container{
+    position: absolute;
+    bottom: -50px;
+    z-index: 1;
+    width: 100%;
+    background: #fff;
+  }
+  #ent-search .ent-list{
+    background: #fff;
+  }
+  #ent-search .van-search{
+    width: 100%;
+    padding: 7px 16px;
+  }
+  .van-search__content{
+    width: 100%;
+    height: 40px;
+    background: #f5f6f7;
+    border: 1px solid rgba(0,0,0,0.05);
+    border-radius: 9px;
+  }
+  .van-cell__value {
+    line-height: 28px;
+    font-size: 14px;
+    font-weight: 500;
+    color: #171826;
+  }
+  .van-cell__value::placeholder {
+    line-height: 28px;
+    font-size: 14px;
+    font-weight: 500;
+    color: #9b9ca3;
+  }
+  .ent-list-item {
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    padding: .28rem .32rem;
+    font-size: .28rem;
+    line-height: .4rem;
+    color: #171826;
+  }
+  .ent-name {
+    flex: 1;
+    word-break: break-all;
+  }
+</style>
+<body>
+<div class="j-container">
+    {{include "/big-member/header.html"}}
+    <div id="ent-search" class="j-main" v-cloak>
+        <div class="j-container search-container" key="list">
+          <div class="j-header">
+            <van-search
+                v-model.trim="searchEntName"
+                placeholder="输入企业名称"
+                @input="searchEnt"
+            >
+                <template #left-icon>
+                    <span class="j-icon base-icon icon-search"></span>
+                </template>
+            </van-search>
+          </div>
+          <div class="j-container ent-list-container" v-if="entList.length !== 0" key="ent-list">
+            <ul class="ent-list">
+              <li
+                class="ent-list-item clickable border-line-b"
+                v-for="(item,index) in entList"
+                :key="index"
+                @click="toEntDetail(item)"
+                >
+                <span class="ent-name" v-html="highlightText(item.entName)"></span>
+              </li>
+            </ul>
+          </div>
+            <div class="j-main" ref="jList">
+                <div>
+                    <van-pull-refresh v-model="listInfo.refreshing" @refresh="onRefresh">
+                        <van-list
+                            v-model="listInfo.loading"
+                            :finished="listInfo.finished"
+                            finished-text=""
+                            @load="getEntFollowList"
+                            class="follow-list"
+                        >
+                            <div
+                                v-for="(item, index) in entFollowList"
+                                class="follow-item"
+                                :immediate-check="false"
+                                @click="leavePage(item)"
+                                :key="index">
+                                <div class="item-hd">
+                                    <span class="left-icons">
+                                        <span class="j-icon icon-company"></span>
+                                        <span class="dot-red" v-show="item.i_apppushunread == 1"></span>
+                                    </span>
+                                    <span class="item-ent-name">${item.entName}</span>
+                                </div>
+                                <div class="item-bd" v-if="conf.showAllInfo">
+                                    <span class="bd-content">
+                                        <span class="bd-c-label">成立日期</span>
+                                        <span class="bd-c-text">${ item.establish_date ? item.establish_date : '-' }</span>
+                                    </span>
+                                    <span class="bd-content">
+                                        <span class="bd-c-label">注册资本</span>
+                                        <span class="bd-c-text">${ item.capital ? item.capital+'万元' : '-' }</span>
+                                    </span>
+                                    <span class="bd-content">
+                                        <span class="bd-c-label">员工人数</span>
+                                        <span class="bd-c-text">${ item.employee_no ? item.employee_no+'人' : '-' }</span>
+                                    </span>
+                                </div>
+                                <div class="item-ft border-line-t" v-if="conf.showAllInfo">
+                                    <span class="ft-location">
+                                        <span class="location-label">企业所在地</span>
+                                        <span class="location-text highlight-text">${ formatArea(item) }</span>
+                                    </span>
+                                    <span class="ft-connect" v-if="item.company_phone" @click.stop="connectEnt(item.company_phone)">
+                                        <span class="j-icon icon-phone"></span>
+                                        <span class="location-r">联系企业</span>
+                                    </span>
+                                </div>
+                            </div>
+                        </van-list>
+                    </van-pull-refresh>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+
+<!--S-必定需要预加载的资源-->
+<script rel="preload" as="script" src=//cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js></script>
+<script rel="preload" as="script" src=//cdn.jsdelivr.net/npm/vant@2.8.2/lib/vant.min.js></script>
+<script rel="preload" as="script" src=//cdn.jsdelivr.net/npm/zepto@1.2.0/dist/zepto.min.js></script>
+<!--E-必定需要预加载的资源-->
+
+<!--S-当前页面的资源-->
+<script src=//cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js></script>
+<script src=//cdn.jsdelivr.net/npm/vant@2.8.2/lib/vant.min.js></script>
+<script src=//cdn.jsdelivr.net/npm/zepto@1.2.0/dist/zepto.min.js></script>
+{{include "/big-member/commonjs.html"}}
+<script src='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/js/common.js?v={{Msg "seo" "version"}}'></script>
+<script src='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/vipsubscribe/js/vip_entSearch.js?v={{Msg "seo" "mod_version"}}'></script>
+{{include "/common/baiducc.html"}}
+</body>
+</html>