index.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. }
  73. },
  74. created: function () {
  75. this.getPType("type")
  76. this.years = new Date().getFullYear()
  77. this.months = parseInt(new Date().getMonth() + 1)
  78. this.dValue = this.years + '年' + this.months + '月'
  79. this.curDate = new Date()
  80. this.minDate = new Date(2021, 0)
  81. this.maxTime = new Date(this.years, this.months - 1)
  82. this.subPoint()
  83. this.onLoad()
  84. this.initHtml()
  85. },
  86. methods: {
  87. initHtml () {
  88. if (this.ptype == "1") {
  89. document.title = '采购单位画像记录'
  90. typeof setHeaderTitle === 'function' ? setHeaderTitle(document.title) : null
  91. $(".btns span").text("当月采购单位画像剩余数")
  92. $(".emptytext").text("暂无采购单位画像记录")
  93. }
  94. },
  95. getPType (paraName) {
  96. let _this = this
  97. var url = document.location.toString();
  98. var arrObj = url.split("?");
  99. if (arrObj.length > 1) {
  100. var arrPara = arrObj[1].split("&");
  101. var arr;
  102. for (var i = 0; i < arrPara.length; i++) {
  103. arr = arrPara[i].split("=");
  104. if (arr != null && arr[0] == paraName) {
  105. _this.ptype = arr[1];
  106. }
  107. }
  108. }
  109. },
  110. usedHised () {
  111. let _this = this
  112. _this.pShow = true
  113. },
  114. subPoint () {
  115. $.ajax({
  116. url: '/jypay/resourcePack/account',
  117. type: 'POST',
  118. contentType: 'application/x-www-form-urlencoded',
  119. data: {
  120. product: 'attachmentDownPack'
  121. },
  122. dataType: 'json'
  123. }).done(res => {
  124. if (res.error_msg === '' && res.data && res.data.data) {
  125. try {
  126. var tempInfo = res.data.data[0]
  127. this.points.total = tempInfo.number
  128. } catch (e) {
  129. console.warn(e)
  130. }
  131. } else {
  132. this.$toast(res.error_msg || '请稍后重试')
  133. }
  134. })
  135. },
  136. onLoad () {
  137. this.ajaxEntList().done(this.doFormatList.bind(this))
  138. },
  139. doFormatList (r) {
  140. if (r && r.error_msg == '' && r.data) {
  141. this.points.usage = r.data.total
  142. this.working = false
  143. this.empty = true
  144. if (this.listInfo.pageNum === 1) {
  145. if (r.data.total || r.data.total === 0) {
  146. this.listInfo.total = r.data.total
  147. } else {
  148. this.listInfo.finished = true
  149. }
  150. }
  151. this.listInfo.pageNum++
  152. if (Array.isArray(r.data.list) && r.data.list.length !== 0) {
  153. this.list = this.list.concat(r.data.list.map(function (v) {
  154. var isDoc = /.doc(x{0,})$/.test(v.s_fileName)
  155. v.icon = isDoc ? 'doc' : 'rar'
  156. return v
  157. }))
  158. } else {
  159. this.listInfo.finished = true
  160. }
  161. this.listInfo.loading = false
  162. if (this.listInfo.total !== -1 && this.listInfo.total <= this.list.length) {
  163. this.listInfo.finished = true
  164. }
  165. }
  166. },
  167. getDatas () {
  168. return {
  169. queryTime: new Date(this.years, this.months-1, 1).pattern('yyyy-MM'),
  170. platform: navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1 ? 'WX' : 'APP',
  171. productName: '附件下载包',
  172. pageSize: this.listInfo.pageSize,
  173. pageNum: this.listInfo.pageNum
  174. }
  175. },
  176. ajaxEntList () {
  177. this.working = true
  178. this.empty = false
  179. return $.ajax({
  180. url: '/jypay/resourcePack/recordList',
  181. type: 'POST',
  182. contentType: 'application/x-www-form-urlencoded',
  183. data: this.getDatas(),
  184. dataType: 'json'
  185. })
  186. },
  187. downFile (item) {
  188. //location.href = item.s_downUrl
  189. $.ajax({
  190. type: 'post',
  191. url: '/jypay/resourcePack/consumePack',
  192. data: {
  193. productName: '附件下载包',
  194. platform: 'APP',
  195. fileName: item.s_fileName,
  196. id: item.s_id,
  197. title: item.s_title
  198. },
  199. success: function (r) {
  200. if (r && r.m === '' && r.r) {
  201. location.href = r.r.downUrl
  202. }else{
  203. vant.Dialog.alert({
  204. message: '附件下载异常,请联系管理员,谢谢!',
  205. className: 'custom-dialog',
  206. confirmButtonText: '我知道了',
  207. confirmButtonColor: '#2ABDD1',
  208. width: 303,
  209. }).then(() => {})
  210. }
  211. }
  212. })
  213. },
  214. commonDialogFn (message, confirmText, callBack) {
  215. if (this.ptype == "1") {
  216. var curDay = new Date().pattern('yyyy/MM/dd')
  217. localStorage.setItem('show-buyer-dialog', curDay)
  218. } else {
  219. var curDay = new Date().pattern('yyyy/MM/dd')
  220. localStorage.setItem('show-ent-dialog', curDay)
  221. }
  222. this.$dialog.confirm({
  223. message: message,
  224. width: 303,
  225. className: 'pro-log',
  226. messageAlign: 'left',
  227. showCancelButton: 'true',
  228. confirmButtonColor: '#2ABED1',
  229. confirmButtonText: confirmText,
  230. showCancelButton: true
  231. }).then(function () {
  232. callBack && callBack()
  233. }).catch(function () { })
  234. },
  235. usedDialog () {
  236. this.commonDialogFn('超级订阅用户每月享有下载10个附件的权限,也可充值附件下载包増加当月附件下载个数,每月1号上月余额清零重新计算。', '我知道了')
  237. },
  238. helpTiped () {
  239. this.$dialog.alert({
  240. width: 303,
  241. message: '超级订阅用户每月享有下载<span class="on">10</span>个附件的权限,也可充值附件下载包増加当月附件下载个数,每月1号上月余额清零重新计算。',
  242. className: 'pro-log',
  243. messageAlign: 'left',
  244. confirmButtonColor: '#2ABED1',
  245. confirmButtonText: '我知道了',
  246. })
  247. },
  248. confirmed (val) {
  249. this.years = val.getFullYear()
  250. this.months = val.getMonth() + 1
  251. this.listInfo.pageNum = 1
  252. this.list = []
  253. this.listInfo.total = -1
  254. this.listInfo.finished = false
  255. this.listInfo.loading = true
  256. this.onLoad()
  257. this.dValue = this.years + '年' + this.months + '月'
  258. this.pShow = false
  259. },
  260. canceled () {
  261. this.pShow = false
  262. },
  263. ChangeDate (time) {
  264. var d = new Date(time)
  265. var Y = d.getFullYear() + '年'
  266. var M = (d.getMonth() + 1 < 10 ? '0' + (d.getMonth() + 1) : d.getMonth() + 1) + '月'
  267. return (Y + M).replace(/^\s+|\s+$/g, "")
  268. },
  269. detailed (ids) {
  270. if (this.ptype == "") {
  271. location.href = '/jyapp/big/page/ent_portrait?eId=' + ids + '&svip=1'
  272. } else {
  273. location.href = '/jyapp/big/page/unit_portrayal?entName=' + ids + '&svip=1'
  274. }
  275. },
  276. contractPerson () {
  277. location.href = '/jyapp/free/customer'
  278. // try {
  279. // JyObj.callPhone('400-108-6670')
  280. // } catch (error) {
  281. // console.log(error)
  282. // }
  283. },
  284. setBook() {
  285. var temp = {
  286. wx: '/jy_mobile/common/order/create/filepack?type=0',
  287. app: '/jy_mobile/common/order/create/filepack?type=0'
  288. }
  289. var isWeixin = navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1
  290. location.href = temp[isWeixin ? 'wx' : 'app']
  291. }
  292. }
  293. })