123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386 |
- var sysT = require('../../../../tool/sys-tool.js')
- var verify = require('../../../../tool/verify.js')
- var businessT = require('../../../../tool/business-tool.js')
- var businessType = require('../../../../public/business-type.js')
- var purchaseO = require('../../public/model/purchaseOrder.js')
- var p = require('../../public/model/public.js')
- var url = require('../../../../constant/url.js')
- import Net from '../../../../tool/net.js'
- var net = new Net()
- var app = getApp()
- //input是原生组件会覆盖非原生组件
- var inputViewS = [
- { id: '1', title: '真实姓名', p: '请输入参保人姓名', l: '16', t: 'text', h: false },
- { id: '2', title: '民族', p: '请输入民族', l: '16', t: 'text', h: false },
- { id: '3', title: '身份证号', p: '请输入身份证号', l: '18', t: 'idcard', h: false },
- { id: '5', title: '户籍地址', p: '请输入身份证户籍地址', l: '100', t: 'text', h: false ,textarea: true },
- { id: '4', title: '手机号码', p: '请输入联系方式', l: '11', t: 'number', h: false, interval: true}
- ]
- // var inputViewH = [
- // { title: '真实姓名', h: true },
- // { title: '民族', h: true },
- // { title: '身份证号', h: true },
- // { title: '手机号码', h: true }
- // ]
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- adapter: {
- bgHeight: '',
- suffix: ''
- },
- inputView: [],
- scroll: true,
- requireView: {
- animation: {},
- hidden: true
- },
- idCard:{
- currentChose: '1',
- front: { id: 1, i: '../../../../icon/home/idcard_front.png', c: '上传身份证正面' },
- back: { id: 2, i: '../../../../icon/home/idcard_back.png', c: '上传身份证背面' }
- },
- },
- hiddenRequireView:businessT.action(function (sender) {
- var animation = wx.createAnimation({
- duration: 300,
- timingFunction: 'ease',
- })
- animation.bottom('-800rpx').step()
- this.setData({
- requireView: {
- animation: animation.export(),
- hidden: false
- }
- })
- setTimeout(function () {
- this.data.requireView.hidden = true
- this.data.inputView[3].h = false
- this.setData({
- requireView: this.data.requireView,
- inputView: this.data.inputView,
- scroll: true
- })
- }.bind(this), 300)
- }),
- requireAction:businessT.action(function (sender) {
- if (!this.data.requireView.hidden) {
- return
- }
- this.data.requireView.hidden = false
- this.data.inputView[3].h = true
- this.setData({
- requireView: this.data.requireView,
- scroll: false,
- inputView: this.data.inputView,
- })
- var animation = wx.createAnimation({
- duration: 300,
- timingFunction: 'ease',
- })
- animation.bottom('0rpx').step()
- this.setData({
- requireView: {
- animation: animation.export(),
- hidden: false
- }
- })
- }),
- toTakePhoto: function (id) {
- this.data.idCard.currentChose = id
- wx.navigateTo({
- url: '../../../../public/pages/take-photo/take-photo',
- })
- },
- photographAction: businessT.action(function (sender) {
- businessT.debugLog(sender.currentTarget.id)
- this.toTakePhoto(sender.currentTarget.id)
-
- }),
- imageAction: businessT.action(function (sender) {
- businessT.debugLog(sender)
- var order = p.getOrder()
- if (sender.currentTarget.id == '1' && order.imageDict.first != '') {
- wx.previewImage({
- urls: [order.imageDict.first],
- })
- } else if (sender.currentTarget.id == '2' && order.imageDict.second != '') {
- wx.previewImage({
- urls: [order.imageDict.second],
- })
- } else {
- this.toTakePhoto(sender.currentTarget.id)
- }
- }),
-
- finishTakePhoto: function(path) {
- var order = p.getOrder()
- if (this.data.idCard.currentChose == '1') {
- this.data.idCard.front.i = path
- order.imageDict.first = path
- this.setData({
- idCard: this.data.idCard
- })
- } else if (this.data.idCard.currentChose == '2') {
- this.data.idCard.back.i = path
- order.imageDict.second = path
- this.setData({
- idCard: this.data.idCard
- })
- }
- },
- formSubmit: businessT.action(function (sender) {
- businessT.debugLog(sender)
- var order = p.getOrder()
- if (order.imageDict.first == '') {
- wx.showToast({
- title: '请拍摄身份证正面',
- icon: 'none'
- })
- } else if (order.imageDict.second == '') {
- wx.showToast({
- title: '请拍摄身份证反面',
- icon: 'none'
- })
- } else if (sender.detail.value['1'].length <= 1) {
- wx.showToast({
- title: '请正确输入姓名',
- icon: 'none'
- })
- } else if (sender.detail.value['2'] == '') {
- wx.showToast({
- title: '请输入民族',
- icon: 'none'
- })
- } else if (sender.detail.value['3'].length != 18 || !verify.isIdentityCard(sender.detail.value['3'])) {
- wx.showToast({
- title: '请填写正确的身份证号',
- icon: 'none'
- })
- } else if (verify.getIdentityCardAge(sender.detail.value['3']) >= 60) {
- wx.showToast({
- title: '暂时只受理60岁以下用户哦',
- icon: 'none'
- })
- } else if (sender.detail.value['5'] == '') {
- wx.showToast({
- title: '请正确输入户籍地址',
- icon: 'none'
- })
- } else if (sender.detail.value['4'].length != 11 || !verify.isPhoneNum(sender.detail.value['4'])) {
- wx.showToast({
- title: '请填写正确的手机号',
- icon: 'none'
- })
- } else {
- order.customerData = {
- 'user_name': sender.detail.value['1'],
- 'id_card': sender.detail.value['3'],
- 'nation': sender.detail.value['2'],
- 'gender': verify.getIdentityCardGender(sender.detail.value['3']),
- 'phone': sender.detail.value['4'],
- 'hk_address': sender.detail.value['5'],
- 'sbuId': ''
- }
- order.isNewCustomer = true
- this.uploadImage()
- businessT.debugLog(order.customerData)
- }
- }),
- uploadImage: function() {
- wx.showLoading({
- title: '正在生成参保人',
- mask: true
- })
- this.uploadFirstImage()
- },
- uploadFirstImage: function() {
- 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) => {
- this.uploadSecondImage(res.data)
- },
- fail: (err, res) => {
- wx.hideLoading()
- businessT.showFailTips(err, '生成参保人信息失败')
- }
- }, true)
- },
- uploadSecondImage: function(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) => {
- this.uploadCustomerImformation(firstPath, res.data)
- },
- fail: (err, res) => {
- wx.hideLoading()
- businessT.showFailTips(err, '生成参保人信息失败')
- }
- }, true)
- },
- uploadCustomerImformation: function(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) => {
- this.modifyCustomerNetworkGetData(res.data.id)
- },
- fail: (err, res) => {
- wx.hideLoading()
- businessT.showFailTips(err, '生成参保人信息失败')
- }
- })
- },
- modifyCustomerNetworkGetData: function(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)
- }
- if (order.purchaseType == businessType.PurchaseType.socialInsurance || order.purchaseType == businessType.PurchaseType.socialInsurancePackage) {
- wx.navigateTo({
- url: '../purchase-s-imformation/purchase-s-imformation',
- })
- } else {
- wx.navigateTo({
- url: '../purchase-a-imformation/purchase-a-imformation',
- })
- }
- },
- wxvoid: function () {
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- sysT.adaptor()
- businessT.debugLog(sysT.usableHeight(112))
- this.data.adapter = {
- bgHeight: sysT.usableHeight(112),
- suffix: sysT.suffixOfClass(),
- }
-
- this.data.inputView = inputViewS
- var isIos = sysT.sysInfo().system.indexOf("iOS") == 0
- this.data.inputView[3].isIos = isIos
- this.setData({
- adapter: this.data.adapter,
- inputView: this.data.inputView
- })
- var order = p.getOrder()
- order.customerData = {
- 'user_name': '',
- 'id_card': '',
- 'nation': '',
- 'gender': '',
- 'phone': '',
- 'sbuId': ''
- }//参保人(购买人)信息
- order.imageDict = {
- 'first': '',
- 'second': ''
- }//身份证照图片
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
- /**
- * 用户点击右上角分享
- */
- // onShareAppMessage: function () {
-
- // }
- })
|