123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- var sysT = require('../../../tool/sys-tool.js')
- var businessT = require('../../../tool/business-tool.js')
- var url = require('../../../constant/url.js')
- import Net from '../../../tool/net.js'
- var net = new Net()
- var p = require('../../../page/home/public/model/public.js')
- import PurchaseOrder from '../../../page/home/public/model/purchaseOrder.js'
- var businessType = require('../../business-type.js')
- var app = getApp()
- var publicData = require('../../../constant/data.js')
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- type: 'nPurchase',
- businessType: 's',//快速购买用
- header: {
- t: '',
- s: ''
- },
- adapter: {
- suffix: ''
- },
- data: [],
- chose: '0'
- },
- nextStep: businessT.action(function (sender) {
- businessT.debugLog(app.globalData.customerList[this.data.chose])
- var customer = app.globalData.customerList[this.data.chose]
- if (this.data.type == 'nPurchase') {
- var order = p.getOrder()
- order.customerData = {
- 'user_name': customer.user_name,
- 'id_card': customer.id_card,
- 'nation': customer.nation,
- 'gender': customer.gender,
- 'phone': customer.phone,
- 'sbuId': customer.id
- }
- order.isNewCustomer = false
- if (order.purchaseType == businessType.PurchaseType.socialInsurance || order.purchaseType == businessType.PurchaseType.socialInsurancePackage) {
- wx.navigateTo({
- url: '../../../page/home/pages/purchase-s-imformation/purchase-s-imformation',
- })
- } else {
- wx.navigateTo({
- url: '../../../page/home/pages/purchase-a-imformation/purchase-a-imformation',
- })
- }
- } else {
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- businessT.debugLog(p.getOrder())
- net.connectNeedLogin({
- url: url.app_host + url.getQuickPurchaseData,
- data: {
- sbuId: customer.id,
- pay_for: this.data.businessType == 's' ? 1 : 2
- },
- success: (err, res) => {
- if (!res.data.buyShebao && res.data.fund_price == 0) {
- wx.hideLoading()
- var order = p.getOrder()
- var title = '此购买人没有成功下单记录哦,请返回选择“立即' + (order.purchaseType == businessType.PurchaseType.socialInsurance ? '参保”' : '缴存”')
- wx.showToast({
- title: title,
- icon: 'none'
- })
- } else {
- this.handleQuickPurchaseData(res.data, customer)
- }
- },
- fail: (err, res) => {
- wx.hideLoading()
- businessT.showFailTips(err, '加载失败')
- }
- }, true)
- }
-
- }),
- handleQuickPurchaseData: function (data, customer) {
- var p_code = Number(String(data.city_code).slice(0, 2) + '00')
- var citys = publicData.purchaseCity[p_code]
- var cityName = null
- for (var index in citys) {
- if (data.city_code == citys[index].id) {
- cityName = citys[index].name
- break
- }
- }
- if (!cityName) {
- wx.hideLoading()
- businessT.showFailTips({
- code: 0,
- msg: ''}, '加载失败')
- return
- }
- businessT.debugLog(cityName)
- var order = new PurchaseOrder()
- order.isNewCustomer = false
- order.city = data.city_code
- order.cityName = cityName
- order.accountType = data.hukou_type
- order.customerData = {
- 'user_name': customer.user_name,
- 'id_card': customer.id_card,
- 'nation': customer.nation,
- 'gender': customer.gender,
- 'phone': customer.phone,
- 'sbuId': customer.id
- }
- order.beginTime = String(data.start_month).slice(0,4) + '年' + String(data.start_month).slice(4, 6) + '月'
- order.accumulationFund = data.fund_price
- order.id = data.cid
- if (this.data.businessType == 's' && data.fund_price != 0) {
- order.pack = true
- order.purchaseType = businessType.PurchaseType.socialInsurancePackage
- } else if (this.data.businessType == 'a' && data.buyShebao) {
- order.pack = true
- order.purchaseType = businessType.PurchaseType.accumulationFundPackage
- } else {
- order.pack = false
- order.purchaseType = this.data.businessType == 's' ? businessType.PurchaseType.socialInsurance : businessType.PurchaseType.accumulationFund
- }
- app.purchase.order = order
- if ((this.data.businessType == 'a' && !order.pack) || !data.mutli_cid) {
- var showCity = cityName
- } else {
- var showCity = cityName + '(' + data.cid_name + ')'
- }
- wx.hideLoading()
- var isNeedSalary = 0
- if (data.wage_flow) {
- isNeedSalary = 1
- }
- wx.navigateTo({
- url: '../../../page/home/pages/quick-purchase/quick-purchase?businessType=' + this.data.businessType + '&cityName=' + showCity + '&minMonths=' + data.min_months + '&beginTime=' + order.beginTime + '&isNeedSalary=' + isNeedSalary,
- })
- },
- chooseAction: businessT.action(function (sender) {
- businessT.debugLog(this.data.chose)
- businessT.debugLog(sender.currentTarget.id)
- if (this.data.chose == sender.currentTarget.id) {
- return
- }
- businessT.debugLog(this.data.data)
- businessT.debugLog(sender.currentTarget.id)
- this.data.data[this.data.chose].img = 'filter_n.png'
- this.data.data[sender.currentTarget.id].img = 'filter_s.png'
- this.data.chose = sender.currentTarget.id
- this.setData({
- data: this.data.data
- })
- }, 100),
- editAction: businessT.action(function (sender) {
- businessT.debugLog(sender.currentTarget.id)
- wx.navigateTo({
- url: '../edit-customer/edit-customer?i=' + sender.currentTarget.id,
- })
- }),
- deleteAction: businessT.action(function (sender) {
- businessT.debugLog(sender.currentTarget.id)
- var that = this
- wx.showModal({
- title: '删除后将无法恢复',
- content: '是否删除TA',
- confirmText: '删除',
- cancelText: '取消',
- confirmColor: '#3296FB',
- cancelColor: '#3296FB',
- success: function (res) {
- if (res.confirm) {
- that.deleteCustomer(sender.currentTarget.id)
- }
- }
- })
- }),
- deleteCustomer: function (i) {
- var customer = this.data.data[i]
- this.data.data.splice(Number(i), 1)
- app.globalData.customerList.splice(Number(i), 1)
- this.setData({
- data: this.data.data
- })
- net.connectNeedLogin({
- url: url.app_host + url.deleteCustomer,
- data: {
- id: customer.id
- },
- success: (err, res) => {
- },
- fail: (err, res) => {
- }
- })
- },
- newCustomerAction: businessT.action(function (sender) {
- businessT.debugLog('newCustomerAction')
- wx.navigateTo({
- url: '../../../page/home/pages/new-customer/new-customer',
- })
- }),
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- if (options.type) {
- this.data.type = options.type
- }
- if (options.businessType) {
- this.data.businessType = options.businessType
- }
- wx.setNavigationBarTitle({
- title: this.data.type == 'manager' ? '人员管理' : '选择人员'
- })
- if (this.data.type == 'manager') {
- this.data.header = {
- t: '人员信息管理',
- s: '可对人员信息进行编辑、查看、删除'
- }
- } else {
- this.data.header = {
- t: '选择人员',
- s: '系统会默认上次最后购买的人'
- }
- }
- this.data.adapter = {
- suffix: sysT.suffixOfClass(),
- }
- var list = []
- for (var i in app.globalData.customerList) {
- var item = app.globalData.customerList[i]
- if (i == 0) {
- item.img = 'filter_s.png'
- } else {
- item.img = 'filter_n.png'
- }
- var h = ''
- if (item.user_name.length > 2) {
- h = item.user_name.substr(item.user_name.length - 2, 2)
- } else {
- h = item.user_name
- }
- item.h = h
- list.push(item)
- }
- this.data.data = list
- this.setData({
- adapter: this.data.adapter,
- type: this.data.type,
- header: this.data.header,
- data: this.data.data
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- return {
- path: '/page/home/index',
- imageUrl: '../../../icon/public/share_img.png',
- title: '自助缴社保公积金,覆盖200多个城市,专业团队操作'
- }
- }
- })
|