123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 |
- <template>
- <view class="content">
- <view class="yz-wrap" v-if="stap == 1">
- <!-- <view class="yz-wrap"> -->
- <view class="top-wrap flex">
- <view class="top-left">
- 实名认证<text>*</text>
- </view>
- </view>
- <view class="sr-wrap flex">
- <view class="sr-tit">
- 姓名
- </view>
- <input type="text" class="sr-inp" placeholder="请输入姓名" v-model="name">
- </view>
- <view class="sr-wrap flex">
- <view class="sr-tit">
- 手机号
- </view>
- <input type="number" class="sr-inp" placeholder="请输入手机号" v-model="phone">
- </view>
- <view class="sr-wrap flex">
- <view class="sr-tit">
- 身份证号
- </view>
- <input type="idcard" class="sr-inp" placeholder="请输入身份证号" v-model="idcard">
- </view>
- <view class="sr-wrap flex">
- <view class="sr-tit">
- 推荐渠道
- </view>
- <input type="text" class="sr-inp" placeholder="请输入推荐渠道" v-model="code">
- <view class="sr-btn" @click="smget()">
- 扫码获取
- </view>
- </view>
- </view>
- <view class="yz-wrap" v-if="stap == 0">
- <view class="top-wrap flex">
- <view class="top-left">
- 上传身份证照片<text>*</text>
- </view>
- </view>
- <view class="sfz flex">
- <!-- #ifdef MP-WEIXIN -->
- <image class="" :src="sfzz||'/static/img/sfzz.png'" mode="widthFix"
- @click="navTo('/pages/shop/upimg?type=front')">
- </image>
- <image class="" :src="sfzf||'/static/img/sfzf.png'" mode="widthFix"
- @click="navTo('/pages/shop/upimg?type=side')">
- </image>
- <!-- #endif -->
- <!-- #ifdef H5 -->
- <image class="" :src="sfzz||'/static/img/sfzz.png'" mode="widthFix"
- @click="upsfz('sfzz')">
- </image>
- <image class="" :src="sfzf||'/static/img/sfzf.png'" mode="widthFix"
- @click="upsfz('sfzf')">
- </image>
- <!-- #endif -->
- <!-- #ifdef APP-PLUS -->
- <image class="" :src="sfzz||'/static/img/sfzz.png'" mode="widthFix"
- @click="upsfz('sfzz')">
- </image>
- <image class="" :src="sfzf||'/static/img/sfzf.png'" mode="widthFix"
- @click="upsfz('sfzf')">
- </image>
- <!-- #endif -->
- <view class="">
- 个人信息面
- </view>
- <view class="">
- 国徽面
- </view>
- </view>
- </view>
- <!-- <view class="yz-wrap">
- <view class="sr-wrap flex">
- <view class="sr-tit">
- 绑定邀请码
- </view>
- <input type="text" class="sr-inp" placeholder="请输入绑定邀请码(非必填)">
- </view>
- </view> -->
- <view class="base-buttom" @click="subsfz" v-if="stap == 0">
- 下一步
- </view>
- <template v-if="stap == 1">
- <view class="base-buttom" @click="stap = 0">
- 上一步
- </view>
- <view class="base-buttom" @click="sub">
- 提交认证
- </view>
- </template>
- </view>
- </template>
- <script>
- import { upload } from '@/api/order.js'
- import {
- certification,
- idcards
- } from '@/api/index.js'
- import {
- mapState
- } from "vuex"
- export default {
- data() {
- return {
- code: '', //推荐渠道
- stap: 0,
- sfzz: '',
- sfzf: '',
- name: '',
- phone: '',
- idcard: '',
- loading: false,
- }
- },
- onLoad() {
- },
- onShow() {
- this.phone = this.userInfo.phone || ''
- },
- computed: {
- // #ifdef H5
- ...mapState(['urlFile']),
- // #endif
- ...mapState('user', ['userInfo'])
- },
- onReachBottom() {
- },
- onReady() {
- },
- methods: {
- upsfz(name) {
- upload().then(res => {
- // this[name] = res[0].url
- this.$set(this,name,res[0].url)
- })
- },
- smget() {
- let that = this
- uni.scanCode({
- success: (res) => {
- that.code = res.result
- }
- })
- },
- upimgg(path, name) {
- let that = this
- that.upLoad(path).then((urldata) => {
- console.log(urldata, '这里')
- that[name] = urldata.url;
- })
- },
- navTo(url) {
- uni.navigateTo({
- url
- })
- },
- back() {
- uni.navigateBack()
- },
- getImage(res) {
- console.log(res)
- },
- subsfz() {
- console.log('这里');
- let that = this
-
- if (that.sfzz == '' || that.sfzf == '') {
- return that.$api.msg('请上传身份证信息')
- }
- console.log('哪里');
- uni.showLoading({
- title:'校验中...'
- })
- try{
- idcards({
- card_front: that.sfzz,
- card_back: that.sfzf
- }).then(res => {
- uni.hideLoading()
- console.log(res)
- that.name = res.data.name
- that.idcard = res.data.number
- that.stap = 1
- }).catch(err => {
- console.log(err);
- })
- }catch(e){
- console.log(e);
- //TODO handle the exception
- }
-
- },
- sub() {
- let that = this
- if (that.loading) {
- return
- }
- if (that.name == '') {
- that.$api.msg('请输入姓名')
- }
- if (that.phone == '') {
- that.$api.msg('请输入手机号码')
- }
- if (that.idcard == '') {
- that.$api.msg('请输入身份证号')
- }
- that.loading = true
- certification({
- name: that.name,
- id_number: that.idcard,
- phone_number: that.phone,
- code: that.code
- }).then(res => {
- uni.showToast({
- title: '提交成功',
- duration: 2000
- });
- setTimeout(() => {
- uni.switchTab({
- url: '/pages/user/user'
- })
- })
- console.log(res)
- that.loading = false
- }).catch(err => {
- that.loading = false
- })
- },
- upLoad(path) {
- uni.showLoading({
- title: '图片上传中',
- mask: true
- });
- console.log('图片上传中')
- return new Promise((resolve, error) => {
- uni.uploadFile({
- url: this.$store.state.baseURL + '/api/upload/image', //仅为示例,非真实的接口地址
- filePath: path,
- name: 'file',
- header: {
- "Authori-zation": 'Bearer ' + uni.getStorageSync('token')
- },
- success: (uploadFileRes) => {
- if ("string" === typeof uploadFileRes.data) {
- resolve(JSON.parse(uploadFileRes.data).data)
- } else {
- resolve(uploadFileRes.data.data)
- }
- },
- complete() {
- uni.hideLoading()
- }
- });
- })
- },
- chooseImage: function(index) {
- const _this = this
- return new Promise((ok, error) => {
- // 从相册/相机选择
- // 如需直接开相机或直接选相册,请只使用一个选项
- const sourceType = index === 0 ? ['camera'] : ['album']
- uni.chooseImage({
- count: 1, //默认9
- sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
- sourceType: sourceType,
- success: function(res) {
- ok(res.tempFilePaths[0])
- },
- fail(e) {
- uni.showModal({
- title: '文件打开错误',
- content: '请设置授权文件存储权限',
- showCancel: false,
- });
- error(e)
- }
- });
- })
- },
- onImg(type) {
- const _this = this
- return new Promise((ok, erro) => {
- // 判断是否需要选择
- if (type == 1) {
- uni.showActionSheet({
- itemList: ['拍照', '选择一张照片'],
- success: function(res) {
- console.log(res, '上传')
- _this.chooseImage(res.tapIndex).then((url) => {
- ok(url)
- }).catch((res) => {
- erro(res)
- })
- },
- fail: function(res) {
- erro(res)
- console.log(res.errMsg);
- }
- });
- }
- // 判断是否只需要拍照
- if (type == 2) {
- _this.chooseImage(0).then((url) => {
- ok(url)
- }).catch((res) => {
- erro(res)
- })
- }
- })
- },
- // 图片裁切
- /**
- * @param {Number} w 裁切宽度比例
- * @param {Number} h 裁切高度比例
- * @param {Number} mw 图片最小宽度
- * @param {Number} mh 图片最小高度
- * @param {String} url url修改
- */
- navCroper(w, h, type) {
- let that = this;
- let tt = (type == 'upimg' ? 2 : 1)
- this.onImg(tt).then((url) => {
- uni.navigateTo({
- url: `/pages/user_home/realName/cropper?width=${w}&height=${h}`,
- events: {
- uploadSuccess(res) {
- console.log(res, '这里')
- that.upLoad(res).then((urldata) => {
- console.log(urldata, '这里')
- that[type] = urldata.url;
- })
- }
- },
- success: function(res) {
- console.log(res, 'success');
- // 通过eventChannel向被打开页面传送数据
- res.eventChannel.emit('urlNext', {
- url
- })
- }
- })
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- page {
- padding-top: 1rpx;
- }
- .yz-wrap {
- background-color: #fff;
- margin: 20rpx 0;
- }
- .top-wrap {
- justify-content: space-between;
- padding: 0 25rpx;
- font-size: 32rpx;
- font-weight: bold;
- color: #00001A;
- height: 85rpx;
- .top-left {
- text {
- color: #FF6B2E;
- margin-left: 10rpx;
- }
- }
- .top-right {
- text {
- font-size: 25rpx;
- font-weight: 500;
- color: #999999;
- }
- image {
- height: 22rpx;
- margin-left: 10rpx;
- }
- }
- }
- .sr-wrap {
- border-top: #fafafa 1rpx solid;
- font-size: 32rpx;
- font-weight: 500;
- width: 690rpx;
- height: 114rpx;
- line-height: 114rpx;
- margin: auto;
- .sr-tit {
- width: 170rpx;
- flex-shrink: 0;
- color: #00001A;
- }
- .sr-inp {
- flex-grow: 1;
- }
- .sr-btn {
- flex-shrink: 0;
- color: $uni-color-primary;
- }
- }
- .sfz {
- padding: 30rpx;
- justify-content: space-between;
- flex-wrap: wrap;
- image {
- width: 332rpx;
- height: 207rpx;
- }
- view {
- width: 332rpx;
- text-align: center;
- font-size: 32rpx;
- color: #5C5C5C;
- }
- }
- .base-buttom {
- margin-top: 25rpx;
- }
- </style>
|