123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- <template>
- <app-layout :overflow='false'>
- <view class="identify">
- <!-- 输入信息 -->
- <view class="info">
- <text class="title">身份信息</text>
- <view class="input-grow first">
- <text class="input-label">您的姓名</text>
- <input class="input" placeholder="请输入您的姓名" v-model="card_name"></input>
- </view>
-
- <view class="input-grow">
- <text class="input-label">证件号码</text>
- <input class="input" placeholder="请输入证件号码" v-model="idcard"></input>
- </view>
- </view>
- <!-- 身份证图片 -->
- <view class="info picture">
- <text class="title">证件照片</text>
- <!-- 正面 -->
- <view class="picture-grow first">
- <view class="picture-box" @click="loadPicture(0)">
- <image v-if="!front_url" class="picture-img" src="/static/image/idcard_front.png" mode=""></image>
- <image v-if="front_url" class="picture-img" :src="front_url" mode=""></image>
- </view>
- <text class="tips">{{front_url ? '点击重新拍摄身份证人像面' : '点击拍摄身份证人像面'}}</text>
- </view>
- <!-- 反面 -->
- <view class="picture-grow first">
- <view class="picture-box" @click="loadPicture(1)">
- <image v-if="!back_url" class="picture-img" src="/static/image/idcard_back.png" mode=""></image>
- <image v-if="back_url" class="picture-img" :src="back_url" mode=""></image>
- </view>
- <text class="tips">{{back_url ? '点击重新拍摄身份证国徽像' : '点击拍摄身份证国徽面'}}</text>
- </view>
- </view>
- <!-- 按钮 -->
- <view class="btn" :style="{'backgroundColor':getTheme.background}" @click="doAuth">
- <text class="submit">立即认证</text>
- </view>
- <!-- tips -->
- <view class="bottom-tips">
- <text class="txt">*依据中华人民共和国法律规定,为保证电子合同的合法有效性,请您配合上传您的有效二代身份证正反面照片,并保证图片文字清晰,无反光、无遮挡。</text>
- </view>
- </view>
- </app-layout>
- </template>
- <script>
- import { mapState, mapGetters } from 'vuex';
- export default {
- data() {
- return {
- card_name: '',
- idcard: '',
- front_url: '',
- back_url: ''
- }
- },
- methods: {
- // 选择照片
- loadPicture(type) {
- const _this = this
- uni.chooseImage({
- count: 1,
- sizeType: ['original', 'compressed'],
- success: function (file) {
- console.log(file)
- uni.uploadFile({
- url: _this.$api.upload.file,
- filePath: file.tempFilePaths[0],
- name: 'file',
- formData: { file },
- success: (res) => {
- const data = JSON.parse(res.data)
- if (data.code === 0) {
- uni.showToast({
- icon: 'success',
- title: '上传成功',
- duration: 1000
- });
- if (type === 0) {
- _this.front_url = data.data.url
- } else if (type === 1) {
- _this.back_url = data.data.url
- }
- }
- },
- fail: () => {
- console.log('上传失败')
- }
- });
- },
- fail: function (err) {
- console.log(err)
- }
- });
- },
-
- doAuth () {
- // 是否输入,是否上传了照片
- if (!this.card_name || !this.idcard) {
- uni.showToast({
- icon: 'error',
- title: '请检查输入内容',
- duration: 1000
- });
- return
- } else if(!this.front_url || !this.back_url) {
- uni.showToast({
- icon: 'error',
- title: '请上传照片',
- duration: 1000
- });
- return
- }
- const data = {
- card_name: this.card_name,
- idcard: this.idcard,
- card_front_url: this.front_url,
- card_back_url: this.back_url
- }
-
- // 发送认证请求
- this.$showLoading({ text: '正在认证,请稍后' })
- const res = this.$request({
- url: this.$api.user.doAuth,
- method: 'post',
- data: data,
- }).then(res => {
- // 状态 1,验证不通过
- if (res.code === 1) {
- uni.showModal({
- title: '提示:验证未通过',
- content: res.msg,
- showCancel: false,
- success: function (res) {
- }
- })
- return
- }
- // 通过的操作:返回结算页面
- uni.showModal({
- title: '提示:验证通过',
- content: "点击确定立即返回结算页面",
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- uni.navigateBack({ delta: 1 })
- }
- }
- })
- }).catch(err => {
- console.log(err)
- }).finally(() => {
- this.$hideLoading()
- });
- }
- },
- computed:{
- ...mapState({
- tabBarHeight: (state) => {
- return state.gConfig.tabBarHeight;
- },
- iphoneHeight: (state) =>{
- return state.gConfig.iphoneHeight;
- },
- iphone: (state) => {
- return state.gConfig.iphone
- }
- }),
- ...mapGetters('iPhoneX', {
- BotHeight: 'getBotHeight',
- getEmpty: 'getEmpty',
- }),
- ...mapGetters('mallConfig', {
- getTheme: 'getTheme',
- }),
- ...mapGetters({
- userInfo: 'user/info',
- })
- },
- }
- </script>
- <style lang="scss" scoped>
- .identify {
- display: flex;
- flex-direction: column;
- align-items: center;
- .info {
- box-sizing: border-box;
- width: 100%;
- margin-top: 30rpx;
- padding: 20rpx 24rpx 10rpx;
- background-color: white;
- .title {
- font-size: 28rpx;
- font-weight: bold;
- }
- .input-grow {
- display: flex;
- align-items: center;
- padding: 10rpx 0;
- .input-label {
- font-size: 26rpx;
- line-height: 26rpx;
- }
- .input {
- flex: 1;
- height: 48rpx;
- margin-left: 20rpx;
- font-size: 26rpx;
- }
- &.first {
- margin-top: 16rpx;
- border-bottom: 1px solid #f6f5f7;
- }
- }
- }
- .picture {
- padding-bottom: 30rpx;
- .picture-grow {
- display: flex;
- flex-direction: column;
- align-items: center;
- .picture-box {
- width: 580rpx;
- height: 320rpx;
- background-color: transparent;
- border-radius: 20rpx;
- overflow: hidden;
- box-shadow: 0 0 20rpx #dddddd;
- .picture-img {
- width: 100%;
- height: 100%;
- }
- }
- .tips {
- font-size: 26rpx;
- margin-top: 10rpx;
- }
- &.first {
- margin-top: 30rpx;
- }
- }
- }
- .btn {
- position: fixed;
- bottom: 0;
- width: 100%;
- height: 80rpx;
- background-color: skyblue;
- text-align: center;
- .submit {
- width: 100%;
- height: 100%;
- margin-top: 30rpx;
- font-size: 30rpx;
- border-radius: 0;
- color: white;
- line-height: 80rpx;
- }
- }
- .bottom-tips {
- padding: 0 24rpx;
- margin-top: 40rpx;
- margin-bottom: 120rpx;
- .txt {
- font-size: 20rpx;
- color: #C2C2C2;
- line-height: 22rpx;
- }
- }
- }
- </style>
|