index.js 12 KB

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