index-wx.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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. function mySysIsIos() {
  33. //ios终端
  34. var flag1 = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
  35. var flag2 = !!navigator.userAgent.match(/\(M[^;]+; Intel Mac OS X/);
  36. return flag1 || flag2
  37. }
  38. function openFileDown (url) {
  39. try {
  40. if (!mySysIsIos() && /\.(jpeg|jpg|png)$/.test(url)) {
  41. wx.previewImage({
  42. current: url, // 当前显示图片的http链接
  43. urls: [url] // 需要预览的图片http链接列表
  44. })
  45. } else {
  46. location.href = url
  47. }
  48. } catch (e) {
  49. console.log(e)
  50. if (vm && typeof vm.$toast === 'function') {
  51. vm.$toast("附件微信端打开失败,请联系客服!");
  52. }
  53. }
  54. }
  55. var formatter11 = (type, val) => {
  56. if (type === 'year') {
  57. return `${val}年`;
  58. }
  59. if (type === 'month') {
  60. return `${val}月`;
  61. }
  62. return val;
  63. }
  64. var vm = new Vue({
  65. el: '#proRecord',
  66. delimiters: ['{', '}'],
  67. data: function () {
  68. return {
  69. dValue: '',
  70. pShow: false,
  71. working: false,
  72. empty: false,
  73. curDate: '',
  74. minDate: '',
  75. maxTime: '',
  76. points: {
  77. total: 0,
  78. usage: 0
  79. },
  80. years: '',
  81. months: '',
  82. contracted: false,
  83. listInfo: {
  84. value: '',
  85. pageNum: 1,
  86. pageSize: 10,
  87. total: -1,
  88. loading: true,
  89. finished: false
  90. },
  91. statusEnum: ['存续', '吊销', '停业', '撤销'],
  92. statusColors: ['#2CB7CA', '#F5AF5C', '#58A1E7', '#51CEA2'],
  93. list: [],
  94. ptype:""
  95. }
  96. },
  97. created: function () {
  98. this.getPType("type")
  99. this.years = new Date().getFullYear()
  100. this.months = parseInt(new Date().getMonth() + 1)
  101. this.dValue = this.years + '年' + this.months + '月'
  102. this.curDate = new Date()
  103. this.minDate = new Date(2021, 0)
  104. this.maxTime = new Date(this.years, this.months - 1)
  105. this.subPoint()
  106. this.onLoad()
  107. this.initHtml()
  108. },
  109. methods: {
  110. initHtml(){
  111. if(this.ptype=="1"){
  112. document.title = '采购单位画像记录'
  113. typeof setHeaderTitle === 'function' ? setHeaderTitle(document.title) : null
  114. $(".btns span").text("当月采购单位画像剩余数")
  115. $(".emptytext").text("暂无采购单位画像记录")
  116. }
  117. },
  118. getPType(paraName){
  119. let _this = this
  120. var url = document.location.toString();
  121.    var arrObj = url.split("?");
  122.    if (arrObj.length > 1) {
  123.        var arrPara = arrObj[1].split("&");
  124.        var arr;
  125.        for (var i = 0; i < arrPara.length; i++) {
  126.          arr = arrPara[i].split("=");
  127.          if (arr != null && arr[0] == paraName) {
  128.            _this.ptype = arr[1];
  129.          }
  130.        }
  131.      }
  132. },
  133. usedHised() {
  134. let _this = this
  135. _this.pShow = true
  136. },
  137. subPoint() {
  138. $.ajax({
  139. url: '/jypay/resourcePack/account',
  140. type: 'POST',
  141. contentType: 'application/x-www-form-urlencoded',
  142. data: {
  143. product: 'attachmentDownPack'
  144. },
  145. dataType: 'json'
  146. }).done(res => {
  147. if (res.error_msg === '' && res.data && res.data.data) {
  148. try {
  149. var tempInfo = res.data.data[0]
  150. this.points.total = tempInfo.number
  151. } catch (e) {
  152. console.warn(e)
  153. }
  154. } else {
  155. this.$toast(res.error_msg || '请稍后重试')
  156. }
  157. })
  158. },
  159. onLoad () {
  160. this.ajaxEntList().done(this.doFormatList.bind(this))
  161. },
  162. doFormatList (r) {
  163. if (r && r.error_msg == '' && r.data) {
  164. this.points.usage = r.data.total
  165. this.working = false
  166. this.empty = true
  167. if (this.listInfo.pageNum === 1) {
  168. if (r.data.total || r.data.total === 0) {
  169. this.listInfo.total = r.data.total
  170. } else {
  171. this.listInfo.finished = true
  172. }
  173. }
  174. this.listInfo.pageNum++
  175. if (Array.isArray(r.data.list) && r.data.list.length !== 0) {
  176. this.list = this.list.concat(r.data.list.map(function (v) {
  177. var isDoc = /.doc(x{0,})$/.test(v.s_fileName)
  178. v.icon = isDoc ? 'doc' : 'rar'
  179. return v
  180. }))
  181. } else {
  182. this.listInfo.finished = true
  183. }
  184. this.listInfo.loading = false
  185. if (this.listInfo.total !== -1 && this.listInfo.total <= this.list.length) {
  186. this.listInfo.finished = true
  187. }
  188. }
  189. },
  190. getDatas() {
  191. return {
  192. queryTime: new Date(this.years, this.months-1, 1).pattern('yyyy-MM'),
  193. platform: navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1 ? 'WX' : 'APP',
  194. productName: '附件下载包',
  195. pageSize: this.listInfo.pageSize,
  196. pageNum: this.listInfo.pageNum
  197. }
  198. },
  199. ajaxEntList() {
  200. this.working = true
  201. this.empty = false
  202. return $.ajax({
  203. url: '/jypay/resourcePack/recordList',
  204. type: 'POST',
  205. contentType: 'application/x-www-form-urlencoded',
  206. data: this.getDatas(),
  207. dataType: 'json'
  208. })
  209. },
  210. downFile (item) {
  211. $.ajax({
  212. type: 'post',
  213. url: '/jypay/resourcePack/consumePack',
  214. data: {
  215. productName: '附件下载包',
  216. platform: 'WX',
  217. fileName: item.s_fileName,
  218. id: item.s_id,
  219. title: item.s_title
  220. },
  221. success: function (r) {
  222. if (r && r.m === '' && r.r) {
  223. openFileDown(r.r.downUrl)
  224. }else{
  225. vant.Dialog.alert({
  226. message: '附件下载异常,请联系管理员,谢谢!',
  227. className: 'custom-dialog',
  228. confirmButtonText: '我知道了',
  229. confirmButtonColor: '#2ABDD1',
  230. width: 303,
  231. }).then(() => {})
  232. }
  233. }
  234. })
  235. },
  236. commonDialogFn (message, confirmText, callBack) {
  237. if (this.ptype == "1") {
  238. var curDay = new Date().pattern('yyyy/MM/dd')
  239. localStorage.setItem('show-buyer-dialog', curDay)
  240. } else {
  241. var curDay = new Date().pattern('yyyy/MM/dd')
  242. localStorage.setItem('show-ent-dialog', curDay)
  243. }
  244. this.$dialog.confirm({
  245. message: message,
  246. width: 303,
  247. className: 'pro-log',
  248. messageAlign: 'left',
  249. showCancelButton: 'true',
  250. confirmButtonColor: '#2ABED1',
  251. confirmButtonText: confirmText,
  252. showCancelButton: true
  253. }).then(function () {
  254. callBack && callBack()
  255. }).catch(function () { })
  256. },
  257. usedDialog () {
  258. this.commonDialogFn('超级订阅用户每月享有下载10个附件的权限,也可充值附件下载包増加当月附件下载个数,每月1号上月余额清零重新计算。', '我知道了')
  259. },
  260. helpTiped() {
  261. this.$dialog.alert({
  262. width: 303,
  263. message: '超级订阅用户每月享有下载<span class="on">10</span>个附件的权限,也可充值附件下载包増加当月附件下载个数,每月1号上月余额清零重新计算。',
  264. className: 'pro-log',
  265. messageAlign: 'left',
  266. confirmButtonColor: '#2ABED1',
  267. confirmButtonText: '我知道了',
  268. })
  269. },
  270. confirmed(val) {
  271. this.years = val.getFullYear()
  272. this.months = val.getMonth() + 1
  273. this.listInfo.pageNum = 1
  274. this.list = []
  275. this.listInfo.total = -1
  276. this.listInfo.finished = false
  277. this.listInfo.loading = true
  278. this.onLoad()
  279. this.dValue = this.years + '年' + this.months + '月'
  280. this.pShow = false
  281. },
  282. canceled() {
  283. this.pShow = false
  284. },
  285. ChangeDate (time){
  286. var d = new Date(time)
  287. var Y = d.getFullYear() + '年'
  288. var M = (d.getMonth()+1 < 10 ? '0'+(d.getMonth()+1) : d.getMonth()+1) + '月'
  289. return (Y + M).replace(/^\s+|\s+$/g,"")
  290. },
  291. detailed(ids) {
  292. if(this.ptype==""){
  293. location.href = '/weixin/frontPage/collection/sess/ent_portrait?eId=' + ids + '&svip=1'
  294. }else{
  295. location.href='/big/wx/page/unit_portrayal?entName=' + ids + '&svip=1'
  296. }
  297. },
  298. contractPerson() {
  299. // location.href = '400-108-6670'
  300. location.href = '/big/wx/page/customer'
  301. },
  302. setBook() {
  303. var temp = {
  304. wx: '/swordfish/filePack/createOrder',
  305. app: '/jyapp/filePack/createOrder'
  306. }
  307. var isWeixin = navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1
  308. location.href = temp[isWeixin ? 'wx' : 'app']
  309. }
  310. }
  311. })