123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- var app = getApp()
- import Net from '../../../tool/net.js'
- var net = new Net()
- var key = require('../../../constant/key.js')
- var url = require('../../../constant/url.js')
- var sysT = require('../../../tool/sys-tool.js')
- Page({
- // 页面的初始数据
- data: {
- canTake: true
- },
- goBack() {
- swan.navigateBack();
- },
- choosePic() {
- swan.chooseImage({
- count: 1,
- sizeType: ['original'],
- sourceType: ['album'],
- success: res => {
- swan.showLoading({
- title: '上传中...',
- mask: true,
- })
- swan.compressImage({
- src: res.tempFilePaths[0],
- quality: 70,
- success: e => {
- if (this.data.status == 'edit') {
- if (this.data.imgStatus == 'front') {
- net.uploadImage({
- url: url.www_host + url.uploadIdcardById,
- imgPath: e.tempFilePath,
- imgName: 'file1',
- data: { sbuId: this.data.id, pos: 0 },
- success: (err, res) => {
- swan.hideLoading();
- app.idCard.front = url.img_host + res.data + '?' + new Date()
- swan.navigateBack()
- },
- fail: (err, res) => {
- swan.hideLoading();
- swan.showToast({
- title: '上传失败',
- icon: 'none',
- });
- swan.navigateBack()
- }
- }, true)
- } else {
- net.uploadImage({
- url: url.www_host + url.uploadIdcardById,
- imgPath: e.tempFilePath,
- imgName: 'file2',
- data: { sbuId: this.data.id, pos: 1 },
- success: (err, res) => {
- swan.hideLoading();
- app.idCard.back = url.img_host + res.data + '?' + new Date()
- swan.navigateBack()
- },
- fail: (err, res) => {
- swan.hideLoading();
- swan.showToast({
- title: '上传失败',
- icon: 'none',
- });
- swan.navigateBack()
- }
- }, true)
- }
- } else {
- if (this.data.imgStatus == 'front') {
- net.uploadImage({
- url: url.www_host + url.uploadIdcardByNumber,
- imgPath: e.tempFilePath,
- imgName: 'file1',
- data: { id_card: this.data.idCard, pos: 0 },
- success: (err, res) => {
- swan.hideLoading();
- app.idCard.front = url.img_host + res.data + '?' + new Date()
- swan.navigateBack()
- },
- fail: (err, res) => {
- swan.hideLoading();
- swan.showToast({
- title: '上传失败',
- icon: 'none',
- });
- swan.navigateBack()
- }
- }, true)
- } else {
- net.uploadImage({
- url: url.www_host + url.uploadIdcardByNumber,
- imgPath: e.tempFilePath,
- imgName: 'file2',
- data: { id_card: this.data.idCard, pos: 1 },
- success: (err, res) => {
- swan.hideLoading();
- app.idCard.back = url.img_host + res.data + '?' + new Date()
- swan.navigateBack()
- },
- fail: (err, res) => {
- swan.hideLoading();
- swan.showToast({
- title: '上传失败',
- icon: 'none',
- });
- swan.navigateBack()
- }
- }, true)
- }
- }
- }
- })
- },
- })
- },
- takePhoto() {
- const ctx = swan.createCameraContext();
- // 成像质量,值为high, normal, low,默认normal。
- ctx.takePhoto({
- quality: 'low',
- success: (res) => {
- app.idCard.loaclPath = res.tempImagePath
- swan.navigateTo({
- url: '../change-photo/change-photo?type=' + this.data.imgStatus + '&idCard=' + this.data.idCard + '&id=' + this.data.id + '&status=' + this.data.status
- })
- }
- })
- this.setData({ canTake: false })
- },
- // 页面的生命周期函数 – 监听页面加载
- onLoad(res) {
- sysT.adaptor()
- var cameraHeight = sysT.usableHeight(316)//相机可是高度rpx
- var widthBorder = 40 * sysT.rpxToPx()//取景框横边距
- var borderWidth = sysT.sysInfo().windowWidth - widthBorder * 2//取景框宽
- var borderHeight = borderWidth / 1.58//取景框高
- var heightBorder = (cameraHeight * sysT.rpxToPx() - borderHeight) / 2//取景框竖边距
- var border = 'width:' + borderWidth + 'px;height:' + borderHeight + 'px;top:' + heightBorder + 'px;left:' + widthBorder + 'px;'
- this.data.adapter = {
- suffix: sysT.suffixOfClass(),
- cameraHeight: cameraHeight,
- border: border
- }
- this.setData({
- adapter: this.data.adapter,
- imgStatus: res.type,
- idCard: res.idCard,
- status: res.status,
- id: res.id
- })
- },
- // 页面的生命周期函数 – 监听页面初次渲染完成
- onReady(res) {
- },
- // 页面的生命周期函数 – 监听页面显示
- onShow(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('设置失败');
- },
- })
- this.setData({ canTake: true })
- },
- // 页面的生命周期函数 – 监听页面隐藏
- onHide(res) {
- },
- // 页面的生命周期函数 – 监听页面卸载
- onUnload(res) {
- },
- // 页面的生命周期函数 – 监听页面重启,单击重启按钮时触发
- onForceReLaunch(res) {
- },
- // 页面的事件处理函数 – 监听用户下拉动作
- onPullDownRefresh(res) {
- },
- // 页面的事件处理函数 – 上拉触底事件的处理函数
- onReachBottom(res) {
- },
- // 页面的事件处理函数 – 用户点击右上角转发
- onShareAppMessage(res) {
- },
- // 页面的事件处理函数 – 页面滚动触发事件的处理函数
- onPageScroll(res) {
- },
- // 页面的事件处理函数 – 当前是 tab 页时,点击 tab 时触发
- onTabItemTap(res) {
- }
- });
|