vip-subscribe-set-template.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951
  1. var subScribeTemplate = `
  2. <div class="sub-scribe">
  3. <ul style="border-radius:.16rem;overflow:hidden">
  4. <li class="body-item area">
  5. <a class="item-container" :href="linkobj.area" @click="userNumOver">
  6. <div class="item">
  7. <span class="item-l">
  8. <span class="leading jy-icon-loaction"></span>
  9. <span class="item-label">区域</span>
  10. </span>
  11. <span class="item-r">
  12. <span class="keywords-text ellipsis" id="menuArea">{{info.area}}</span>
  13. <span class="iconfont icon-arrow"></span>
  14. </span>
  15. </div>
  16. </a>
  17. <div class="amendmentNum" v-show="vSwitch === 'f'">
  18. 当<span v-show="userAreaAllNum === 0">年</span><span v-show="userAreaAllNum > 0">月</span>剩余可修改次数:<span class="numColor" v-show="userAreaNum != -1">{{userAreaNum}}&nbsp;</span><span v-show="userAreaNum != -1">次</span><span v-show="userAreaNum === -1">无限制</span>
  19. <i class="iconfont icon-bangzhu" @click="amendmentNumNotice"></i>
  20. </div>
  21. </li>
  22. <li class="body-item industry">
  23. <a class="item-container" :href="linkobj.industry" @click="userNoIndustry">
  24. <div class="item">
  25. <span class="item-l">
  26. <span class="leading jy-icon-industry"></span>
  27. <span class="item-label">采购单位类型</span>
  28. <span class="openVip" v-show="vSwitch === 'f'">开通</span>
  29. </span>
  30. <span class="item-r">
  31. <span class="keywords-text ellipsis">{{info.industry}}</span>
  32. <span class="iconfont icon-arrow"></span>
  33. </span>
  34. </div>
  35. </a>
  36. </li>
  37. <li class="body-item keywords">
  38. <a class="item-container" :href="linkobj.keyword">
  39. <div class="item">
  40. <span class="item-l">
  41. <span class="leading jy-icon-keywords"></span>
  42. <span class="item-label">关键词</span>
  43. </span>
  44. <span class="item-r">
  45. <span class="keywords-text ellipsis">请设置关键词</span>
  46. <span class="iconfont icon-arrow"></span>
  47. </span>
  48. </div>
  49. </a>
  50. </li>
  51. <li class="body-item match-way" @click="matchWay">
  52. <a class="item-container" href="javascript:;">
  53. <div class="item">
  54. <span class="item-l">
  55. <span class="leading jy-icon-matchkeywords"></span>
  56. <span class="item-label" style="white-space: nowrap;">关键词匹配方式</span>
  57. </span>
  58. <span class="item-r">
  59. <span class="keywords-text ellipsis match-way-value"></span>
  60. <span class="iconfont icon-arrow"></span>
  61. </span>
  62. </div>
  63. </a>
  64. </li>
  65. <li class="body-item info-type">
  66. <a class="item-container" href="javascript:;" :thisHref="linkobj.infotype" @click="openInfoType">
  67. <div class="item">
  68. <span class="item-l">
  69. <span class="leading jy-icon-info-type"></span>
  70. <span class="item-label">信息类型</span>
  71. </span>
  72. <span class="item-r">
  73. <span class="info-type-text ellipsis">{{info.infoType}}</span>
  74. <span class="iconfont icon-arrow"></span>
  75. </span>
  76. </div>
  77. </a>
  78. </li>
  79. <li class="body-item project-match">
  80. <a class="item-container" href="javascript:;">
  81. <div class="item">
  82. <span class="item-l">
  83. <span class="leading jy-icon-project-match"></span>
  84. <span class="item-label matching">
  85. <span class="label-text">项目匹配</span>
  86. <i class="iconfont icon-bangzhu" @click="projectNotice"></i>
  87. <span class="openVip" v-show="vSwitch === 'f'">开通</span>
  88. </span>
  89. </span>
  90. <span class="item-r media_switch">
  91. <div class="weui-cell__ft">
  92. <button class="jy-switch switch" :class="{checked:checkedflag}" @click="switchs"></button>
  93. </div>
  94. </span>
  95. </div>
  96. </a>
  97. </li>
  98. <li class="body-item resultpreview">
  99. <a class="item-container" :href="linkobj.resultview" id="pushResultPreview">
  100. <div class="item">
  101. <span class="item-l">
  102. <span class="leading_ jy-icon-resultpreview-match"></span>
  103. <span class="item-label-other">
  104. <span class="label-text">推送结果预览<span class="threeInfo">{{resultTime}}</span></span>
  105. <span v-if="littleShow" class="info-little">当前匹配信息过少,请适当修改订阅条件</span>
  106. </span>
  107. </span>
  108. <span class="item-r media_switch">
  109. <span class="info-type-text ellipsis"></span>
  110. <span class="iconfont icon-arrow"></span>
  111. </span>
  112. </div>
  113. </a>
  114. </li>
  115. <li class="body-item push-set" v-if="pushsetShow">
  116. <a class="item-container" :href="linkobj.pushsetting">
  117. <div class="item">
  118. <span class="item-l">
  119. <span class="leading_ jy-icon-push-set"></span>
  120. <span class="item-label-other">
  121. <span class="label-text">推送设置</span>
  122. </span>
  123. </span>
  124. <span class="item-r media_switch">
  125. <span class="info-type-text ellipsis"></span>
  126. <span class="iconfont icon-arrow"></span>
  127. </span>
  128. </div>
  129. </a>
  130. </li>
  131. </ul>
  132. <!-- 匹配方式 -->
  133. <div class="match-keywords-actionsheet">
  134. <div class="weui-mask" id="iosMask" @click="iosMask" style="opacity: 1;display: none;"></div>
  135. <div class="weui-actionsheet" id="iosActionsheet">
  136. <div class="weui-actionsheet__title" style="display:none">
  137. <p class="weui-actionsheet__title-text">关键词匹配方式</p>
  138. <i class="weui-icon-clear" id="iosActionsheetCancel" @click="iosActionsheetCancel"></i>
  139. </div>
  140. <div class="weui-actionsheet__menu">
  141. <div class="weui-actionsheet__cell titleMacth" :class="{active:active==1}" @click="actionSheet('按标题匹配', 1)">
  142. <p class="cell_title">按标题匹配</p>
  143. </div>
  144. <div class="weui-actionsheet__cell allMacth" :class="{active:active==2}" @click="actionSheet('按全文匹配', 2)">
  145. <p class="cell_title">按全文匹配<span class="openVip-keywords" v-show="vSwitch === 'f'">开通</span></p>
  146. <p class="small-title">会产生无效信息,请根据需要选择</p>
  147. </div>
  148. </div>
  149. <!-- <div class="weui-actionsheet__action">
  150. <div class="weui-actionsheet__cell" id="iosActionsheetCancel" @click="iosActionsheetCancel">取消</div>
  151. </div> -->
  152. </div>
  153. </div>
  154. <!-- 信息类型 -->
  155. <div class="menu-infoType-wrap" v-show="infoTypeMenu">
  156. <div class="infoType-content">
  157. <div class="infoType-title">
  158. <div class="menu-title">选择信息类型</div>
  159. <div class="close-btn" @click="closeInfoType"></div>
  160. </div>
  161. <div class="menu-content">
  162. <div class="infoType-btn" @click="changeBtnType('全部')" :class="infoTypeData.indexOf('全部') !== -1 ? 'infoTypeActive' : ''">全部</div>
  163. <div v-for="(item, index) in infoTypeList" :key="index" class="infoType-item">
  164. <div class="infoType-btn" @click="changeBtnType(item.value)" :class="infoTypeData.indexOf(item.value) !== -1 ? 'infoTypeActive' : ''">{{item.title}}</div>
  165. <div class="infoType-msg">{{item.desc}}</div>
  166. </div>
  167. </div>
  168. <div class="bottom-btn-wrap">
  169. <div class="bottom-btn cancel" @click="reset" :class="isChange?'thisChange':''">重置</div>
  170. <div class="bottom-btn enter" @click="confirm">确认</div>
  171. </div>
  172. </div>
  173. </div>
  174. <!-- 免费用户未设置地区弹窗 -->
  175. <div class="oldUserTips" v-show="noAreaFreeType">
  176. <div class="updateTips-wrap">
  177. <div class="close-btn closeNoAreaIcon" @click="closeNoAreaTips"></div>
  178. <div class="updateTips-text" style="text-align:center">您的订阅区域尚未设置,为了不影响您的使用,还请您尽快完善哦</div>
  179. <div class="updateTips-btnWrap">
  180. <div class="updateTips-btn levelUp" id="gotoPay" @click="gotoArea">去完善</div>
  181. </div>
  182. </div>
  183. </div>
  184. </div>
  185. `
  186. var subComponent = {
  187. name: 'vip-subscribe-set-template',
  188. template: subScribeTemplate,
  189. props: {
  190. 'linkobj': {
  191. type: Object,
  192. default: function() {
  193. return {}
  194. }
  195. },
  196. "initdata": {
  197. type: Object,
  198. default: function() {
  199. return {}
  200. }
  201. },
  202. "type": {
  203. type: String,
  204. default: ''
  205. },
  206. vSwitch: {
  207. type: String,
  208. default: 'f'
  209. }
  210. },
  211. data: function() {
  212. return {
  213. info: {
  214. area: '请选择区域',
  215. industry: '请选择采购单位行业',
  216. infoType: '请选择信息类型'
  217. },
  218. // 信息类型数据
  219. infoTypeList: [
  220. {
  221. title: '拟建项目',
  222. value: '拟建',
  223. desc: '采集建筑工程、信息化等类项目在招标前由发改委等部门审批的信息,并向用户提供“拟建项目预告”功能。'
  224. },
  225. {
  226. title: '招标预告',
  227. value: '预告',
  228. desc: '在正式招标之前发布的公告信息,主要有采购计划、项目预告、采购预告、招标文件预公示、招标方式公示等信息'
  229. },
  230. {
  231. title: '招标公告',
  232. value: '招标',
  233. desc: '包括公开招标、邀请招标、询价采购、竞争性谈判、单一来源、公开竞价、电子反拍、变更公告等公告信息'
  234. },
  235. {
  236. title: '招标结果',
  237. value: '结果',
  238. desc: '包括中标公示、成交公告、废标公告、流标公告等'
  239. },
  240. {
  241. title: '其他信息',
  242. value: '其它',
  243. desc: '包括合同公告、验收公告、违规处理等'
  244. },
  245. ],
  246. // 匹配方式
  247. active: 1,
  248. pushsetShow: true,
  249. resultTime: '(近3个月内共条信息)',
  250. checkedflag: false,
  251. littleShow: false,
  252. accStatus: 0,
  253. userAreaNum: 1, // 用户修改地区剩余次数
  254. userType: false, // 用户是否为付费用户
  255. userAreaAllNum: 1, // 用户可修改地区总次数
  256. infoTypeMenu: false, // 信息类型弹窗状态
  257. infoTypeData: ['全部'], // 信息类型选择列表
  258. isChange: false, // 信息类型是否做过更改
  259. conf: {}, // 信息类型数据
  260. noAreaFreeType: false, // 免费用户未设置地区时显示弹窗
  261. backTipShowCount: 0, // 离开页面展示弹窗次数
  262. thisvSwitch: 'f',
  263. UserSubscribe: {}, // 免费用户数据
  264. }
  265. },
  266. mounted () {
  267. let switchpro = sessionStorage.getItem('switch-product')
  268. if(switchpro) {
  269. if(switchpro == 'bigmember') {
  270. this.accStatus = 2
  271. } else if(switchpro == 'supervip') {
  272. this.accStatus = 1
  273. }
  274. }
  275. this.getData()
  276. this.$emit('mounted')
  277. // this.addBackTip()
  278. },
  279. watch: {
  280. initdata: function(newVal, oldVal) {
  281. if(newVal) {
  282. this.getResultView()
  283. this.getData()
  284. if (this.vSwitch !== 'f') {
  285. this.setIosData()
  286. }
  287. }
  288. },
  289. vSwitch: function (val) {
  290. sessionStorage.setItem('infoTypeVswitch', val)
  291. if (val === 'f') {
  292. this.getUserSubscribe()
  293. }
  294. }
  295. },
  296. methods: {
  297. getData: function() {
  298. this.setArea()
  299. this.setIndustry()
  300. this.setKeyword()
  301. this.getActionDefault()
  302. this.getIndustryType()
  303. this.getProjectMatch()
  304. this.iosBackRefresh()
  305. },
  306. // 判断用户权限
  307. // 设置区域
  308. setArea: function() {
  309. let _this = this
  310. if(this.initdata.area) {
  311. if(_this.accStatus == 2) {
  312. sessionStorage.setItem('big-setArea', JSON.stringify(this.initdata.area))
  313. }
  314. if(JSON.stringify(this.initdata.area) === '{}') {
  315. this.info.area = '全国'
  316. } else {
  317. let proStr = ''
  318. Object.keys(this.initdata.area).forEach(function(item,index) {
  319. if(_this.initdata.area[item].length == 0) {
  320. proStr += item + '、'
  321. } else {
  322. let cityStr = ''
  323. _this.initdata.area[item].forEach(function(data, i) {
  324. cityStr += data + '、'
  325. })
  326. if (cityStr.length > 0) {
  327. cityStr = cityStr.substr(0,cityStr.length - 1);
  328. }
  329. proStr += item+ '(' + cityStr + ')' + '、'
  330. }
  331. })
  332. if(proStr[proStr.length - 1] == '、') {
  333. proStr = proStr.substr(0,proStr.length - 1);
  334. }
  335. _this.info.area = '已选:' + proStr
  336. }
  337. } else {
  338. this.info.area = '请选择区域'
  339. }
  340. var areaNull = sessionStorage.getItem('areaNull')
  341. if(areaNull) {
  342. this.initdata.area = {}
  343. this.info.area = '请选择区域'
  344. }
  345. },
  346. // 设置行业
  347. setIndustry: function() {
  348. let _this = this
  349. if(this.initdata.industry) {
  350. // this.initdata.industry = JSON.parse(this.initdata.industry)
  351. if(this.accStatus == 2) {
  352. sessionStorage.setItem('big-setCate', JSON.stringify(this.initdata.industry))
  353. }
  354. if(this.initdata.industry.length == 0) {
  355. this.info.industry = '已选:全部'
  356. } else {
  357. this.info.industry = '已选:' + this.initdata.industry.join('、')
  358. }
  359. } else {
  360. this.info.industry = '请选择采购单位类型'
  361. }
  362. var industryNull = sessionStorage.getItem('industryNull')
  363. if(industryNull) {
  364. this.initdata.industry = []
  365. this.info.industry = '请选择采购单位类型'
  366. }
  367. },
  368. // 设置关键词
  369. setKeyword: function() {
  370. let state = this.initdata
  371. if(state) {
  372. if(state.items) {
  373. if (state.items.length === 0) {
  374. $('.body-item.keywords .keywords-text').text('请设置关键词')
  375. } else {
  376. var arr = []
  377. state.items.forEach(function (item, index) {
  378. item.a_key.forEach(function(data,i) {
  379. arr.push(data.key[0])
  380. })
  381. })
  382. if(arr.length == 0) {
  383. $('.body-item.keywords .keywords-text').text('请设置关键词')
  384. } else {
  385. $('.body-item.keywords .keywords-text').text('已设置' +arr.length+ '组关键词')
  386. }
  387. // $('.body-item.keywords .keywords-text').text(arr.join('、'))
  388. }
  389. }
  390. } else {
  391. $('.body-item.keywords .keywords-text').text('请设置关键词')
  392. }
  393. },
  394. // ios关键词重新赋值
  395. setIosData: function () {
  396. let _this = this
  397. let u = navigator.userAgent;
  398. let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
  399. let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
  400. if (isAndroid == true) {
  401. console.log("安卓手机")
  402. } else {
  403. $.ajax({
  404. type: 'POST',
  405. url: '/subscribepay/vipsubscribe/getSubBuyMsg?t=' + Date.now(),
  406. success:function(res) {
  407. if(res.success) {
  408. _this.setKeyword()
  409. }
  410. }
  411. })
  412. }
  413. },
  414. // 信息类型
  415. getIndustryType: function() {
  416. if(this.initdata) {
  417. if(this.initdata.infotype) {
  418. if(this.accStatus == 2) {
  419. sessionStorage.setItem('big-setInfoType', JSON.stringify(this.initdata.infotype))
  420. }
  421. if (this.initdata.infotype.length === 0) {
  422. this.info.infoType = '全部类型'
  423. } else {
  424. this.info.infoType = this.initdata.infotype.join('、')
  425. }
  426. } else {
  427. this.info.infoType = '全部类型'
  428. }
  429. }
  430. },
  431. // 项目匹配
  432. getProjectMatch: function() {
  433. if (this.initdata.projectmatch == 1) {
  434. $('.switch').addClass('checked')
  435. this.checkedflag = true
  436. } else {
  437. $('.switch').removeClass('checked')
  438. this.checkedflag = false
  439. }
  440. },
  441. switchs: function() {
  442. // 用户未购买项目匹配功能
  443. if (this.vSwitch === 'f') {
  444. $('.switch').removeClass('checked')
  445. this.checkedflag = false
  446. if (location.href.indexOf('front') !== -1) {
  447. var href = '/front/vipsubscribe/introducePage'
  448. } else {
  449. var href = '/jyapp/vipsubscribe/introducePage'
  450. }
  451. location.href = href
  452. } else {
  453. // switch点击切换
  454. if (!this.checkedflag) {
  455. this.checkedflag = !this.checkedflag;
  456. this.setprojectmatch('projectMatch', 1);
  457. } else {
  458. this.checkedflag = !this.checkedflag;
  459. this.setprojectmatch('projectMatch', 0);
  460. weui.toast('项目匹配已关闭', {
  461. duration: 1500,
  462. className: 'jy-toast',
  463. callback: function () {
  464. console.log('close')
  465. }
  466. });
  467. }
  468. }
  469. },
  470. setprojectmatch(pagetype,index) {
  471. let _this = this
  472. let vswitch ='v'
  473. if(_this.accStatus == 2) {
  474. vswitch = 'm'
  475. } else if(_this.accStatus == 1) {
  476. vswitch = 'v'
  477. }
  478. $.post("/publicapply/subscribe/setUserInfo", {pageType: pagetype, pmindex: index, vSwitch:vswitch}, function (r) {
  479. if (r.flag) {
  480. if(index == 0 || index == 1) {
  481. var subVipState = sessionStorage.getItem('sub_vip_state');
  482. var reqData = JSON.parse(subVipState);
  483. reqData.projectmatch = index;
  484. sessionStorage.setItem('sub_vip_state', JSON.stringify(reqData))
  485. }
  486. }
  487. })
  488. },
  489. // 关键词匹配方式
  490. getActionDefault: function() {
  491. let _this = this
  492. let defaultTitle = ''
  493. if(this.initdata.matchway == 1 || !this.initdata.matchway) {
  494. $('.match-way-value').text('按标题匹配')
  495. this.active = 1
  496. } else if(this.initdata.matchway == 2) {
  497. $('.match-way-value').text('按全文匹配')
  498. this.active = 2
  499. }
  500. // $('#iosActionsheet .weui-actionsheet__cell').each(function (index, item) {
  501. // var t = $(item).children().text().trim();
  502. // if (t == defaultTitle) {
  503. // $(this).addClass('active')
  504. // }
  505. // })
  506. },
  507. hideActionSheet: function() {
  508. var update_renew = $('.update_renew')
  509. var $iosMask = $('#iosMask');
  510. var $iosActionsheet = $('#iosActionsheet');
  511. $iosActionsheet.removeClass('weui-actionsheet_toggle');
  512. $('.match-keywords-actionsheet').hide()
  513. $iosMask.fadeOut(200);
  514. if(update_renew) {
  515. if(this.accStatus == 2) {
  516. update_renew.hide()
  517. } else {
  518. update_renew.show()
  519. }
  520. }
  521. this.$emit('footershow', 'false')
  522. },
  523. iosMask: function() {
  524. this.hideActionSheet()
  525. },
  526. iosActionsheetCancel: function() {
  527. this.hideActionSheet()
  528. },
  529. matchWay: function() {
  530. var update_renew = $('.update_renew')
  531. var $iosMask = $('#iosMask');
  532. var $iosActionsheet = $('#iosActionsheet');
  533. $iosActionsheet.addClass('weui-actionsheet_toggle');
  534. $('.match-keywords-actionsheet').show()
  535. $iosMask.fadeIn(200);
  536. if(update_renew) {
  537. update_renew.hide()
  538. }
  539. this.$emit('footershow', 'true')
  540. },
  541. actionSheet: function(title, index) {
  542. let _this = this
  543. let vswitch = 'v'
  544. var href = ''
  545. if (index === 2 && this.vSwitch === 'f') {
  546. if (location.href.indexOf('front') !== -1) {
  547. href = '/front/vipsubscribe/introducePage'
  548. } else {
  549. href = '/jyapp/vipsubscribe/introducePage'
  550. }
  551. location.href = href
  552. } else {
  553. if(_this.accStatus == 2) {
  554. vswitch = 'm'
  555. } else if(_this.accStatus == 1) {
  556. vswitch = 'v'
  557. }
  558. var update_renew = $('.update_renew')
  559. $.post("/publicapply/subscribe/setUserInfo", {pageType: "saveSeniorset", matchtype: index, vSwitch: vswitch}, function (r) {
  560. if (r.flag) {
  561. var subVipState = sessionStorage.getItem('sub_vip_state');
  562. var reqData = JSON.parse(subVipState);
  563. _this.active = index
  564. var $iosMask = $('#iosMask');
  565. var $iosActionsheet = $('#iosActionsheet');
  566. $iosActionsheet.removeClass('weui-actionsheet_toggle');
  567. $('.match-keywords-actionsheet').hide()
  568. $iosMask.fadeOut(200);
  569. if(update_renew) {
  570. if(_this.accStatus == 2) {
  571. update_renew.hide()
  572. } else {
  573. update_renew.show()
  574. }
  575. }
  576. _this.$emit('footershow', 'false')
  577. $('.match-way-value').text(title)
  578. if(index == 1) {
  579. $('.titleMacth').addClass('active')
  580. $('.allMacth').removeClass('active')
  581. } else {
  582. $('.titleMacth').removeClass('active')
  583. $('.allMacth').addClass('active')
  584. }
  585. reqData.matchway = index;
  586. sessionStorage.setItem('sub_vip_state', JSON.stringify(reqData))
  587. } else {
  588. weui.toast('关键词匹配方式修改失败', {
  589. duration: 1500,
  590. className: 'jy-toast',
  591. callback: function () {
  592. console.log('close')
  593. }
  594. });
  595. }
  596. })
  597. // var nowMode = title
  598. // var ModeArr = ['按标题匹配', '按全文匹配']
  599. // var nowIndex = ModeArr.indexOf(nowMode)
  600. // if (nowIndex !== -1) {
  601. // this.setMatchway(ModeArr.indexOf(nowMode) + 1)
  602. // } else {
  603. // // $(this).removeClass('active').siblings().addClass('active');
  604. // $('.match-way-value').text($(this).siblings().children('.cell_title').text())
  605. // weui.toast('关键词匹配方式修改失败', {
  606. // duration: 1500,
  607. // className: 'jy-toast',
  608. // callback: function () {
  609. // console.log('close')
  610. // }
  611. // });
  612. // }
  613. this.getResultView()
  614. }
  615. },
  616. // 项目匹配问号点击事件
  617. projectNotice: function () {
  618. var str = '开启后,系统将根据你订阅的关键词自动匹配出相关联的项目,并将相关联项目的后续动态在超级订阅内一并推送。'
  619. weui.alert(str, {
  620. title: '项目匹配',
  621. className: 'jy-alert',
  622. buttons: [{
  623. label: '我知道了'
  624. }]
  625. });
  626. },
  627. // 用户未购买修改采购单位类型功能
  628. userNoIndustry: function () {
  629. if (this.vSwitch !== 'f') {
  630. var href = '/jyapp/vipsubscribe/toChangeIndustry?header=save'
  631. } else {
  632. if (location.href.indexOf('front') !== -1) {
  633. var href = '/front/vipsubscribe/introducePage'
  634. } else {
  635. var href = '/jyapp/vipsubscribe/introducePage'
  636. }
  637. }
  638. this.linkobj.industry = href
  639. },
  640. // 修改地区无次数点击事件
  641. userNumOver: function () {
  642. if (this.vSwitch === 'f' && this.userAreaNum === 0) {
  643. this.linkobj.area = 'javascript:;'
  644. if (this.userAreaAllNum > 0) {
  645. var str = `对不起,您当月修改区域的机会(${this.userAreaAllNum}次)已消耗完毕,无法再次修改~可前往升级省份订阅包增加订阅省份和修改次数`
  646. } else {
  647. var str = `对不起,您今年修改免费订阅区域的机会(1次)已消耗完毕,无法再次修改~可前往购买省份订阅包增加订阅省份`
  648. }
  649. weui.alert(str, {
  650. title: '',
  651. className: 'area-noNum',
  652. buttons: [{
  653. label: '取消',
  654. type: 'default'
  655. },{
  656. label: this.userType ? '去升级' : '去购买',
  657. onClick: function(){
  658. if (this.userType) {
  659. if (location.href.indexOf('front') !== -1) {
  660. var href = '/areaPack/wx/page/buy?type=upgrade'
  661. } else {
  662. var href = '/jyapp/areaPack/page/buy?type=upgrade'
  663. }
  664. } else {
  665. if (location.href.indexOf('front') !== -1) {
  666. var href = '/areaPack/wx/page/buy?type=buy'
  667. } else {
  668. var href = '/jyapp/areaPack/page/buy?type=buy'
  669. }
  670. }
  671. location.href = href
  672. }
  673. }]
  674. });
  675. }
  676. else {
  677. // this.linkobj.area = '/jyapp/big/page/set_area?callback=setting_save'
  678. if (location.href.indexOf('front') !== -1) {
  679. this.linkobj.area = '/areaPack/wx/page/set_area'
  680. } else {
  681. this.linkobj.area = '/jyapp/areaPack/page/set_area'
  682. }
  683. }
  684. },
  685. // 修改地区剩余次数问号点击事件
  686. amendmentNumNotice: function () {
  687. if (this.userAreaAllNum > 0) {
  688. var str = '每月可修改次数=可订阅省份数量,即每增加购买1个省份,可增加1次修改机会,次月清零重新计算,购买全国不限制每月修改次数。'
  689. } else {
  690. var str = '免费用户每年享有 1 次修改区域的机会'
  691. }
  692. weui.alert(str, {
  693. title: '',
  694. className: 'area-alert',
  695. buttons: [{
  696. label: '我知道了'
  697. }]
  698. });
  699. },
  700. // 打开信息类型
  701. openInfoType: function () {
  702. this.infoTypeMenu = true
  703. },
  704. // 重置信息类型
  705. reset: function () {
  706. if (this.isChange) {
  707. this.infoTypeData = ['全部']
  708. this.isChange = false
  709. }
  710. },
  711. // 确认信息类型
  712. confirm: function () {
  713. this.infoTypeMenu = false
  714. // var callback = utils.getParam('callback')
  715. // 如果有callback,则使用页面内部自己定义的方法来恢复和保存数据
  716. if (true) {
  717. try {
  718. custom['_setting_save'](this.infoTypeData)
  719. } catch (error) {
  720. console.log(error)
  721. }
  722. } else {
  723. setInfoTypeFn.saveToSessionStorage(this.infoTypeData)
  724. }
  725. },
  726. // 关闭信息类型菜单
  727. closeInfoType: function () {
  728. this.infoTypeMenu = false
  729. },
  730. // 点击按钮改变按钮状态
  731. changeBtnType: function (item) {
  732. this.isChange = true
  733. let thisIndex = this.infoTypeData.indexOf(item)
  734. let allType = this.infoTypeData.indexOf('全部')
  735. if (allType !== -1) {
  736. this.infoTypeData.splice(allType,1)
  737. }
  738. if (item === '全部') {
  739. this.infoTypeData = ['全部']
  740. } else {
  741. if (thisIndex !== -1) {
  742. this.infoTypeData.splice(thisIndex,1)
  743. } else {
  744. this.infoTypeData.push(item)
  745. }
  746. if (this.infoTypeData.length === 0 || this.infoTypeData.length === this.infoTypeList.length) {
  747. this.infoTypeData = ['全部']
  748. }
  749. }
  750. },
  751. // 跳转地区选择
  752. gotoArea: function () {
  753. if (location.href.indexOf('front') !== -1) {
  754. location.href = '/areaPack/wx/page/set_area'
  755. } else {
  756. location.href = '/jyapp/areaPack/page/set_area'
  757. }
  758. },
  759. // 获取用户权限
  760. getUserSubscribe: function () {
  761. let _this = this
  762. $.ajax({
  763. url: '/publicapply/free/subscribe',
  764. type: 'POST',
  765. success: function (res) {
  766. console.info(res)
  767. _this.UserSubscribe = res
  768. _this.info.area = res.data.area
  769. _this.userAreaNum = res.data.areanum
  770. _this.userType = res.data.provincenum === 0 ? false : true
  771. _this.userAreaAllNum = res.data.provincenum
  772. _this.initdata.infotype = res.data.infotype || []
  773. _this.info.infoType = _this.initdata.infotype.join('、')
  774. // _this.$emit('UserSubscribe',res)
  775. // let proStr = ''
  776. // Object.keys(res.data.area).forEach(function(item,index) {
  777. // if(res.data.area[item].length == 0) {
  778. // proStr += item + '、'
  779. // } else {
  780. // let cityStr = ''
  781. // res.data.area[item].forEach(function(data, i) {
  782. // cityStr += data + '、'
  783. // })
  784. // if (cityStr.length > 0) {
  785. // cityStr = cityStr.substr(0,cityStr.length - 1);
  786. // }
  787. // proStr += item+ '(' + cityStr + ')' + '、'
  788. // }
  789. // })
  790. // if(proStr[proStr.length - 1] == '、') {
  791. // proStr = proStr.substr(0,proStr.length - 1);
  792. // }
  793. // _this.info.area = '已选:' + proStr
  794. let areaArr = []
  795. if (res.data.area === {} || res.data.provincenum === 0) {
  796. _this.noAreaFreeType = true
  797. } else {
  798. for (const key in res.data.area) {
  799. areaArr.push(key)
  800. }
  801. }
  802. $('#menuArea').text('已选:'+ areaArr.join('、'))
  803. _this.info.infoType = sessionStorage.getItem('thisUserInfoType')
  804. }
  805. })
  806. },
  807. // 关闭未选择地区提示
  808. closeNoAreaTips: function () {
  809. this.noAreaFreeType = false
  810. },
  811. // 页面跳转返回提示
  812. addBackTip: function () {
  813. var _this = this
  814. var pushContent = {
  815. info: '订阅管理返回',
  816. url: '#tipover'
  817. }
  818. if (!history.state && this.backTipShowCount < 1) {
  819. history.pushState(pushContent, null, pushContent.url);
  820. }
  821. $(window).on('popstate', function () {
  822. _this.noAreaFreeType = true
  823. _this.backTipShowCount++
  824. })
  825. },
  826. //
  827. // 最近三个月推送结果预览总数
  828. getResultView: function () {
  829. let keyArr = []
  830. let notKeyArr = []
  831. let matchway = this.initdata.matchway
  832. let vt = 'v'
  833. let switchpro = sessionStorage.getItem('switch-product')
  834. if(switchpro) {
  835. if(switchpro == 'bigmember') {
  836. vt = 'm'
  837. } else if(switchpro == 'supervip') {
  838. vt = 'v'
  839. }
  840. }
  841. if (this.initdata.items) {
  842. this.initdata.items.forEach(function(item) {
  843. item.a_key.forEach(function(r) {
  844. keyArr.push(r.key[0])
  845. if(r.notkey) {
  846. r.notkey.forEach(function(nok) {
  847. notKeyArr.push(nok)
  848. })
  849. }
  850. })
  851. })
  852. }
  853. let _this = this
  854. $.ajax({
  855. type: 'POST',
  856. url: '/publicapply/subscribe/getPushAllCount',
  857. data: {
  858. item: '',
  859. index: -1,
  860. vt: vt
  861. },
  862. success: function(res) {
  863. if(_this.type == 'introduce') {
  864. _this.pushsetShow = false
  865. _this.resultTime = '(仅限超级订阅用户预览)'
  866. _this.linkobj.resultview = 'javascript:;'
  867. $('.resultpreview .icon-arrow').hide()
  868. } else {
  869. if(res.count < 30) {
  870. _this.littleShow = true
  871. } else {
  872. _this.littleShow = false
  873. }
  874. _this.resultTime = '(近3个月内共' + res.count + '条信息)'
  875. }
  876. }
  877. })
  878. },
  879. // 解决ios返回不刷新页面的问题
  880. iosBackRefresh: function () {
  881. var isPageHide = false;
  882. window.addEventListener('pageshow', function () {
  883. if (isPageHide) {
  884. location.reload();
  885. }
  886. });
  887. window.addEventListener('pagehide', function () {
  888. isPageHide = true;
  889. });
  890. },
  891. },
  892. }
  893. var setInfoTypeFn = {
  894. conf: {
  895. sKey: 'big-setInfoType'
  896. },
  897. init: function () {
  898. var setKey = ''
  899. if (setKey) {
  900. this.conf.sKey = setKey
  901. }
  902. var initData = sessionStorage.getItem(this.conf.sKey)
  903. if (initData) {
  904. initData = JSON.parse(initData)
  905. console.log(initData)
  906. // vNode.data.initInfoType = initData
  907. // vueComponent.setInfoTypeState(vNode.data.initInfoType)
  908. }
  909. },
  910. saveToSessionStorage: function (data) {
  911. sessionStorage.setItem(this.conf.sKey, JSON.stringify(data))
  912. }
  913. }
  914. var custom = {
  915. _setting_save: function (setdata) {
  916. if(setdata.length == 0) {
  917. setdata = ''
  918. } else {
  919. setdata = setdata.join(',')
  920. }
  921. sessionStorage.setItem('thisUserInfoType', setdata)
  922. let vswitch = sessionStorage.getItem('infoTypeVswitch')
  923. $.ajax({
  924. type:'POST',
  925. url:'/publicapply/subscribe/setUserInfo',
  926. data: {
  927. pageType: 'infoType',
  928. infoTypeArr: setdata,
  929. vSwitch: vswitch
  930. },
  931. success:function(res){
  932. sessionStorage.removeItem('infoTypeVswitch')
  933. if(res.flag) {
  934. sessionStorage.removeItem('big-setInfoType')
  935. location.reload()
  936. } else {
  937. vueComponent.$toast(res.data.error_msg)
  938. }
  939. }
  940. })
  941. }
  942. }
  943. setInfoTypeFn.init()