index-pc.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. function getShortName (comName) {
  2. var areaMap = chinaMapJSON || []
  3. var shortname = comName
  4. // 1. 循环省份城市进行替换
  5. areaMap.forEach(function (item) {
  6. var p = item.name.replace(/[省市]/, '')
  7. if (shortname.indexOf(p) !== -1) {
  8. shortname = shortname.replace(item.name, '').replace(p, '')
  9. console.log(p + ' -> \'\'')
  10. }
  11. item.city.forEach(function (iitem) {
  12. var c = iitem.name.replace(/[省市]/, '')
  13. if (shortname.indexOf(c) !== -1) {
  14. shortname = shortname.replace(iitem.name, '').replace(c, '')
  15. console.log(c + ' -> \'\'')
  16. }
  17. iitem.area.forEach(function (iiitem) {
  18. if (shortname.indexOf(iiitem) !== -1) {
  19. shortname = shortname.replace(iiitem, '')
  20. console.log(iiitem + ' -> \'\'')
  21. }
  22. })
  23. })
  24. })
  25. var matchRes = shortname.match(/[\u4e00-\u9fa5]{4}/gm)
  26. var shortname = matchRes ? matchRes[0] : shortname.slice(0, 4)
  27. if (shortname.length < 4) {
  28. shortname = shortname.slice(0, 4)
  29. }
  30. return shortname
  31. }
  32. function debounce(func, wait) {
  33. var timeout;
  34. return function () {
  35. var context = this;
  36. var args = Array.prototype.slice.call(arguments);
  37. if (timeout) clearTimeout(timeout);
  38. var callNow = !timeout;
  39. timeout = setTimeout(function () {
  40. timeout = null;
  41. }, wait);
  42. if (callNow) func.apply(context, args);
  43. };
  44. }
  45. function downFile (src, name) {
  46. var a = document.createElement('a')
  47. var event = new MouseEvent('click')
  48. a.download = name || '附件名称'
  49. a.href = src
  50. a.dispatchEvent(event)
  51. }
  52. var downFileOfURL = debounce(function (src , name) {
  53. return downFile(src, name)
  54. }, 1500)
  55. var fileRecorder = new Vue({
  56. el: '.see-container',
  57. delimiters: ['{', '}'],
  58. data () {
  59. return {
  60. userPower: {
  61. // 免费用户
  62. isFree: false,
  63. // 超级订阅(超级订阅默认一定有附件下载权益)
  64. vipStatus: 0,
  65. // 大会员
  66. memberStatus: 0,
  67. // 大会员power包含3, 则表示大会员有附件下载权益
  68. power: []
  69. },
  70. // 附件下载相关权益信息
  71. accountInfo: {
  72. // 权益剩余总数量
  73. number: 0,
  74. // 剩余购买数量(充值)/number1
  75. purchaseNum: 0,
  76. // 剩余兑换数量/number2
  77. exchangeNum: 0,
  78. // 剩余定期投放数量(超级订阅剩余权益个数)/number3
  79. grantNum: 0,
  80. // 剩余留资数量(免费用户权益个数)/number4
  81. freeNum: 0
  82. },
  83. working: false,
  84. empty: false,
  85. dateVal: '',
  86. years: '',
  87. months: '',
  88. points: {},
  89. statusEnum: ['存续', '吊销', '注销', '撤销'],
  90. statusColors: ['#2CB7CA', '#F5AF5C', '#58A1E7', '#51CEA2'],
  91. seeList: {
  92. pageNum: 1, // 当前页
  93. pageSize: 10, // 每页多少条数据
  94. total: 0, // 总页数
  95. list: [] // 返回的数据
  96. },
  97. helpDialog: false,
  98. tipDialog: false
  99. }
  100. },
  101. computed: {
  102. bigmember () {
  103. return this.userPower.memberStatus > 0
  104. },
  105. bigmemberNoPower () {
  106. return this.userPower.power.indexOf(3) === -1 && this.bigmember
  107. },
  108. // 大会员有附件下载包权益
  109. bigmemberHasPower () {
  110. return this.userPower.power.indexOf(3) > -1 && this.bigmember
  111. },
  112. // 免费用户或者老超级订阅
  113. freeUser () {
  114. var oldVip = this.userPower.vipStatus > 0 && !this.userPower.viper
  115. return this.userPower.isFree || oldVip
  116. },
  117. // 超级订阅用户
  118. vipUser () {
  119. return this.userPower.vipStatus > 0 && this.userPower.viper
  120. },
  121. showHeaderCard () {
  122. // 大会员有附件下载包权益,不显示卡片
  123. return !this.bigmemberHasPower
  124. },
  125. showFreeTip () {
  126. return this.accountInfo.freeNum > 0
  127. },
  128. dialogBtnText: function() {
  129. if (this.points.provin == -1) {
  130. return '联系客服'
  131. } else {
  132. return '前往升级'
  133. }
  134. }
  135. },
  136. created () {
  137. this.years = new Date().getFullYear()
  138. this.months = parseInt(new Date().getMonth() + 1)
  139. this.dateVal = new Date()
  140. this.getUserPower()
  141. this.subPoint()
  142. this.subRecord()
  143. },
  144. methods: {
  145. getUserPower () {
  146. var _this = this
  147. $.ajax({
  148. type: 'post',
  149. url: '/bigmember/use/isAdd',
  150. success: function (res) {
  151. if (res && res.data) {
  152. for (var key in res.data) {
  153. _this.$set(_this.userPower, key, res.data[key])
  154. }
  155. }
  156. }
  157. })
  158. },
  159. cellClick (row, column, cell, event) {
  160. console.log(row, column, cell, event)
  161. if (column.label === '附件') {
  162. $.ajax({
  163. type: 'post',
  164. url: '/jypay/resourcePack/consumePack',
  165. data: {
  166. productName: '附件下载包',
  167. platform: 'PC',
  168. fileName: row.s_fileName,
  169. id: row.s_id,
  170. title: row.s_title
  171. },
  172. success: function (r) {
  173. if (r && r.m === '' && r.r) {
  174. downFileOfURL(r.r.downUrl, row.s_fileName);
  175. }else{
  176. console.log("附件下载异常,请联系管理员,谢谢!")
  177. }
  178. }
  179. })
  180. return
  181. }
  182. if (column.label === '公告来源') {
  183. // location.href = row.articleUrl + '?aside=0'
  184. window.open(row.articleUrl)
  185. }
  186. },
  187. indexMethod (index) {
  188. return ((this.seeList.pageNum - 1) * this.seeList.pageSize) + index + 1
  189. },
  190. showTip () {
  191. this.tipDialog = true
  192. },
  193. goHandle (item) {
  194. if (item == '前往升级') {
  195. window.open('/swordfish/page_big_pc/free/svip/buy?type=upgrade')
  196. this.tipDialog = false
  197. } else {
  198. $('.open-customer').unbind('click').trigger('click')
  199. this.tipDialog = false
  200. }
  201. },
  202. subPoint () {
  203. var _this = this
  204. $.ajax({
  205. url: '/jypay/resourcePack/account',
  206. type: 'POST',
  207. contentType: 'application/x-www-form-urlencoded',
  208. data: {
  209. product: 'attachmentDownPack'
  210. },
  211. dataType: 'json'
  212. }).done(res => {
  213. if (res.error_msg === '' && res.data && res.data.data) {
  214. try {
  215. var tempInfo = res.data.data[0]
  216. for (var key in tempInfo) {
  217. _this.$set(_this.accountInfo, key, tempInfo[key])
  218. }
  219. } catch (e) {
  220. console.warn(e)
  221. }
  222. }
  223. })
  224. },
  225. getDatas () {
  226. return {
  227. queryTime: new Date(this.years, this.months - 1, 1).pattern('yyyy-MM'),
  228. platform: 'PC',
  229. productName: '附件下载包',
  230. pageSize: this.seeList.pageSize,
  231. pageNum: this.seeList.pageNum
  232. }
  233. },
  234. subRecord () {
  235. this.working = true
  236. this.empty = false
  237. $.ajax({
  238. url: '/jypay/resourcePack/recordList',
  239. type: 'POST',
  240. contentType: 'application/x-www-form-urlencoded',
  241. data: this.getDatas(),
  242. dataType: 'json'
  243. }).done(res => {
  244. var _this = this
  245. if (res.error_code === 0) {
  246. this.working = false
  247. this.empty = true
  248. if (res.data.total) {
  249. this.seeList.total = res.data.total
  250. }
  251. if (!res.data.list) {
  252. res.data.list = []
  253. return
  254. }
  255. this.seeList.list = this.seeList.list.concat(res.data.list)
  256. }
  257. })
  258. },
  259. onPageChange (page) {
  260. this.seeList.pageNum = page
  261. this.seeList.list = []
  262. this.subRecord()
  263. },
  264. dateHandler (val) {
  265. this.years = val.getFullYear()
  266. this.months = val.getMonth() + 1
  267. this.seeList.pageNum = 1
  268. this.seeList.total = 0
  269. this.seeList.list = []
  270. this.subRecord()
  271. },
  272. goToBuySvip: function () {
  273. window.open('/swordfish/page_big_pc/free/svip/buy')
  274. },
  275. rechargeFilePack: function () {
  276. window.open('/swordfish/page_big_pc/free/filePack/buy')
  277. },
  278. toBuyWithPoint () {
  279. console.log('兑换附件下载,跳转工作桌面兑换')
  280. if (goTemplateData.inIframe) {
  281. try {
  282. window.$BRACE.methods.open({
  283. route: {
  284. link: '/points',
  285. appName: 'pointSubApp',
  286. appType: 'qiankun'
  287. }
  288. })
  289. } catch (error) {
  290. window.open('/swordfish/integral/index')
  291. }
  292. } else {
  293. window.open('/swordfish/integral/index')
  294. }
  295. },
  296. goToFileNumberDetail () {
  297. if (goTemplateData.inIframe) {
  298. try {
  299. window.$BRACE.methods.open({
  300. route: {
  301. link: '/big/filepack/history',
  302. appName: 'bigMemberSubApp',
  303. appType: 'qiankun'
  304. }
  305. })
  306. } catch (error) {
  307. window.open('/swordfish/page_big_pc/filepack/history')
  308. }
  309. } else {
  310. window.open('/swordfish/page_big_pc/filepack/history')
  311. }
  312. },
  313. doLeaveInfo: function () {
  314. vm.isNeedSubmit('pc_mine_member_attach_learnmore',function(){
  315. // vm.showSuccess = true
  316. })
  317. },
  318. concatKf () {
  319. if (goTemplateData.inIframe) {
  320. window.$BRACE.$emit('open-customer')
  321. } else {
  322. // 打开客服弹窗
  323. checkCustomerService()
  324. }
  325. },
  326. detailed (ids) {
  327. window.open('/swordfish/page_big_pc/unit_portrayal/' + ids, '_blank')
  328. }
  329. }
  330. })