index-wx.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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: 0,
  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. this.listInfo.pageNum++
  145. if (this.listInfo.pageNum === 1) {
  146. if (r.data.total || r.data.total === 0) {
  147. this.listInfo.total = r.data.total
  148. } else {
  149. this.listInfo.finished = true
  150. }
  151. }
  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. $.ajax({
  189. type: 'post',
  190. url: '/jypay/resourcePack/consumePack',
  191. data: {
  192. productName: '附件下载包',
  193. platform: 'WX',
  194. fileName: item.s_fileName,
  195. id: item.s_id,
  196. title: item.s_title
  197. },
  198. success: function (r) {
  199. if (r && r.m === '' && r.r) {
  200. location.href = r.r.downUrl
  201. setTimeout(function(){
  202. location.reload();
  203. },2000)
  204. }else{
  205. vant.Dialog.alert({
  206. message: '附件下载异常,请联系管理员,谢谢!',
  207. className: 'custom-dialog',
  208. confirmButtonText: '我知道了',
  209. confirmButtonColor: '#2ABDD1',
  210. width: 303,
  211. }).then(() => {})
  212. }
  213. }
  214. })
  215. },
  216. commonDialogFn (message, confirmText, callBack) {
  217. if (this.ptype == "1") {
  218. var curDay = new Date().pattern('yyyy/MM/dd')
  219. localStorage.setItem('show-buyer-dialog', curDay)
  220. } else {
  221. var curDay = new Date().pattern('yyyy/MM/dd')
  222. localStorage.setItem('show-ent-dialog', curDay)
  223. }
  224. this.$dialog.confirm({
  225. message: message,
  226. width: 303,
  227. className: 'pro-log',
  228. messageAlign: 'left',
  229. showCancelButton: 'true',
  230. confirmButtonColor: '#2ABED1',
  231. confirmButtonText: confirmText,
  232. showCancelButton: true
  233. }).then(function () {
  234. callBack && callBack()
  235. }).catch(function () { })
  236. },
  237. usedDialog () {
  238. this.commonDialogFn('超级订阅用户每月享有下载10个附件的权限,也可充值附件下载包増加当月附件下载个数,每月1号上月余额清零重新计算。', '我知道了')
  239. },
  240. helpTiped() {
  241. this.$dialog.alert({
  242. width: 303,
  243. message: '超级订阅用户每月享有下载<span class="on">10</span>个附件的权限,也可充值附件下载包増加当月附件下载个数,每月1号上月余额清零重新计算。',
  244. className: 'pro-log',
  245. messageAlign: 'left',
  246. confirmButtonColor: '#2ABED1',
  247. confirmButtonText: '我知道了',
  248. })
  249. },
  250. confirmed(val) {
  251. this.years = val.getFullYear()
  252. this.months = val.getMonth() + 1
  253. this.listInfo.pageNum = 0
  254. this.list = []
  255. this.listInfo.total = -1
  256. this.listInfo.finished = false
  257. this.listInfo.loading = true
  258. this.onLoad()
  259. this.dValue = this.years + '年' + this.months + '月'
  260. this.pShow = false
  261. },
  262. canceled() {
  263. this.pShow = false
  264. },
  265. ChangeDate (time){
  266. var d = new Date(time)
  267. var Y = d.getFullYear() + '年'
  268. var M = (d.getMonth()+1 < 10 ? '0'+(d.getMonth()+1) : d.getMonth()+1) + '月'
  269. return (Y + M).replace(/^\s+|\s+$/g,"")
  270. },
  271. detailed(ids) {
  272. if(this.ptype==""){
  273. location.href = '/weixin/frontPage/collection/sess/ent_portrait?eId=' + ids + '&svip=1'
  274. }else{
  275. location.href='/big/wx/page/unit_portrayal?entName=' + ids + '&svip=1'
  276. }
  277. },
  278. contractPerson() {
  279. // location.href = '400-108-6670'
  280. location.href = '/big/wx/page/customer'
  281. },
  282. setBook() {
  283. var temp = {
  284. wx: '/swordfish/filePack/createOrder',
  285. app: '/jyapp/filePack/createOrder'
  286. }
  287. var isWeixin = navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1
  288. location.href = temp[isWeixin ? 'wx' : 'app']
  289. }
  290. }
  291. })