336 lines
9.2 KiB
Vue
336 lines
9.2 KiB
Vue
<template>
|
||
<view class="">
|
||
<view class="foot-box"
|
||
:style="{
|
||
background: isGradualChange ? `linear-gradient( to ${direction}, ${colorOne} 0%, ${colorTwo} 20%, ${colorThree} 80%, ${colorFour} 100%)` : `url(${backgroundImage}) ${backgroundColor} `,
|
||
boxShadow: `-10rpx 0rpx 20rpx rgba( 0, 0, 0, ${boxShadowNum})`
|
||
}">
|
||
<!-- 后台动态改变的icon与标题 start -->
|
||
<view @tap="choosefoot(index)" class="item-box" v-for="(item,index) in footList" :key="index">
|
||
<image :class="isIcon==index ? 'bulge' : ''" :style="{width:[40,40,40,40,37][index]+'rpx',height:[40,40,40,40,40][index]+'rpx'}" :src="current == index ? item.selectedIconPath : item.iconPath" mode="widthFix"></image>
|
||
<view class="clips1" :class="current==index ? 'activeclass' : 'defaultclass'">{{item.title}}</view>
|
||
</view>
|
||
<!-- 后台动态改变的icon图 end -->
|
||
</view>
|
||
</view>
|
||
|
||
</template>
|
||
<script>
|
||
// 引入qrcode.js (必须导出qrcode.js )
|
||
var qrcode = require('@/jsFile/qrcode.js');
|
||
export default {
|
||
name:'foot-tab',
|
||
props:{
|
||
// 当前选中项
|
||
current:{
|
||
type:Number,
|
||
default:0
|
||
},
|
||
// 默认哪个图标突出
|
||
isIcon:{
|
||
type:Number,
|
||
default:2
|
||
},
|
||
// 底部导航背景图片
|
||
backgroundImage:{
|
||
type:String,
|
||
default:'http://img.netbian.com/file/2021/1212/232713y3bCy.jpg'
|
||
},
|
||
// 背景颜色
|
||
backgroundColor:{
|
||
type:String,
|
||
default:'#FFFFFF'
|
||
},
|
||
// 是否开启背景颜色渐变
|
||
isGradualChange:{
|
||
type:Boolean,
|
||
default:true
|
||
},
|
||
// 渐变方向
|
||
direction:{
|
||
type:String,
|
||
default:'right top'
|
||
},
|
||
// 第一种颜色
|
||
colorOne:{
|
||
type:String,
|
||
default:'#FFFFFF'
|
||
},
|
||
// 第二种颜色
|
||
colorTwo:{
|
||
type:String,
|
||
default:'#FFFFFF'
|
||
},
|
||
// 第三种颜色
|
||
colorThree:{
|
||
type:String,
|
||
default:'#FFFFFF'
|
||
},
|
||
// 第四种颜色
|
||
colorFour:{
|
||
type:String,
|
||
default:'#FFFFFF'
|
||
},
|
||
// 阴影大小0~1之间 0表示没有阴影
|
||
boxShadowNum:{
|
||
type:Number,
|
||
default:0.1
|
||
},
|
||
},
|
||
data() {
|
||
return {
|
||
ifCustomerService:false,//是否存在客服 默认不存在客服
|
||
footList:[
|
||
{
|
||
iconPath: "/static/tabbar/icon-mo-home.png",
|
||
selectedIconPath: "/static/tabbar/icon-select-home.png",
|
||
title:'首页'
|
||
},
|
||
{
|
||
iconPath: "/static/tabbar/icon-mo-fun.png",
|
||
selectedIconPath: "/static/tabbar/icon-select-fun.png",
|
||
title:'项目列表'
|
||
},
|
||
{
|
||
iconPath: "/static/tabbar/icon-scan.png",
|
||
selectedIconPath: "/static/tabbar/icon-scan.png",
|
||
title:'扫码报修'
|
||
},
|
||
{
|
||
iconPath: "/static/tabbar/icon-mo-news.png",
|
||
selectedIconPath: "/static/tabbar/icon-select-news.png",
|
||
title:'意见反馈'
|
||
},
|
||
{
|
||
iconPath: "/static/tabbar/icon-mo-person.png",
|
||
selectedIconPath: "/static/tabbar/icon-select-person.png",
|
||
title:'我的'
|
||
}
|
||
]
|
||
};
|
||
},
|
||
mounted() {
|
||
// 打印qrcode 查看是否引入成功
|
||
console.log(qrcode,111)
|
||
},
|
||
methods:{
|
||
choosefoot(index){
|
||
if(index==0){
|
||
uni.reLaunch({url:'/pages/tabbar/pagehome/pagehome'})
|
||
} else {
|
||
if(this.$toolAll.tools.judgeAuth()) {
|
||
// 已授权
|
||
switch (index){
|
||
case 1:
|
||
uni.reLaunch({url:'/pagesA/project/projectList'})
|
||
break;
|
||
case 2:
|
||
// #ifdef APP-PLUS || MP-WEIXIN
|
||
this.$toolAll.tools.showToast(3)
|
||
uni.scanCode({
|
||
onlyFromCamera:false, // 是否只能从相机扫码,不允许从相册选择图片
|
||
scanType: ['qrCode'], // barCode:一维码, qrCode:二维码, datamatrix:Data Matrix 码, pdf417:PDF417 条码
|
||
autoDecodeCharset:true, // 是否启用自动识别字符编码功能,默认为否
|
||
success: function (res) {
|
||
// console.log(res);
|
||
// console.log('条码类型:' + res.scanType);
|
||
// console.log('条码内容:' + res.result);
|
||
let project_number = JSON.parse(res.result).project_number;
|
||
if(project_number) {
|
||
uni.navigateTo({
|
||
url:`/pagesA/repairsPage/repairsPage?project_number=${project_number}`
|
||
})
|
||
} else {
|
||
this.$toolAll.tools.showToast('请出示正确的码')
|
||
}
|
||
},fail() {
|
||
this.$toolAll.tools.showToast('扫描失败')
|
||
}
|
||
});
|
||
// #endif
|
||
// #ifdef H5
|
||
uni.showModal({
|
||
title:'提示',
|
||
content:'请使用,飞猴云服务APP进行扫一扫,是否马上下载APP?',
|
||
confirmText:'马上下载',
|
||
cancelText:'暂不下载',
|
||
success: (res) => {
|
||
if(res.confirm) {
|
||
|
||
}
|
||
}
|
||
})
|
||
// this.scanCode();
|
||
// #endif
|
||
break;
|
||
case 3:
|
||
uni.reLaunch({url:'/pagesA/feedback/feedback'})
|
||
break;
|
||
case 4:
|
||
uni.reLaunch({url:'/pages/tabbar/my/my'})
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
},
|
||
scanCode() {
|
||
let that = this
|
||
// 调用uni提供的调用相机api
|
||
uni.chooseImage({
|
||
sizeType: ['original'],
|
||
count: 1,
|
||
success: (res)=> {
|
||
// uni.showModal({
|
||
// title:'进入了'+JSON.stringify(res) ,
|
||
// content:JSON.stringify(res.tempFilePaths[0])
|
||
// })
|
||
qrcode.decode(this.getObjectURL(res.tempFilePaths[0]))
|
||
qrcode.callback = (codeRes) => {
|
||
if (codeRes.indexOf('error') >= 0) {
|
||
this.footList[2].title = 3;
|
||
// 二维码识别失败
|
||
console.log('不合法二维码:' + codeRes);
|
||
uni.showModal({
|
||
title:'请出示正确的码',
|
||
content:res
|
||
})
|
||
// this.$toolAll.tools.showToast('请出示正确的码')
|
||
} else {
|
||
this.footList[2].title = 2;
|
||
// 二维码识别成功
|
||
let r = this.decodeStr(codeRes)
|
||
// this.qrCodeRes = r
|
||
console.log(r);
|
||
}
|
||
}
|
||
// const tempFilePaths = res.tempFilePaths[0] // 获取到二维码图片的链接
|
||
// qrcode.decode(tempFilePaths); // 解析二维码图片
|
||
// qrcode.callback = function(res1) {
|
||
// // 解析失败返回 error decoding QR Code
|
||
// if (res1 == "error decoding QR Code") {
|
||
// uni.showToast({
|
||
// title: "识别二维码失败,请重新上传!",
|
||
// duration: 2000,
|
||
// icon: 'none'
|
||
// })
|
||
// } else {
|
||
// // 解析成功返回二维码链接
|
||
// console.log(res1)
|
||
// }
|
||
// }
|
||
},fail:(err)=> {
|
||
this.footList[2].title = 1;
|
||
this.$toolAll.tools.showToast(err)
|
||
this.$toolAll.tools.checkQx(err.code);
|
||
}
|
||
});
|
||
},
|
||
// 获取文件地址函数
|
||
getObjectURL(file) {
|
||
var url = null
|
||
// if (window.createObjectURL !== undefined) { // basic
|
||
// url = window.createObjectURL(file)
|
||
// } else if (window.URL !== undefined) { // mozilla(firefox)
|
||
// url = window.URL.createObjectURL(file)
|
||
// } else if (window.webkitURL !== undefined) { // webkit or chrome
|
||
// url = window.webkitURL.createObjectURL(file)
|
||
// }
|
||
url = window.URL.createObjectURL(file)
|
||
this.footList[2].title = url;
|
||
return url
|
||
},
|
||
// 解码,输出:中文
|
||
decodeStr(str) {
|
||
var out, i, len, c;
|
||
var char2, char3;
|
||
out = "";
|
||
len = str.length;
|
||
i = 0;
|
||
while (i < len) {
|
||
c = str.charCodeAt(i++);
|
||
switch (c >> 4) {
|
||
case 0:
|
||
case 1:
|
||
case 2:
|
||
case 3:
|
||
case 4:
|
||
case 5:
|
||
case 6:
|
||
case 7:
|
||
// 0xxxxxxx
|
||
out += str.charAt(i - 1);
|
||
break;
|
||
case 12:
|
||
case 13:
|
||
// 110x xxxx 10xx xxxx
|
||
char2 = str.charCodeAt(i++);
|
||
out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
|
||
break;
|
||
case 14:
|
||
// 1110 xxxx 10xx xxxx 10xx xxxx
|
||
char2 = str.charCodeAt(i++);
|
||
char3 = str.charCodeAt(i++);
|
||
out += String.fromCharCode(((c & 0x0F) << 12) |
|
||
((char2 & 0x3F) << 6) |
|
||
((char3 & 0x3F) << 0));
|
||
break;
|
||
}
|
||
}
|
||
return out;
|
||
},
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style scoped>
|
||
.clips1{display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 1;overflow: hidden;text-overflow: ellipsis;word-wrap: break-word;word-break:break-all;}
|
||
/* 外框样式 start */
|
||
.foot-box{
|
||
height: 110rpx;
|
||
font-size: 24rpx;
|
||
position: fixed;bottom: 0;left: 0;right: 0;z-index: 10;
|
||
display: flex;justify-content: space-around;
|
||
background-repeat: no-repeat;background-size: 100% 100%;
|
||
}
|
||
/* 外框样式 end */
|
||
.item-box {
|
||
position: relative;
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
padding: 16rpx 10rpx;
|
||
box-sizing: border-box;
|
||
width: 100%;
|
||
height: 110rpx;
|
||
}
|
||
/* 图标样式 */
|
||
.item-box image {
|
||
width: 64rpx;
|
||
height: 64rpx;
|
||
}
|
||
.item-box view{
|
||
margin-top: 10rpx;
|
||
}
|
||
/* 字体默认样式 */
|
||
.defaultclass {
|
||
color: #999999;
|
||
}
|
||
/* 字体选中样式 */
|
||
.activeclass {
|
||
color: #000000;
|
||
}
|
||
/* 凸出样式 */
|
||
.bulge {
|
||
position: absolute;
|
||
top: -30rpx;
|
||
width: 80rpx!important;
|
||
height: 80rpx!important;
|
||
border: 8rpx solid #FFFFFF;
|
||
border-radius: 100%;
|
||
vertical-align: middle;
|
||
box-shadow: 0rpx -3rpx 6rpx rgba(0,0,0,.1);
|
||
background-color: #FFFFFF;
|
||
}
|
||
</style>
|