<template>
<div>
<van-sticky>
<div class="header_box">
<van-nav-bar :border="false" left-text="" left-arrow>
<template #left>
<van-icon name="arrow-left" size="22" @click="goto_out" />
</template>
<template #title>
<span>123</span>
</template>
<template #right></template>
</van-nav-bar>
</div>
<!-- 搜索-->
<form action="">
<van-search v-model.trim="vinNo" placeholder="请输入123" @search="onSearch">
<template #left-icon>
<van-icon name="scan" @click="btn_scancode" size="20px" />
</template>
</van-search>
</form>
</van-sticky>
<!-- 123 -->
<!-- 内容 开始 -->
<div class="content">
<!-- 提示 -->
<div class="content_top" v-if="blackobj != null">
<div class="content_top_img box_img">
<img :src="blackobj.banner ? blackobj.banner : logoimg" alt="" srcset="">
</div>
<div style="margin-left: 5px;">
<div style="font-size: 16px;padding: 0 0 5px 0;"> {{ vinNo }}</div>
<div style="color: #A5B4DA;padding: 2px 0;"> {{ blackobj.sku }}</div>
<div style="color: #A5B4DA;padding: 2px 0;"> {{ blackobj.bikeModel }}</div>
</div>
</div>
<div class="content_bot">
<FlexLinePI :title="'123'" :dropshow="true">
<van-field v-model="remark" rows="3" autosize label="" type="textarea" placeholder="请填写123"
style="border: 1px solid #ddd;border-radius: 10px;" />
</FlexLinePI>
</div>
<div class="content_bot">
<div style="margin: 10px 0;">
<div style="font-size: 16px;padding:5px 0;">上传图片</div>
<div
style="width: 80px;height: 80px;float: left;margin: 0 10px 10px 0;position: relative;display: flex;justify-content: center;"
v-for="(it, id) in filepictureList" :key="id" @click="looktype(it, 'img')">
<img :src="it" alt="" style="max-width: 100%;max-height: 100%;">
<div class="close" style="" @click.stop="delimg(id)"><van-icon name="cross" /></div>
</div>
<van-uploader :max-count="10" multiple accept=".jpg, .jpeg, .png" :after-read="afterReadImg"
:max-size="10 * 1024 * 1024" @oversize="onOversize" v-if="filepictureList.length < 10" />
<div style="color: #A5B4DA;width: 100%;display: flex;justify-content: flex-start;">*(JPEG,PEG,最大10M,最多10张)</div>
</div>
</div>
<div class="content_bot">
<div style="margin: 10px 0;">
<div style="font-size: 16px;padding:5px 0;">上传视频</div>
<div
style="width: 80px;height: 80px;float: left;margin: 0 10px 10px 0;position: relative;display: flex;justify-content: center;"
v-for="(it, id) in filevideoList" :key="id" @click="looktype(it, 'video')">
<!-- :autoplay="false" -->
<video id="video" :autoplay="false" :controls="false" style="max-width: 100%;max-height: 100%;" :src="it" :poster="generatePosterUrl(it)">
<!-- <source :src="it" type="video/mp4" /> -->
</video>
<!-- <img :src="logoimg" alt="" style="max-width: 100%;max-height: 100%;"> -->
<div class="close" style="" @click.stop="delvideo(id)"><van-icon name="cross" /></div>
<van-icon name="play-circle-o" class="open_video" size="30px" color="#fff" />
</div>
<van-uploader :max-count="5" multiple accept="video/*" :after-read="afterReadVideo" :max-size="50 * 1024 * 1024"
@oversize="onOversizevideo" v-if="filevideoList.length < 5" />
<div style="color: #A5B4DA;width: 100%;display: flex;justify-content: flex-start;">*(MP4,最大50M,最多5个)</div>
</div>
</div>
</div>
<!-- 内容 结束 -->
<div class="bottom" style="justify-content: flex-end;">
<van-button type="info" round size="normal" block style="width: 100%;margin: 0 auto;" @click="btn_from"
class="">提交</van-button>
</div>
<!-- 弹框展示 图片 和视频 -->
<van-overlay :show="show" @click="show = false">
<div class="look_type">
<img :src="content" alt="" v-if="contenttype == 'img'" style="max-width: 100%;max-height: 100%;">
<video v-if="contenttype == 'video'" :autoplay="true" style="max-width: 100%;max-height: 100%;" :src="content"
controls disablepictureinpicture></video>
</div>
</van-overlay>
<van-overlay :show="upoadshow" @click="upoadshow = false" :close-on-click-overlay="false">
<div class="upoadshow_type">
<van-loading size="24px" vertical>上传中...</van-loading>
</div>
</van-overlay>
</div>
</template>
<script>
import {
compressImgNew
} from "@/assets/js/picture.js";
import { bikeinfo, fileSave } from '@/api/common.js'
import { flowsave, flowrupdate } from '@/api/index/index.js'
export default {
data() {
return {
logoimg: require('../../../../static/images/back_list.png'),
vinNo: '',
blackobj: null,
remark: "",
filepictureList: [],
filevideoList: [],
html5Qrcode: null,
error: '',
isScaning: false,
content: '',
contenttype: '',
show: false,
upoadshow: false
}
},
components: {
},
mounted() {
let _this = this;
window.giantapp_scan_callback = (res) => {
_this.giantapp_scan_callback(res);
};
window.onLoadQr = (res) => {
_this.onLoadQr(res);
};
},
computed: {},
methods: {
goto_out() {
const _this = this;
_this.$router.go(-1)
},
onSearch(val) {
const _this = this
bikeinfo({ vinNo: _this.vinNo }).then(res => {
if (res.status == 200) {
if (typeof res.data != "object") {
res.data = JSON.parse(res.data);
}
if (res.data.code == 200) {
_this.blackobj = res.data.data
_this.isScaning = false
} else if (res.data.code == 0) {
_this.$toast(res.data.msg ? res.data.msg : '网络加载失败,请稍后再试');
} else {
_this.blackobj = null
_this.$toast(res.data.msg ? res.data.msg : '网络加载失败,请稍后再试');
}
} else {
_this.$toast(res.data.msg ? res.data.msg : '网络加载失败,请稍后再试');
}
})
.catch(err => {
_this.$toast('网络加载失败,请稍后再试');
});
},
btn_from() {
const _this = this;
if (_this.blackobj == null) {
_this.$toast('请扫码或搜索进行添加信息');
return
}
if (_this.remark == '') {
_this.$toast('请输入123');
return
}
let parms = {
images: _this.filepictureList,
videos: _this.filevideoList,
shopCode: _this.GLOBAL.loginUser.mainOrgCode,
shopName: _this.GLOBAL.loginUser.mainOrgName,
dealerCode: _this.GLOBAL.loginUser.dealercode,
sbuCode: _this.GLOBAL.loginUser.sbucode,
sku: _this.blackobj.sku,
vinNo: _this.vinNo,
bikeModel: _this.blackobj.bikeModel,
banner: _this.blackobj.banner,
remark: _this.remark,
dealerName: _this.GLOBAL.loginUser.dealerName,
sbuName: _this.GLOBAL.loginUser.sbuName,
staffId: _this.GLOBAL.loginUser.staffId,
}
flowsave(
parms
).then(res => {
if (res.status == 200) {
if (typeof res.data != "object") {
res.data = JSON.parse(res.data);
}
if (res.data.code == 200) {
_this.$router.push({
path: "/",
})
_this.$toast(res.data.msg ? res.data.msg : '网络加载失败,请稍后再试');
} else {
_this.$toast(res.data.msg ? res.data.msg : '网络加载失败,请稍后再试');
}
} else {
_this.$toast(res.data.msg ? res.data.msg : '网络加载失败,请稍后再试');
}
})
.catch(err => {
_this.$toast('网络加载失败,请稍后再试');
});
},
afterReadImg(file) {
const _this = this;
_this.uploadfile(file, 'img')
},
afterReadVideo(file) {
const _this = this;
_this.uploadfile(file, 'video')
},
onOversize() {
_this.$toast('图片不能大于10M');
},
onOversizevideo() {
_this.$toast('图片不能大于50M');
},
delimg(id) {
const _this = this;
_this.filepictureList.splice(id, 1)
},
delvideo(id) {
const _this = this;
_this.filevideoList.splice(id, 1)
},
uploadfile(file, type) {
const _this = this;
_this.upoadshow = true
let formdata = new FormData();
formdata.append("file", file.file);
_this.axios.post(_this.GLOBAL.opo_gcross_api + '/crossSend/fileSave', formdata).then(function (res) {
if (res.status == 200) {
if (typeof res.data != "object") {
res.data = JSON.parse(res.data);
}
if (res.data.code == 200) {
if (type == 'img') {
_this.filepictureList = _this.filepictureList.concat(res.data.data)
} else {
_this.filevideoList = _this.filevideoList.concat(res.data.data)
}
_this.upoadshow = false
} else {
_this.upoadshow = false
_this.$toast(res.data.msg ? res.data.msg : '网络加载失败,请稍后再试');
}
} else {
_this.upoadshow = false
_this.$toast(res.data.msg ? res.data.msg : '网络加载失败,请稍后再试');
}
})
},
generatePosterUrl(videoUrl) {
return `${videoUrl}?vframe/jpg/offset/10/w/80px/h/80px`;
},
looktype(it, type) {
const _this = this;
_this.show = true
_this.content = it
_this.contenttype = type
},
btn_scancode() {
const _this = this;
if (_this.browser['wx']) {
_this.axios
.post(
"https://wechat.giant.com.cn/third/wechat.ashx?action=jspack2",
_this.qs.stringify({
apiname: "Giant",
apipwd: "Dline!@1587",
wxname: "giantfwh",
url: location.href.split("#")[0],
})
)
.then(function (res) {
var fetch_data = res.data.jspack;
wx.config({
debug: false,
appId: fetch_data.appId,
timestamp: fetch_data.timeStamp,
nonceStr: fetch_data.nonceStr,
signature: fetch_data.signatureStr,
jsApiList: ["scanQRCode"],
});
wx.ready(function () {
wx.checkJsApi({
jsApiList: ["scanQRCode"],
success: function (res) {
if (res.checkResult.scanQRCode === true) {
wx.scanQRCode({
desc: "scanQRCode desc",
needResult: 1,
scanType: ["qrCode", "barCode"],
success: function (res) {
let url_type = 0;
if (
res.resultStr.indexOf("https://") == 0 ||
res.resultStr.indexOf("http://") == 0
) {
if (res.resultStr.indexOf("giant.com.cn") == -1) {
url_type = 1;
}
if (res.resultStr.indexOf("qrgiant.com") == -1) {
url_type = 1;
}
if (res.resultStr.indexOf("qrgiant.cn") != -1) {
url_type = 1;
}
} else {
url_type = 1;
}
if (!url_type) {
_this.$dialog
.alert({
title: "提示",
message:
"您购买的产品可能属于假冒伪劣产品,请与门店确认",
confirmButtonText: "我知道了",
confirmButtonColor: "#4E66FF",
showCancelButton: false,
})
.then(() => { })
.catch(() => { });
return false;
}
const getCode = res.resultStr;
let url_index = res.resultStr.lastIndexOf("/");
_this.vinNo = res.resultStr.substring(
url_index + 1,
res.length
);
_this.onSearch()
},
});
} else {
alert("抱歉,当前客户端版本不支持扫一扫");
}
},
fail: function (res) {
alert("fail" + res);
},
});
});
wx.error(function (res) {
alert("配置验证失败: " + res.errMsg);
});
})
.catch(function (error) {
_this.$toast("出现了一些问题:" + error);
});
} else if (_this.browser['giantapp']) {
location.href = "ridelifegc://qrcode/scan";
} else if (_this.browser['giantopoapp']) {
if (_this.browser['ios']) {
window.webkit.messageHandlers.toQr.postMessage("");
} else {
android.toQr();
}
} else {
_this.$toast(
"请在微信端或者捷安特O+O经营助手APP与捷安特骑行APP环境下使用"
);
return false;
}
},
giantapp_scan_callback(res) {
const _this = this;
let url_type = 0;
if (res.indexOf("https://") == 0 || res.indexOf("http://") == 0) {
if (res.indexOf("giant.com.cn") != -1) {
url_type = 1;
}
if (res.indexOf("giantqrcode.kssina.com") != -1) {
url_type = 1;
}
if (res.indexOf("qrgiant.com") != -1) {
url_type = 1;
}
if (res.indexOf("qrgiant.cn") != -1) {
url_type = 1;
}
} else {
url_type = 1;
}
if (!url_type) {
_this.$dialog
.alert({
title: "提示",
message: "您购买的产品可能属于假冒伪劣产品,请与门店确认",
confirmButtonText: "我知道了",
confirmButtonColor: "#4E66FF",
showCancelButton: false,
})
.then(() => { })
.catch(() => { });
return false;
}
let url_index = res.lastIndexOf("/");
_this.vinNo = res.substring(url_index + 1, res.length);
_this.onSearch()
},
onLoadQr(res) {
const _this = this;
let url_type = 0;
if (res.indexOf("https://") == 0 || res.indexOf("http://") == 0) {
if (res.indexOf("giant.com.cn") != -1) {
url_type = 1;
}
if (res.indexOf("giantqrcode.kssina.com") != -1) {
url_type = 1;
}
if (res.indexOf("qrgiant.com") != -1) {
url_type = 1;
}
if (res.indexOf("qrgiant.cn") != -1) {
url_type = 1;
}
} else {
url_type = 1;
}
if (!url_type) {
_this.$dialog
.alert({
title: "提示",
message: "您购买的产品可能属于假冒伪劣产品,请与门店确认",
confirmButtonText: "我知道了",
confirmButtonColor: "#4E66FF",
showCancelButton: false,
})
.then(() => { })
.catch(() => { });
return false;
}
let url_index = res.lastIndexOf("/");
_this.vinNo = res.substring(url_index + 1, res.length);
_this.onSearch()
},
},
}
</script>
<style lang='less' scoped>
/deep/ .van-dropdown-menu__bar {
box-shadow: none;
}
.title_prompt {
background: #FFFBF3;
color: #DD9E1E;
border-radius: 10px;
padding: 10px;
margin: 0 0 10px 0;
}
.content {
padding: 10px;
margin-bottom: 60px;
.content_top {
display: flex;
background: #fff;
border-radius: 10px;
padding: 10px;
.content_top_img {
width: 100px;
height: 100px;
}
}
.content_bot {
background: #fff;
border-radius: 10px;
margin: 10px 0;
padding: 0 10px 10px 10px;
}
}
.line_radios {
display: inline-block;
margin: 5px 0;
color: #DD9E1E;
border: 1px solid #DD9E1E;
border-radius: 50px;
width: 20px;
height: 20px;
line-height: 17px;
text-align: center;
}
.container {
height: 100%;
width: 100%;
}
.qrcode {
position: fixed;
width: 100%;
height: 100%;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 999;
background-color: rgba(0, 0, 0, 0.48);
.close_icon {
position: absolute;
right: 10px;
top: 10px;
}
}
#reader {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.wrapper {
position: relative;
height: 100%;
}
.look_type {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.content_bot video::-webkit-media-controls {
display: none !important;
}
.custom-video-controls button {
}
</style>