index.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  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. var formatter11 = (type, val) => {
  33. if (type === 'year') {
  34. return `${val}年`;
  35. }
  36. if (type === 'month') {
  37. return `${val}月`;
  38. }
  39. return val;
  40. }
  41. var vm = new Vue({
  42. el: '#proRecord',
  43. delimiters: ['{', '}'],
  44. data: function () {
  45. return {
  46. dValue: '',
  47. pShow: false,
  48. working: false,
  49. empty: false,
  50. curDate: '',
  51. minDate: '',
  52. maxTime: '',
  53. points: {
  54. total: 0,
  55. usage: 0
  56. },
  57. years: '',
  58. months: '',
  59. contracted: false,
  60. listInfo: {
  61. value: '',
  62. pageNum: 1,
  63. pageSize: 10,
  64. total: -1,
  65. loading: true,
  66. finished: false
  67. },
  68. statusEnum: ['存续', '吊销', '停业', '撤销'],
  69. statusColors: ['#2CB7CA', '#F5AF5C', '#58A1E7', '#51CEA2'],
  70. list: [],
  71. ptype: "",
  72. userPower: {
  73. // 免费用户
  74. isFree: false,
  75. // 超级订阅(超级订阅默认一定有附件下载权益)
  76. vipStatus: 0,
  77. // 大会员
  78. memberStatus: 0,
  79. // 大会员power包含3, 则表示大会员有附件下载权益
  80. power: []
  81. },
  82. // 附件下载相关权益信息
  83. accountInfo: {
  84. // 充值数量
  85. purchaseNum: 0,
  86. // 兑换数量
  87. exchangeNum: 0,
  88. // 超级订阅剩余权益个数
  89. grantNum: 0,
  90. // 免费数量(免费用户权益个数)
  91. freeNum: 0
  92. },
  93. kfDialogShow: false,
  94. // 客服信息
  95. kefuInfo: {
  96. name: '',
  97. remark: "专属客服",
  98. wxer: ''
  99. },
  100. // 保存图片是否成功
  101. savePicSuccess: false,
  102. picImgUrl: null
  103. }
  104. },
  105. computed: {
  106. // 大会员是否拥有附件下载权益
  107. hasDownloadPower () {
  108. return this.userPower.power.indexOf(3) > -1
  109. }
  110. },
  111. created: function () {
  112. this.getKefuInfo()
  113. this.getPType("type")
  114. this.years = new Date().getFullYear()
  115. this.months = parseInt(new Date().getMonth() + 1)
  116. this.dValue = this.years + '年' + this.months + '月'
  117. this.curDate = new Date()
  118. this.minDate = new Date(2021, 0)
  119. this.maxTime = new Date(this.years, this.months - 1)
  120. this.getUserPower()
  121. this.subPoint()
  122. this.onLoad()
  123. },
  124. methods: {
  125. // 获取用户权限
  126. getUserPower() {
  127. var _this = this
  128. $.ajax({
  129. url: '/bigmember/use/isAdd',
  130. type: 'POST',
  131. success: function (res) {
  132. console.log(res)
  133. if (res.data) {
  134. var resData = res.data
  135. _this.userPower.isFree = resData.isFree
  136. _this.userPower.vipStatus = resData.vipStatus
  137. _this.userPower.memberStatus = resData.memberStatus
  138. _this.userPower.power = resData.power
  139. }
  140. }
  141. })
  142. },
  143. // 获取客服信息
  144. getKefuInfo () {
  145. var _this = this
  146. $.ajax({
  147. type: 'post',
  148. url: '/bigmember/use/getCustom',
  149. success: function (res) {
  150. if (res && res.data) {
  151. const resData = res.data || {}
  152. _this.kefuInfo = resData
  153. }
  154. }
  155. })
  156. },
  157. // 超级订阅-了解详情
  158. knowMore () {
  159. var source = 'app_mine_member_attach_learnmore'
  160. if(utils.$env.platform === 'h5') {
  161. source = 'h5_mine_member_attach_learnmore'
  162. }
  163. location.href = '/jyapp/frontPage/bigmember/free/perfect_info?source=' + source
  164. },
  165. // 咨询客服
  166. consultKf () {
  167. this.kfDialogShow = true
  168. },
  169. // 保存二维码
  170. savePicHandle () {
  171. var _this = this
  172. if(_this.savePicSuccess) return
  173. var loading = _this.$toast.loading({ duration: 0, message: '保存中...' })
  174. if(!_this.picImgUrl) {
  175. $("#creat-img-box").append($('#QRCode-pic').clone().attr('id', 'clone-image'))
  176. html2canvas(document.querySelector('#clone-image'), {
  177. // allowTaint: true,
  178. useCORS: true,
  179. backgroundColor: null,
  180. scale: 3,
  181. imageTimeout: 30000,
  182. }).then(canvas => {
  183. var imgUrl = canvas.toDataURL('image/png');
  184. imgUrl = imgUrl.replace('data:image/png;base64,', '')
  185. _this.picImgUrl = imgUrl
  186. $('#clone-image').remove()
  187. try {
  188. if (typeof window.__compatibleAppFn === 'function') {
  189. window.__compatibleAppFn(JyObj.savePic, _this.picImgUrl, '剑鱼标讯需要您的存储权限,将用于下载、保存二维码图片到相册,以便您能及时联系客服,处理附件下载时遇到的问题。')
  190. }
  191. _this.$toast('图片已经保存~')
  192. loading.clear()
  193. setTimeout(() => {
  194. _this.saveSuccess = false
  195. }, 1500)
  196. } catch (e) {
  197. $('#clone-image').remove()
  198. loading.clear()
  199. _this.$toast('保存失败')
  200. setTimeout(() => {
  201. _this.saveSuccess = false
  202. }, 1500)
  203. }
  204. })
  205. }else {
  206. try {
  207. if (typeof window.__compatibleAppFn === 'function') {
  208. window.__compatibleAppFn(JyObj.savePic, _this.picImgUrl, '剑鱼标讯需要您的存储权限,将用于下载、保存二维码图片到相册,以便您能及时联系客服,处理附件下载时遇到的问题。')
  209. }
  210. loading.clear()
  211. _this.$toast('图片已经保存,快去分享吧~')
  212. } catch (e) {
  213. loading.clear()
  214. _this.$toast('保存失败')
  215. }
  216. setTimeout(() => {
  217. _this.saveSuccess = false
  218. }, 1500)
  219. }
  220. },
  221. // 去兑换
  222. exchangeHandle() {
  223. location.href = '/jy_mobile/points/my_points'
  224. },
  225. // 兑换明细
  226. viewDetail () {
  227. location.href = '/jy_mobile/fileRecord/exchange'
  228. },
  229. // 去充值
  230. setBook() {
  231. if(this.userPower && this.userPower.isFree){
  232. location.href = '/jy_mobile/common/order/create/svip?type=buy'
  233. return
  234. }
  235. location.href = '/jy_mobile/common/order/create/filepack?type=0'
  236. },
  237. getPType (paraName) {
  238. let _this = this
  239. var url = document.location.toString();
  240. var arrObj = url.split("?");
  241. if (arrObj.length > 1) {
  242. var arrPara = arrObj[1].split("&");
  243. var arr;
  244. for (var i = 0; i < arrPara.length; i++) {
  245. arr = arrPara[i].split("=");
  246. if (arr != null && arr[0] == paraName) {
  247. _this.ptype = arr[1];
  248. }
  249. }
  250. }
  251. },
  252. usedHised () {
  253. let _this = this
  254. _this.pShow = true
  255. },
  256. subPoint () {
  257. $.ajax({
  258. url: '/jypay/resourcePack/account',
  259. type: 'POST',
  260. contentType: 'application/x-www-form-urlencoded',
  261. data: {
  262. product: 'attachmentDownPack'
  263. },
  264. dataType: 'json'
  265. }).done(res => {
  266. if (res.error_msg === '' && res.data && res.data.data) {
  267. try {
  268. var tempInfo = res.data.data[0]
  269. this.accountInfo = tempInfo
  270. this.points.total = tempInfo.number
  271. } catch (e) {
  272. console.warn(e)
  273. }
  274. } else {
  275. this.$toast(res.error_msg || '请稍后重试')
  276. }
  277. })
  278. },
  279. onLoad () {
  280. this.ajaxEntList().done(this.doFormatList.bind(this))
  281. },
  282. doFormatList (r) {
  283. if (r && r.error_msg == '' && r.data) {
  284. this.points.usage = r.data.total
  285. this.working = false
  286. this.empty = true
  287. if (this.listInfo.pageNum === 1) {
  288. if (r.data.total || r.data.total === 0) {
  289. this.listInfo.total = r.data.total
  290. } else {
  291. this.listInfo.finished = true
  292. }
  293. }
  294. this.listInfo.pageNum++
  295. if (Array.isArray(r.data.list) && r.data.list.length !== 0) {
  296. this.list = this.list.concat(r.data.list.map(function (v) {
  297. var isDoc = /.doc(x{0,})$/.test(v.s_fileName)
  298. v.icon = isDoc ? 'doc' : 'rar'
  299. return v
  300. }))
  301. } else {
  302. this.listInfo.finished = true
  303. }
  304. this.listInfo.loading = false
  305. if (this.listInfo.total !== -1 && this.listInfo.total <= this.list.length) {
  306. this.listInfo.finished = true
  307. }
  308. }
  309. },
  310. getDatas () {
  311. return {
  312. queryTime: new Date(this.years, this.months-1, 1).pattern('yyyy-MM'),
  313. platform: __pageData.platform.toUpperCase(),
  314. productName: '附件下载包',
  315. pageSize: this.listInfo.pageSize,
  316. pageNum: this.listInfo.pageNum
  317. }
  318. },
  319. ajaxEntList () {
  320. this.working = true
  321. this.empty = false
  322. return $.ajax({
  323. url: '/jypay/resourcePack/recordList',
  324. type: 'POST',
  325. contentType: 'application/x-www-form-urlencoded',
  326. data: this.getDatas(),
  327. dataType: 'json'
  328. })
  329. },
  330. downFile (item) {
  331. //location.href = item.s_downUrl
  332. if (utils.$envs.inWxMini) {
  333. return utils.toDownloadApp()
  334. }
  335. $.ajax({
  336. type: 'post',
  337. url: '/jypay/resourcePack/consumePack',
  338. data: {
  339. productName: '附件下载包',
  340. platform: 'APP',
  341. fileName: item.s_fileName,
  342. id: item.s_id,
  343. title: item.s_title
  344. },
  345. success: function (r) {
  346. if (r && r.m === '' && r.r) {
  347. location.href = r.r.downUrl
  348. }else{
  349. vant.Dialog.alert({
  350. message: '附件下载异常,请联系管理员,谢谢!',
  351. className: 'custom-dialog',
  352. confirmButtonText: '我知道了',
  353. confirmButtonColor: '#2ABDD1',
  354. width: 303,
  355. }).then(() => {})
  356. }
  357. }
  358. })
  359. },
  360. commonDialogFn (message, confirmText, callBack) {
  361. if (this.ptype == "1") {
  362. var curDay = new Date().pattern('yyyy/MM/dd')
  363. localStorage.setItem('show-buyer-dialog', curDay)
  364. } else {
  365. var curDay = new Date().pattern('yyyy/MM/dd')
  366. localStorage.setItem('show-ent-dialog', curDay)
  367. }
  368. this.$dialog.confirm({
  369. message: message,
  370. width: 303,
  371. className: 'pro-log',
  372. messageAlign: 'left',
  373. showCancelButton: 'true',
  374. confirmButtonColor: '#2ABED1',
  375. confirmButtonText: confirmText,
  376. showCancelButton: true
  377. }).then(function () {
  378. callBack && callBack()
  379. }).catch(function () { })
  380. },
  381. usedDialog () {
  382. this.commonDialogFn('超级订阅用户每月享有下载10个附件的权限,也可充值附件下载包増加当月附件下载个数,每月1号上月余额清零重新计算。', '我知道了')
  383. },
  384. helpTiped () {
  385. this.$dialog.alert({
  386. width: 303,
  387. message: '超级订阅用户每月享有下载<span class="on">10</span>个附件的权限,也可充值附件下载包増加当月附件下载个数,每月1号上月余额清零重新计算。',
  388. className: 'pro-log',
  389. messageAlign: 'left',
  390. confirmButtonColor: '#2ABED1',
  391. confirmButtonText: '我知道了',
  392. })
  393. },
  394. confirmed (val) {
  395. this.years = val.getFullYear()
  396. this.months = val.getMonth() + 1
  397. this.listInfo.pageNum = 1
  398. this.list = []
  399. this.listInfo.total = -1
  400. this.listInfo.finished = false
  401. this.listInfo.loading = true
  402. this.onLoad()
  403. this.dValue = this.years + '年' + this.months + '月'
  404. this.pShow = false
  405. },
  406. canceled () {
  407. this.pShow = false
  408. },
  409. ChangeDate (time) {
  410. var d = new Date(time)
  411. var Y = d.getFullYear() + '年'
  412. var M = (d.getMonth() + 1 < 10 ? '0' + (d.getMonth() + 1) : d.getMonth() + 1) + '月'
  413. return (Y + M).replace(/^\s+|\s+$/g, "")
  414. },
  415. detailed (ids) {
  416. if (this.ptype == "") {
  417. location.href = '/jyapp/big/page/ent_portrait?eId=' + ids + '&svip=1'
  418. } else {
  419. location.href = '/jyapp/big/page/unit_portrayal?entName=' + ids + '&svip=1'
  420. }
  421. },
  422. contractPerson () {
  423. location.href = '/jyapp/free/customer'
  424. // try {
  425. // JyObj.callPhone('400-108-6670')
  426. // } catch (error) {
  427. // console.log(error)
  428. // }
  429. }
  430. }
  431. })