9 changed files with 312 additions and 36 deletions
Unified View
Diff Options
-
33app.js
-
1app.json
-
29pages/agent/address/index.js
-
5pages/agent/address/index.wxml
-
101pages/home/certificate/index.js
-
6pages/home/certificate/index.json
-
103pages/home/certificate/index.wxml
-
64pages/home/certificate/index.wxss
-
6project.config.json
@ -0,0 +1,101 @@ |
|||||
|
// pages/home/authory/index.js
|
||||
|
import { getAuthSession, certificateImage } from "../../api/user" |
||||
|
const util = require('../../../utils/util') |
||||
|
const event = require('../../../utils/event.js') |
||||
|
|
||||
|
Page({ |
||||
|
/** |
||||
|
* 页面的初始数据 |
||||
|
*/ |
||||
|
data: { |
||||
|
form: { identityAuthToken: null }, |
||||
|
flag: false, // 是否不可以编辑, false:可编辑;true:不可编辑
|
||||
|
imgList: [null, null] |
||||
|
}, |
||||
|
|
||||
|
onLoad: function (options) { |
||||
|
event.on('EventMessage', this, this.onEvent) |
||||
|
wx.showLoading({ title: '加载中', mask: true }) |
||||
|
getAuthSession().then(result => { |
||||
|
wx.hideLoading() |
||||
|
this.data.form.identityAuthToken = result.data.token |
||||
|
}).catch(error => { |
||||
|
wx.hideLoading() |
||||
|
}) |
||||
|
}, |
||||
|
onEvent: function (message) { |
||||
|
if (message.what == 82) { |
||||
|
wx.navigateBack() |
||||
|
} |
||||
|
}, |
||||
|
submitForm: function () { |
||||
|
if (util.isEmpty(this.data.form.frontImg)) { |
||||
|
util.showToast('请上传身份证正面照片') |
||||
|
return |
||||
|
} |
||||
|
if (util.isEmpty(this.data.form.backImg)) { |
||||
|
util.showToast('请上传身份证背面照片') |
||||
|
return |
||||
|
} |
||||
|
wx.showLoading({ title: '处理中', mask: true }) |
||||
|
certificateImage(this.data.form).then(result => { |
||||
|
wx.hideLoading() |
||||
|
var tokenJson = JSON.stringify(result.data) |
||||
|
wx.setStorageSync('identityAuthToken', tokenJson) |
||||
|
wx.navigateTo({ url: '/pages/home/authory/index' }) |
||||
|
}).catch(error => { |
||||
|
wx.hideLoading() |
||||
|
util.showToast(error) |
||||
|
}) |
||||
|
}, |
||||
|
/*******************************************************图片上传************************************************************/ |
||||
|
chooseImage: function(e) { |
||||
|
if (this.data.flag) { |
||||
|
return |
||||
|
} |
||||
|
var index = e.currentTarget.dataset.index |
||||
|
var that = this |
||||
|
wx.chooseImage({ |
||||
|
count: 1, //默认9
|
||||
|
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
||||
|
sourceType: ['album', 'camera'], //从相册选择
|
||||
|
success: (res) => { |
||||
|
that.setData({ ['imgList[' + index + ']']: res.tempFilePaths[0] }) |
||||
|
const fileSystemManager = wx.getFileSystemManager() |
||||
|
var type = that.suffixImage(res.tempFilePaths[0]) |
||||
|
fileSystemManager.readFile({ |
||||
|
filePath: that.data.imgList[index], // 例如图片临时路径
|
||||
|
encoding: 'base64', |
||||
|
success(res) { |
||||
|
let { data } = res // 编码后的数据
|
||||
|
if(index == 0){ |
||||
|
that.data.form.frontImg = {base64: data, type} |
||||
|
} else { |
||||
|
that.data.form.backImg = {base64: data, type} |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
suffixImage: function(path){ |
||||
|
return path.substring(path.lastIndexOf('.') + 1) |
||||
|
}, |
||||
|
viewImage: function(e) { |
||||
|
var urlList = [] |
||||
|
for (var i = 0; i < this.data.imgList.length; i++) { |
||||
|
if (!util.isEmpty(this.data.imgList[i])) { |
||||
|
urlList.push(this.data.imgList[i]) |
||||
|
} |
||||
|
} |
||||
|
wx.previewImage({ urls: urlList, current: e.currentTarget.dataset.url }) |
||||
|
}, |
||||
|
deleteImg: function(e) { |
||||
|
var index = e.currentTarget.dataset.index |
||||
|
this.data.imgList[index] = null; |
||||
|
this.setData({ imgList: this.data.imgList }) |
||||
|
}, |
||||
|
onUnload: function () { |
||||
|
event.remove('EventMessage', this) |
||||
|
} |
||||
|
}) |
||||
@ -0,0 +1,6 @@ |
|||||
|
{ |
||||
|
"usingComponents": { |
||||
|
"picker-view": "/components/picker-view/index", |
||||
|
"wux-button": "/components/button/index" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,103 @@ |
|||||
|
<!--pages/home/authory/index.wxml--> |
||||
|
<cu-custom bgColor="bg-white" isBack="{{true}}"> |
||||
|
<view slot="content">企业认证</view> |
||||
|
</cu-custom> |
||||
|
|
||||
|
<view class="cu-bar bg-white" style="min-height:90rpx"> |
||||
|
<view class="action" style="color:#333333"><text class="text-red must">*</text>请拍摄/上传本人身份证(头像面)</view> |
||||
|
</view> |
||||
|
<view class="cu-list menu no-card sm-border"> |
||||
|
<view class="cu-item" style="width:100%;padding-bottom:30rpx"> |
||||
|
<view class="image-reader-item" bindtap="chooseImage" data-index="0" wx:if="{{!imgList[0]}}"> |
||||
|
<!-- <text class="cuIcon-cameraadd md-icon" style="font-size:50rpx" wx:if="{{!flag}}"></text> |
||||
|
<text class="md-hint" wx:if="{{!flag}}">身份证正面</text> --> |
||||
|
<image style="width:100%;height:400rpx" mode="aspectFill" src="https://pic.downk.cc/item/5f34a45714195aa5942df93b.png"></image> |
||||
|
</view> |
||||
|
<view class="image-reader-item" bindtap="viewImage" data-url="{{imgList[0]}}" wx:else> |
||||
|
<image style="width:100%;height: 400rpx" src="{{imgList[0]}}" mode="aspectFill"></image> |
||||
|
<view class="delete" catchtap="deleteImg" data-index="0" wx:if="{{!flag}}"> |
||||
|
<text class="cuIcon-close {{pathList[0].status===-1?'text-red':'text-white'}}"></text> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="cu-item"> |
||||
|
<view class="flex content cu-item" style="font-size:28rpx"> |
||||
|
<view style="min-width:200rpx"><text class="text-red must">*</text>公司名称:</view> |
||||
|
<input maxlength="8" value="{{form.realName}}" class="inputs" placeholder="请输入公司名称" bindinput="bindForm"></input> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="cu-item"> |
||||
|
<view class="flex content cu-item" style="font-size:28rpx"> |
||||
|
<view style="min-width:200rpx"><text class="text-red must">*</text>信用代码:</view> |
||||
|
<input value="{{form.certificateNo}}" class="inputs" type="idcard" bindblur="inputBlur" placeholder="请输社会入统一信用代码" bindinput="bindForm"></input> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="cu-item"> |
||||
|
<view class="flex content cu-item" style="font-size:28rpx"> |
||||
|
<view style="min-width:200rpx">工厂占地面积:</view> |
||||
|
<input maxlength="8" value="{{form.realName}}" disabled="{{disabled}}" style="width:65%" placeholder="请输入工厂占地面积(㎡)" bindinput="bindForm"></input> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="cu-item"> |
||||
|
<view class="flex content cu-item" style="font-size:28rpx"> |
||||
|
<view style="min-width:200rpx">工厂人数:</view> |
||||
|
<input maxlength="8" value="{{form.realName}}" disabled="{{disabled}}" style="width:65%" placeholder="请输入工厂人数" bindinput="bindForm"></input> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="cu-item"> |
||||
|
<view class="flex content cu-item" style="font-size:28rpx"> |
||||
|
<view style="min-width:200rpx">工厂设备数:</view> |
||||
|
<input maxlength="8" value="{{form.realName}}" disabled="{{disabled}}" style="width:65%" placeholder="请输入工厂设备数" bindinput="bindForm"></input> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="cu-item"> |
||||
|
<view class="flex content cu-item" style="font-size:28rpx"> |
||||
|
<view style="min-width:200rpx">月出货量:</view> |
||||
|
<input maxlength="8" value="{{form.realName}}" disabled="{{disabled}}" style="width:65%" placeholder="请选择月出货量" bindinput="bindForm"></input> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="cu-item"> |
||||
|
<view class="flex content cu-item" style="font-size:28rpx"> |
||||
|
<view style="min-width:200rpx">从业经验:</view> |
||||
|
<input maxlength="8" value="{{form.realName}}" disabled="{{disabled}}" style="width:65%" placeholder="请选择从业年限" bindinput="bindForm"></input> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
<view class="cu-bar bg-white margin-top" style="min-height:90rpx"> |
||||
|
<view class="action" style="color:#333333"><text class="text-red must">*</text>请拍摄/上传本人身份证(国徽面)</view> |
||||
|
</view> |
||||
|
<view class="cu-list menu no-card sm-border"> |
||||
|
<view class="cu-item" style="width:100%;padding-bottom:30rpx"> |
||||
|
<view class="image-reader-item" bindtap="chooseImage" data-index="1" wx:if="{{!imgList[1]}}"> |
||||
|
<!-- <text class="cuIcon-cameraadd md-icon" style="font-size:50rpx" wx:if="{{!flag}}"></text> |
||||
|
<text class="md-hint" wx:if="{{!flag}}">身份证背面</text> --> |
||||
|
<image style="width:100%;height:400rpx" mode="aspectFill" src="https://pic.downk.cc/item/5f34a45714195aa5942df939.png"></image> |
||||
|
</view> |
||||
|
<view class="image-reader-item" bindtap="viewImage" data-url="{{imgList[1]}}" wx:else> |
||||
|
<image style="width:100%;height: 400rpx" src="{{imgList[1]}}" mode="aspectFill"></image> |
||||
|
<view class="delete" catchtap="deleteImg" data-index="1" wx:if="{{!flag}}"> |
||||
|
<text class="cuIcon-close {{pathList[1].status===-1?'text-red':'text-white'}}"></text> |
||||
|
</view> |
||||
|
<!-- <view class="md-load load-spinner text-white" wx:if="{{pathList[1].status===1}}"/> --> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="cu-item"> |
||||
|
<view class="flex content cu-item" style="font-size:28rpx"> |
||||
|
<view style="min-width:200rpx">真实姓名:</view> |
||||
|
<input maxlength="8" value="{{form.realName}}" disabled="{{disabled}}" style="width:65%" placeholder="请输入真实姓名" bindinput="bindForm"></input> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="cu-item"> |
||||
|
<view class="flex content cu-item" style="font-size:28rpx"> |
||||
|
<view style="min-width:200rpx">身份证号码:</view> |
||||
|
<input disabled="{{disabled}}" value="{{form.certificateNo}}" style="width:65%" type="idcard" bindblur="inputBlur" placeholder="请输入身份证号码" bindinput="bindForm"></input> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
<view class="flex flex-direction" style="padding: 32rpx"> |
||||
|
<wux-button block type="positive" bind:click="submitForm">提交认证</wux-button> |
||||
|
</view> |
||||
|
|
||||
|
<picker-view id="picker-view" bindcustomevent="onPickerChange"></picker-view> |
||||
@ -0,0 +1,64 @@ |
|||||
|
/* pages/home/authory/index.wxss */ |
||||
|
.margin-top { |
||||
|
margin-top: 18rpx |
||||
|
} |
||||
|
|
||||
|
.image-reader-item { |
||||
|
position: relative; |
||||
|
width: 99%; |
||||
|
height: 400rpx; |
||||
|
background-color: #f8f8f8; |
||||
|
box-sizing: border-box; |
||||
|
list-style: none; |
||||
|
background-size: cover; |
||||
|
border-radius: 6rpx; |
||||
|
} |
||||
|
|
||||
|
.image-reader-item .md-icon { |
||||
|
position: absolute; |
||||
|
top: 45%; |
||||
|
left: 50%; |
||||
|
transform: translate(-50%, -50%); |
||||
|
opacity: 0.5; |
||||
|
} |
||||
|
|
||||
|
.image-reader-item .md-load { |
||||
|
position: absolute; |
||||
|
top: 50%; |
||||
|
left: 50%; |
||||
|
transform: translate(-50%, -50%); |
||||
|
} |
||||
|
|
||||
|
.image-reader-item .md-hint { |
||||
|
position: absolute; |
||||
|
top: 50%; |
||||
|
left: 0; |
||||
|
width: 100%; |
||||
|
margin-top: 10px; |
||||
|
font-size: 12px; |
||||
|
color: #bababa; |
||||
|
text-align: center; |
||||
|
} |
||||
|
|
||||
|
.image-reader-item .delete { |
||||
|
position: absolute; |
||||
|
top: 0px; |
||||
|
right: 0px; |
||||
|
opacity: 0.8; |
||||
|
border-top-right-radius: 6rpx; |
||||
|
border-bottom-left-radius: 8rpx; |
||||
|
padding: 6rpx 12rpx; |
||||
|
height: auto; |
||||
|
background-color: rgba(0, 0, 0, 0.5); |
||||
|
} |
||||
|
|
||||
|
.inputs{ |
||||
|
width: 65%; |
||||
|
height: 36px; |
||||
|
padding: 10px 0px; |
||||
|
} |
||||
|
|
||||
|
.must{ |
||||
|
padding-top: 14px; |
||||
|
font-size: 28px; |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save