|
@@ -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)
|