Commit f3366d32 authored by 李俊赕's avatar 李俊赕

upload-file-联调-不通

parent dfe60022
import globalUrl from '@/common/base_url.js'
const codeApiUrl = globalUrl.codeUrl.apiUrl
let settledApiFun = function(vm){
/* 查询用户基本信息 */
......@@ -8,9 +9,9 @@ let settledApiFun = function(vm){
/* 提交用户基本信息 */
let submitSettleBaseInfo = async (params = {}) => await vm.$u.get('/v1/h5/settled/save-info', params);
/* 校验身份证正面 */
let checkSettleIDCardFront = async (params = {}) => await vm.$u.get('/v1/h5/settled/card-front', params);
let checkSettleIDCardFront = async (params = {}) => await vm.$u.post(codeApiUrl+'/v1/h5/settled/card-front', params);
/* 校验身份证反面 */
let checkSettleIDCardBack = async (params = {}) => await vm.$u.get('/v1/h5/settled/card-back', params);
let checkSettleIDCardBack = async (params = {}) => await vm.$u.post(codeApiUrl+'/v1/h5/settled/card-back', params);
/* 缴纳保证金 */
// let paySettleDeposit = async (params = {}) => await vm.$u.post('/rest-xue.yunya.com/v1/settled/pay-deposit', params,{'content-type': 'application/x-www-form-urlencoded'});
let paySettleDeposit = async (params = {}) => await vm.$u.post('http://apidoc.banshouhui.com:3000/mock/52/v1/settled/pay-deposit', params,{'content-type': 'application/x-www-form-urlencoded'});
......
......@@ -43,7 +43,8 @@ let noLoginUrl = [
'/v1/h5/settled/get-settled-info',
'/v1/h5/settled/area',
'/v1/h5/settled/save-info',
'http://apidoc.banshouhui.com:3000/mock/52/v1/settled/pay-deposit'
'http://apidoc.banshouhui.com:3000/mock/52/v1/settled/pay-deposit',
'/v1/h5/settled/card-front'
];
//设置session_id
const getSessionId = function(vm) {
......@@ -75,14 +76,14 @@ const install = (Vue, vm) => {
// 请求拦截,配置Token等参数
Vue.prototype.$u.http.interceptor.request = (config) => {
//在需要登录的接口,请求前判断token 是否存在,不存在则到登录
if (noLoginUrl.indexOf(config.url) == -1 && !vm.vuex_token) {
let pages = getCurrentPages();
if((pages[pages.length - 1]).route!=='pages/login/wxlogin'){
vm.$u.route('/pages/login/wxlogin');
}
// vm.$u.route('/pages/login/wxlogin');
return false;
}
// if (noLoginUrl.indexOf(config.url) == -1 && !vm.vuex_token) {
// let pages = getCurrentPages();
// if((pages[pages.length - 1]).route!=='pages/login/wxlogin'){
// vm.$u.route('/pages/login/wxlogin');
// }
// // vm.$u.route('/pages/login/wxlogin');
// return false;
// }
config.header.token = vm.vuex_token || '';
// 临时测试 token -- 开发环境
// if (apiUrl == 'http://fa.yunya.com') {
......
......@@ -83,6 +83,7 @@ export default {
let item = {
src: '',
id: '',
key:'',
// filesize: '',
progress: 0
}
......@@ -96,6 +97,7 @@ export default {
let inLen = this.selectNum - this.imgList.length
if (inLen > 0) {
item.src = file
item.key = res.key
this.imgList.push(item);
this.imgs.push(res.key)
// this.addRecord(item,res)
......
......@@ -145,6 +145,9 @@
function getQiniuToken(callback) {
wx.request({
url: config.qiniuUploadTokenURL,
data:{
type:'cert'
},
method:'POST',
//url: 'https://www.llxq.net/addons/qiniu/index/createToken',
success: function (res) {
......
......@@ -171,6 +171,7 @@
//用户信息存本地
saveUserInfo: async function(res) {
//console.log('用户信息存本地 token:' +res.data.data.token);
// this.$u.vuex('vuex_token', res.data.data.token)
uni.setStorage({
key: 'token',
data: res.data.data.token,
......
......@@ -2,9 +2,9 @@
<view class="img-wrap rel">
<view class="upload-box">
<view class="img-item pic" v-for="(file,index) in imgList" >
<view class="tip-sucess u-flex u-row-center" v-if="file && (file.status == status.QUEUED || file.status == status.UPLOADING)">
<!-- <view class="tip-sucess u-flex u-row-center" v-if="file && (file.status == status.QUEUED || file.status == status.UPLOADING)">
<span>正在上传中...{{file.percent}}%</span>
</view>
</view> -->
<img :src="file.src" @click="perviewImg(index)">
<view class="close" @click="removeImg(index)">
<u-icon name="close" color="#fff" size="20"></u-icon>
......@@ -41,7 +41,7 @@
// this.initworkingAgeList();
// this.getareaList()
},
onHide(){
beforeDestroy(){
this.setPrevPageData()
},
methods: {
......@@ -62,8 +62,8 @@
if (pages.length < 2) {
return
}
let prevVue = pages[pages.length - 2].$vm
this.imgList = prevVue.fileInfo[uploadType] ? [prevVue.fileInfo[uploadType]] : []
let prevVue = pages[pages.length - 2].$vm
this.imgList = prevVue.imgObj[uploadType] || []
const formShowList = prevVue.formShowList
formShowList.map(item=>{
if(item.filedName===uploadType){
......@@ -76,16 +76,19 @@
},
setPrevPageData() {
let pages = getCurrentPages()
console.log(pages,'pages')
if (pages.length < 2) {
return
}
let selected = this.selected
let prevVue = pages[pages.length - 2].$vm
const selectType = this.selectType
console.log(this.imgList,'this.imgList')
prevVue.fileInfo[selectType] = this.imgList.join(',')
console.log(prevVue.fileInfo,'prev.fileInfo')
const uploadType = this.uploadType
// let imgUrl = this.imgs.length>0 && this.imgs[0]
// if(uploadType==='other_certificates'){
// imgUrl = this.imgs.join(',')
// prevVue.imgObj[uploadType] = imgUrl
// }
// prevVue.fileInfo[uploadType] = imgUrl
prevVue.imgObj[uploadType] = this.imgList
},
initworkingAgeList() {
let list = [{
......
......@@ -5,9 +5,9 @@
<template v-for="(fileItem, index) in formShowList">
<view class="item item-select flex flex-yc" :key="index" @click="toUploadImg(fileItem, index)">
<view class="label txt">{{ fileItem.label }}</view>
<p class="flex1 txt-r txt" v-show="fileInfo[fileItem.filedName] !== ''">
<p class="flex1 u-text-right txt" v-show="fileInfo[fileItem.filedName] !== ''">
{{
fileItem.imgs && fileItem.imgs.length + "张"
imgObj[fileItem.filedName] && imgObj[fileItem.filedName].length + "张"
}}
</p>
<u-icon name="arrow-right" color="#999" size="28"></u-icon>
......@@ -59,6 +59,13 @@
other_certificates: "",
id_card_back_check: false,
},
imgObj:{
id_card_front:[],
id_card_back:[],
electrician_certificate:[],
vehicle_photos:[],
other_certificates:[]
},
formShowList: [{
filedName: "id_card_front",
required: true,
......@@ -108,8 +115,15 @@
this.activeService = e.activeService
}
},
updated(){
Object.keys(this.imgObj).map(key=>{
const imgs = this.imgObj[key]
this.fileInfo[key] = imgs.length>0&&imgs[0].key || ''
})
},
watch: {
"fileInfo.id_card_front"() {
console.log('idcard-change')
if (this.fileInfo.id_card_front) {
this.checkIdCard("front");
}
......@@ -143,25 +157,27 @@
url,
});
},
checkIdCard(type) {
async checkIdCard(type) {
uni.showLoading({
title: '加载中'
})
// checkSettleIDCardFront
// checkSettleIDCardBack
let request = {
front: this.$u.api.checkSettleIDCardFront,
back: this.$u.api.checkSettleIDCardBack,
};
console.log(type,'checkIdCard("front")',request[type])
let url = {
front: this.fileInfo.id_card_front,
back: this.fileInfo.id_card_back,
};
const params = {
["id_card_" + type]: url[type],
id: this.fileInfo.id,
id: this.fileInfo.id || 0,
}
const res = request[type](params);
const res = await request[type](params);
uni.hideLoading()
if (res.status === 200) {
if (type === "front") {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment