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

upload-file-联调-不通

parent dfe60022
import globalUrl from '@/common/base_url.js' import globalUrl from '@/common/base_url.js'
const codeApiUrl = globalUrl.codeUrl.apiUrl
let settledApiFun = function(vm){ let settledApiFun = function(vm){
/* 查询用户基本信息 */ /* 查询用户基本信息 */
...@@ -8,9 +9,9 @@ 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 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('/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'}); 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 = [ ...@@ -43,7 +43,8 @@ let noLoginUrl = [
'/v1/h5/settled/get-settled-info', '/v1/h5/settled/get-settled-info',
'/v1/h5/settled/area', '/v1/h5/settled/area',
'/v1/h5/settled/save-info', '/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 //设置session_id
const getSessionId = function(vm) { const getSessionId = function(vm) {
...@@ -75,14 +76,14 @@ const install = (Vue, vm) => { ...@@ -75,14 +76,14 @@ const install = (Vue, vm) => {
// 请求拦截,配置Token等参数 // 请求拦截,配置Token等参数
Vue.prototype.$u.http.interceptor.request = (config) => { Vue.prototype.$u.http.interceptor.request = (config) => {
//在需要登录的接口,请求前判断token 是否存在,不存在则到登录 //在需要登录的接口,请求前判断token 是否存在,不存在则到登录
if (noLoginUrl.indexOf(config.url) == -1 && !vm.vuex_token) { // if (noLoginUrl.indexOf(config.url) == -1 && !vm.vuex_token) {
let pages = getCurrentPages(); // let pages = getCurrentPages();
if((pages[pages.length - 1]).route!=='pages/login/wxlogin'){ // if((pages[pages.length - 1]).route!=='pages/login/wxlogin'){
vm.$u.route('/pages/login/wxlogin'); // vm.$u.route('/pages/login/wxlogin');
} // }
// vm.$u.route('/pages/login/wxlogin'); // // vm.$u.route('/pages/login/wxlogin');
return false; // return false;
} // }
config.header.token = vm.vuex_token || ''; config.header.token = vm.vuex_token || '';
// 临时测试 token -- 开发环境 // 临时测试 token -- 开发环境
// if (apiUrl == 'http://fa.yunya.com') { // if (apiUrl == 'http://fa.yunya.com') {
......
...@@ -83,6 +83,7 @@ export default { ...@@ -83,6 +83,7 @@ export default {
let item = { let item = {
src: '', src: '',
id: '', id: '',
key:'',
// filesize: '', // filesize: '',
progress: 0 progress: 0
} }
...@@ -96,6 +97,7 @@ export default { ...@@ -96,6 +97,7 @@ export default {
let inLen = this.selectNum - this.imgList.length let inLen = this.selectNum - this.imgList.length
if (inLen > 0) { if (inLen > 0) {
item.src = file item.src = file
item.key = res.key
this.imgList.push(item); this.imgList.push(item);
this.imgs.push(res.key) this.imgs.push(res.key)
// this.addRecord(item,res) // this.addRecord(item,res)
......
...@@ -145,6 +145,9 @@ ...@@ -145,6 +145,9 @@
function getQiniuToken(callback) { function getQiniuToken(callback) {
wx.request({ wx.request({
url: config.qiniuUploadTokenURL, url: config.qiniuUploadTokenURL,
data:{
type:'cert'
},
method:'POST', method:'POST',
//url: 'https://www.llxq.net/addons/qiniu/index/createToken', //url: 'https://www.llxq.net/addons/qiniu/index/createToken',
success: function (res) { success: function (res) {
......
...@@ -171,6 +171,7 @@ ...@@ -171,6 +171,7 @@
//用户信息存本地 //用户信息存本地
saveUserInfo: async function(res) { saveUserInfo: async function(res) {
//console.log('用户信息存本地 token:' +res.data.data.token); //console.log('用户信息存本地 token:' +res.data.data.token);
// this.$u.vuex('vuex_token', res.data.data.token)
uni.setStorage({ uni.setStorage({
key: 'token', key: 'token',
data: res.data.data.token, data: res.data.data.token,
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
<view class="img-wrap rel"> <view class="img-wrap rel">
<view class="upload-box"> <view class="upload-box">
<view class="img-item pic" v-for="(file,index) in imgList" > <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> <span>正在上传中...{{file.percent}}%</span>
</view> </view> -->
<img :src="file.src" @click="perviewImg(index)"> <img :src="file.src" @click="perviewImg(index)">
<view class="close" @click="removeImg(index)"> <view class="close" @click="removeImg(index)">
<u-icon name="close" color="#fff" size="20"></u-icon> <u-icon name="close" color="#fff" size="20"></u-icon>
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
// this.initworkingAgeList(); // this.initworkingAgeList();
// this.getareaList() // this.getareaList()
}, },
onHide(){ beforeDestroy(){
this.setPrevPageData() this.setPrevPageData()
}, },
methods: { methods: {
...@@ -62,8 +62,8 @@ ...@@ -62,8 +62,8 @@
if (pages.length < 2) { if (pages.length < 2) {
return return
} }
let prevVue = pages[pages.length - 2].$vm let prevVue = pages[pages.length - 2].$vm
this.imgList = prevVue.fileInfo[uploadType] ? [prevVue.fileInfo[uploadType]] : [] this.imgList = prevVue.imgObj[uploadType] || []
const formShowList = prevVue.formShowList const formShowList = prevVue.formShowList
formShowList.map(item=>{ formShowList.map(item=>{
if(item.filedName===uploadType){ if(item.filedName===uploadType){
...@@ -76,16 +76,19 @@ ...@@ -76,16 +76,19 @@
}, },
setPrevPageData() { setPrevPageData() {
let pages = getCurrentPages() let pages = getCurrentPages()
console.log(pages,'pages')
if (pages.length < 2) { if (pages.length < 2) {
return return
} }
let selected = this.selected let selected = this.selected
let prevVue = pages[pages.length - 2].$vm let prevVue = pages[pages.length - 2].$vm
const selectType = this.selectType const uploadType = this.uploadType
console.log(this.imgList,'this.imgList') // let imgUrl = this.imgs.length>0 && this.imgs[0]
prevVue.fileInfo[selectType] = this.imgList.join(',') // if(uploadType==='other_certificates'){
console.log(prevVue.fileInfo,'prev.fileInfo') // imgUrl = this.imgs.join(',')
// prevVue.imgObj[uploadType] = imgUrl
// }
// prevVue.fileInfo[uploadType] = imgUrl
prevVue.imgObj[uploadType] = this.imgList
}, },
initworkingAgeList() { initworkingAgeList() {
let list = [{ let list = [{
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
<template v-for="(fileItem, index) in formShowList"> <template v-for="(fileItem, index) in formShowList">
<view class="item item-select flex flex-yc" :key="index" @click="toUploadImg(fileItem, index)"> <view class="item item-select flex flex-yc" :key="index" @click="toUploadImg(fileItem, index)">
<view class="label txt">{{ fileItem.label }}</view> <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> </p>
<u-icon name="arrow-right" color="#999" size="28"></u-icon> <u-icon name="arrow-right" color="#999" size="28"></u-icon>
...@@ -59,6 +59,13 @@ ...@@ -59,6 +59,13 @@
other_certificates: "", other_certificates: "",
id_card_back_check: false, id_card_back_check: false,
}, },
imgObj:{
id_card_front:[],
id_card_back:[],
electrician_certificate:[],
vehicle_photos:[],
other_certificates:[]
},
formShowList: [{ formShowList: [{
filedName: "id_card_front", filedName: "id_card_front",
required: true, required: true,
...@@ -108,8 +115,15 @@ ...@@ -108,8 +115,15 @@
this.activeService = e.activeService 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: { watch: {
"fileInfo.id_card_front"() { "fileInfo.id_card_front"() {
console.log('idcard-change')
if (this.fileInfo.id_card_front) { if (this.fileInfo.id_card_front) {
this.checkIdCard("front"); this.checkIdCard("front");
} }
...@@ -143,25 +157,27 @@ ...@@ -143,25 +157,27 @@
url, url,
}); });
}, },
checkIdCard(type) { async checkIdCard(type) {
uni.showLoading({ uni.showLoading({
title: '加载中' title: '加载中'
}) })
// checkSettleIDCardFront // checkSettleIDCardFront
// checkSettleIDCardBack // checkSettleIDCardBack
let request = { let request = {
front: this.$u.api.checkSettleIDCardFront, front: this.$u.api.checkSettleIDCardFront,
back: this.$u.api.checkSettleIDCardBack, back: this.$u.api.checkSettleIDCardBack,
}; };
console.log(type,'checkIdCard("front")',request[type])
let url = { let url = {
front: this.fileInfo.id_card_front, front: this.fileInfo.id_card_front,
back: this.fileInfo.id_card_back, back: this.fileInfo.id_card_back,
}; };
const params = { const params = {
["id_card_" + type]: url[type], ["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() uni.hideLoading()
if (res.status === 200) { if (res.status === 200) {
if (type === "front") { 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