index-wx.js 12 KB

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