对接大兴app上传图片

main
yanzai 2 years ago
parent 6cdbe2af11
commit 24ee305293

@ -3,9 +3,11 @@
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Log;
use App\Services\Admin\YeWu\HealthCheckupService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
class UpLoadController extends Controller
{
@ -19,12 +21,20 @@ class UpLoadController extends Controller
$save = $file->store('public/H5Upload/'.$date);
return \Yz::Return(true,'上传成功',$save);
}else{
return \Yz::echoError1('获取文件失败');
}
}
public function UpFileBase64()
{
$base64Image =request('base64file'); // 获取 base64 图片字符串
// Log::info($base64Image);
// 将 base64 字符串转换为图片并保存
$image = base64_decode(explode(',', $base64Image)[1]);
$date = date("Ymd");
$filename = 'image_' . time() . '.png'; // 或者使用其他方式生成文件名
Storage::disk('public')->put('/H5Upload/'.$date.'/'.$filename, $image); // 保存图片到 public 目录
return \Yz::Return(true,'上传成功',['fileurl' =>'/storage/H5Upload/'.$date.'/'.$filename]);
}
}

@ -112,7 +112,13 @@ class LogService
$str_len = mb_strlen(json_encode($post_datum, JSON_UNESCAPED_UNICODE));
$str_size = $str_len / 1024;
if ($str_size > 10) {
$post_data->$key= 'Row size too large';
if(is_array($post_data)){
$post_data[$key]= 'Row size too large';
}elseif(is_object($post_data)){
$post_data->$key= 'Row size too large';
}else{
$post_data="data size too large";
}
}
}
$post_data = json_encode($post_data, JSON_UNESCAPED_UNICODE);

@ -66,6 +66,7 @@ Route::group(['middleware'=>['checktoken','log'],'prefix'=>'v1/mH5'],function ()
Route::post('GetEnableCalendar','App\Http\Controllers\API\mH5\OrganizationController@GetEnableCalendar'); //获取可用体检机构日历
Route::post('StartYuYue','App\Http\Controllers\API\mH5\OrganizationController@StartYuYue'); //开始预约
Route::post('UpFile','App\Http\Controllers\API\UpLoadController@UpFile'); //上传文件
Route::post('UpFileBase64','App\Http\Controllers\API\UpLoadController@UpFileBase64');//上传文件base64
Route::post('GetPersonReportDetail','App\Http\Controllers\API\mH5\PersonController@GetPersonReportDetail');//获取用户pdf
Route::post('GetIndustryList','App\Http\Controllers\API\mH5\IndustryController@GetIndustry');
});

@ -29,6 +29,10 @@ export const StartYuYue = (data) => {
export const UpFile = (data) => {
return axios({url:import.meta.env.VITE_APP_API+'v1/mH5/UpFile',data:data})
}
//上传图片base64
export const UpFileBase64 = (data) => {
return axios({url:import.meta.env.VITE_APP_API+'v1/mH5/UpFileBase64',data:data})
}
//获取体检报告详情
export const GetPersonReportDetail = (data) => {

@ -0,0 +1,66 @@
const isAndroid = navigator.userAgent.indexOf('Android') > -1 || navigator.userAgent.indexOf('Adr') > -1
const isiOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
// 这是必须要写的,用来创建一些设置
function setupWebViewJavascriptBridge(callback) {
// Android使用
if (isAndroid) {
if (window.WebViewJavascriptBridge) {
callback(window.WebViewJavascriptBridge)
} else {
document.addEventListener(
'WebViewJavascriptBridgeReady',
() => {
callback(window.WebViewJavascriptBridge)
},
false
)
}
sessionStorage.phoneType = 'android'
}
// iOS使用
if (isiOS) {
if (window.WebViewJavascriptBridge) {
return callback(window.WebViewJavascriptBridge)
}
if (window.WVJBCallbacks) {
return window.WVJBCallbacks.push(callback)
}
window.WVJBCallbacks = [callback]
var WVJBIframe = document.createElement('iframe')
WVJBIframe.style.display = 'none'
WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__'
document.documentElement.appendChild(WVJBIframe)
setTimeout(() => {
document.documentElement.removeChild(WVJBIframe)
}, 0)
sessionStorage.phoneType = 'ios'
}
}
// 注册回调函数,第一次连接时调用 初始化函数(android需要初始化,ios不用)
setupWebViewJavascriptBridge((bridge) => {
if (isAndroid) {
// 初始化
bridge.init((message, responseCallback) => {
var data = {
'Javascript Responds': 'Wee!'
}
responseCallback(data)
})
}
})
export default {
// js调APP方法 (参数分别为:app提供的方法名 传给app的数据 回调)
callHandler(name, data, callback) {
setupWebViewJavascriptBridge((bridge) => {
bridge.callHandler(name, JSON.stringify(data), callback)
})
},
// APP调js方法 (参数分别为:js提供的方法名 回调)
registerHandler(name, callback) {
setupWebViewJavascriptBridge((bridge) => {
bridge.registerHandler(name, (data, responseCallback) => {
callback(data, responseCallback)
})
})
}
}

@ -0,0 +1,216 @@
(function(global) {
var task, img, styleTask, styleImg;
function createLoading() {
task = document.createElement('div');
task.style.cssText = 'position:fixed;background:rgba(0,0,0,0);left:0;top:0;width:100%;height:100%;z-index:9999';
document.documentElement.appendChild(task);
};
function removeLoading() {
document.documentElement.removeChild(task);
task = null;
};
function JSBridge() {
this.name = 'JSBridge';
this.reset = true;
};
JSBridge.prototype.device = function() {
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1;
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
return isAndroid;
};
/**
* @param null
* JSBridge初始化
*/
JSBridge.prototype._init = function(callback) {
if (window.WebViewJavascriptBridge) {
return callback(WebViewJavascriptBridge);
}
if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); }
window.WVJBCallbacks = [callback];
var WVJBIframe = document.createElement('iframe');
WVJBIframe.style.display = 'none';
WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';
document.documentElement.appendChild(WVJBIframe);
setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0)
};
/**
* @param null
* JSBridge 安卓初始化回调接口
*/
JSBridge.prototype.__init__ = function(bridge) {
var isAn = this.device();
if (this.reset && isAn) {
this.reset = false;
bridge.init(function(message, responseCallback) {
console.log('JS got a message', message);
var data = {
'Javascript Responds': '测试中文!'
};
console.log('JS responding with', data);
responseCallback(data);
});
}
};
/*
* 调用原生方法
*/
JSBridge.prototype.callHandler = function(funcName, data, callback) {
var isAn = this.device();
var _this = this;
// _this._init(function (bridge) {
// _this.__init__(bridge);
// bridge.callHandler(funcName, JSON.stringify(data), function (response) {
// if (callback)
// callback(JSON.parse(response));
// })
// }.bind(this))
if(isAn){
if(window.WebViewJavascriptBridge){
_this._init(function (bridge) {
_this.__init__(bridge);
bridge.callHandler(funcName, JSON.stringify(data), function (response) {
if (callback)
callback(JSON.parse(response));
})
}.bind(this))
}else{
document.addEventListener(
'WebViewJavascriptBridgeReady'
, function() {
_this._init(function (bridge) {
_this.__init__(bridge);
bridge.callHandler(funcName, JSON.stringify(data), function (response) {
if (callback)
callback(JSON.parse(response));
})
}.bind(this))
},
false
);
}
}else{
_this._init(function (bridge) {
_this.__init__(bridge);
bridge.callHandler(funcName, JSON.stringify(data), function (response) {
if (callback)
callback(JSON.parse(response));
})
}.bind(this))
}
};
/*
* 注册方法
*/
JSBridge.prototype.registerHandler = function(funcName,initFuc, params) {
var isAn = this.device();
var _this = this;
//处理android WebViewJavascriptBridge延时问题
if(isAn) {
if(window.WebViewJavascriptBridge){
_this._init(function (bridge) {
_this.__init__(bridge);
bridge.registerHandler(funcName, function (data, callback) {
if (initFuc) {
if (data) {
initFuc(JSON.parse(data));
} else {
initFuc();
}
}
/* if(callback)
callback(JSON.parse(data))*/
if (params) {
callback(JSON.stringify(params));
} else {
callback();
}
})
}.bind(this))
}else{
document.addEventListener('WebViewJavascriptBridgeReady', function() {
_this._init(function (bridge) {
_this.__init__(bridge);
bridge.registerHandler(funcName, function (data, callback) {
if (initFuc) {
if (data) {
initFuc(JSON.parse(data));
} else {
initFuc();
}
}
/* if(callback)
callback(JSON.parse(data))*/
if (params) {
callback(JSON.stringify(params));
} else {
callback();
}
})
}.bind(this))
}, false);
}
}else{
_this._init(function (bridge) {
_this.__init__(bridge);
bridge.registerHandler(funcName, function (data, callback) {
if (initFuc) {
if (data) {
initFuc(JSON.parse(data));
} else {
initFuc();
}
}
/* if(callback)
callback(JSON.parse(data))*/
if (params) {
callback(JSON.stringify(params));
} else {
callback();
}
})
}.bind(this))
}
};
/*
* 获取经纬度
*/
JSBridge.prototype.getJwd = function(callback, params) {
this._init(function(bridge) {
this.__init__(bridge);
bridge.callHandler( 'getJwd', JSON.stringify({}), function(response) {
var res = JSON.parse(response);
jwd = res["longitude"]+","+res["latitude"];
params["userLocation"] = jwd;
if(callback)
callback(params);
})
}.bind(this))
};
/*
* 全局变量设置
*/
if (typeof module !== 'undefined' && module.exports) {
module.exports = JSBridge;
} else if (typeof define === 'function' && (define.amd || define.cmd)) {
define(function() {
return JSBridge;
});
} else {
global.JSBridge = JSBridge;
};
})(this);

@ -0,0 +1,462 @@
/**使
* 目测会替换掉
* quick-view.js里面的
* QuickUrlUtils
* createOptions
*
* quick-easyuiUtils里面的
* createTreeList
* */
function QuickUtils() { }
QuickUtils.findByList = function (list, value, valueField) {
var item = null;
for (var i = 0; i < list.length; i++) {
var list_item = list[i];
var v = list_item[valueField];
if (v == value) {
item = list_item;
} else {
var children = list_item["children"];
if (children && children.length > 0) {
item = QuickUtils.findByList(children, value, valueField);
if (!item) {
continue;
} else {
break;
}
}
}
}
return item;
}
QuickUtils.createTreeList = function (config) {
var finalConfig = $.extend({}, QuickUtils.convertTreeListDefaultConfig, config);
var list = finalConfig["list"];
var sjdm = finalConfig["sjdm"];
var idField = finalConfig["idField"];
var textField = finalConfig["textField"];
var reldateField = finalConfig["reldateField"];
var itemIDField = finalConfig["itemIDField"];
var itemTextField = finalConfig["itemTextField"];
return QuickUtils.innerCreateTreeList(list, sjdm, idField, textField, reldateField, itemIDField, itemTextField);
}
QuickUtils.innerCreateTreeList = function (list, sjjgdm, idField, textField, reldateField, itemIDField, itemTextField) {
var childList = [];
for (var i = 0; i < list.length; i++) {
var item = list[i];
if (item == null) {
continue;
}
var sjjgdm1 = item[reldateField];
if (sjjgdm1 != sjjgdm) {
continue;
} else {
var id = item[idField];
item[itemTextField] = item[textField];
item[itemIDField] = item[idField];
var lt = QuickUtils.innerCreateTreeList(list, id, idField, textField, reldateField, itemIDField, itemTextField);
if (lt != null && lt.length != 0) {
item["children"] = lt;
}
childList.push(item);
list[i] = null;
}
}
if (childList.length == 0) {
childList = null;
}
return childList;
}
QuickUtils.convertTreeListDefaultConfig = {
/*上级代码值*/
sjdm: ""
/*ID字段*/
, idField: "XMDM"
/*text字段*/
, textField: "XMMC"
/*关联字段*/
, reldateField: "SJDM"
/*item的id字段*/
, itemIDField: "id"
/*item的text字段*/
, itemIDField: "text"
};
/**URL工具类*/
(function ($) {
var host = window.location.host;
var pathName = window.document.location.pathname.replace(/\/\//g, "/");
var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
var currPagePath = pathName.substring(0, pathName.substr(1).lastIndexOf('/') + 1)
$.QuickUrlUtils = {
redirectUrl: function (url) {
location = currPagePath + "/" + url;
},
redirectRootUrl: function (url) {
location = projectName + "/" + url;
}
, getProjectName: function () {
return projectName;
}
, geCurrPagePath: function () {
return currPagePath;
}
, getHost: function () {
return host;
}
, getHostProject: function () {
return host + projectName;
}
, forward: function (url, title, subTitle, isClose) {
StoreCache.setCache("title", title);
if ($.QuickVersion["isWeb"]) {
location = url;
}
else if ($.QuickVersion["isWeixin"]) {
location = url;
}
else if ($.QuickVersion["android"]) {
if (!isClose) isClose = "2";
var tzurl = currPagePath + "/" + url;
if (url.indexOf("FJZLYD") != -1) {
tzurl = url;
}
android.toWebViewActivity(tzurl, title, "", isClose);
}
else if ($.QuickVersion["iPhone"]) {
window.webkit.messageHandlers.fjzlyd.postMessage({ functionName: "toWebViewActivity", parameter: { url: currPagePath + "/" + url, title: title, subTitle: "", isClose: isClose } });
}
}
, forwardRootUrl: function (url, title, subTitle, isClose) {
if ($.QuickVersion["isWeb"]) {
location = projectName + "/" + url;
}
else if ($.QuickVersion["isWeixin"]) {
location = projectName + "/" + url;
}
else if ($.QuickVersion["android"]) {
if (!isClose) isClose = "2";
android.closeAllWebView(projectName + "/" + url, title, "", isClose);
}
else if ($.QuickVersion["iPhone"]) {
window.webkit.messageHandlers.fjzlyd.postMessage({ functionName: "toWebViewActivity", parameter: { url: projectName + "/" + url, title: title, subTitle: "", isClose: isClose } });
}
}
, forwardAny: function (url) {
location = url;
}
, openNewWindow: function (url, title) {
window.open(url);
}
//获取URL参数
, getRequest: function (key) {
var url = decodeURI(location.search); //获取url中"?"符后的字串
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substring(url.indexOf("?") + 1, url.length);
strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
if (!StringUtils.isEmpty(strs[i]))
theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
if (!key)
return theRequest;
else
return theRequest[key];
}
//获取URL参数
, getRequestByURL: function (url, key) {
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substring(url.indexOf("?") + 1, url.length);
strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
if (key == "")
return theRequest;
else
return theRequest[key];
}
/**退回上级页面*/
, back: function () {
history.back(-1);
}
/**预留jsbriage统一页面跳转*/
, redirectJSBridge: function (options, data) {
if ($.QuickVersion["isIOSApp"] || $.QuickVersion["isApp"]) {
//console.log('use app');
var params = {
"type": "H5",
"toPage": options["url"],
"hasNavigation": "true",
"animate": options.animate == undefined ? "push" : options.animate,
"params": data != undefined ? data : {},
"refreshUrl": options["refreshUrl"]
};
JSBridge.prototype.callHandler("forward", params);
//JSBridge.prototype.callHandler("gotoWebView", options);
}
else if ($.QuickVersion["isWeixin"] || $.QuickVersion["isWeb"]) {
console.log("进入判断了")
location.href = options["url"];
//当出现登录超时时,记住当前地址,登录之后跳转到当前地址。登录页和注册页以及忘记密码页 不做登录之后跳转的地址保存
// if(location.href && location.href.indexOf('login')<0){
// if(location.href.indexOf("?")>0){
// StoreCache.setCache("afterLoginUrl",location.href+"&afterLoginUrl=yes");
// }else{
// StoreCache.setCache("afterLoginUrl",location.href+"?afterLoginUrl=yes");
// }
// }else{
StoreCache.removeCache("afterLoginUrl");
// }
}
else {
location.href = options["url"];
StoreCache.removeCache("afterLoginUrl");
}
}
/**预留jsbriage统一页面返回*/
, rebackJSBridge: function (options) {
if ($.QuickVersion["isWeixin"]) {
location = options["url"];
}
else if ($.QuickVersion["isIOSApp"] || $.QuickVersion["isApp"]) {
// if(StringUtils.isEmpty(options["app_user_agent"])){
// options["url"] = currPagePath + "/" + options["url"];
// }
var params = {
"type": "H5",
"toPage": options["url"],
"hasNavigation": "true",
"animate": "pop",
};
JSBridge.prototype.callHandler("forward", params);
//JSBridge.prototype.callHandler("backtoWebView", options);
}
else if ($.QuickVersion["isWeb"]) {
location = options["url"];
}
else {
}
}
/**预留jsbriage统一页面刷新*/
, refreshJSBridge: function (options) {
if ($.QuickVersion["isIOSApp"] || $.QuickVersion["isApp"]) {
JSBridge.prototype.callHandler("refreshPage", options);
}
else if ($.QuickVersion["isWeb"] && options["url"]) {
location = options["url"];
}
else {
}
}
//在不提供上一页地址,返回上一页并刷新
, reBackAndRefreshJSBridge: function (url, topage) {
if ($.QuickVersion["isIOSApp"] || $.QuickVersion["isApp"]) {
var options = {
"type": "H5",
"toPage": topage ? topage : "",
"hasNavigation": "true",
"animate": "pop",
"refreshUrl": url ? url : ""
};
JSBridge.prototype.callHandler("forward", options);
}
else {
if(url && url!='*'){
location = url;
}else{
history.back(-1);
}
}
}
}
})(jQuery);
/**创建下拉框选项*/
(function ($) {
var defaultConfig = {
needNull: "true"
, textField: "XMMC"
, valueField: "XMDM"
};
$.fn.createOptions = function (ary, config) {
var finalConfig = $.extend({}, defaultConfig, config);
$(this).empty();
var needNull = finalConfig["needNull"];
var textField = finalConfig["textField"];
var valueField = finalConfig["valueField"];
var opts = [];
if (needNull == "true") {
var opt = $('<option>');
opt.attr("value", "");
opt.text("请选择");
//opt.css("display", "none");
opts.push(opt);
}
for (var i = 0; i < ary.length; i++) {
var item = ary[i];
var value = item[valueField];
var text = item[textField];
var option = $('<option>');
$(option).attr('value', value);
$(option).html(text);
$(option).data(item);
var children = item['children'];
if (!StringUtils.isEmpty(children)) {
$(option).attr("children", JSON.stringify(children));
}
opts.push(option);
//options += $(option)[0].outerHTML;
}
$(this).append(opts);
};
})(jQuery);
/**与原生交互*/
(function ($) {
$.JkcsUtils = {
getUserLocation: function (callBack, params) {
if ($.QuickVersion["isWeb"]) {
jwd = "";
params["userMapInfo"] = jwd;
if (callBack)
callBack(params);
}
else {
$.JkcsUtils.jsbridgeRegister("localCallBack",function(data){
var res = data;
if(res["longitude"]=='' && res["latitude"]==''){
var jwd = ''
}else{
var jwd = res["longitude"]+","+res["latitude"];
}
params["userMapInfo"] = jwd;
if(callBack)
callBack(params);
});
$.JkcsUtils.nativePermission({
"type": "location",
"callBackMethod": "localCallBack"
})
}
},
/**跳转到首页的方法*/
gotoHome: function (options) {
if ($.QuickVersion["isWeb"]) {
location = options["url"];
} else {
// alert(JSON.stringify(options));
JSBridge.prototype.callHandler("gotoHome", options);
}
},
/**收藏按钮图片加载*/
loadScImg: function (sfsc) {
if ($.QuickVersion["isWeb"]) {
if (sfsc == "delete") {
$(".sc-icon").removeAttr("style");
} else {
$(".sc-icon").attr("style", "background:url('/static/images/red-star.png') no-repeat;background-size: 100% 100%;");
}
}
else {
var params = {
"title": title
};
if (sfsc == "add") {
params["scImg"] = "sc_red";
} else {
params["scImg"] = "sc_white";
}
var option = $.JkcsTile.getTitle(titleType, params);
$.JkcsUtils.setHeader(option);
//JSBridge.prototype.callHandler("loadScImg", {sfsc: sfsc});
}
},
/**jsbridge注册*/
jsbridgeRegister: function (funName, initFunction, params) {
if ($.QuickVersion["isApp"] || $.QuickVersion["isIOSApp"]) {
JSBridge.prototype.registerHandler(funName, initFunction, params);
}
},
/**调用原生地图*/
gotoMap: function (params) {
if ($.QuickVersion["isApp"] || $.QuickVersion["isIOSApp"]) {
JSBridge.prototype.callHandler("forward", {
"type": "Native",
"toPage": "gotoMap",
"hasNavigation": "false",
"params": params
});
}
},
/**设置头部*/
setHeader: function (params) {
// alert("进入setHeader");
if ($.QuickVersion["isIOSApp"]) {
// alert("进入app的判断");
JSBridge.prototype.callHandler("setHeader", params);
} else if ($.QuickVersion["isApp"]) {
if (window.WebViewJavascriptBridge) {
//do your work here
// appInit();
JSBridge.prototype.callHandler("setHeader", params);
} else {
document.addEventListener(
'WebViewJavascriptBridgeReady'
, function () {
// appInit();
JSBridge.prototype.callHandler("setHeader", params);
//do your work here
},
false
);
}
}
},
/**请求数据*/
requestData: function (params) {
if ($.QuickVersion["isApp"] || $.QuickVersion["isIOSApp"]) {
JSBridge.prototype.callHandler("requestData", params);
}
},
/**请求数据*/
forward: function (params) {
if ($.QuickVersion["isApp"] || $.QuickVersion["isIOSApp"]) {
JSBridge.prototype.callHandler("forward", params);
}
},
/**原生权限*/
nativePermission: function (params) {
console.log(params);
JSBridge.prototype.callHandler("nativePermission", params);
// if ($.QuickVersion["isApp"] || $.QuickVersion["isIOSApp"]) {
// JSBridge.prototype.callHandler("nativePermission", params);
// }
}
}
})(jQuery);

@ -0,0 +1,176 @@
<template>
<div class="uploadfiles">
<LoadingD :status="loading"></LoadingD>
<van-steps active="0" active-icon="checked" active-color="#33cdc9">
<van-step>类型选择(上传)</van-step>
<van-step>选择日期</van-step>
<van-step>预约完成</van-step>
</van-steps>
<div class="head">
请上传"{{needinfo.label}}"相关证件
</div>
<div><van-button type="primary" round @click="callAPP()">4</van-button></div>
<div v-for="(item,index) in needinfo.fileList">
<div class="l_title">
{{item.label}}
</div>
<van-uploader :ref="`uploader${index}`" accept="" :name="index" :key="index" :after-read="afterRead"
v-model="needinfo.fileList[index].fileurl" preview-size="2.5rem" multiple>
<!-- <van-button icon="plus" plain size="small" type="primary">上传文件</van-button> -->
</van-uploader>
<van-button icon="plus" plain size="small" @click="callAPP(index)" type="primary">上传文件</van-button>
</div>
<van-button type="primary" class="button" round @click="to()"></van-button>
</div>
</template>
<script setup>
import {
onMounted,
ref
} from 'vue';
import {
showToast
} from 'vant';
import {
useRouter
} from "vue-router"
import {
UpFile
} from "@/api/api.js";
import {
usePiniaStore
} from '@/stores/index.js'
import Bridge from '@/jsBridge/Bridge.js'
let selectedNum=ref(null);//
const callAPP = () => {
console.log(66666);
// JSAPP
const param = {
type: 'photoLibrary',
callBackMethod: 'upLoadAjax',
params: {
maxCount: '1',
maxBytes: '2097152',
}
}
Bridge.callHandler('nativePermission', param, (res) => {
})
}
const zhuce=()=>{
Bridge.registerHandler('upLoadAjax', (datas, responseCallback) => {
alert(datas)
// this.msg = `appjs${datas}`
// console.log(`appjs${datas}`)
// console.log(`responseCallback:${responseCallback}`)
})
}
const pinia = usePiniaStore()
const router = useRouter();
const to = () => {
//
let t_filelist = []
let check_status = true
needinfo.value.fileList.forEach((v, k) => {
t_filelist.push([])
if (v.fileurl.length == 0) {
showToast('第' + (k + 1) + '项,不能为空');
check_status = false
}
v.fileurl.forEach((v1, k1) => {
t_filelist[k].push(v1.upurl)
})
})
let info = pinia.yuyue_info
info.upfileList = t_filelist
pinia.ChangeYuYueInfo(info)
console.log(info);
if (check_status) {
router.push('/selectDate')
}
}
let loading = ref(false)
let needinfo = ref([]) //
onMounted(() => {
zhuce()
if (pinia.yuyue_info.doc_id) {
needinfo.value = pinia.hangyeInfo[pinia.yuyue_info.doc_id - 1]
}
})
const afterRead = (file, detail) => {
if (Array.isArray(file)) {
file.forEach(item => {
item.status = 'uploading'
item.message = '上传中...'
uploadMaterialImg(item, detail)
})
} else {
file.status = 'uploading'
file.message = '上传中...'
uploadMaterialImg(file, detail)
}
}
const uploadMaterialImg = (file, detail) => {
var data = new FormData();
data.append('file', file.file);
loading.value = true
UpFile(data).then(res => {
loading.value = false
if (res.status == true) {
file.message = ''
file.status = ''
file.upurl = res.data
} else {
showToast(res.msg);
}
})
}
</script>
<style scoped>
.uploadfiles {
height: 100vh;
background-image: url('../assets/image/r_head2.jpg');
background-size: 50vw;
background-repeat: no-repeat;
background-position: 100% 100%;
padding: 20px;
}
.head {
font-size: 20px;
font-weight: 700;
color: #175e5c;
padding-top: 10px;
}
.l_title {
font-size: 14px;
color: #4e4e4e;
margin: 5px
}
.button {
width: calc(100vw - 40px);
background-color: #33cdc9;
border: 0px;
position: fixed;
bottom: 20px;
border: 3px solid #fff;
left: 20px
}
</style>

@ -9,15 +9,22 @@
<div class="head">
请上传"{{needinfo.label}}"相关证件
</div>
<!-- <div><van-button type="primary" round @click="callAPP()">4</van-button></div> -->
<div v-for="(item,index) in needinfo.fileList">
<div class="l_title">
{{item.label}}
</div>
<van-uploader :ref="`uploader${index}`" accept="" :name="index" :key="index" :after-read="afterRead"
v-model="needinfo.fileList[index].fileurl" preview-size="2.5rem" multiple>
<van-button icon="plus" plain size="small" type="primary">上传文件</van-button>
</van-uploader>
<!-- <van-uploader :ref="`uploader${index}`" accept="" :name="index" :key="index" :after-read="afterRead"
v-model="needinfo.fileList[index].fileurl" preview-size="2.5rem" multiple>
<van-button icon="plus" plain size="small" type="primary">上传文件</van-button>
</van-uploader> -->
<div style="display: flex;">
<img v-for="(item_image,index_image) in backImageList[index]" :key="index_image"
@click="DelImage(index,index_image)" style="width:40px;height: 40px;margin-right: 8px;"
:src="item_image" alt="">
<van-button icon="plus" plain size="small" @click="callAPP(index)" type="primary">上传文件</van-button>
</div>
</div>
<van-button type="primary" class="button" round @click="to()"></van-button>
</div>
@ -27,47 +34,130 @@
onMounted,
ref
} from 'vue';
import { showToast } from 'vant';
import {
showToast,showConfirmDialog
} from 'vant';
import {
useRouter
} from "vue-router"
import {
UpFile
UpFile,
UpFileBase64
} from "@/api/api.js";
import {
usePiniaStore
} from '@/stores/index.js'
import Bridge from '@/jsBridge/Bridge.js'
let selectedNum = ref(null); //
let backImageList = ref([
[],
[],
[],
[]
]); //
const callAPP = (index) => {
selectedNum.value = index
//console.log(66666);
// JSAPP
const param = {
type: 'photoLibrary',
callBackMethod: 'upLoadAjax',
params: {
maxCount: '1',
maxBytes: '2097152',
}
}
Bridge.callHandler('nativePermission', param, (res) => {
})
}
const zhuce = () => {
Bridge.registerHandler('upLoadAjax', (datas, responseCallback) => {
let dd = JSON.parse(datas)
//
loading.value = true
UpFileBase64({
base64file: dd['avatar']
}).then(res => {
loading.value = false
if (res.status == true) {
if (res.data.fileurl) {
try {
// alert(res.data.fileurl);
let data = {
upurl: res.data.fileurl
}
needinfo.value.fileList[selectedNum.value].fileurl.push(data);
let data2 = import.meta.env.VITE_APP_FILE_URL + res.data.fileurl
backImageList.value[selectedNum.value].push(data2);
} catch (e) {
alert(e)
}
}
} else {
showToast(res.msg);
}
})
// this.msg = `appjs${datas}`
// console.log(`appjs${datas}`)
// console.log(`responseCallback:${responseCallback}`)
})
}
const DelImage = (index,img_index) => {
showConfirmDialog({
title: '提示',
message:
'确定删除此图片吗',
})
.then(() => {
backImageList.value[index].splice(img_index,1);
needinfo.value.fileList[index].fileurl.splice(img_index,1);
})
.catch(() => {
// on cancel
});
}
const pinia = usePiniaStore()
const router = useRouter();
const to = () => {
//
let t_filelist=[]
let check_status=true
needinfo.value.fileList.forEach((v,k)=>{
let t_filelist = []
let check_status = true
needinfo.value.fileList.forEach((v, k) => {
t_filelist.push([])
if(v.fileurl.length==0){
showToast('第'+(k+1)+'项,不能为空');
check_status=false
if (v.fileurl.length == 0) {
showToast('第' + (k + 1) + '项,不能为空');
check_status = false
}
v.fileurl.forEach((v1,k1)=>{
v.fileurl.forEach((v1, k1) => {
t_filelist[k].push(v1.upurl)
})
})
})
let info = pinia.yuyue_info
info.upfileList = t_filelist
pinia.ChangeYuYueInfo(info)
console.log(info);
if(check_status){
if (check_status) {
router.push('/selectDate')
}
}
let loading = ref(false)
let needinfo = ref([]) //
onMounted(() => {
zhuce()
if (pinia.yuyue_info.doc_id) {
needinfo.value = pinia.hangyeInfo[pinia.yuyue_info.doc_id - 1]
}
@ -80,27 +170,27 @@
file.forEach(item => {
item.status = 'uploading'
item.message = '上传中...'
uploadMaterialImg(item,detail)
uploadMaterialImg(item, detail)
})
} else {
file.status = 'uploading'
file.message = '上传中...'
uploadMaterialImg(file,detail)
uploadMaterialImg(file, detail)
}
}
const uploadMaterialImg=(file,detail)=>{
const uploadMaterialImg = (file, detail) => {
var data = new FormData();
data.append('file', file.file);
loading.value = true
UpFile(data).then(res => {
loading.value = false
if (res.status == true) {
file.message = ''
file.status = ''
file.upurl=res.data
file.upurl = res.data
} else {
showToast(res.msg);
}

Loading…
Cancel
Save