index-wx.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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. userPower: {
  96. // 免费用户
  97. isFree: false,
  98. // 超级订阅(超级订阅默认一定有附件下载权益)
  99. vipStatus: 0,
  100. // 大会员
  101. memberStatus: 0,
  102. // 大会员power包含3, 则表示大会员有附件下载权益
  103. power: []
  104. },
  105. // 附件下载相关权益信息
  106. accountInfo: {
  107. // 购买数量(充值)
  108. number1: 0,
  109. // 兑换数量
  110. number2: 0,
  111. // 定期投放数量(超级订阅剩余权益个数)
  112. number3: 0,
  113. // 留资数量(免费用户权益个数)
  114. number4: 0
  115. }
  116. }
  117. },
  118. computed: {
  119. // 大会员是否拥有附件下载权益
  120. hasDownloadPower () {
  121. return this.userPower.power.indexOf(3) > -1
  122. },
  123. // 展示外层边框(权益)(非大会员、免费用户且有免费权益、或者为超级订阅)
  124. showSubscribeBox () {
  125. return (this.userPower.vipStatus > 0 || (this.userPower.isFree && this.accountInfo.number4)) && this.userPower.memberStatus <= 0
  126. }
  127. },
  128. created: function () {
  129. this.getPType("type")
  130. this.years = new Date().getFullYear()
  131. this.months = parseInt(new Date().getMonth() + 1)
  132. this.dValue = this.years + '年' + this.months + '月'
  133. this.curDate = new Date()
  134. this.minDate = new Date(2021, 0)
  135. this.maxTime = new Date(this.years, this.months - 1)
  136. this.getUserPower()
  137. this.subPoint()
  138. this.onLoad()
  139. },
  140. methods: {
  141. // 获取用户权限
  142. getUserPower() {
  143. var _this = this
  144. $.ajax({
  145. url: '/bigmember/use/isAdd',
  146. type: 'POST',
  147. success: function (res) {
  148. console.log(res)
  149. if (res.data) {
  150. var resData = res.data
  151. _this.userPower.isFree = resData.isFree
  152. _this.userPower.vipStatus = resData.vipStatus
  153. _this.userPower.memberStatus = resData.memberStatus
  154. _this.userPower.power = resData.power
  155. }
  156. }
  157. })
  158. },
  159. // 超级订阅-了解详情
  160. knowMore () {
  161. location.href = '/weixin/frontPage/bigmember/free/perfect_info?source=wx_test'
  162. },
  163. // 咨询客服
  164. consultKf () {
  165. console.log('咨询客服')
  166. },
  167. // 去兑换
  168. exchangeHandle() {
  169. location.href = '/jy_mobile/points/my_points'
  170. },
  171. // 兑换明细
  172. viewDetail () {
  173. },
  174. getPType(paraName){
  175. let _this = this
  176. var url = document.location.toString();
  177.    var arrObj = url.split("?");
  178.    if (arrObj.length > 1) {
  179.        var arrPara = arrObj[1].split("&");
  180.        var arr;
  181.        for (var i = 0; i < arrPara.length; i++) {
  182.          arr = arrPara[i].split("=");
  183.          if (arr != null && arr[0] == paraName) {
  184.            _this.ptype = arr[1];
  185.          }
  186.        }
  187.      }
  188. },
  189. usedHised() {
  190. let _this = this
  191. _this.pShow = true
  192. },
  193. subPoint() {
  194. $.ajax({
  195. url: '/jypay/resourcePack/account',
  196. type: 'POST',
  197. contentType: 'application/x-www-form-urlencoded',
  198. data: {
  199. product: 'attachmentDownPack'
  200. },
  201. dataType: 'json'
  202. }).done(res => {
  203. if (res.error_msg === '' && res.data && res.data.data) {
  204. try {
  205. var tempInfo = res.data.data[0]
  206. this.points.total = tempInfo.number
  207. } catch (e) {
  208. console.warn(e)
  209. }
  210. } else {
  211. this.$toast(res.error_msg || '请稍后重试')
  212. }
  213. })
  214. },
  215. onLoad () {
  216. this.ajaxEntList().done(this.doFormatList.bind(this))
  217. },
  218. doFormatList (r) {
  219. if (r && r.error_msg == '' && r.data) {
  220. this.points.usage = r.data.total
  221. this.working = false
  222. this.empty = true
  223. if (this.listInfo.pageNum === 1) {
  224. if (r.data.total || r.data.total === 0) {
  225. this.listInfo.total = r.data.total
  226. } else {
  227. this.listInfo.finished = true
  228. }
  229. }
  230. this.listInfo.pageNum++
  231. if (Array.isArray(r.data.list) && r.data.list.length !== 0) {
  232. this.list = this.list.concat(r.data.list.map(function (v) {
  233. var isDoc = /.doc(x{0,})$/.test(v.s_fileName)
  234. v.icon = isDoc ? 'doc' : 'rar'
  235. return v
  236. }))
  237. } else {
  238. this.listInfo.finished = true
  239. }
  240. this.listInfo.loading = false
  241. if (this.listInfo.total !== -1 && this.listInfo.total <= this.list.length) {
  242. this.listInfo.finished = true
  243. }
  244. }
  245. },
  246. getDatas() {
  247. return {
  248. queryTime: new Date(this.years, this.months-1, 1).pattern('yyyy-MM'),
  249. platform: navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1 ? 'WX' : 'APP',
  250. productName: '附件下载包',
  251. pageSize: this.listInfo.pageSize,
  252. pageNum: this.listInfo.pageNum
  253. }
  254. },
  255. ajaxEntList() {
  256. this.working = true
  257. this.empty = false
  258. return $.ajax({
  259. url: '/jypay/resourcePack/recordList',
  260. type: 'POST',
  261. contentType: 'application/x-www-form-urlencoded',
  262. data: this.getDatas(),
  263. dataType: 'json'
  264. })
  265. },
  266. downFile (item) {
  267. $.ajax({
  268. type: 'post',
  269. url: '/jypay/resourcePack/consumePack',
  270. data: {
  271. productName: '附件下载包',
  272. platform: 'WX',
  273. fileName: item.s_fileName,
  274. id: item.s_id,
  275. title: item.s_title
  276. },
  277. success: function (r) {
  278. if (r && r.m === '' && r.r) {
  279. openFileDown(r.r.downUrl)
  280. }else{
  281. vant.Dialog.alert({
  282. message: '附件下载异常,请联系管理员,谢谢!',
  283. className: 'custom-dialog',
  284. confirmButtonText: '我知道了',
  285. confirmButtonColor: '#2ABDD1',
  286. width: 303,
  287. }).then(() => {})
  288. }
  289. }
  290. })
  291. },
  292. commonDialogFn (message, confirmText, callBack) {
  293. if (this.ptype == "1") {
  294. var curDay = new Date().pattern('yyyy/MM/dd')
  295. localStorage.setItem('show-buyer-dialog', curDay)
  296. } else {
  297. var curDay = new Date().pattern('yyyy/MM/dd')
  298. localStorage.setItem('show-ent-dialog', curDay)
  299. }
  300. this.$dialog.confirm({
  301. message: message,
  302. width: 303,
  303. className: 'pro-log',
  304. messageAlign: 'left',
  305. showCancelButton: 'true',
  306. confirmButtonColor: '#2ABED1',
  307. confirmButtonText: confirmText,
  308. showCancelButton: true
  309. }).then(function () {
  310. callBack && callBack()
  311. }).catch(function () { })
  312. },
  313. usedDialog () {
  314. this.commonDialogFn('超级订阅用户每月享有下载10个附件的权限,也可充值附件下载包増加当月附件下载个数,每月1号上月余额清零重新计算。', '我知道了')
  315. },
  316. helpTiped() {
  317. this.$dialog.alert({
  318. width: 303,
  319. message: '超级订阅用户每月享有下载<span class="on">10</span>个附件的权限,也可充值附件下载包増加当月附件下载个数,每月1号上月余额清零重新计算。',
  320. className: 'pro-log',
  321. messageAlign: 'left',
  322. confirmButtonColor: '#2ABED1',
  323. confirmButtonText: '我知道了',
  324. })
  325. },
  326. confirmed(val) {
  327. this.years = val.getFullYear()
  328. this.months = val.getMonth() + 1
  329. this.listInfo.pageNum = 1
  330. this.list = []
  331. this.listInfo.total = -1
  332. this.listInfo.finished = false
  333. this.listInfo.loading = true
  334. this.onLoad()
  335. this.dValue = this.years + '年' + this.months + '月'
  336. this.pShow = false
  337. },
  338. canceled() {
  339. this.pShow = false
  340. },
  341. ChangeDate (time){
  342. var d = new Date(time)
  343. var Y = d.getFullYear() + '年'
  344. var M = (d.getMonth()+1 < 10 ? '0'+(d.getMonth()+1) : d.getMonth()+1) + '月'
  345. return (Y + M).replace(/^\s+|\s+$/g,"")
  346. },
  347. detailed(ids) {
  348. if(this.ptype==""){
  349. location.href = '/weixin/frontPage/collection/sess/ent_portrait?eId=' + ids + '&svip=1'
  350. }else{
  351. location.href='/big/wx/page/unit_portrayal?entName=' + ids + '&svip=1'
  352. }
  353. },
  354. contractPerson() {
  355. // location.href = '400-108-6670'
  356. location.href = '/big/wx/page/customer'
  357. },
  358. // 去充值
  359. setBook() {
  360. var temp = {
  361. wx: '/jy_mobile/common/order/create/filepack?type=0',
  362. app: '/jy_mobile/common/order/create/filepack?type=0'
  363. }
  364. var isWeixin = navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1
  365. location.href = temp[isWeixin ? 'wx' : 'app']
  366. }
  367. }
  368. })