123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441 |
- var vNode = {
- delimiters: ['${', '}'],
- el: '#myCollection',
- components: {
- tagsComponent: tagsComponent,
- dateComponent: dateComponent,
- cateComponent: cateComponent,
- phoneComponent: phoneComponent
- },
- data: {
- sessStorageKey: '$data-collection',
- listState: {
- value: '',
- loading: false,
- finished: false,
- pageSize: 10,
- offset: 80,
- scrollTop: 0,
- total: 0,
- list: []
- },
- listInfo: {
- scrollTop: 0
- },
- // 筛选参数
- limitlist: {
- pageNum: 1,
- label: '',
- selectTime: '',
- buyerclass: '',
- buyerPhone: 0,
- winnerPhone: 0
- },
- tagList: [], // 个人标签列表
- selectTagList: [], //选择标签列表
- selectCateList: [], // 选择的采购单位类型列表
- // 下拉菜单参数
- params: {
- value2: '',
- buyerData: {
- dataType: '1',
- option: [
- { text: '有联系方式', value: 1, type: false },
- { text: '无联系方式', value: -1, type: false },
- ],
- },
- winnerData: {
- dataType: '2',
- option: [
- { text: '有联系方式', value: 1, type: false },
- { text: '无联系方式', value: -1, type: false },
- ]
- }
- },
- // 收藏日期选择时间参数
- selectDate: {
- startDate: '',
- endDate: '',
- exact: ''
- },
- tagText: {
- timeText: '收藏时间',
- perText: '个人标签',
- cateText: '采购单位类型',
- },
- limitshow: false, // 筛选框显示
- condition: true, // 列表星星显示
- personTagactive:0, //个人标签选择按钮下标
- screenShow: false, // 筛选按钮是否显示
- },
- computed: {
- getParamsStatus () {
- return this.limitlist.label=='' && this.limitlist.selectTime=='' && this.limitlist.buyerclass=='' && this.limitlist.buyerPhone==0 && this.limitlist.winnerPhone==0 && this.limitlist.pageNum==1
- }
- },
- created () {
- var recover = this.recover()
- if (!recover) {
- this.getList()
- this.getUserRoot()
- this.getTagsList()
- }
- },
- mounted() {
- if(this.limitlist.label !=='' || this.limitlist.selectTime != '' || this.limitlist.buyerclass != '' || this.limitlist.buyerPhone != 0 || this.limitlist.winnerPhone != 0) {
- this.limitshow = true
- } else {
- this.limitshow = false
- }
- },
- mounted () {
- setTimeout(() => {
- $(this.$refs.jList).scrollTop(this.listState.scrollTop)
- }, 300)
- },
- methods: {
- recover: function () {
- let _this = this
- var excludeKey = ['sessStorageKey']
- var $data = sessionStorage.getItem(this.sessStorageKey)
- if ($data) {
- $data = JSON.parse($data)
- var listState = $data["listState"];
- var list = listState["list"];
- for (var i=0;i<list.length;i++){
- if (sessionStorage.getItem('listCollSessionId')&&sessionStorage.getItem('listCollSessionId')==list[i]["_id"]){
- if (sessionStorage.getItem('listCollSessionBool')=="0"){
- listState["list"].splice(i,1);
- }
- sessionStorage.removeItem('listCollSessionId')
- sessionStorage.removeItem('listCollSessionBool')
- }
- }
- for (var key in $data) {
- if (excludeKey.indexOf(key) !== -1) {
- continue
- }
- this.$data[key] = $data[key]
- }
- const res = _this.$data.limitlist
- // 标签
- if(res.label != '') {
- this.selectTagList = res.label.split(',')
- }
- // 时间
- if(res.selectTime != '') {
- this.selectDate.startDate = res.selectTime.split('_')[0] * 1000
- this.selectDate.endDate= res.selectTime.split('_')[1] * 1000
- }
- // 采购单位类型
- if(res.buyerclass != '') {
- this.selectCateList = res.buyerclass.split(',')
- }
- sessionStorage.removeItem(this.sessStorageKey)
- }
- return !!$data
- },
- setrecover: function() {
- var scrollTop = $(this.$refs.jList).scrollTop()
- // 如果滚动高度为0,或者entList长度为0,则不缓存数据(即返回刷新)
- this.listState.scrollTop = scrollTop
- sessionStorage.setItem(this.sessStorageKey, JSON.stringify(this.$data))
- },
- // 判断是否是有权限
- getUserRoot: function() {
- let _this = this
- $.ajax({
- url: '/publicapply/bidcoll/power',
- type: 'POST',
- success: function(res) {
- console.log(res)
- if(res.data.entniche || res.data.member || res.data.vip > 0) {
- _this.screenShow = true
- } else {
- _this.screenShow = false
- }
- }
- })
- },
- // 列表跳转
- linkRouter: function(id) {
- this.setrecover()
- location.href = '/article/content/' + id + '.html'
- },
- // 筛选按钮
- screenBtn() {
- this.limitshow = !this.limitshow
- setTimeout(()=>{
- this.setToggle()
- })
- },
- getContainer: function() {
- return this.$refs.searchContainer
- },
- // 获取列表数据
- getList: function(isScreen) {
- let _this = this
- _this.listState.loading = true
- let params = _this.limitlist
- $.ajax({
- url: '/publicapply/bidcoll/list',
- type: "POST",
- contentType: 'application/json;charset=utf-8',
- data: JSON.stringify(params),
- success: function(res){
- console.log(res)
- if (res.error_code == 0) {
- if (res.data && res.data.res && $.isArray(res.data.res)) {
- // 当数组为空时,且不为第一页,底部显示没有更多数据
- if(res.data.res.length == 0 && _this.limitlist.pageNum != 1){
- if(isScreen) {
- _this.listState.list = res.data.res
- } else {
- _this.listState.list = _this.listState.list.concat(res.data.res)
- }
- _this.listState.loading = false
- if(!res.data.haveNextPage){
- _this.listState.loading = true
- _this.listState.finished = true;
- }else{
- _this.listState.loading = false
- _this.limitlist.pageNum++
- }
- } else if(res.data.res.length == 0 && _this.limitlist.pageNum == 1){
- // 当数组为空时,且为第一页,页面为暂无数据页面
- _this.listState.loading = true
- _this.listState.finished = true;
- _this.listState.list = res.data.res
- } else {
- // 数据正常加载更多
- for (let i = 0; i < res.data.res.length; i++) {
- res.data.res[i].bidamount = utils.moneyUnit(res.data.res[i].bidamount)
- res.data.res[i].publishtime = utils.dateFromNow(res.data.res[i].publishtime * 1000)
- }
- if(isScreen) {
- _this.listState.list = res.data.res
- } else {
- _this.listState.list = _this.listState.list.concat(res.data.res)
- }
- _this.listState.loading = false
- if(!res.data.haveNextPage){
- _this.listState.loading = true
- _this.listState.finished = true;
- }else{
- _this.listState.loading = false
- _this.limitlist.pageNum++
- }
- }
- } else {
- _this.listState.loading = true
- _this.listState.finished = true;
- }
- } else {
- _this.$toast(res.error_msg)
- }
- },
- error: function(err){
- _this.listState.loading = true
- _this.listState.finished = true;
- }
- })
- },
- // 取消收藏
- collecClick: function(e,id) {
- e.stopPropagation()
- let _this = this
- let params = {
- baction: 'R',
- binfo: [
- {
- bid: id
- }
- ]
- }
- $.ajax({
- url: '/publicapply/bidcoll/action',
- type: "POST",
- contentType: 'application/json;charset=utf-8',
- data:JSON.stringify(params),
- success: function(res){
- console.log(res)
- if(res.error_code == 0) {
- if(res.data) {
- _this.$toast('取消收藏成功')
- if(_this.listState.list.length <= 1) {
- location.reload()
- }else {
- _this.reLoadList(true)
- }
- } else {
- _this.$toast('取消收藏失败')
- }
- }
- },
- error: function(err){
- _this.$toast('取消收藏失败')
- }
- })
- },
- // 确定按钮事件
- confirm: function(data) {
- console.log(data)
- if(data.name == 'dateItem'){
- const timeRange = {
- start: (data.data.start / 1000).toFixed(0),
- end: (data.data.end / 1000).toFixed(0)
- }
- // 开始时间未选择,则默认开始时间为2000年
- if (!timeRange.start || timeRange.start == 0) {
- timeRange.start = +new Date('2000') / 1000
- }
- // 结束时间未选择,则默认当天23点
- if (!timeRange.end || timeRange.end == 0) {
- var today = new Date().pattern('yyyy/MM/dd')
- var day1 = 24 * 60 * 60 * 1000
- var todayEnd = +new Date(today) + day1 - 1000
- timeRange.end = Math.round(todayEnd / 1000)
- }
- if (timeRange.start == 0 && timeRange.end == 0) {
- this.limitlist.selectTime = ''
- this.tagText.timeText = '收藏时间'
- } else if(timeRange.start == 0 && timeRange.end != 0) {
- this.limitlist.selectTime = '_' + timeRange.end
- } else if(timeRange.start != 0 && timeRange.end == 0) {
- this.limitlist.selectTime = timeRange.start + '_'
- } else {
- this.limitlist.selectTime = timeRange.start + '_' + timeRange.end
- }
- this.selectDate.exact = data.data.exact
- switch (data.data.exact) {
- case 'all': {
- this.tagText.timeText = '收藏时间'
- break
- }
- case 'lately7': {
- this.tagText.timeText = '最近7天'
- break
- }
- case 'lately30': {
- this.tagText.timeText = '最近30天'
- break
- }
- case 'lastYear': {
- this.tagText.timeText = '去年'
- break
- }
- case 'exact': {
- if(timeRange.start == 0 && timeRange.end == 0) {
- this.limitlist.selectTime = ''
- this.tagText.timeText = '收藏时间'
- this.setToggle()
- return
- } else {
- this.tagText.timeText = new Date(timeRange.start*1000).pattern('yyyy.MM.dd') + '~' + new Date(timeRange.end*1000).pattern('yyyy.MM.dd')
- }
- break
- }
- }
- } else if (data.name == 'cateItem') {
- this.tagText.cateText = '采购单位类型' + data.t
- this.limitlist.buyerclass = data.data.join(',')
- } else if (data.name == 'tagsItem') {
- this.tagText.perText = data.t
- this.limitlist.label = data.data
- } else if (data.name == 'buyerItem') {
- this.limitlist.buyerPhone = parseInt(data.data)
- } else if (data.name == 'winnerItem') {
- this.limitlist.winnerPhone = parseInt(data.data)
- }
- this.limitlist.pageNum = 1
- this.setToggle()
- this.reLoadList(true)
- },
- // 取消按钮事件
- cancel: function(data) {
- console.log(data)
- if(data.name == 'dateItem'){
- this.limitlist.selectTime = ''
- this.tagText.timeText = '收藏时间'
- this.selectDate.exact = 'all'
- this.$refs.datecom.setState()
- } else if (data.name == 'cateItem') {
- this.tagText.cateText = '采购单位类型'
- this.limitlist.buyerclass = ''
- this.selectCateList = []
- this.$refs.catecom.setState()
- } else if (data.name == 'tagsItem') {
- this.limitlist.label = ''
- this.tagText.perText = '个人标签'
- this.selectTagList = []
- this.$refs.tagcom.setState()
- } else if (data.name == 'buyerItem') {
- this.limitlist.buyerPhone = 0
- } else if (data.name == 'winnerItem') {
- this.limitlist.winnerPhone = 0
- }
- this.reLoadList(true)
- this.setToggle()
- },
- // 刷新列表
- reLoadList: function(isScreen) {
- this.getList(isScreen)
- },
- // 关闭菜单
- setToggle: function() {
- this.$refs.dateItem.toggle(false)
- this.$refs.cateItem.toggle(false)
- this.$refs.tagItem.toggle(false)
- this.$refs.buyerItem.toggle(false)
- this.$refs.winnerItem.toggle(false)
- },
- // 获取个人标签列表
- getTagsList: function() {
- let _this = this
- $.ajax({
- url: '/publicapply/bidcoll/getLabel',
- type: "POST",
- success: function(res){
- console.log(res)
- if(res.error_code == 0 && res.data) {
- res.data.forEach(function(item, index){
- item.type = false
- })
- _this.tagList = res.data
- } else {
- _this.tagList = []
- }
- },
- error: function(err){
- console.log(err)
- }
- })
- },
- // 数据导出
- dataReport: function() {
- if(this.listState.list.length == 0) {
- this.$toast('暂无数据')
- } else {
- $.ajax({
- url: '/publicapply/dataexpoet/bycollection',
- type: 'POST',
- data: {
- label: this.limitlist.label,
- selectTime: this.limitlist.selectTime,
- buyerclass: this.limitlist.buyerclass,
- buyerPhone: this.limitlist.buyerPhone,
- winnerPhone: this.limitlist.winnerPhone,
- },
- success: function(res) {
- if(res.error_code == 0 && res.data) {
- location.href = '/front/wx_dataExport/submitOrder?id=' + res.data._id + '&source=d&dataspec='
- }
- }
- })
- }
- }
- }
- }
- var myCollection = new Vue(vNode)
|