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

删除多余e页面

parent 4f3ca04f
...@@ -6,19 +6,13 @@ ...@@ -6,19 +6,13 @@
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{ {
"path": "pages/photo/product", "path": "pages/photo/index",
"style": { "style": {
"navigationBarTitleText": "拍照小工具", "navigationBarTitleText": "拍照小工具",
"navigationBarBackgroundColor":"#FFFFFF", "navigationBarBackgroundColor":"#FFFFFF",
"backgroundColor":"#F4F5F7" "backgroundColor":"#F4F5F7"
} }
}, },
{
"path": "pages/photo/index",
"style": {
"navigationBarTitleText": "拍照小工具首页"
}
},
{ {
"path": "pages/index/index", "path": "pages/index/index",
"style": { "style": {
...@@ -141,16 +135,6 @@ ...@@ -141,16 +135,6 @@
"disableScroll": true "disableScroll": true
} }
}, },
{
"path": "pages/photo/detail",
"style": {
"navigationBarTitleText": "图片展示",
"navigationBarBackgroundColor": "#333333",
"navigationBarTextStyle": "#FFFFFF",
"disableScroll": true
}
},
{ {
"path": "pages/photo/preview", "path": "pages/photo/preview",
"style": { "style": {
...@@ -167,17 +151,6 @@ ...@@ -167,17 +151,6 @@
} }
}, },
{
"path": "pages/photo/brand",
"style": {
"navigationBarTitleText": "扳手会工单规范"
}
},
{ {
"path": "pages/index/success", "path": "pages/index/success",
"style": { "style": {
...@@ -278,8 +251,8 @@ ...@@ -278,8 +251,8 @@
"path": "pages/settle/index", //启动页面,必选 "path": "pages/settle/index", //启动页面,必选
"query": "" //启动参数,在页面的onLoad函数里面得到 "query": "" //启动参数,在页面的onLoad函数里面得到
},{ },{
"name": "拍照-规范", //模式名称 "name": "拍照-首页", //模式名称
"path": "pages/photo/take", //启动页面,必选 "path": "pages/photo/index", //启动页面,必选
"query": "" //启动参数,在页面的onLoad函数里面得到 "query": "" //启动参数,在页面的onLoad函数里面得到
},{ },{
"name": "基本信息", //模式名称 "name": "基本信息", //模式名称
......
<template>
<view class="backView">
<text class="topTitle"> {{product}} > 选择品牌</text>
<view class="u-p-b-48">
<view class="itemView u-m-t-48" @click="itemClick(item)" v-for="(item,ikey) in brandList":key="ikey">
<text class="itemTitle">{{item.name}}</text>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
product_code:'',
brandList:[],
brand_code:'',
product:'',
brand:'',
}
},
onLoad(e) {
getApp().trackPage('选择品牌页')
if(e && e.product_code){
this.product_code = e.product_code
}
if(e && e.product){
this.product = e.product
}
this.getBrandList()
},
methods: {
getBrandList: function () {
let that = this
this.$u.cloudApi.getBrand({product_code:this.product_code}).then(res =>{
console.log('获取品牌数据:')
console.log(res)
if(res.result.data){
that.brandList = res.result.data
}
}
)
},
//选择 点击
itemClick: function (item) {
if(item.product_code){
this.brand_code = item.code
}
if(item.name){
this.brand = item.name
}
uni.navigateTo({
url:'/pages/photo/list'
+ '?brand_code=' + this.brand_code
+ '&brand=' + this.brand
+ '&product_code=' + this.product_code
+ '&product=' + this.product,
})
},
}
}
</script>
<style>
.backView{
background-color: #FAFAFA;
position: absolute;
top: 0;
left: 0;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
.topTitle{
margin-top: 192rpx;
font-size: 32rpx;
}
.itemView{
background-color: #FFFFFF;
width: 548rpx;
height: 96rpx;
display: flex;
align-items: center;
justify-content: center;
border-style: solid;
box-shadow:0px 2px 7px 0px rgba(0, 0, 0, 0.05);
border-width: 0rpx;
}
.itemTitle{
font-size: 32rpx;
font-weight:bold;
}
</style>
<template>
<view class="backView">
<view class="topView">
<!--text class="topTitle">示范照片 ({{currentNumber}}/{{totalNumber}})</text-->
</view>
<view class="wrap">
<u-swiper
@click="imageClick"
@change="changeSwipter"
img-mode="aspectFit"
bg-color="#333333"
:height="600" :list="swiperList"
:autoplay="false"
:circular='false'
mode="dot"
:current="done_count"
></u-swiper>
</view>
<view class="bottomView">
<image class="takeView" :src="icon_gotake" mode="" @click="takeClick"></image>
<image class="backIcon" :src="icon_arrow_down" mode="" @click="backClick"></image>
</view>
</view>
</template>
<script>
import uSwiper from '@/uview-ui/components/u-swiper/u-swiper'
export default {
components:{
uSwiper
},
data() {
return {
// background: ['color1', 'color2', 'color3'],
// indicatorDots: true,
// autoplay: true,
// interval: 2000,
// duration: 500,
image_count:1,
current_count:1,
current_image:'',
done_count:0,
images:[],
icon_gotake:'https://qn-static.banshouhui.com/gotake.png',
icon_arrow_down:'https://qn-static.banshouhui.com/arrow_down.png',
ifFirst:true,
last_done_count:0,
swiperList:[],
windowHeight:0,
title:''
}
},
watch:{
images(val){
let list = val.map(img=>{
return {
image:img
}
})
this.swiperList = list
// console.log(this.swiperList,'this.swiperList')
}
},
computed:{
// swiperList(){
// console.log(this.images,'this.images')
// let list = this.images.map(img=>{
// return {
// image:img
// }
// })
// return list
// }
},
onLoad(e) {
getApp().trackPage('照片规范详情页')
this.initData(e)
},
onShow(){
if(this.isFirst == false){
this.checkDoneCount()
}
},
methods: {
initData: function (e) {
if(e && e.current_image){
this.current_image = e.current_image
}
if(e && e.image_count){
this.image_count = e.image_count
}
if(e && e.current_count){
this.done_count = e.current_count
}
if(e && e.current_count){
this.current_count = Math.max(e.current_count - 1, 0)
}
if(e && e.images){
this.images = [].concat(JSON.parse(e.images))
}
if(e && e.title){
this.title = e.title
if(this.title.length>6){
this.title = this.title.substr(0,6) + '...'
}
}
uni.setNavigationBarTitle({
title: this.title + ' (' + this.current_count + '/'+ this.image_count + ')'
})
uni.setNavigationBarColor({
frontColor:'#FFFFFF',
backgroundColor:'#333333',
})
},
//检查已拍照数量
checkDoneCount: function (){
let pages = getCurrentPages();
let currPage = pages[pages.length-1];
this.done_count = currPage.data.done_count
console.log('是否清除:')
//console.log(currPage.data.isClean)
if (currPage.data.done_count == this.image_count){
console.log('已拍完 所有数量照片')
uni.showToast({
icon:'none',
title:'已拍完此项照片'
})
setTimeout(function() {
uni.navigateBack({
})
}, 2000);
}else{
if(this.done_count != this.last_done_count ){
console.log('没有拍完 所有数量照片')
this.last_done_count = this.done_count
this.current_count = currPage.data.done_count + 1
this.current_image = this.images[currPage.data.done_count]
console.log('没有拍完 所有数量照片 current_count:'+this.current_count)
console.log('没有拍完 所有数量照片 current_image:'+this.current_image)
uni.setNavigationBarTitle({
title: this.title + ' (' + this.current_count + '/'+ this.image_count + ')'
})
}
}
},
//照片预览
imageClick: function (index) {
let currentImg = this.images[index]
uni.previewImage({
urls: [currentImg],
current:index
})
},
changeSwipter(index){
let txt = '走线照片 (' + (index + 1) + '/'+ this.image_count + ')'
uni.setNavigationBarTitle({
title: txt
})
},
//拍照 点击
takeClick: function () {
this.isFirst = false
uni.navigateTo({
url:'/pages/photo/try'
})
},
//返回 点击
backClick: function () {
uni.navigateBack({
})
},
}
}
</script>
<style>
.wrap {
width:100%;
height:calc(100vh - 600rpx);
background-color:#333;
/* padding:0 40rpx; */
}
.backView{
background-color: #FAFAFA;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
.topView{
background-color: #333333;
width: 100%;
height: 12%;
display: flex;
align-items: center;
justify-content: center;
}
.topTitle{
font-size: 28rpx;
color: #FFFFFF;
}
.centerBackView{
background-color: #333333;
height: 47.3%;
display: flex;
flex-direction: row;
}
.photoImage{
background-color: #333333;
width: 750rpx;
height: 568rpx;
}
.bottomView{
background-color: #333333;
width: 100%;
height: 40.7%;
position: fixed;
bottom: 0;
display: flex;
flex-direction: column-reverse;
align-items: center;
}
.takeView{
background-color: #FFFFFF;
width: 146rpx;
height: 102rpx;
border-radius: 16rpx;
margin-bottom: 50rpx;
display: flex;
align-items: center;
justify-content: center;
}
.takeText{
font-size: 28rpx;
text-align: center;
}
.backIcon{
background-color: #FFFFFF;
width: 54rpx;
height: 54rpx;
border-radius: 27rpx;
position: fixed;
left: 60rpx;
bottom: 50rpx;
}
</style>
<template> <template>
<view class="backView"> <view class="backView">
<view class="topView"> <view class="ph-pr-arr" v-for="(dataItem, index) in list" :key="index">
<view :class="activeTop == ikey ? 'topItemView whiteBackColor' : 'topItemView FAbackColor' " @click="topItemClick(ikey,item)" v-for="(item,ikey) in dataList":key="ikey"> <template v-if="dataItem.data.length > 0">
<text class="topActiveItemTitle" v-if="activeTop == ikey">{{item.type}}</text> <view class="topTitle"><text>{{ dataItem.title }}</text></view>
<text class="topItemTitle" v-if="activeTop != ikey">{{item.type}}</text> <view class="ph-pr-content">
</view> <view v-for="(item,ikey) in dataItem.data"
</view> :class="param[dataItem.type] === item._id ? 'select-item-view' : 'item-view'"
<view class="rightView"> @click="itemClick(dataItem.type, item)" :key="item._id">
<template <text class="itemTitle">{{item.name}}</text>
v-for="(item,ikey) in rightList"
>
<view :class="['rightItemView',item.clickable ? 'FAbackColor' : '']" @click="rightItemClick(item,ikey)" :key="ikey">
<view :class=" item.images ? 'rightContentView width_50' : 'rightContentView width_100' ">
<text :class=" item.clickable ? 'gray999Color rightTitle u-m-t-30 u-m-l-30' : 'rightTitle u-m-t-30 u-m-l-30' ">{{item.name}} ({{item.image_count}}张)</text>
<text class="rightContent u-m-t-14 u-m-l-30 u-p-b-30">{{item.describe}}</text>
</view>
<view class="rightImageView" v-if="item.images">
<image class="rightImage" :src="item.images[0]" mode=""></image>
</view> </view>
</view> </view>
</template> </template>
</view> </view>
<button class="ph-pr-button" type="primary" @click="handleClick" :disabled="!selectedAll"
:style="buttonStyle">下一步</button>
</view> </view>
</template> </template>
...@@ -29,128 +21,150 @@ ...@@ -29,128 +21,150 @@
export default { export default {
data() { data() {
return { return {
topList:[], classifyList: [],
topTitle:'', systemList: [],
activeTop:0, brandList: [],
leftList:[], param: {
rightList:[], classifyId: '',
product:'', systemId: '',
product_code:'', brandId: '',
brand:'',
brand_code:'',
dataList:[],
}
}, },
onLoad(e) { brandName: '',
getApp().trackPage('照片规范列表页') selectedAll: false,
if(e && e.product){
this.product = e.product
} }
},
if(e && e.product_code){ computed: {
this.product_code = e.product_code list() {
} return [{
title: '请选择类别',
if(e && e.brand){ type: 'classifyId',
this.brand = e.brand data: this.classifyList
uni.setNavigationBarTitle({ },
title: this.brand {
}); title: '请选择系统',
type: 'systemId',
data: this.systemList
},
{
title: '请选择品牌',
type: 'brandId',
data: this.brandList
} }
]
if(e && e.brand_code){ },
this.brand_code = e.brand_code buttonStyle() {
return this.selectedAll ? 'color: #FFFFFF;background-color: #2272FF;' :
'color: #FFFFFF;background-color: #D1D4D4;'
} }
this.topTitle = this.product + '-' + this.brand
this.getListData()
}, },
onLoad(e) {
getApp().trackPage('选择产品页')
this.getclassifyList()
onShow() {
console.log('onShow 里的rightList:')
console.log(this.rightList)
}, },
onShareAppMessage(res) {
let shareObj = {
title: '',
path: '/pages/photo/product',
imageUrl: '',
success() {},
fail() {}
}
return shareObj
},
methods: { methods: {
getListData: function (){ getclassifyList: function() {
console.log('getListData:')
console.log('product_code' + this.product_code)
console.log('brand_code' + this.brand_code)
let that = this let that = this
this.$u.cloudApi.getGroupStandard({product_code:this.product_code,brand_code:this.brand_code}).then(res =>{ this.$u.cloudApi.getClassifyDictionary().then(res => {
console.log('获取规范标准数据:') console.log('获取产品数据:')
console.log(res) console.log(res)
if(res.result && res.result.length){ if (res.result && res.result.data) {
that.handleData(res) that.classifyList = res.result.data
} that.param.classifyId = that.classifyList[0]._id
that.$u.cloudApi.getRelationDictionary({
"classify_id": that.param.classifyId,
"field": "system_id"
}).then(res1 => {
that.systemList = res1.result
}) })
}
})
}, },
handleData: function (res){ //选择 点击
itemClick: function(type, item) {
this.dataList = res.result
switch (type) {
this.dataList.forEach(item => { case 'classifyId':
this.param = {
item.list.forEach(subItem => { classifyId: item._id,
subItem.isClicked = false systemId: '',
brandId: ''
}
this.selectedAll = false
this.systemList = []
this.brandList = []
this.$u.cloudApi.getRelationDictionary({
"classify_id": this.param.classifyId,
"field": "system_id"
}).then(res => {
this.systemList = res.result
}) })
break
case 'systemId':
this.param = {
classifyId: this.param.classifyId,
systemId: item._id,
brandId: ''
}
this.selectedAll = false
this.brandList = []
this.$u.cloudApi.getRelationDictionary({
"classify_id": this.param.classifyId,
"system_id": this.param.systemId,
"field": "brand_id"
}).then(res => {
console.log('获取品牌数据:', res)
this.brandList = res.result
}) })
break
console.log('添加 新字段 后的数组:') case 'brandId':
console.log(this.dataList) this.param.brandId = item._id
this.selectedAll = true
var item = res.result[0] this.brandName = item.name
this.rightList = item.list break
}, default:
break
//顶部点击 }
topItemClick: function (ikey,item) {
this.activeTop = ikey
this.rightList = item.list
uni.pageScrollTo({scrollTop: 0, duration: 0});
}, },
//右侧点击 // 点击下一步
rightItemClick: function (item,ikey) { handleClick() {
// 点击下一步设置全局拍照品牌品类
// for (let i = 0; i < this.rightList.length; i++) { const globalData = getApp().globalData
// var subItem = this.rightList[i] let keys = ['brandId', 'brandName', 'classifyId', 'systemId']
// if(i == ikey){ keys.map(key => {
// subItem.isClicked = true globalData.photo.product[key] = this[key] || this.param[key]
// } })
// }
// item.clickable = true
this.$set(this.rightList[ikey],'clickable',true)
var current_image = item.images[0]
var current_count = 1
uni.navigateTo({ uni.navigateTo({
url:'/pages/photo/detail' url: '/pages/photo/list' +
+'?current_image=' + current_image '?brandId=' + this.param.brandId +
+'&image_count=' + item.image_count '&brand=' + this.brandName +
+'&current_count=' + current_count '&classifyId=' + this.param.systemId +
+'&images=' + JSON.stringify(item.images) '&systemId=' + this.param.systemId,
+'&title=' + item.name,
}) })
}, }
} }
} }
</script> </script>
<style> <style>
.backView{ .backView {
background-color: #FAFAFA; background-color: #FAFAFA;
position: absolute; position: absolute;
top: 0; top: 0;
...@@ -159,153 +173,73 @@ ...@@ -159,153 +173,73 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
height: 100%;
} }
.topTitle{ .topTitle {
margin-top: 80rpx; margin-top: 50rpx;
font-size: 32rpx; padding-left: 30rpx;
font-size: 36rpx;
font-weight: bold;
color: #333333;
} }
.centerBackView{ .ph-pr-content {
display: flex; display: flex;
flex-direction: row; flex-wrap: wrap;
margin-top: 80rpx; justify-content: flex-start;
width: 100%; width: 100%;
padding: 22rpx 22rpx;
} }
.leftView{ .ph-pr-arr {
background-color: #FFFFFF;
width: 20%;
display: flex;
flex-direction: column;
}
.leftItemView{
display: flex;
align-items: center;
justify-content: center;
width: 100%; width: 100%;
height: 80rpx;
border-bottom: 2rpx solid #F3F3F3;
}
.leftItemText{
font-size: 28rpx;
} }
.rightView{ .item-view {
background-color: #FFFFFF; background-color: #FFFFFF;
width: 100%; /* width: 548rpx; */
display: flex; margin: 0rpx 8rpx 24rpx 8rpx;
flex-direction: column; /* flex: 1 1 0%;
margin-top: 96rpx; max-width: 33%; */
} width: 222rpx;
height: 76rpx;
.rightItemView{
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
border-bottom: 20rpx solid #F3F3F3;
}
.rightContentView{
display: flex;
flex-direction: column;
border-left: 2rpx solid #F3F3F3;
}
.rightActiveContentView{
background-color: #4CD964;
display: flex;
flex-direction: column;
border-left: 2rpx solid #F3F3F3;
}
.width_50{
width: 480rpx;
}
.width_100{
width: 100%;
}
.rightTitle{
font-size: 32rpx;
color: #4D87EA;
}
.rightContent{
font-size: 28rpx;
color: #333333;
line-height: 40rpx;
}
.rightImageView{
width: 300rpx;
height: 320rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} border-style: solid;
box-shadow: 0px 2px 7px 0px rgba(0, 0, 0, 0.05);
.rightImage{ border-width: 0rpx;
background-color: #F3F3F3; border-radius: 12rpx;
width: 240rpx; font-size: 26rpx;
height: 240rpx; color: #666666;
} }
.select-item-view {
.topView{ background-color: #2272FF;
background-color: #FAFAFA; margin: 0rpx 8rpx 24rpx 8rpx;
width: 100%; /* flex: 1 1 0%;
height: 96rpx; max-width: 33%; */
position: fixed; width: 222rpx;
display: flex; height: 76rpx;
flex-direction: row;
}
.topItemView{
width: 210rpx;
height: 96rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
border-style: solid;
box-shadow: 0px 2px 7px 0px rgba(0, 0, 0, 0.05);
border-width: 0rpx;
border-radius: 12rpx;
font-size: 26rpx;
color: #FFFFFF;
} }
.whiteBackColor{ .ph-pr-button {
background-color: #FFFFFF; position: absolute;
} bottom: 76rpx;
border-radius: 52rpx;
.FAbackColor{ height: 104rpx;
background-color: #FAFAFA;
}
.topItemTitle{
font-size: 32rpx;
color: #999999;
padding-left: 30rpx;
}
.topActiveItemTitle{
font-size: 32rpx; font-size: 32rpx;
font-weight: bold; width: 600rpx;
color: #333333; line-height: 104rpx;
padding-left: 30rpx;
}
.greenBackColor{
background-color: #4CD964;
}
.gray999Color{
color: #999999;
} }
</style> </style>
<template>
<view class="backView">
<view class="ph-pr-arr" v-for="(dataItem, index) in list" :key="index">
<template v-if="dataItem.data.length > 0">
<view class="topTitle"><text>{{ dataItem.title }}</text></view>
<view class="ph-pr-content">
<view v-for="(item,ikey) in dataItem.data"
:class="param[dataItem.type] === item._id ? 'select-item-view' : 'item-view'"
@click="itemClick(dataItem.type, item)" :key="item._id">
<text class="itemTitle">{{item.name}}</text>
</view>
</view>
</template>
</view>
<button class="ph-pr-button" type="primary" @click="handleClick" :disabled="!selectedAll"
:style="buttonStyle">下一步</button>
</view>
</template>
<script>
export default {
data() {
return {
classifyList: [],
systemList: [],
brandList: [],
param: {
classifyId: '',
systemId: '',
brandId: '',
},
brandName: '',
selectedAll: false,
}
},
computed: {
list() {
return [{
title: '请选择类别',
type: 'classifyId',
data: this.classifyList
},
{
title: '请选择系统',
type: 'systemId',
data: this.systemList
},
{
title: '请选择品牌',
type: 'brandId',
data: this.brandList
}
]
},
buttonStyle() {
return this.selectedAll ? 'color: #FFFFFF;background-color: #2272FF;' :
'color: #FFFFFF;background-color: #D1D4D4;'
}
},
onLoad(e) {
getApp().trackPage('选择产品页')
this.getclassifyList()
},
onShareAppMessage(res) {
let shareObj = {
title: '',
path: '/pages/photo/product',
imageUrl: '',
success() {},
fail() {}
}
return shareObj
},
methods: {
getclassifyList: function() {
let that = this
this.$u.cloudApi.getClassifyDictionary().then(res => {
console.log('获取产品数据:')
console.log(res)
if (res.result && res.result.data) {
that.classifyList = res.result.data
that.param.classifyId = that.classifyList[0]._id
that.$u.cloudApi.getRelationDictionary({
"classify_id": that.param.classifyId,
"field": "system_id"
}).then(res1 => {
that.systemList = res1.result
})
}
})
},
//选择 点击
itemClick: function(type, item) {
switch (type) {
case 'classifyId':
this.param = {
classifyId: item._id,
systemId: '',
brandId: ''
}
this.selectedAll = false
this.systemList = []
this.brandList = []
this.$u.cloudApi.getRelationDictionary({
"classify_id": this.param.classifyId,
"field": "system_id"
}).then(res => {
this.systemList = res.result
})
break
case 'systemId':
this.param = {
classifyId: this.param.classifyId,
systemId: item._id,
brandId: ''
}
this.selectedAll = false
this.brandList = []
this.$u.cloudApi.getRelationDictionary({
"classify_id": this.param.classifyId,
"system_id": this.param.systemId,
"field": "brand_id"
}).then(res => {
console.log('获取品牌数据:', res)
this.brandList = res.result
})
break
case 'brandId':
this.param.brandId = item._id
this.selectedAll = true
this.brandName = item.name
break
default:
break
}
},
// 点击下一步
handleClick() {
// 点击下一步设置全局拍照品牌品类
const globalData = getApp().globalData
let keys = ['brandId', 'brandName', 'classifyId', 'systemId']
keys.map(key => {
globalData.photo.product[key] = this[key] || this.param[key]
})
uni.navigateTo({
url: '/pages/photo/list' +
'?brandId=' + this.param.brandId +
'&brand=' + this.brandName +
'&classifyId=' + this.param.systemId +
'&systemId=' + this.param.systemId,
})
}
}
}
</script>
<style>
.backView {
background-color: #FAFAFA;
position: absolute;
top: 0;
left: 0;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
height: 100%;
}
.topTitle {
margin-top: 50rpx;
padding-left: 30rpx;
font-size: 36rpx;
font-weight: bold;
color: #333333;
}
.ph-pr-content {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
width: 100%;
padding: 22rpx 22rpx;
}
.ph-pr-arr {
width: 100%;
}
.item-view {
background-color: #FFFFFF;
/* width: 548rpx; */
margin: 0rpx 8rpx 24rpx 8rpx;
/* flex: 1 1 0%;
max-width: 33%; */
width: 222rpx;
height: 76rpx;
display: flex;
align-items: center;
justify-content: center;
border-style: solid;
box-shadow: 0px 2px 7px 0px rgba(0, 0, 0, 0.05);
border-width: 0rpx;
border-radius: 12rpx;
font-size: 26rpx;
color: #666666;
}
.select-item-view {
background-color: #2272FF;
margin: 0rpx 8rpx 24rpx 8rpx;
/* flex: 1 1 0%;
max-width: 33%; */
width: 222rpx;
height: 76rpx;
display: flex;
align-items: center;
justify-content: center;
border-style: solid;
box-shadow: 0px 2px 7px 0px rgba(0, 0, 0, 0.05);
border-width: 0rpx;
border-radius: 12rpx;
font-size: 26rpx;
color: #FFFFFF;
}
.ph-pr-button {
position: absolute;
bottom: 76rpx;
border-radius: 52rpx;
height: 104rpx;
font-size: 32rpx;
width: 600rpx;
line-height: 104rpx;
}
</style>
<template>
<view class="blackBackColor">
<camera device-position="front" flash="on" style='width:100%; height:100vh; overflow: hidden;' @error="cameraRefuse">
<cover-view class="locationView">
<cover-view class="locationText u-m-l-20 u-m-t-30">经度:{{longitude}}</cover-view>
<cover-view class="locationText u-m-l-20 u-m-t-10">维度:{{latitude}}</cover-view>
<cover-view class="locationText u-m-l-20 u-m-t-10">地址:{{address}}</cover-view>
<cover-view class="locationText u-m-l-20 u-m-t-10">时间:{{date}}</cover-view>
</cover-view>
<cover-image class="liveWatermarkNormal" mode="aspectFit" :src="liveWaterMarkImage"></cover-image>
</camera>
<cover-view class="bottomView">
<cover-image class="backIcon" :src="icon_arrow_down" mode="" @click="simpleBack"></cover-image>
<!--cover-image class='switchIcon' :src='icon_switch_white' @click="switchClick()"> </cover-image-->
<cover-image class='takeIcon' :src='icon_take' @click="takePhoto()"> </cover-image>
<!--cover-image class='flashIcon' :src='icon_light_on_white' @click="flashClick()"> </cover-image-->
</cover-view>
<!--button @click="openSetting">打开设置页</button-->
<!--button open-type="openSetting" @opensetting="callback">打开设置页1111</button-->
<canvas v-show='showImage' canvas-id="canvas" :style="{'width':canvasWidth+'px','height': canvasHeight + 'px'}"></canvas>
</view>
</template>
<script>
let r = require("../../libs/bmap-wx.min.js");
let h = new r.BMapWX({
// ak: "rpVq5d3yxaRCoKzVwmFMo0o4iC524CAG",
ak: "lF1HoyXdiv4uZx6TrGQEZs48F5y8kEHI"
});
export default {
data() {
return {
title: '',
ctx: null,
path: "",
image: "",
showImage: false,
canvas: null,
longitude: '正在获取中...',
latitude: '正在获取中...',
address: '正在获取中...',
date: '正在获取中...',
icon_location: 'https://qn-static.banshouhui.com/take_order/icon/location.png',
scale: "4_3",
icon_take: 'https://qn-static.banshouhui.com/take.png',
icon_switch_white: 'https://qn-static.banshouhui.com/switch_white.png',
icon_light_on_white: 'https://qn-static.banshouhui.com/light_on_white.png',
liveWaterMarkImage: '/static/live_mark.png',
icon_arrow_down: 'https://qn-static.banshouhui.com/arrow_down.png',
icon_live_mark: 'https://qn-static.banshouhui.com/live_mark.png',
width: '',
height: '',
markPath: '',
canvasWidth: 0,
canvasHeight: 0,
restuleImage: '',
authSetting: []
}
},
onLoad(e) {
getApp().trackPage('拍照页')
this.ctx = uni.createCameraContext();
this.date = this.getTime()
this.getLocation()
this.getMarkPath()
this.getSystemInfo()
uni.setNavigationBarColor({
frontColor: '#FFFFFF',
backgroundColor: '#333333',
})
//this.address = ''
},
onShow() {
// uni.authorize({
// scope: 'scope.writePhotosAlbum',
// success() {
// console.log('userLocation')
// // uni.getLocation()
// }
// })
},
methods: {
baiduLocation() {
console.log('baiduLocation')
let a = this,
t = function() {
let t = {
success: function(res) {
let e = res.wxMarkerData[0];
console.log(e,e.address,'e.address')
let i = e.address;
a.address = i
// a.setData({
// addressValue: i
// }), o.globalData.addressValue = i, a.initWatermarkBoxHeightAndWidth();
},
fail: function(a) {
console.log(a, 'a')
// n.error(a), console.log(a);
}
};
if (a.latitude && a.longitude) {
let e = a.latitude + "," + a.longitude;
// let e = "113.88308" + ',' + "22.55329"
// let e = "22.55329" + ',' + "113.88308"
t.location = e;
}
h.regeocoding(t);
};
t()
},
goPage() {
// 进入图片预览页
},
simpleBack(){
const FileSystemManager = wx.getFileSystemManager()
FileSystemManager.getSavedFileList({
success (res) {
console.log(res,'res-getSavedFileList')
if (res.fileList.length > 0){
wx.removeSavedFile({
filePath: res.fileList[0].filePath,
complete (res) {
console.log(res)
}
})
}
}
})
return
wx.getSavedFileList({
success (res) {
console.log(res,'res')
if (res.fileList.length > 0){
wx.removeSavedFile({
filePath: res.fileList[0].filePath,
complete (res) {
console.log(res)
}
})
}
}
})
return
uni.navigateBack({
//delta: 2
});
},
goBack() {
let pages = getCurrentPages();
let prevPage = pages[pages.length - 2]; //上一个页面
prevPage.$vm.done_count++;
uni.navigateBack({
//delta: 2
});
},
getSystemInfo() {
// 获取设备信息
try {
const res = uni.getSystemInfoSync();
this.canvasWidth = res.windowWidth * 2
this.canvasHeight = res.windowHeight * 2
} catch (e) {
// error
}
},
//返回 点击
backClick: function() {
uni.navigateBack({
})
},
//获取位置
getLocation() {
let that = this
uni.getLocation({
type: 'gcj02',
success: function(res) {
console.log(res,'res')
that.longitude = parseFloat(res.longitude).toFixed(4)
that.latitude = parseFloat(res.latitude).toFixed(3)
console.log(that.longitude,'that.longitude',that.latitude,'that.latitude')
that.baiduLocation()
},
fail() {
that.showLocationAuthModal()
}
});
},
//定位 再次授权弹窗
showLocationAuthModal:function (){
let that = this
uni.showModal({
content:'拒绝授权将无法定位当前位置,是否去设置打开?',
confirmText: "确认",
cancelText: '取消',
success(res) {
if(res.confirm){
that.openLocationSetting()
}
if(res.cancel){
uni.navigateBack({
})
}
},
fail() {
console.log('')
}
})
},
//定位设置界面
openLocationSetting() {
let that = this
wx.openSetting({
success(res) {
console.log(res, 'openSetting.res')
console.log(res.authSetting, 'openSetting.res.authSetting')
console.log(res.authSetting['scope.camera'], 'openSetting.res.authSetting.scope.camera')
console.log(res.authSetting['scope.userLocation'], 'openSetting.res.authSetting.scope.userLocation')
if( res.authSetting['scope.userLocation'] && res.authSetting['scope.userLocation'] == true){
console.log('33333location reload page')
that.getLocation()
}else{
that.showLocationAuthModal()
console.log('444444')
}
}
})
},
//刷新当前页
reloadPage:function (){
uni.redirectTo({
url:'/pages/photo/try'
});
},
//获取 水印 本地缓存路径
getMarkPath: function() {
let that = this
uni.downloadFile({
url: this.icon_live_mark, //仅为示例,并非真实的资源
success: (res) => {
if (res.statusCode === 200) {
that.markPath = res.tempFilePath
}
},
fail() {
// console.log('水印图片 下载失败')
}
})
},
callback(res) {
console.log(res, 'res-callback')
},
//相机设置界面
openCameraSetting() {
let that = this
wx.openSetting({
success(res) {
console.log(res, 'openSetting.res')
console.log(res.authSetting, 'openSetting.res.authSetting')
console.log(res.authSetting['scope.camera'], 'openSetting.res.authSetting.scope.camera')
console.log(res.authSetting['scope.userInfo'], 'openSetting.res.authSetting.scope.userInfo')
if( res.authSetting['scope.camera'] && res.authSetting['scope.camera'] == true){
console.log('11111camera reload page')
that.reloadPage()
}else{
that.showCameraAuthModal()
console.log('222222')
}
}
})
},
//相机 再次授权弹窗
showCameraAuthModal:function (){
let that = this
uni.showModal({
content:'拒绝授权将无法拍照,是否去设置打开?',
confirmText: "确认",
cancelText: '取消',
success(res) {
if(res.confirm){
that.openCameraSetting()
}
if(res.cancel){
uni.navigateBack({
})
}
},
fail() {
console.log('')
}
})
},
//相机拒绝授权
cameraRefuse:function (){
console.log('相机拒绝授权')
this.showCameraAuthModal()
},
//第一步: 拍照
takePhoto() {
this.getLocation()
return
let that = this
this.ctx.takePhoto({
quality: 'high',
success: (res) => {
console.log(res)
//this.imageChange(res)
this.getImageInfo(res.tempImagePath)
//this.saveToLocal(res.tempImagePath)
}
});
},
//第二步: 获取图片信息
getImageInfo(tempImagePath) {
let that = this
uni.getImageInfo({
src: tempImagePath,
success(res) {
that.width = res.width + 'px';
that.height = res.height + 'px';
that.drawCanvas(tempImagePath, res)
}
})
},
//第三步: 绘制画布
drawCanvas: function(tempImagePath, res) {
uni.showLoading({
title: '数据处理中...',
icon: 'loading'
})
let canvasWidth = this.canvasWidth
let canvasHeight = this.canvasHeight
this.showImage = true
//将原图画到canvas上面
this.canvas = uni.createCanvasContext("canvas", this)
this.canvas.rect(0, 0, canvasWidth, canvasHeight)
this.canvas.drawImage(tempImagePath, 0, 0, canvasWidth, canvasHeight)
// this.canvas.draw()
//加入 水印文字
this.canvas.setFontSize(28)
this.canvas.setFillStyle('#f2f2f2')
let h = 1
let txtHeight = 36
this.canvas.fillText( '经度: ' + this.longitude, 20, canvasHeight - txtHeight * h++);
this.canvas.fillText( '维度: ' + this.latitude, 20, canvasHeight - txtHeight * h++);
this.canvas.fillText( '地址: ' + this.address, 20, canvasHeight - txtHeight * h++);
this.canvas.fillText( '时间: ' +this.date, 20, canvasHeight - txtHeight * h++);
//加入 水印图片
this.canvas.drawImage(this.markPath, canvasWidth / 2 - 200, canvasHeight / 2 - 50, 400, 100)
this.canvasImage()
// this.canvas.draw()
// uni.showLoading({
// title: '数据处理中...',
// icon: 'loading'
// })
// this.exportCanvasTempFilePath(res.width,res.height)
},
canvasImage() {
let self = this
this.canvas.draw(false, setTimeout(() => {
setTimeout(() => {
uni.canvasToTempFilePath({
// x: 0,
// y: 0,
width: Number(this.canvasWidth),
height: Number(this.canvasHeight),
canvasId: 'canvas',
success: (res) => {
self.saveToLocal(res.tempFilePath)
const FileSystemManager = wx.getFileSystemManager()
FileSystemManager.saveFile({
tempFilePath:res.tempFilePath,
success (res) {
console.log(res,'res-saveFile')
}
})
// this.$emit('canvasImage', res.tempFilePath);
// if (this.showPreview) {
// this.restultImage = res.tempFilePath
// self.showPreviewFn(res.tempFilePath);
// }
},
fail: (res) => {
console.log(res);
},
complete: () => {
uni.hideLoading();
}
}, this);
}, 500);
}));
},
showPreviewFn(img) {
uni.previewImage({
current: 0,
urls: [img]
});
},
//第五步: 保存到本地相册
saveToLocal(tempImagePath) {
let that = this
uni.saveImageToPhotosAlbum({
filePath: tempImagePath,
success() {
uni.showToast({
icon: 'none',
title: '已将照片保存到本地相册'
})
let timer = setTimeout(() => {
that.goBack()
}, 1500)
},
fail() {
// console.log('保存本地相册 失败')
///*
uni.showToast({
icon: 'none',
title: '保存本地相册失败'
})
uni.setStorage({
key: 'photo_tempPath',
data: tempImagePath,
success: function () {
console.log('tempImagePath save success');
let timer = setTimeout(() => {
that.showAlbumAuthModal()
}, 1500)
}
});
//*/
/*
let txt = '保存本地相册失败'
uni.getSetting({
success(res) {
let authSetting = res.authSetting
if (!authSetting['scope.writePhotosAlbum']) {
txt = '请打开相册权限'
}
uni.showToast({
icon: 'none',
title: txt
})
}
})
*/
// wx.openSetting({
// success (res) {
// console.log(res.authSetting,'openSetting')
// // res.authSetting = {
// // "scope.userInfo": true,
// // "scope.userLocation": true
// // }
// }
// })
// uni.authorize({
// scope: 'scope.writePhotosAlbum',
// success() {
// console.log('userLocation')
// uni.openSetting({
// success(res) {
// console.log(res,'openSetting')
// }
// });
// }
// })
}
})
},
//相册 再次授权弹窗
showAlbumAuthModal:function (){
let that = this
uni.showModal({
content:'拒绝授权照片将无法保存到本地相册,是否去设置打开?',
confirmText: "确认",
cancelText: '取消',
success(res) {
if(res.confirm){
that.openAlbumSetting()
}
if(res.cancel){
uni.navigateBack({
})
}
},
fail() {
console.log('')
}
})
},
//相机设置界面
openAlbumSetting() {
let that = this
wx.openSetting({
success(res) {
console.log(res, 'openSetting.res')
console.log(res.authSetting, 'openSetting.res.authSetting')
console.log(res.authSetting['scope.writePhotosAlbum'], 'openSetting.res.authSetting.scope.writePhotosAlbum')
if( res.authSetting['scope.writePhotosAlbum'] && res.authSetting['scope.writePhotosAlbum'] == true){
console.log('11111camera reload page')
uni.getStorage({
key:'photo_tempPath',
success: function (res) {
that.saveToLocal(res.data)
}
})
//that.reloadPage()
}else{
that.showAlbumAuthModal()
console.log('222222')
}
}
})
},
//获取当前时间
getTime: function() {
var date = new Date(),
year = date.getFullYear(),
month = date.getMonth() + 1,
day = date.getDate(),
hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
month >= 1 && month <= 9 ? (month = "0" + month) : "";
day >= 0 && day <= 9 ? (day = "0" + day) : "";
var timer = year + '/' + month + '/' + day + ' ' + hour + ':' + minute + ':' + second;
return timer;
},
}
}
</script>
<style>
.blackBackColor {
background-color: #000000;
overflow: hidden;
}
.bottomView {
background-color: #333333;
z-index: 5;
width: 100%;
height: 200rpx;
position: absolute;
bottom: 0;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.switchIcon {
background-color: #000000;
width: 50rpx;
height: 50rpx;
}
.takeIcon {
background-color: #333333;
width: 150rpx;
height: 150rpx;
}
.flashIcon {
background-color: #000000;
width: 50rpx;
height: 50rpx;
margin-left: 100rpx;
}
.locationView {
/* z-index: 5;
width: 300rpx;
position: absolute;
left: 0;
bottom: 200rpx;
display: flex;
flex-direction: column;
padding-bottom: 20rpx;
padding-right: 20rpx; */
bottom: 200rpx;
padding-bottom: 20rpx;
padding-right: 20rpx;
z-index: 4;
position: absolute;
font-size: 14px;
line-height: 18px;
color: #fff;
}
.locationText {
/* font-size: 24rpx;
color: #999999;
width: 260rpx; */
margin: 2px 0;
}
.liveWatermarkNormal {
z-index: 3;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 360rpx;
height: 90rpx;
z-index: 6;
}
.backIcon {
background-color: #FFFFFF;
width: 54rpx;
height: 54rpx;
border-radius: 27rpx;
position: fixed;
left: 60rpx;
bottom: 50rpx;
border: 2rpx solid #aaa;
}
.showCanvas {
background-color: #007AFF;
width: 100%;
height: 100%;
}
</style>
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