vip-subscribe-set-template.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919
  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.pushLink || 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('all')" :class="infoTypeData.length === 0 ? '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. <button class="bottom-btn cancel" @click="reset" :disabled="infoTypeData.length === 0">重置</button>
  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. conf: {}, // 信息类型数据
  259. noAreaFreeType: false, // 免费用户未设置地区时显示弹窗
  260. backTipShowCount: 0, // 离开页面展示弹窗次数
  261. thisvSwitch: 'f',
  262. UserSubscribe: {}, // 免费用户数据
  263. }
  264. },
  265. mounted () {
  266. let switchpro = sessionStorage.getItem('switch-product')
  267. if(switchpro) {
  268. if(switchpro == 'bigmember') {
  269. this.accStatus = 2
  270. } else if(switchpro == 'supervip') {
  271. this.accStatus = 1
  272. }
  273. }
  274. this.getData()
  275. this.$emit('mounted')
  276. // this.addBackTip()
  277. },
  278. watch: {
  279. initdata: function(newVal, oldVal) {
  280. if(newVal) {
  281. this.getResultView()
  282. this.getData()
  283. if (this.vSwitch !== 'f') {
  284. this.setIosData()
  285. }
  286. }
  287. },
  288. vSwitch: function (val) {
  289. if (val === 'f') {
  290. this.getUserSubscribe()
  291. }
  292. }
  293. },
  294. methods: {
  295. getData: function() {
  296. this.setArea()
  297. this.setIndustry()
  298. this.setKeyword()
  299. this.getActionDefault()
  300. this.getIndustryType()
  301. this.getProjectMatch()
  302. this.iosBackRefresh()
  303. },
  304. // 判断用户权限
  305. // 设置区域
  306. setArea: function() {
  307. let _this = this
  308. if(this.initdata.area) {
  309. if(_this.accStatus == 2) {
  310. sessionStorage.setItem('big-setArea', JSON.stringify(this.initdata.area))
  311. }
  312. if(JSON.stringify(this.initdata.area) === '{}') {
  313. this.info.area = '全国'
  314. } else {
  315. let proStr = ''
  316. Object.keys(this.initdata.area).forEach(function(item,index) {
  317. if(_this.initdata.area[item].length == 0) {
  318. proStr += item + '、'
  319. } else {
  320. let cityStr = ''
  321. _this.initdata.area[item].forEach(function(data, i) {
  322. cityStr += data + '、'
  323. })
  324. if (cityStr.length > 0) {
  325. cityStr = cityStr.substr(0,cityStr.length - 1);
  326. }
  327. proStr += item+ '(' + cityStr + ')' + '、'
  328. }
  329. })
  330. if(proStr[proStr.length - 1] == '、') {
  331. proStr = proStr.substr(0,proStr.length - 1);
  332. }
  333. _this.info.area = '已选:' + proStr
  334. }
  335. } else {
  336. this.info.area = '请选择区域'
  337. }
  338. var areaNull = sessionStorage.getItem('areaNull')
  339. if(areaNull) {
  340. this.initdata.area = {}
  341. this.info.area = '请选择区域'
  342. }
  343. },
  344. // 设置行业
  345. setIndustry: function() {
  346. let _this = this
  347. if(this.initdata.industry) {
  348. // this.initdata.industry = JSON.parse(this.initdata.industry)
  349. if(this.accStatus == 2) {
  350. sessionStorage.setItem('big-setCate', JSON.stringify(this.initdata.industry))
  351. }
  352. if(this.initdata.industry.length == 0) {
  353. this.info.industry = '已选:全部'
  354. if (this.vSwitch === 'f') {
  355. this.info.industry = '请选择采购单位类型'
  356. }
  357. } else {
  358. this.info.industry = '已选:' + this.initdata.industry.join('、')
  359. }
  360. } else {
  361. this.info.industry = '请选择采购单位类型'
  362. }
  363. var industryNull = sessionStorage.getItem('industryNull')
  364. if(industryNull) {
  365. this.initdata.industry = []
  366. this.info.industry = '请选择采购单位类型'
  367. }
  368. },
  369. // 设置关键词
  370. setKeyword: function() {
  371. let state = this.initdata
  372. if(state) {
  373. if(state.items) {
  374. if (state.items.length === 0) {
  375. $('.body-item.keywords .keywords-text').text('请设置关键词')
  376. } else {
  377. var arr = []
  378. state.items.forEach(function (item, index) {
  379. item.a_key.forEach(function(data,i) {
  380. arr.push(data.key[0])
  381. })
  382. })
  383. if(arr.length == 0) {
  384. $('.body-item.keywords .keywords-text').text('请设置关键词')
  385. } else {
  386. $('.body-item.keywords .keywords-text').text('已设置' +arr.length+ '组关键词')
  387. }
  388. // $('.body-item.keywords .keywords-text').text(arr.join('、'))
  389. }
  390. }
  391. } else {
  392. $('.body-item.keywords .keywords-text').text('请设置关键词')
  393. }
  394. },
  395. // ios关键词重新赋值
  396. setIosData: function () {
  397. let _this = this
  398. let u = navigator.userAgent;
  399. let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
  400. let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
  401. if (isAndroid == true) {
  402. console.log("安卓手机")
  403. } else {
  404. $.ajax({
  405. type: 'POST',
  406. url: '/subscribepay/vipsubscribe/getSubBuyMsg?t=' + Date.now(),
  407. success:function(res) {
  408. if(res.success) {
  409. _this.setKeyword()
  410. }
  411. }
  412. })
  413. }
  414. },
  415. // 信息类型
  416. getIndustryType: function() {
  417. if(this.initdata) {
  418. if(this.initdata.infotype) {
  419. if(this.accStatus == 2) {
  420. sessionStorage.setItem('big-setInfoType', JSON.stringify(this.initdata.infotype))
  421. }
  422. if (this.initdata.infotype.length === 0) {
  423. this.info.infoType = '全部类型'
  424. } else {
  425. this.info.infoType = this.initdata.infotype.join('、')
  426. }
  427. } else {
  428. this.info.infoType = '全部类型'
  429. }
  430. }
  431. },
  432. // 项目匹配
  433. getProjectMatch: function() {
  434. if (this.initdata.projectmatch == 1) {
  435. $('.switch').addClass('checked')
  436. this.checkedflag = true
  437. } else {
  438. $('.switch').removeClass('checked')
  439. this.checkedflag = false
  440. }
  441. },
  442. switchs: function() {
  443. // 用户未购买项目匹配功能
  444. if (this.vSwitch === 'f') {
  445. $('.switch').removeClass('checked')
  446. this.checkedflag = false
  447. if (location.href.indexOf('front') !== -1) {
  448. var href = '/front/vipsubscribe/introducePage'
  449. } else {
  450. var href = '/jyapp/vipsubscribe/introducePage'
  451. }
  452. location.href = href
  453. } else {
  454. // switch点击切换
  455. if (!this.checkedflag) {
  456. this.checkedflag = !this.checkedflag;
  457. this.setprojectmatch('projectMatch', 1);
  458. } else {
  459. this.checkedflag = !this.checkedflag;
  460. this.setprojectmatch('projectMatch', 0);
  461. weui.toast('项目匹配已关闭', {
  462. duration: 1500,
  463. className: 'jy-toast',
  464. callback: function () {
  465. console.log('close')
  466. }
  467. });
  468. }
  469. }
  470. },
  471. setprojectmatch(pagetype,index) {
  472. let _this = this
  473. let vswitch ='v'
  474. if(_this.accStatus == 2) {
  475. vswitch = 'm'
  476. } else if(_this.accStatus == 1) {
  477. vswitch = 'v'
  478. }
  479. $.post("/publicapply/subscribe/setUserInfo", {pageType: pagetype, pmindex: index, vSwitch:vswitch}, function (r) {
  480. if (r.flag) {
  481. if(index == 0 || index == 1) {
  482. var subVipState = sessionStorage.getItem('sub_vip_state');
  483. var reqData = JSON.parse(subVipState);
  484. reqData.projectmatch = index;
  485. sessionStorage.setItem('sub_vip_state', JSON.stringify(reqData))
  486. }
  487. }
  488. })
  489. },
  490. // 关键词匹配方式
  491. getActionDefault: function() {
  492. let _this = this
  493. let defaultTitle = ''
  494. if(this.initdata.matchway == 1 || !this.initdata.matchway) {
  495. $('.match-way-value').text('按标题匹配')
  496. this.active = 1
  497. } else if(this.initdata.matchway == 2) {
  498. $('.match-way-value').text('按全文匹配')
  499. this.active = 2
  500. }
  501. // $('#iosActionsheet .weui-actionsheet__cell').each(function (index, item) {
  502. // var t = $(item).children().text().trim();
  503. // if (t == defaultTitle) {
  504. // $(this).addClass('active')
  505. // }
  506. // })
  507. },
  508. hideActionSheet: function() {
  509. var update_renew = $('.update_renew')
  510. var $iosMask = $('#iosMask');
  511. var $iosActionsheet = $('#iosActionsheet');
  512. $iosActionsheet.removeClass('weui-actionsheet_toggle');
  513. $('.match-keywords-actionsheet').hide()
  514. $iosMask.fadeOut(200);
  515. // 免费用户
  516. if (this.thisvSwitch === 'f') {
  517. return
  518. }
  519. // 超级订阅升级提示
  520. if(update_renew) {
  521. if(this.accStatus == 2) {
  522. update_renew.hide()
  523. } else {
  524. update_renew.show()
  525. }
  526. }
  527. this.$emit('footershow', 'false')
  528. },
  529. iosMask: function() {
  530. this.hideActionSheet()
  531. },
  532. iosActionsheetCancel: function() {
  533. this.hideActionSheet()
  534. },
  535. matchWay: function() {
  536. var update_renew = $('.update_renew')
  537. var $iosMask = $('#iosMask');
  538. var $iosActionsheet = $('#iosActionsheet');
  539. $iosActionsheet.addClass('weui-actionsheet_toggle');
  540. $('.match-keywords-actionsheet').show()
  541. $iosMask.fadeIn(200);
  542. if(update_renew) {
  543. update_renew.hide()
  544. }
  545. this.$emit('footershow', 'true')
  546. },
  547. actionSheet: function(title, index) {
  548. let _this = this
  549. let vswitch = 'v'
  550. var href = ''
  551. if (index === 2 && this.vSwitch === 'f') {
  552. if (location.href.indexOf('front') !== -1) {
  553. href = '/front/vipsubscribe/introducePage'
  554. } else {
  555. href = '/jyapp/vipsubscribe/introducePage'
  556. }
  557. location.href = href
  558. } else {
  559. if (this.vSwitch === 'f') {
  560. return this.hideActionSheet()
  561. }
  562. if(_this.accStatus == 2) {
  563. vswitch = 'm'
  564. } else if(_this.accStatus == 1) {
  565. vswitch = 'v'
  566. }
  567. var update_renew = $('.update_renew')
  568. $.post("/publicapply/subscribe/setUserInfo", {pageType: "saveSeniorset", matchtype: index, vSwitch: vswitch}, function (r) {
  569. if (r.flag) {
  570. var subVipState = sessionStorage.getItem('sub_vip_state');
  571. var reqData = JSON.parse(subVipState);
  572. _this.active = index
  573. var $iosMask = $('#iosMask');
  574. var $iosActionsheet = $('#iosActionsheet');
  575. $iosActionsheet.removeClass('weui-actionsheet_toggle');
  576. $('.match-keywords-actionsheet').hide()
  577. $iosMask.fadeOut(200);
  578. if(update_renew) {
  579. if(_this.accStatus == 2) {
  580. update_renew.hide()
  581. } else {
  582. update_renew.show()
  583. }
  584. }
  585. _this.$emit('footershow', 'false')
  586. $('.match-way-value').text(title)
  587. if(index == 1) {
  588. $('.titleMacth').addClass('active')
  589. $('.allMacth').removeClass('active')
  590. } else {
  591. $('.titleMacth').removeClass('active')
  592. $('.allMacth').addClass('active')
  593. }
  594. reqData.matchway = index;
  595. sessionStorage.setItem('sub_vip_state', JSON.stringify(reqData))
  596. } else {
  597. weui.toast('关键词匹配方式修改失败', {
  598. duration: 1500,
  599. className: 'jy-toast',
  600. callback: function () {
  601. console.log('close')
  602. }
  603. });
  604. }
  605. })
  606. // var nowMode = title
  607. // var ModeArr = ['按标题匹配', '按全文匹配']
  608. // var nowIndex = ModeArr.indexOf(nowMode)
  609. // if (nowIndex !== -1) {
  610. // this.setMatchway(ModeArr.indexOf(nowMode) + 1)
  611. // } else {
  612. // // $(this).removeClass('active').siblings().addClass('active');
  613. // $('.match-way-value').text($(this).siblings().children('.cell_title').text())
  614. // weui.toast('关键词匹配方式修改失败', {
  615. // duration: 1500,
  616. // className: 'jy-toast',
  617. // callback: function () {
  618. // console.log('close')
  619. // }
  620. // });
  621. // }
  622. this.getResultView()
  623. }
  624. },
  625. // 项目匹配问号点击事件
  626. projectNotice: function () {
  627. var str = '开启后,系统将根据你订阅的关键词自动匹配出相关联的项目,并将相关联项目的后续动态在超级订阅内一并推送。'
  628. weui.alert(str, {
  629. title: '项目匹配',
  630. className: 'jy-alert',
  631. buttons: [{
  632. label: '我知道了'
  633. }]
  634. });
  635. },
  636. // 用户未购买修改采购单位类型功能
  637. userNoIndustry: function () {
  638. if (this.vSwitch !== 'f') {
  639. var href = '/jyapp/vipsubscribe/toChangeIndustry?header=save'
  640. } else {
  641. if (location.href.indexOf('front') !== -1) {
  642. var href = '/front/vipsubscribe/introducePage'
  643. } else {
  644. var href = '/jyapp/vipsubscribe/introducePage'
  645. }
  646. }
  647. this.linkobj.industry = href
  648. },
  649. // 修改地区无次数点击事件
  650. userNumOver: function () {
  651. var _this = this
  652. if (this.vSwitch === 'f' && this.userAreaNum === 0) {
  653. this.linkobj.area = 'javascript:;'
  654. if (this.userAreaAllNum > 0) {
  655. var str = `对不起,您当月修改区域的机会(${this.userAreaAllNum}次)已消耗完毕,无法再次修改~可前往升级省份订阅包增加订阅省份和修改次数`
  656. } else {
  657. var str = `对不起,您今年修改免费订阅区域的机会(1次)已消耗完毕,无法再次修改~可前往购买省份订阅包增加订阅省份`
  658. }
  659. weui.alert(str, {
  660. title: '',
  661. className: 'area-noNum',
  662. buttons: [{
  663. label: '取消',
  664. type: 'default'
  665. },{
  666. label: _this.userType ? '去升级' : '去购买',
  667. onClick: function(){
  668. if (_this.userType) {
  669. if (location.href.indexOf('front') !== -1) {
  670. var href = '/areaPack/wx/page/buy?type=upgrade'
  671. } else {
  672. var href = '/jyapp/areaPack/page/buy?type=upgrade'
  673. }
  674. } else {
  675. if (location.href.indexOf('front') !== -1) {
  676. var href = '/areaPack/wx/page/buy?type=buy'
  677. } else {
  678. var href = '/jyapp/areaPack/page/buy?type=buy'
  679. }
  680. }
  681. location.href = href
  682. }
  683. }]
  684. });
  685. }
  686. else {
  687. // this.linkobj.area = '/jyapp/big/page/set_area?callback=setting_save'
  688. if (this.vSwitch === 'f') {
  689. if (location.href.indexOf('front') !== -1) {
  690. this.linkobj.area = '/areaPack/wx/page/set_area'
  691. } else {
  692. this.linkobj.area = '/jyapp/areaPack/page/set_area'
  693. }
  694. }
  695. }
  696. },
  697. // 修改地区剩余次数问号点击事件
  698. amendmentNumNotice: function () {
  699. if (this.userAreaAllNum > 0) {
  700. var str = '每月可修改次数=可订阅省份数量,即每增加购买1个省份,可增加1次修改机会,次月清零重新计算,购买全国不限制每月修改次数。'
  701. } else {
  702. var str = '免费用户每年享有 1 次修改区域的机会'
  703. }
  704. weui.alert(str, {
  705. title: '',
  706. className: 'area-alert',
  707. buttons: [{
  708. label: '我知道了'
  709. }]
  710. });
  711. },
  712. // 打开信息类型
  713. openInfoType: function () {
  714. if (this.vSwitch === 'f') {
  715. this.infoTypeMenu = true
  716. } else {
  717. if (location.href.indexOf('front') !== -1) {
  718. location.href = '/front/vipsubscribe/toSetInfoTypePage'
  719. } else {
  720. location.href = '/jyapp/vipsubscribe/toSetInfoTypePage'
  721. }
  722. }
  723. },
  724. // 重置信息类型
  725. reset: function () {
  726. this.infoTypeData = []
  727. },
  728. // 确认信息类型
  729. confirm: function () {
  730. this.infoTypeMenu = false
  731. this.saveInfoTypeChange()
  732. },
  733. saveInfoTypeChange: function () {
  734. var _this = this
  735. $.ajax({
  736. type:'POST',
  737. url:'/publicapply/subscribe/setUserInfo',
  738. data: {
  739. pageType: 'infoType',
  740. infoTypeArr: this.infoTypeData.join(','),
  741. vSwitch: this.vSwitch
  742. },
  743. success:function(res){
  744. if(res.flag) {
  745. location.reload()
  746. } else {
  747. _this.$toast(res.data.error_msg)
  748. }
  749. }
  750. })
  751. },
  752. // 关闭信息类型菜单
  753. closeInfoType: function () {
  754. this.infoTypeMenu = false
  755. },
  756. // 点击按钮改变按钮状态
  757. changeBtnType: function (item) {
  758. if (item === 'all') {
  759. this.infoTypeData = []
  760. } else {
  761. let thisIndex = this.infoTypeData.indexOf(item)
  762. if (thisIndex !== -1) {
  763. this.infoTypeData.splice(thisIndex, 1)
  764. } else {
  765. this.infoTypeData.push(item)
  766. }
  767. }
  768. },
  769. // 跳转地区选择
  770. gotoArea: function () {
  771. if (location.href.indexOf('front') !== -1) {
  772. location.href = '/areaPack/wx/page/set_area?type=new'
  773. } else {
  774. location.href = '/jyapp/areaPack/page/set_area?type=new'
  775. }
  776. },
  777. // 获取用户权限
  778. getUserSubscribe: function () {
  779. let _this = this
  780. $.ajax({
  781. url: '/publicapply/free/subscribe',
  782. type: 'POST',
  783. success: function (res) {
  784. let freeArea = JSON.stringify(res.data)
  785. sessionStorage.setItem('sub_free_state', freeArea)
  786. _this.UserSubscribe = res
  787. _this.info.area = res.data.area
  788. _this.userAreaNum = res.data.areanum
  789. _this.userType = res.data.provincenum === 0 ? false : true
  790. _this.userAreaAllNum = res.data.provincenum
  791. _this.initdata.infotype = res.data.infotype || []
  792. _this.infoTypeData = res.data.infotype || []
  793. _this.info.infoType = _this.infoTypeData.length === 0 ? '全部类型' : _this.infoTypeData.join('、')
  794. // let proStr = ''
  795. // Object.keys(res.data.area).forEach(function(item,index) {
  796. // if(res.data.area[item].length == 0) {
  797. // proStr += item + '、'
  798. // } else {
  799. // let cityStr = ''
  800. // res.data.area[item].forEach(function(data, i) {
  801. // cityStr += data + '、'
  802. // })
  803. // if (cityStr.length > 0) {
  804. // cityStr = cityStr.substr(0,cityStr.length - 1);
  805. // }
  806. // proStr += item+ '(' + cityStr + ')' + '、'
  807. // }
  808. // })
  809. // if(proStr[proStr.length - 1] == '、') {
  810. // proStr = proStr.substr(0,proStr.length - 1);
  811. // }
  812. // _this.info.area = '已选:' + proStr
  813. let areaArr = []
  814. if (res.data) {
  815. if (!res.data.area) {
  816. _this.noAreaFreeType = true
  817. } else {
  818. for (const key in res.data.area) {
  819. areaArr.push(key)
  820. }
  821. }
  822. }
  823. $('#menuArea').text('已选:'+ areaArr.join('、'))
  824. }
  825. })
  826. },
  827. // 关闭未选择地区提示
  828. closeNoAreaTips: function () {
  829. this.noAreaFreeType = false
  830. },
  831. // 页面跳转返回提示
  832. addBackTip: function () {
  833. var _this = this
  834. var pushContent = {
  835. info: '订阅管理返回',
  836. url: '#tipover'
  837. }
  838. if (!history.state && this.backTipShowCount < 1) {
  839. history.pushState(pushContent, null, pushContent.url);
  840. }
  841. $(window).on('popstate', function () {
  842. _this.noAreaFreeType = true
  843. _this.backTipShowCount++
  844. })
  845. },
  846. //
  847. // 最近三个月推送结果预览总数
  848. getResultView: function () {
  849. let keyArr = []
  850. let notKeyArr = []
  851. let matchway = this.initdata.matchway
  852. let vt = 'v'
  853. let switchpro = sessionStorage.getItem('switch-product')
  854. if(switchpro) {
  855. if(switchpro == 'bigmember') {
  856. vt = 'm'
  857. } else if(switchpro == 'supervip') {
  858. vt = 'v'
  859. }
  860. }
  861. if (this.initdata.items) {
  862. this.initdata.items.forEach(function(item) {
  863. item.a_key.forEach(function(r) {
  864. keyArr.push(r.key[0])
  865. if(r.notkey) {
  866. r.notkey.forEach(function(nok) {
  867. notKeyArr.push(nok)
  868. })
  869. }
  870. })
  871. })
  872. }
  873. let _this = this
  874. $.ajax({
  875. type: 'POST',
  876. url: '/publicapply/subscribe/getPushAllCount',
  877. data: {
  878. item: '',
  879. index: -1,
  880. vt: vt
  881. },
  882. success: function(res) {
  883. if(_this.type == 'introduce') {
  884. _this.pushsetShow = false
  885. _this.resultTime = '(仅限超级订阅用户预览)'
  886. _this.linkobj.resultview = 'javascript:;'
  887. $('.resultpreview .icon-arrow').hide()
  888. } else {
  889. if(res.count < 30) {
  890. _this.littleShow = true
  891. } else {
  892. _this.littleShow = false
  893. }
  894. _this.resultTime = '(近3个月内共' + res.count + '条信息)'
  895. }
  896. }
  897. })
  898. },
  899. // 解决ios返回不刷新页面的问题
  900. iosBackRefresh: function () {
  901. var isPageHide = false;
  902. window.addEventListener('pageshow', function () {
  903. if (isPageHide) {
  904. location.reload();
  905. }
  906. });
  907. window.addEventListener('pagehide', function () {
  908. isPageHide = true;
  909. });
  910. },
  911. },
  912. }