123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- var businessT = require('../../../tool/business-tool.js')
- var sysT = require('../../../tool/sys-tool.js')
- var url = require('../../../constant/url.js')
- import Net from '../../../tool/net.js'
- var net = new Net()
- var app = getApp()
- var wxyj = require('../../../public/wxyj.js')
- Page({
- data: {
- cheapMoney: 0,
- cheapCount: 0,
- cheapStatus: '未使用',
- cheapData: []
- },
- initData(res) {
- var order = wxyj.wxyjData.order, date, userIndex, sy, sm, ey, em
- sy = Number(order.month.substring(0, 4))
- sm = Number(order.month.slice(-2))
- ey = sy
- em = sm
- res.nums = Number(res.nums)
- if (res.nums == 1) {
- date = sy + '年' + sm + '月'
- } else {
- console.log(sm + res.nums)
- if (sm + res.nums > 13) {
- ey += 1
- em = sm + res.nums - 13
- } else if (sm + res.nums == 13) {
- em = 12
- } else {
- em = sm + res.nums - 1
- }
- // if (sy == ey) {
- // date = sy + '年' + sm + '月-' + em + '月'
- // } else {
- date = sy + '年' + sm + '月-' + ey + '年' + em + '月'
- // }
- }
- app.globalData.customerList.forEach((item, index) => {
- if (item.id == order.sbuId) {
- userIndex = index
- }
- })
- this.setData({
- res,
- date,
- newCard: wxyj.wxyjData.order.newCard,
- name: app.globalData.customerList[userIndex].user_name,
- idcard: app.globalData.customerList[userIndex].id_card,
- card_charge: res.price.card_charge.toFixed(2),
- service: (res.price.f_charge + res.price.s_charge).toFixed(2),
- shebao: res.price.shebao.toFixed(2),
- fund: res.price.fund.toFixed(2),
- totalPrice: res.price.total_fee.toFixed(2)
- })
- var totalPrice = String((this.data.totalPrice - this.data.cheapMoney).toFixed(2))
- var totalPriceArr = []
- totalPriceArr[0] = totalPrice.substring(0, totalPrice.length - 2)
- totalPriceArr[1] = totalPrice.slice(-2)
- this.setData({ totalPriceArr })
- },
- goCheap() {
- swan.navigateTo({
- url: '.././../../page/mypage/pages/cheap/cheap?status=choose&nums=' + this.data.res.nums,
- })
- },
- createPayLaterOrder() {
- swan.showLoading({
- title: '正在提交订单',
- mask: true
- })
- var order = wxyj.wxyjData.order
- var path
- if (this.data.res.type == 0 || this.data.res.type == 2) {
- path = url.createPayLaterOrder
- } else {
- path = url.createLaterSupplementaryPayOrder
- }
- var obj = this.getParameters()
- net.connectNeedLogin({
- url: url.app_host + path,
- data: obj,
- success: (err, res) => {
- swan.hideLoading()
- swan.switchTab({
- url: '../../../page/mypage/index/index',
- success: res => {
- swan.navigateTo({
- url: '../../../page/mypage/pages/pay/pay',
- });
- },
- });
- },
- fail: (err, res) => {
- swan.hideLoading()
- businessT.showFailTips(err, '提交订单失败')
- }
- })
- },
- getParameters: function (par) {
- var order = wxyj.wxyjData.order
- var np = {
- sbuId: order.sbuId,
- id_card: order.id_card,
- cid: order.cid,
- buyShebao: order.buyShebao,
- shebao_card: order.shebao_card ? order.shebao_card : 0,
- hukou_type: order.hukou_type,
- fund: order.fund,
- pay_channel: 13,
- pay_for: order.pay_for,
- couponuser_id: this.data.couponuser_id ? this.data.couponuser_id : '',
- month: order.month,
- nums: order.nums,
- newCard: order.newCard,
- first_sb: order.first_sb,
- first_fund: order.first_fund,
- sb_wage: order.sb_wage,
- working: order.working
- }
- for (var key in par) {
- np[key] = par[key]
- }
- return np
- },
- getDiscountCount() {
- net.connectNeedLogin({
- url: url.app_host + url.getCashCouponCount,
- data: {
- phone: app.globalData.userInfo.phone
- },
- success: (err, res) => {
- console.log(res)
- this.data.cheapCount = res.data.total
- if (this.data.cheapCount == 0) {
- this.data.cheapStatus = '暂无优惠券'
- }
- this.setData({
- cheapCount: this.data.cheapCount
- })
- }
- }, true)
- },
- refreshCheap() {
- var totalPrice = this.data.totalPrice, totalPriceArr = this.data.totalPriceArr, cheapMoney = 0
- if (this.data.cheapData.length) {
- this.data.cheapData.forEach((item) => {
- cheapMoney += item.coupon_price
- })
- cheapMoney = cheapMoney.toFixed(2)
- totalPrice = totalPrice - cheapMoney
- totalPrice = String(totalPrice)
- totalPriceArr[0] = totalPrice.substring(0, totalPrice.length - 2)
- totalPriceArr[1] = totalPrice.slice(-2)
- this.setData({
- cheapStatus: "-¥" + cheapMoney,
- cheapMoney,
- totalPriceArr
- })
- } else {
- this.setData({
- cheapStatus: '未使用',
- cheapMoney: 0
- })
- this.initData(this.data.res)
- }
- },
- payAction() {
- var id = '', path, order = wxyj.wxyjData.order
- this.data.cheapData.forEach((item) => {
- if (item) {
- id += item.id + ','
- }
- })
- if (id) { id = id.slice(0, -1) }
- var obj = this.getParameters({ pay_channel: 13, couponuser_id: id })
- switch (this.data.res.orderStatus) {
- case '0':
- path = url.createShebaoOrder
- break
- case '1':
- path = url.createShebaoSupplementaryPayOrder
- break
- case '2':
- path = url.createFundOrder
- break
- case '3':
- path = url.createFundSupplementaryPayOrder
- break
- }
-
- net.connectNeedLogin({
- url: url.app_host + path,
- data: obj,
- success: (err, res) => {
- swan.requestPolymerPayment({
- orderInfo: res.data,
- success: res => {
- this.needSurvey()
- },
- fail: err => {
- swan.showToast({
- title: '支付失败',
- icon: 'none'
- });
- }
- });
- },
- fail: (err, res) => {
- swan.hideLoading()
- businessT.showFailTips(err, '提交订单失败')
- }
- }, true)
- },
- needSurvey() {
- if(wxyj.wxyjData.order.sb_wage){
- swan.navigateTo({
- url: '../pay-success/pay-success?type=salary'
- });
- return
- }
- net.connectNeedLogin({
- url: url.app_host + url.checkSurvey,
- data: {},
- success: (err, res) => {
- if (res.data) {
- swan.navigateTo({
- url: '../pay-success/pay-success?type=survey&payfor=' + order.pay_for,
- });
- }else{
- this.needRepair()
- }
- },
- fail: (err, res) => {
- swan.navigateTo({
- url: '../pay-success/pay-success?type=share'
- });
- }
- }, false)
- },
- needRepair(){
- net.connectNeedLogin({
- url: url.app_host + url.queryPayPriceDifference,
- data: {},
- success: (err, res) => {
- if(res.data){
- swan.navigateTo({
- url: '../pay-success/pay-success?type=repair'
- });
- }else{
- swan.navigateTo({
- url: '../pay-success/pay-success?type=share'
- });
- }
- },
- fail: (err, res) => {
- swan.navigateTo({
- url: '../pay-success/pay-success?type=share'
- });
- }
- },false)
- },
- onLoad: function (res) {
- // 监听页面加载的生命周期函数
- swan.setPageInfo && swan.setPageInfo({
- title: '【我的社保】官方APP-社保挂靠公积金代理全国自助缴纳查询社保公积金_主页',
- keywords: '我的社保,我的社保网,我的社保APP,社会保障,社保,社保代缴,公积金代缴,社会保险,五险一金,医保,医疗保险,公积金,养老,生育,工伤,失业,住房公积金,社保代理,代缴社保,公积金代理,查悦社保,大社保,亲亲小保,社保掌上通,招聘求职,创业,买房,贷款,计算器,人社局,摇号',
- description: '我的社保APP是为个人、企业提供社保代缴代扣、公积金代扣代缴、社保查询、公积金查询服务的名牌产品。解决个体工商户、自由职业者、待业人员、全职妈妈、创业者等的个人社保公积金断缴难题,同时解决贷款, 买房, 买车, 养老, 医疗, 生育, 医疗报销等难题。同时为企业提供全国专业社保代理和公积金代理。',
- articleTitle: '【我的社保】官方APP-社保挂靠公积金代理全国自助缴纳查询社保公积金_主页',
- release_date: '2019-02-23 20:00:00',
- success: function () {
- console.log('页面基础信息设置完成');
- },
- fail: function (res) {
- console.log('设置失败');
- },
- })
- console.log(res)
- res.price = JSON.parse(res.price)
- this.initData(res)
- this.setData({ suffix: sysT.suffixOfClass() })
- this.getDiscountCount()
- },
- onReady: function () {
- // 监听页面初次渲染完成的生命周期函数
- },
- onShow: function () {
- // 监听页面显示的生命周期函数
- this.refreshCheap()
- },
- onHide: function () {
- // 监听页面隐藏的生命周期函数
- },
- onUnload: function () {
- // 监听页面卸载的生命周期函数
- },
- onPullDownRefresh: function () {
- // 监听用户下拉动作
- },
- onReachBottom: function () {
- // 页面上拉触底事件的处理函数
- },
- onShareAppMessage: function () {
- // 用户点击右上角转发
- }
- });
|