123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- import Net from '../../../../tool/net.js'
- var net = null
- var url = require('../../../../constant/url.js')
- var p = require('../model/public.js')
- var businessType = require('../../../../public/business-type.js')
- var businessT = require('../../../../tool/business-tool.js')
- var isS = true
- var _reload = null
- var app = getApp()
- var _shebao = 0
- var _cardCharge = 0
- function setOut (i) {
- net = new Net()
- isS = i
- }
- function finish () {
- net = null
- }
- function handleImformation (reload) {
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- _reload = reload
- var order = p.getOrder()
- getBuyTotalFee()
- // if (order.customerData.sbuId && order.customerData.sbuId != '') {
- // getBuyTotalFee()
- // } else {
- // uploadImage()
- // }
- }
- // function uploadImage () {
- // uploadFirstImage()
- // }
- // function uploadFirstImage() {
- // var order = p.getOrder()
- // net.uploadImage({
- // url: url.www_host + url.uploadIdcardByNumber,
- // imgPath: order.imageDict.first,
- // imgName: 'file1',
- // data: { id_card: order.customerData.id_card, pos: 0 },
- // success: (err, res) => {
- // uploadSecondImage(res.data)
- // },
- // fail: (err, res) => {
- // wx.hideLoading()
- // businessT.showFailTips(err, '生成参保人信息失败')
- // }
- // }, true)
- // }
- // function uploadSecondImage(firstPath) {
- // var order = p.getOrder()
- // net.uploadImage({
- // url: url.www_host + url.uploadIdcardByNumber,
- // imgPath: order.imageDict.second,
- // imgName: 'file2',
- // data: { id_card: order.customerData.id_card, pos: 1 },
- // success: (err, res) => {
- // uploadCustomerImformation(firstPath, res.data)
- // },
- // fail: (err, res) => {
- // wx.hideLoading()
- // businessT.showFailTips(err, '生成参保人信息失败')
- // }
- // }, true)
- // }
- // function uploadCustomerImformation (fp, sp) {
- // businessT.debugLog(fp)
- // businessT.debugLog(sp)
- // var order = p.getOrder()
- // var data = order.customerData
- // data.id_card_img = fp
- // data.id_card_img1 = sp
- // net.connectNeedLogin({
- // url: url.app_host + url.modifyCustomer,
- // data: data,
- // success: (err, res) => {
- // modifyCustomerNetworkGetData(res.data.id)
- // getBuyTotalFee()
- // },
- // fail: (err, res) => {
- // wx.hideLoading()
- // businessT.showFailTips(err, '生成参保人信息失败')
- // }
- // })
- // }
- // function modifyCustomerNetworkGetData (id) {
- // var order = p.getOrder()
- // order.customerData.sbuId = id
- // order.customerData.id = id
- // order.customerData.id_card_img = null
- // order.customerData.id_card_img1 = null
- // order.customerData.id_card = String(order.customerData.id_card).slice(0, 2) + '**************' + String(order.customerData.id_card).slice(16, 18)
- // var isNew = true
- // for (var i in app.globalData.customerList) {
- // var customer = app.globalData.customerList[i]
- // if (customer.id == order.customerData.id) {
- // order.customerData.shebao_card = customer.shebao_card
- // order.customerData.fund_card = customer.fund_card
- // app.globalData.customerList[i] = order.customerData
- // isNew = false
- // break
- // }
- // }
- // if (isNew) {
- // app.globalData.customerList.push(order.customerData)
- // }
- // }
- function calculateBuyTotalFee(o) {
- var order = p.getOrder()
- var path = order.isSupplementaryPay ? url.getTotalSupplementaryPayFee : url.getTotalFee
- var obj = {
- sbuId: order.customerData.sbuId,
- cid: order.id,
- shebao_card: order.SSCard,
- hukou_type: order.accountType,
- month: businessT.changeTimeToNumber(order.beginTime),
- fund: '0',
- nums: order.timeInterval,
- pay_for: businessType.PurchasePayFor.socialInsurance
- }
- net.connectNeedLogin({
- url: url.app_host + path,
- data: obj,
- success: (err, res) => {
- wx.hideLoading()
- setTotal(res.data)
- o.success(res.data)
- },
- fail: (err, res) => {
- wx.hideLoading()
- if (err.code == businessType.NetworkErrorCode.netwrokMiss) {
- o.failure(err)
- businessT.showFailTips(err, '切换失败')
- return
- }
- setTotal(null)
- o.success(null)
-
- }
- }, true)
- }
- function setTotal(data) {
- if (data) {
- _shebao = Number(data.shebao).toFixed(2)
- _cardCharge = String(data.card_charge)
- businessT.debugLog('you')
- } else {
- var order = p.getOrder()
- var purchase = app.purchase.purchaseData
- _cardCharge = order.SSCard == 0 ? 0 : app.purchase.purchaseData.shebao_card_charge
- var shebao = 0
- if (purchase.shebaos && Object.prototype.toString.call(purchase.shebaos) == '[object Array]') {
- var arr = purchase.shebaos[order.accountType - 1].data
- for (var index in arr) {
- var item = arr[index]
- shebao += Number(item.p)
- }
- }
- _shebao = (shebao * order.timeInterval).toFixed(2)
- businessT.debugLog('meiyou')
- }
- }
- function getTotal() {
- return [_shebao, _cardCharge]
- }
- function getBuyTotalFee() {
- var order = p.getOrder()
- if (isS) {
- order.payFor = order.pack ? businessType.PurchasePayFor.socialInsurancePackage : businessType.PurchasePayFor.socialInsurance
- var fund = order.pack ? Number(order.accumulationFund) : 0
- } else {
- order.payFor = order.pack ? businessType.PurchasePayFor.accumulationFundPackage : businessType.PurchasePayFor.accumulationFund
- var fund = Number(order.accumulationFund)
- }
- var path = order.isSupplementaryPay ? url.getTotalSupplementaryPayFee : url.getTotalFee
- var obj = {
- sbuId: order.customerData.sbuId,
- cid: order.id,
- shebao_card: order.SSCard,
- hukou_type: order.accountType,
- month: businessT.changeTimeToNumber(order.beginTime),
- fund: fund,
- nums: order.timeInterval,
- pay_for: order.payFor
- }
- net.connectNeedLogin({
- url: url.app_host + path,
- data: obj,
- success: (err, res) => {
- order.totalFee = res.data
- if (order.payFor == businessType.PurchasePayFor.socialInsurance) {
- goToOrder()
- } else {
- getFundOfBuyBefore()
- }
- },
- fail: (err, res) => {
- wx.hideLoading()
- businessT.showFailTips(err, '生成参保人信息失败')
- }
- }, true)
- }
- function getFundOfBuyBefore() {
- var order = p.getOrder()
- net.connectNeedLogin({
- url: url.app_host + url.getFundOfBuyBefore,
- data: {
- sbuId: order.customerData.sbuId,
- city_code: order.city
- },
- success: (err, res) => {
- var fund = Number(res.data)
- if (fund != 0 && Number(order.accumulationFund) - fund > 0) {
- wx.hideLoading()
- wx.showModal({
- title: '',
- content: '你最近一次缴公积金金额为' + fund + '元,若非系统调整请不要随意更改',
- confirmColor: '#3296FB',
- cancelColor: '#3296FB',
- confirmText: '返回修改',
- cancelText: '继续购买',
- success: function (res) {
- if (res.confirm) {
- _reload(fund)
- } else if (res.cancel) {
- goToOrder()
- }
- }
- })
- } else if (fund != 0 && Number(order.accumulationFund) - fund < 0) {
- wx.hideLoading()
- wx.showModal({
- title: '',
- content: '你最近一次缴公积金金额为' + fund + '元,若非系统调整请不要随意更改',
- confirmColor: '#3296FB',
- cancelColor: '#3296FB',
- confirmText: '我知道了',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- _reload(fund)
- }
- }
- })
- } else {
- goToOrder()
- }
- },
- fail: (err, res) => {
- wx.hideLoading()
- businessT.showFailTips(err, '生成参保人信息失败')
- }
- })
- }
- function goToOrder() {
- wx.hideLoading()
- var order = p.getOrder()
- var app = getApp()
- app.purchase.order = order
- wx.navigateTo({
- url: '../pay-order/pay-order',
- })
- }
- module.exports = {
- setOut: setOut,
- finish: finish,
- handleImformation: handleImformation,
- calculateBuyTotalFee: calculateBuyTotalFee,
- getTotal: getTotal
- }
|