purchase-a-details.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. var sysT = require('../../../../tool/sys-tool.js')
  2. var businessT = require('../../../../tool/business-tool.js')
  3. var purchaseO = require('../../public/model/purchaseOrder.js')
  4. var p = require('../../public/model/public.js')
  5. var app = getApp()
  6. var publicData = require('../../../../constant/data.js')
  7. var purchaseData = require('../../public/model/purchase-details.js')
  8. var url = require('../../../../constant/url.js')
  9. import Net from '../../../../tool/net.js'
  10. var net = new Net()
  11. var businessType = require('../../../../public/business-type.js')
  12. var key = require('../../../../constant/key.js')
  13. import PurchaseOrder from '../../public/model/purchaseOrder.js'
  14. var login = require('../../../../public/login.js')
  15. Page({
  16. /**
  17. * 页面的初始数据
  18. */
  19. data: {
  20. isFirstLoad: true,
  21. ui: {
  22. tips: {
  23. explain: [],
  24. choose: [],
  25. process: 'process_a',
  26. question: {},
  27. tips: []
  28. }
  29. },
  30. adapter: {
  31. suffix: '',
  32. isSupplementaryPay: false,
  33. leftButton: '一键续缴',
  34. rightButton: '立即缴存',
  35. city: {
  36. t: '缴存城市',
  37. c: ''
  38. },
  39. charge: 0,
  40. count: 10000
  41. },
  42. tips: {
  43. s: false,
  44. t: []
  45. },
  46. showContact: false,
  47. showContactHeight: -68,
  48. scroll: true,
  49. choseCity: {},
  50. limit: [0, 0],
  51. scrollView: {
  52. top: 0
  53. },
  54. positionHeight: [0, 0, 0, 0, 0],
  55. chooseHidden: true,
  56. chooseing: false,//是否点击选择购买流程等
  57. //客服需要的
  58. isLogin: false,
  59. userInfo: {
  60. avatarUrl: ''
  61. },
  62. params: {
  63. }
  64. },
  65. hiddenContactListener: function (e) {
  66. businessT.debugLog('hiddenContactListener')
  67. this.setData({
  68. scroll: true
  69. })
  70. },
  71. judgeIsLogin: function () {
  72. if (app.loginStatus.key == "") {
  73. wx.navigateTo({
  74. url: '../../../login/index',
  75. })
  76. return false
  77. }
  78. return true
  79. },
  80. contactAction: function (sender) {
  81. businessT.debugLog('contact')
  82. if (!this.judgeIsLogin()) {
  83. return
  84. }
  85. // wx.navigateTo({
  86. // url: '../../../../public/pages/html/html?host=https://kf.shanp.com/user.html&channel=h5XCX&phone=' + app.globalData.userInfo.phone + '&uid=' + app.globalData.userInfo.uid + '&t=' + new Date().getTime(),
  87. // })
  88. },
  89. phoneAction: function (sender) {
  90. this.setData({
  91. showContact: true,
  92. scroll: false
  93. })
  94. },
  95. supplementaryPay: function (sender) {
  96. if (!this.judgeIsLogin()) {
  97. return
  98. }
  99. var purchase = app.purchase.purchaseData
  100. if (purchase.addedf_num == 0) {
  101. wx.showToast({
  102. title: '该城市不支持补缴公积金',
  103. icon: 'none'
  104. })
  105. return
  106. }
  107. if (!purchase.fund_buy) {
  108. var tips = '该城市不支持单独补缴公积金,请确保已补缴同月份社保,有任何疑问咨询' + businessT.getPhone()
  109. var that = this
  110. wx.showModal({
  111. title: '',
  112. content: tips,
  113. confirmColor: '#3296FB',
  114. cancelColor: '#3296FB',
  115. confirmText: '暂不补缴',
  116. cancelText: '我要补缴',
  117. success: function (res) {
  118. if (res.cancel) {
  119. that.toCustomer()
  120. }
  121. }
  122. })
  123. return
  124. }
  125. this.toCustomer()
  126. },
  127. toCustomer: function () {
  128. if (app.globalData.customerList.length > 0) {
  129. wx.navigateTo({
  130. url: '../../../../public/pages/customer-view/customer-view?type=nPurchase',
  131. })
  132. return
  133. }
  134. wx.navigateTo({
  135. url: '../new-customer/new-customer',
  136. })
  137. },
  138. quickPurchase: function (sender) {
  139. if (!this.judgeIsLogin()) {
  140. return
  141. }
  142. if (app.globalData.customerList.length == 0) {
  143. wx.showToast({
  144. title: '你还没有参保记录,请选择“立即缴存”',
  145. icon: 'none'
  146. })
  147. return
  148. }
  149. wx.navigateTo({
  150. url: '../../../../public/pages/customer-view/customer-view?type=qPurchase&businessType=a',
  151. })
  152. },
  153. purchase: function (sender) {
  154. if (!this.judgeIsLogin()) {
  155. return
  156. }
  157. var purchase = app.purchase.purchaseData
  158. if (!purchase.fund_buy && !purchase.pack) {
  159. wx.showToast({
  160. title: '该城市不能购买公积金',
  161. icon: 'none'
  162. })
  163. return
  164. }
  165. if (!purchase.fund_buy) {
  166. var that = this
  167. wx.showModal({
  168. title: '',
  169. content: '该城市不支持单独购买公积金,您将打包社保一起购买',
  170. confirmColor: '#3296FB',
  171. cancelColor: '#3296FB',
  172. confirmText: '重新选择',
  173. cancelText: '确定',
  174. success: function (res) {
  175. if (res.cancel) {
  176. var order = p.getOrder()
  177. p.setOrderPack(true)
  178. that.toCustomer()
  179. }
  180. }
  181. })
  182. return
  183. }
  184. this.toCustomer()
  185. },
  186. chooseCity: function (sender) {
  187. //防止第一列还在滑动就确定,再次展示会错位
  188. this.data.adapter.city.d[1] = publicData.purchaseCity[(publicData.purchaseCity.p)[sender.detail.value[0]].id]
  189. this.data.adapter.city.v = sender.detail.value
  190. var pr = publicData.purchaseCity.p[sender.detail.value[0]].id
  191. var c = publicData.purchaseCity[pr][sender.detail.value[1]]
  192. if (!c) {
  193. c = publicData.purchaseCity[pr][0]
  194. this.data.adapter.city.v[1] = 0
  195. }
  196. this.data.choseCity = c
  197. this.setData({
  198. adapter: this.data.adapter
  199. })
  200. this.getData(c.id)
  201. },
  202. chooseCityColumn: function (sender) {
  203. if (sender.detail.column == 0) {
  204. this.data.adapter.city.d[1] = publicData.purchaseCity[(publicData.purchaseCity.p)[sender.detail.value].id]
  205. this.data.adapter.city.v = [sender.detail.value, 0]
  206. this.setData({
  207. adapter: this.data.adapter
  208. })
  209. }
  210. },
  211. chooseView: businessT.action(function (sender) {
  212. businessT.debugLog('chooseView')
  213. }),
  214. getData: function (cityId) {
  215. wx.showLoading({
  216. title: '加载中',
  217. mask: true
  218. })
  219. var order = p.getOrder()
  220. var path = order.isSupplementaryPay ? url.getSupplementaryPurchaseData : url.getNormalPurchaseData
  221. net.connect({
  222. url: url.app_host + path,
  223. method: 'POST',
  224. data: {
  225. city_code: cityId,
  226. type: 2
  227. },
  228. success: (err, res) => {
  229. if (Object.prototype.toString.call(res.data) == '[object Array]' && res.data.length > 0) {
  230. purchaseData.handleData(res.data)
  231. this.handleData()
  232. if (order.isSupplementaryPay) {
  233. wx.setStorageSync(key.StorageKey.lastCity_s, this.data.choseCity)
  234. } else {
  235. wx.setStorageSync(key.StorageKey.lastCity_n, this.data.choseCity)
  236. }
  237. wx.hideLoading()
  238. } else {
  239. this.getDataFail()
  240. businessT.showFailTips({ code: 0, msg: '' }, '加载失败')
  241. }
  242. },
  243. fail: (err, res) => {
  244. this.getDataFail()
  245. businessT.showFailTips(err, '加载失败')
  246. }
  247. }, true)
  248. },
  249. getDataFail: function () {
  250. wx.hideLoading()
  251. var order = p.getOrder()
  252. this.data.choseCity = { name: order.cityName, id: order.city }
  253. this.data.adapter.city.c = this.data.choseCity.name
  254. this.setData({
  255. adapter: this.data.adapter
  256. })
  257. if (app.purchase.purchaseData == null) {
  258. setTimeout(function () {
  259. wx.navigateBack({
  260. })
  261. }.bind(this), 1000)
  262. }
  263. },
  264. handleData: function () {
  265. if (this.data.ui.tips.question.height[0] == 0) {
  266. businessT.debugLog('算问题')
  267. var query = wx.createSelectorQuery();
  268. for (var i in this.data.ui.tips.question.ids) {
  269. var id = this.data.ui.tips.question.ids[i]
  270. query.select('#' + id).boundingClientRect()
  271. }
  272. var that = this;
  273. query.exec(function (res) {
  274. //res就是 该元素的信息 数组
  275. businessT.debugLog(res)
  276. for (var i in res) {
  277. that.data.ui.tips.question.height[i] = res[i].height
  278. }
  279. that.setData({
  280. ui: that.data.ui
  281. })
  282. })
  283. }
  284. var order = p.getOrder()
  285. var data = app.purchase.purchaseData
  286. this.data.adapter.city.c = this.data.choseCity.name
  287. this.data.adapter.charge = order.isSupplementaryPay ? data.added_charge : data.fund_charge
  288. this.data.adapter.city.des = '目前可购买' + data.month + '及之后月份,截止时间为' + purchaseData.getPurchaseDeadline(data.inc_date) + '月' + data.inc_date + '日'
  289. if (order.isSupplementaryPay) {
  290. if (data.fund_note == '') {
  291. this.data.tips.t = []
  292. } else {
  293. this.data.tips.t = data.fund_note.split('\n')
  294. }
  295. } else {
  296. if (data.fund_desc == '') {
  297. this.data.tips.t = []
  298. } else {
  299. this.data.tips.t = data.fund_desc.split('\n')
  300. }
  301. }
  302. if (this.data.tips.t.length > 0) {
  303. this.data.tips.s = true
  304. } else {
  305. this.data.tips.s = false
  306. }
  307. this.data.limit = [data.funds[order.accountType - 1][0], data.funds[order.accountType - 1][1]]
  308. purchaseData.changeShebaoDataToCustomerData()
  309. order.cityName = this.data.choseCity.name
  310. this.setData({
  311. adapter: this.data.adapter,
  312. tips: this.data.tips,
  313. limit: this.data.limit
  314. })
  315. this.calculateHeight()
  316. },
  317. scroll: function (sender) {
  318. this.data.scrollView.top = sender.detail.scrollTop
  319. if (sender.detail.scrollTop >= this.data.positionHeight[0]) {
  320. this.data.chooseHidden = false
  321. this.setData({
  322. chooseHidden: this.data.chooseHidden
  323. })
  324. if (this.data.chooseing) {
  325. this.data.chooseing = false
  326. return
  327. }
  328. var chooseHeight = this.data.positionHeight[1] - this.data.positionHeight[0]
  329. if (sender.detail.scrollTop >= this.data.positionHeight[4] - chooseHeight) {
  330. this.changeChoose(3)
  331. } else if (sender.detail.scrollTop >= this.data.positionHeight[3] - chooseHeight) {
  332. this.changeChoose(2)
  333. } else if (sender.detail.scrollTop >= this.data.positionHeight[2] - chooseHeight) {
  334. this.changeChoose(1)
  335. } else if (sender.detail.scrollTop >= this.data.positionHeight[1] - chooseHeight) {
  336. this.changeChoose(0)
  337. }
  338. } else {
  339. this.data.chooseHidden = true
  340. this.setData({
  341. chooseHidden: this.data.chooseHidden
  342. })
  343. }
  344. },
  345. tipsChoose: businessT.action(function (sender) {
  346. businessT.debugLog(sender.currentTarget.id)
  347. var index = Number(sender.currentTarget.id)
  348. var chooseHeight = this.data.positionHeight[1] - this.data.positionHeight[0]
  349. this.data.scrollView.top = this.data.positionHeight[index + 1] - chooseHeight
  350. this.setData({
  351. scrollView: this.data.scrollView
  352. })
  353. this.data.chooseing = true
  354. this.changeChoose(index)
  355. }),
  356. changeChoose: function (index) {
  357. var animation = wx.createAnimation({
  358. duration: 300,
  359. timingFunction: 'ease',
  360. })
  361. animation.translateX(index * 190 * sysT.rpxToPx()).step()
  362. this.data.ui.tips.choose.animation = animation.export()
  363. this.data.ui.tips.choose.c = index
  364. this.setData({
  365. ui: this.data.ui
  366. })
  367. },
  368. calculateHeight: function () {
  369. //purchase-details-choose
  370. var query = wx.createSelectorQuery();
  371. var that = this;
  372. //选择id
  373. query.select('#purchase-details-choose').boundingClientRect()
  374. query.select('#purchase-details-process').boundingClientRect()
  375. query.select('#purchase-details-advantage').boundingClientRect()
  376. query.select('#purchase-details-question').boundingClientRect()
  377. query.select('#purchase-details-tips').boundingClientRect()
  378. query.exec(function (res) {
  379. //res就是 该元素的信息 数组
  380. that.data.positionHeight[0] = res[0].top + that.data.scrollView.top
  381. that.data.positionHeight[1] = res[1].top + that.data.scrollView.top
  382. that.data.positionHeight[2] = res[2].top + that.data.scrollView.top
  383. that.data.positionHeight[3] = res[3].top + that.data.scrollView.top
  384. that.data.positionHeight[4] = res[4].top + that.data.scrollView.top
  385. businessT.debugLog(that.data.positionHeight)
  386. })
  387. },
  388. /**
  389. * 生命周期函数--监听页面加载
  390. */
  391. onLoad: function (options) {
  392. if (options.first) {
  393. login.autoLogin(true)
  394. }
  395. var order = p.getOrder()
  396. if (!order) {
  397. var order = new PurchaseOrder()
  398. p.setOrder(order)
  399. }
  400. if (options.isSupplementaryPay == 1) {
  401. order.isSupplementaryPay = true
  402. } else {
  403. order.isSupplementaryPay = false
  404. }
  405. order.setCity()
  406. order.purchaseType = businessType.PurchaseType.accumulationFund
  407. this.data.choseCity = { name: order.cityName, id: order.city }
  408. var title
  409. var tips
  410. if (order.isSupplementaryPay) {
  411. title = '公积金补缴详情'
  412. tips = {
  413. explain: ['补缴必须与正常月份一起操作,所以下补缴单前请先下一个月正常单(点击首页-缴公积金)', '补缴不能跨月操作。例如,现在可以下10月份订单,那么补缴必须从9月份开始往前连续购买,不可从8月份或其他月份开始(若9月份已缴费就不能操作补缴了)。']
  414. }
  415. } else {
  416. title = '公积金缴存详情'
  417. tips = {
  418. explain: ['以前曾在单位缴存过公积金,第一次下单购买前,请先确认前单位是否已经封存公积金,否则导致购买不成功,本平台不负责哦。', '每月公积金缴费额要一致,第一次下单确定后不要随意更改。一般每年7月通知调整一次,需要调整的请提前致电客服。'],
  419. attention: ['若您停止购买后,本平台通常会于次月截止时间后的一周操作封存公积金(部分地区可能会有延迟),需提前封存的用户,请提前3-7工作日联系客服。', '如果您当月申请封存后,又想重新购买当月的公积金,请务必先联系客服撤销封存,避免漏缴。'],
  420. attentionT: '公积金封存注意事项'
  421. }
  422. }
  423. tips.choose = {
  424. t: ['购买流程', '平台优势', '常见问题', '温馨提示'],
  425. c: 0,
  426. animation: {}
  427. }
  428. tips.process = 'process_a'
  429. tips.tips = ['本平台仅支持代缴服务,不支持证明出具,如有疑问请咨询客服。',
  430. '避免因错过了截止时间忘记下单,造成公积金断缴的,建议一次性购买多个月份。若有新的工作单位,未缴费的月份可申请退款。',
  431. '每年政府会调整公积金缴费基数,我们会在第一时间通知您。若因政府调整通知滞后导致划扣金额不准确的,我们承诺多退少补,童叟无欺。',
  432. '本套餐适合于16岁至法定退休年龄之间的用户购买。']
  433. tips.question = { t: '公积金购买常见问题', c: [
  434. '付款成功后,一般什么时候可以查询公积金缴费情况呢?',
  435. ['当月下单截止后,专员会开始进行跟进。\n如有异常,则会通过信息或电话通知您;没有通知则表示正常操作,一般可于','次月1日-15日查询','缴费情况。'],
  436. '如果公积金缴费没有成功,你们会给予退款么?',
  437. '会的,因您自身原因办理不成功,或符合申请退款条件的,则可退款。但支付宝或微信平台收取0.6%的手续费需由您承担。\n退款一般会于月底或次月初前原路退还给您。',
  438. '缴存公积金后,会有公积金对账薄/卡么?',
  439. '首次缴存公积金,仅少数城市默认办理公积金对账薄/卡(如湛江、佛山、汕头)。\n不出对账薄 / 卡的城市,您本人可以去有公积金业务的银行,办理公积金联名卡。'
  440. ], ids: ['questionLeft1', 'questionRight1', 'questionLeft2', 'questionRight2', 'questionLeft3', 'questionRight3'], height: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }
  441. this.data.ui.tips = tips
  442. wx.setNavigationBarTitle({
  443. title: title
  444. })
  445. var cityData = [publicData.purchaseCity.p, publicData.purchaseCity[(publicData.purchaseCity.p)[0].id]]
  446. this.data.adapter = {
  447. suffix: sysT.suffixOfClass(),
  448. isSupplementaryPay: order.isSupplementaryPay,
  449. banner: order.isSupplementaryPay ? '../../../../icon/home/a_s_banner.png' : '../../../../icon/home/a_p_banner.png',
  450. title: '自助缴公积金,方便快捷,全面优质服务',
  451. leftButton: '一键续缴',
  452. rightButton: '立即缴存',
  453. city: {
  454. t: '缴存城市',
  455. c: this.data.choseCity.name,
  456. d: cityData,
  457. v: [0, 0],
  458. des: ''
  459. },
  460. charge: 0,
  461. count: 10000,
  462. //客服需要的
  463. isLogin: false,
  464. userInfo: {
  465. avatarUrl: ''
  466. },
  467. params: {
  468. }
  469. }
  470. this.setData({
  471. choseCity: this.data.choseCity,
  472. adapter: this.data.adapter,
  473. ui: this.data.ui,
  474. limit: this.data.limit,
  475. showContactHeight: sysT.suffixOfClass() == '-X' ? 0 : -68
  476. })
  477. this.getData(this.data.choseCity.id)
  478. },
  479. /**
  480. * 生命周期函数--监听页面初次渲染完成
  481. */
  482. onReady: function () {
  483. // var order = p.getOrder()
  484. // if (order.isSupplementaryPay) {
  485. // app.purchase.purchaseDataArray = app.purchase.supplementaryPurchaseDataArray
  486. // } else {
  487. // app.purchase.purchaseDataArray = app.purchase.normalPurchaseDataArray
  488. // }
  489. // var purchaseArray = app.purchase.purchaseDataArray
  490. // if (purchaseArray.length > 0) {
  491. // var purchase = purchaseArray[0]
  492. // if (purchase.city_code == this.data.choseCity.id && purchase.pack == 1) {
  493. // app.purchase.purchaseData = purchase
  494. // this.handleData()
  495. // } else {
  496. // app.purchase.purchaseDataArray = []
  497. // app.purchase.purchaseData = null
  498. // this.getData(this.data.choseCity.id)
  499. // }
  500. // } else {
  501. // this.getData(this.data.choseCity.id)
  502. // }
  503. },
  504. /**
  505. * 生命周期函数--监听页面显示
  506. */
  507. onShow: function () {
  508. //客服
  509. this.data.adapter.isLogin = app.loginStatus.isLogin
  510. this.data.adapter.userInfo.nickName = app.globalData.userInfo.phone
  511. this.data.adapter.params.phone = app.globalData.userInfo.phone
  512. this.data.adapter.params.userId = app.globalData.userInfo.uid
  513. this.setData({
  514. adapter: this.data.adapter
  515. })
  516. if (this.data.isFirstLoad) {
  517. this.data.isFirstLoad = false
  518. return
  519. }
  520. var order = p.getOrder()
  521. this.data.choseCity = { name: order.cityName, id: order.city }
  522. this.handleData()
  523. businessT.debugLog(this.data.tips)
  524. },
  525. /**
  526. * 生命周期函数--监听页面隐藏
  527. */
  528. onHide: function () {
  529. },
  530. /**
  531. * 生命周期函数--监听页面卸载
  532. */
  533. onUnload: function () {
  534. },
  535. /**
  536. * 页面相关事件处理函数--监听用户下拉动作
  537. */
  538. onPullDownRefresh: function () {
  539. },
  540. /**
  541. * 页面上拉触底事件的处理函数
  542. */
  543. onReachBottom: function () {
  544. },
  545. /**
  546. * 用户点击右上角分享
  547. */
  548. onShareAppMessage: function () {
  549. return {
  550. path: '/page/home/index',
  551. imageUrl: '../../../../icon/public/share_img.png',
  552. title: '自助缴社保公积金,覆盖200多个城市,专业团队操作'
  553. }
  554. }
  555. })