index-wx.js 8.3 KB

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