index-pc.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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. kefu: {
  98. qr: '',
  99. name: ''
  100. },
  101. helpDialog: false,
  102. tipDialog: false,
  103. kefuDialog: false,
  104. }
  105. },
  106. computed: {
  107. bigmember () {
  108. return this.userPower.memberStatus > 0
  109. },
  110. bigmemberNoPower () {
  111. return this.userPower.power.indexOf(3) === -1 && this.bigmember
  112. },
  113. // 大会员有附件下载包权益
  114. bigmemberHasPower () {
  115. return this.userPower.power.indexOf(3) > -1 && this.bigmember
  116. },
  117. // 免费用户或者老超级订阅
  118. freeUser () {
  119. var oldVip = this.userPower.vipStatus > 0 && !this.userPower.viper
  120. return this.userPower.isFree || oldVip
  121. },
  122. // 超级订阅用户
  123. vipUser () {
  124. return this.userPower.vipStatus > 0 && this.userPower.viper
  125. },
  126. showHeaderCard () {
  127. // 大会员有附件下载包权益,不显示卡片
  128. return !this.bigmemberHasPower
  129. },
  130. showFreeTip () {
  131. return this.accountInfo.freeNum > 0
  132. },
  133. dialogBtnText: function() {
  134. if (this.points.provin == -1) {
  135. return '联系客服'
  136. } else {
  137. return '前往升级'
  138. }
  139. }
  140. },
  141. created () {
  142. this.years = new Date().getFullYear()
  143. this.months = parseInt(new Date().getMonth() + 1)
  144. this.dateVal = new Date()
  145. this.getUserPower()
  146. this.subPoint()
  147. this.subRecord()
  148. },
  149. methods: {
  150. getUserPower () {
  151. var _this = this
  152. $.ajax({
  153. type: 'post',
  154. url: '/bigmember/use/isAdd',
  155. success: function (res) {
  156. if (res && res.data) {
  157. for (var key in res.data) {
  158. _this.$set(_this.userPower, key, res.data[key])
  159. _this.calcKefuInfo()
  160. }
  161. }
  162. }
  163. })
  164. },
  165. calcKefuInfo: function () {
  166. var customers = this.userPower.customers
  167. if (!$.isArray(customers)) {
  168. return
  169. }
  170. var target;
  171. for (var i = 0; i < customers.length; i++) {
  172. if (customers[i].remark.indexOf('成功') > -1) {
  173. target = customers[i]
  174. break
  175. }
  176. }
  177. if (target) {
  178. this.kefu.qr = target.wxer
  179. this.kefu.name = target.remark
  180. }
  181. },
  182. cellClick (row, column, cell, event) {
  183. console.log(row, column, cell, event)
  184. if (column.label === '附件') {
  185. $.ajax({
  186. type: 'post',
  187. url: '/jypay/resourcePack/consumePack',
  188. data: {
  189. productName: '附件下载包',
  190. platform: 'PC',
  191. fileName: row.s_fileName,
  192. id: row.s_id,
  193. title: row.s_title
  194. },
  195. success: function (r) {
  196. if (r && r.m === '' && r.r) {
  197. downFileOfURL(r.r.downUrl, row.s_fileName);
  198. }else{
  199. console.log("附件下载异常,请联系管理员,谢谢!")
  200. }
  201. }
  202. })
  203. return
  204. }
  205. if (column.label === '公告来源') {
  206. // location.href = row.articleUrl + '?aside=0'
  207. window.open(row.articleUrl)
  208. }
  209. },
  210. indexMethod (index) {
  211. return ((this.seeList.pageNum - 1) * this.seeList.pageSize) + index + 1
  212. },
  213. showTip () {
  214. this.tipDialog = true
  215. },
  216. goHandle (item) {
  217. if (item == '前往升级') {
  218. window.open('/swordfish/page_big_pc/free/svip/buy?type=upgrade')
  219. this.tipDialog = false
  220. } else {
  221. $('.open-customer').unbind('click').trigger('click')
  222. this.tipDialog = false
  223. }
  224. },
  225. subPoint () {
  226. var _this = this
  227. $.ajax({
  228. url: '/jypay/resourcePack/account',
  229. type: 'POST',
  230. contentType: 'application/x-www-form-urlencoded',
  231. data: {
  232. product: 'attachmentDownPack'
  233. },
  234. dataType: 'json'
  235. }).done(res => {
  236. if (res.error_msg === '' && res.data && res.data.data) {
  237. try {
  238. var tempInfo = res.data.data[0]
  239. for (var key in tempInfo) {
  240. _this.$set(_this.accountInfo, key, tempInfo[key])
  241. }
  242. } catch (e) {
  243. console.warn(e)
  244. }
  245. }
  246. })
  247. },
  248. getDatas () {
  249. return {
  250. queryTime: new Date(this.years, this.months - 1, 1).pattern('yyyy-MM'),
  251. platform: 'PC',
  252. productName: '附件下载包',
  253. pageSize: this.seeList.pageSize,
  254. pageNum: this.seeList.pageNum
  255. }
  256. },
  257. subRecord () {
  258. this.working = true
  259. this.empty = false
  260. $.ajax({
  261. url: '/jypay/resourcePack/recordList',
  262. type: 'POST',
  263. contentType: 'application/x-www-form-urlencoded',
  264. data: this.getDatas(),
  265. dataType: 'json'
  266. }).done(res => {
  267. var _this = this
  268. if (res.error_code === 0) {
  269. this.working = false
  270. this.empty = true
  271. if (res.data.total) {
  272. this.seeList.total = res.data.total
  273. }
  274. if (!res.data.list) {
  275. res.data.list = []
  276. return
  277. }
  278. this.seeList.list = this.seeList.list.concat(res.data.list)
  279. }
  280. })
  281. },
  282. onPageChange (page) {
  283. this.seeList.pageNum = page
  284. this.seeList.list = []
  285. this.subRecord()
  286. },
  287. dateHandler (val) {
  288. this.years = val.getFullYear()
  289. this.months = val.getMonth() + 1
  290. this.seeList.pageNum = 1
  291. this.seeList.total = 0
  292. this.seeList.list = []
  293. this.subRecord()
  294. },
  295. goToBuySvip: function () {
  296. window.open('/swordfish/page_big_pc/free/svip/buy')
  297. },
  298. rechargeFilePack: function () {
  299. window.open('/swordfish/page_big_pc/free/filePack/buy')
  300. },
  301. toBuyWithPoint () {
  302. console.log('兑换附件下载,跳转工作桌面兑换')
  303. if (goTemplateData.inIframe) {
  304. try {
  305. window.$BRACE.methods.open({
  306. route: {
  307. link: '/points',
  308. appName: 'pointSubApp',
  309. appType: 'qiankun'
  310. }
  311. })
  312. } catch (error) {
  313. window.open('/swordfish/integral/index')
  314. }
  315. } else {
  316. window.open('/swordfish/integral/index')
  317. }
  318. },
  319. goToFileNumberDetail () {
  320. if (goTemplateData.inIframe) {
  321. try {
  322. window.$BRACE.methods.open({
  323. route: {
  324. link: '/big/filepack/history',
  325. appName: 'bigMemberSubApp',
  326. appType: 'qiankun'
  327. }
  328. })
  329. } catch (error) {
  330. window.open('/swordfish/page_big_pc/filepack/history')
  331. }
  332. } else {
  333. window.open('/swordfish/page_big_pc/filepack/history')
  334. }
  335. },
  336. doLeaveInfo: function () {
  337. vm.isNeedSubmit('pc_mine_member_attach_learnmore',function(){
  338. // vm.showSuccess = true
  339. })
  340. },
  341. // 显示专属客服弹窗
  342. showZhuanShuKfDialog () {
  343. this.kefuDialog = true
  344. },
  345. concatKf () {
  346. if (goTemplateData.inIframe) {
  347. window.$BRACE.$emit('open-customer')
  348. } else {
  349. // 打开客服弹窗
  350. checkCustomerService()
  351. }
  352. },
  353. detailed (ids) {
  354. window.open('/swordfish/page_big_pc/unit_portrayal/' + ids, '_blank')
  355. }
  356. }
  357. })