123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- function getShortName (comName) {
- var areaMap = chinaMapJSON || []
- var shortname = comName
- // 1. 循环省份城市进行替换
- areaMap.forEach(function (item) {
- var p = item.name.replace(/[省市]/, '')
- if (shortname.indexOf(p) !== -1) {
- shortname = shortname.replace(item.name, '').replace(p, '')
- console.log(p + ' -> \'\'')
- }
- item.city.forEach(function (iitem) {
- var c = iitem.name.replace(/[省市]/, '')
- if (shortname.indexOf(c) !== -1) {
- shortname = shortname.replace(iitem.name, '').replace(c, '')
- console.log(c + ' -> \'\'')
- }
- iitem.area.forEach(function (iiitem) {
- if (shortname.indexOf(iiitem) !== -1) {
- shortname = shortname.replace(iiitem, '')
- console.log(iiitem + ' -> \'\'')
- }
- })
- })
- })
- var matchRes = shortname.match(/[\u4e00-\u9fa5]{4}/gm)
- var shortname = matchRes ? matchRes[0] : shortname.slice(0, 4)
- if (shortname.length < 4) {
- shortname = shortname.slice(0, 4)
- }
- return shortname
- }
- function debounce(func, wait) {
- var timeout;
- return function () {
- var context = this;
- var args = Array.prototype.slice.call(arguments);
- if (timeout) clearTimeout(timeout);
- var callNow = !timeout;
- timeout = setTimeout(function () {
- timeout = null;
- }, wait);
- if (callNow) func.apply(context, args);
- };
- }
- function downFile (src, name) {
- var a = document.createElement('a')
- var event = new MouseEvent('click')
- a.download = name || '附件名称'
- a.href = src
- a.dispatchEvent(event)
- }
- var downFileOfURL = debounce(function (src , name) {
- return downFile(src, name)
- }, 1500)
- var fileRecorder = new Vue({
- el: '.see-container',
- delimiters: ['{', '}'],
- data () {
- return {
- userPower: {
- // 免费用户
- isFree: false,
- // 超级订阅(超级订阅默认一定有附件下载权益)
- vipStatus: 0,
- // 大会员
- memberStatus: 0,
- // 大会员power包含3, 则表示大会员有附件下载权益
- power: []
- },
- // 附件下载相关权益信息
- accountInfo: {
- // 权益剩余总数量
- number: 0,
- // 剩余购买数量(充值)/number1
- purchaseNum: 0,
- // 剩余兑换数量/number2
- exchangeNum: 0,
- // 剩余定期投放数量(超级订阅剩余权益个数)/number3
- grantNum: 0,
- // 剩余留资数量(免费用户权益个数)/number4
- freeNum: 0
- },
- working: false,
- empty: false,
- dateVal: '',
- years: '',
- months: '',
- points: {},
- statusEnum: ['存续', '吊销', '注销', '撤销'],
- statusColors: ['#2CB7CA', '#F5AF5C', '#58A1E7', '#51CEA2'],
- seeList: {
- pageNum: 1, // 当前页
- pageSize: 10, // 每页多少条数据
- total: 0, // 总页数
- list: [] // 返回的数据
- },
- kefu: {
- qr: '',
- name: ''
- },
- helpDialog: false,
- tipDialog: false,
- kefuDialog: false,
- }
- },
- computed: {
- bigmember () {
- return this.userPower.memberStatus > 0
- },
- bigmemberNoPower () {
- return this.userPower.power.indexOf(3) === -1 && this.bigmember
- },
- // 大会员有附件下载包权益
- bigmemberHasPower () {
- return this.userPower.power.indexOf(3) > -1 && this.bigmember
- },
- // 免费用户或者老超级订阅
- freeUser () {
- var oldVip = this.userPower.vipStatus > 0 && !this.userPower.viper
- return this.userPower.isFree || oldVip
- },
- // 超级订阅用户
- vipUser () {
- return this.userPower.vipStatus > 0 && this.userPower.viper
- },
- showHeaderCard () {
- // 大会员有附件下载包权益,不显示卡片
- return !this.bigmemberHasPower
- },
- showFreeTip () {
- return this.accountInfo.freeNum > 0
- },
- dialogBtnText: function() {
- if (this.points.provin == -1) {
- return '联系客服'
- } else {
- return '前往升级'
- }
- }
- },
- created () {
- this.years = new Date().getFullYear()
- this.months = parseInt(new Date().getMonth() + 1)
- this.dateVal = new Date()
- this.getUserPower()
- this.subPoint()
- this.subRecord()
- },
- methods: {
- getUserPower () {
- var _this = this
- $.ajax({
- type: 'post',
- url: '/bigmember/use/isAdd',
- success: function (res) {
- if (res && res.data) {
- for (var key in res.data) {
- _this.$set(_this.userPower, key, res.data[key])
- _this.calcKefuInfo()
- }
- }
- }
- })
- },
- calcKefuInfo: function () {
- var customers = this.userPower.customers
- if (!$.isArray(customers)) {
- return
- }
- var target;
- for (var i = 0; i < customers.length; i++) {
- if (customers[i].remark.indexOf('成功') > -1) {
- target = customers[i]
- break
- }
- }
- if (target) {
- this.kefu.qr = target.wxer
- this.kefu.name = target.remark
- }
- },
- cellClick (row, column, cell, event) {
- console.log(row, column, cell, event)
- if (column.label === '附件') {
- $.ajax({
- type: 'post',
- url: '/jypay/resourcePack/consumePack',
- data: {
- productName: '附件下载包',
- platform: 'PC',
- fileName: row.s_fileName,
- id: row.s_id,
- title: row.s_title
- },
- success: function (r) {
- if (r && r.m === '' && r.r) {
- downFileOfURL(r.r.downUrl, row.s_fileName);
- }else{
- console.log("附件下载异常,请联系管理员,谢谢!")
- }
- }
- })
- return
- }
- if (column.label === '公告来源') {
- // location.href = row.articleUrl + '?aside=0'
- window.open(row.articleUrl)
- }
- },
- indexMethod (index) {
- return ((this.seeList.pageNum - 1) * this.seeList.pageSize) + index + 1
- },
- showTip () {
- this.tipDialog = true
- },
- goHandle (item) {
- if (item == '前往升级') {
- window.open('/swordfish/page_big_pc/free/svip/buy?type=upgrade')
- this.tipDialog = false
- } else {
- $('.open-customer').unbind('click').trigger('click')
- this.tipDialog = false
- }
- },
- subPoint () {
- var _this = this
- $.ajax({
- url: '/jypay/resourcePack/account',
- type: 'POST',
- contentType: 'application/x-www-form-urlencoded',
- data: {
- product: 'attachmentDownPack'
- },
- dataType: 'json'
- }).done(res => {
- if (res.error_msg === '' && res.data && res.data.data) {
- try {
- var tempInfo = res.data.data[0]
- for (var key in tempInfo) {
- _this.$set(_this.accountInfo, key, tempInfo[key])
- }
- } catch (e) {
- console.warn(e)
- }
- }
- })
- },
- getDatas () {
- return {
- queryTime: new Date(this.years, this.months - 1, 1).pattern('yyyy-MM'),
- platform: 'PC',
- productName: '附件下载包',
- pageSize: this.seeList.pageSize,
- pageNum: this.seeList.pageNum
- }
- },
- subRecord () {
- this.working = true
- this.empty = false
- $.ajax({
- url: '/jypay/resourcePack/recordList',
- type: 'POST',
- contentType: 'application/x-www-form-urlencoded',
- data: this.getDatas(),
- dataType: 'json'
- }).done(res => {
- var _this = this
- if (res.error_code === 0) {
- this.working = false
- this.empty = true
- if (res.data.total) {
- this.seeList.total = res.data.total
- }
- if (!res.data.list) {
- res.data.list = []
- return
- }
- this.seeList.list = this.seeList.list.concat(res.data.list)
- }
- })
- },
- onPageChange (page) {
- this.seeList.pageNum = page
- this.seeList.list = []
- this.subRecord()
- },
- dateHandler (val) {
- this.years = val.getFullYear()
- this.months = val.getMonth() + 1
- this.seeList.pageNum = 1
- this.seeList.total = 0
- this.seeList.list = []
- this.subRecord()
- },
- goToBuySvip: function () {
- window.open('/swordfish/page_big_pc/free/svip/buy')
- },
- rechargeFilePack: function () {
- window.open('/swordfish/page_big_pc/free/filePack/buy')
- },
- toBuyWithPoint () {
- console.log('兑换附件下载,跳转工作桌面兑换')
- if (goTemplateData.inIframe) {
- try {
- window.$BRACE.methods.open({
- route: {
- link: '/points',
- appName: 'pointSubApp',
- appType: 'qiankun'
- }
- })
- } catch (error) {
- window.open('/swordfish/integral/index')
- }
- } else {
- window.open('/swordfish/integral/index')
- }
- },
- goToFileNumberDetail () {
- if (goTemplateData.inIframe) {
- try {
- window.$BRACE.methods.open({
- route: {
- link: '/big/filepack/history',
- appName: 'bigMemberSubApp',
- appType: 'qiankun'
- }
- })
- } catch (error) {
- window.open('/swordfish/page_big_pc/filepack/history')
- }
- } else {
- window.open('/swordfish/page_big_pc/filepack/history')
- }
- },
- doLeaveInfo: function () {
- vm.isNeedSubmit('pc_mine_member_attach_learnmore',function(){
- // vm.showSuccess = true
- })
- },
- // 显示专属客服弹窗
- showZhuanShuKfDialog () {
- this.kefuDialog = true
- },
- concatKf () {
- if (goTemplateData.inIframe) {
- window.$BRACE.$emit('open-customer')
- } else {
- // 打开客服弹窗
- checkCustomerService()
- }
- },
- detailed (ids) {
- window.open('/swordfish/page_big_pc/unit_portrayal/' + ids, '_blank')
- }
- }
- })
|