Commit 1092ea9e authored by 李俊赕's avatar 李俊赕

delete-nouse-page

parent b5a22276
...@@ -110,24 +110,27 @@ ...@@ -110,24 +110,27 @@
}, },
{ {
"path": "pages/photo/product", "path": "pages/take/detail",
"style": { "style": {
"navigationBarTitleText": "扳手会工单规范" "navigationBarTitleText": "工单详情"
} }
}, },
{ {
"path": "pages/take/detail", "path": "pages/photo/index",
"style": { "style": {
"navigationBarTitleText": "工单详情" "navigationBarTitleText": "拍照小工具首页"
}
},
{
"path": "pages/photo/product",
"style": {
"navigationBarTitleText": "扳手会工单规范"
} }
}, },
{ {
"path": "pages/photo/try", "path": "pages/photo/take",
"style": { "style": {
"navigationBarTitleText": "拍照", "navigationBarTitleText": "拍照",
"navigationBarBackgroundColor": "#333333", "navigationBarBackgroundColor": "#333333",
...@@ -136,8 +139,6 @@ ...@@ -136,8 +139,6 @@
} }
}, },
{ {
"path": "pages/photo/detail", "path": "pages/photo/detail",
"style": { "style": {
...@@ -148,10 +149,6 @@ ...@@ -148,10 +149,6 @@
} }
}, },
{ {
"path": "pages/photo/preview", "path": "pages/photo/preview",
"style": { "style": {
...@@ -177,17 +174,6 @@ ...@@ -177,17 +174,6 @@
"navigationBarTitleText": "扳手会工单规范" "navigationBarTitleText": "扳手会工单规范"
} }
}, },
{
"path": "pages/photo/take",
"style": {
"navigationBarTitleText": "拍照-ljd",
"disableScroll": true
}
},
{ {
"path": "pages/index/success", "path": "pages/index/success",
"style": { "style": {
...@@ -289,7 +275,7 @@ ...@@ -289,7 +275,7 @@
"query": "" //启动参数,在页面的onLoad函数里面得到 "query": "" //启动参数,在页面的onLoad函数里面得到
},{ },{
"name": "拍照小工具", //模式名称 "name": "拍照小工具", //模式名称
"path": "pages/photo/try", //启动页面,必选 "path": "pages/photo/take", //启动页面,必选
"query": "" //启动参数,在页面的onLoad函数里面得到 "query": "" //启动参数,在页面的onLoad函数里面得到
},{ },{
"name": "基本信息", //模式名称 "name": "基本信息", //模式名称
......
<template>
<view class="backView">
<view class="topView">
<view :class="activeTop == ikey ? 'topItemView whiteBackColor' : 'topItemView FAbackColor' " @click="topItemClick(ikey,item)" v-for="(item,ikey) in dataList":key="ikey">
<text class="topActiveItemTitle" v-if="activeTop == ikey">{{item.type}}</text>
<text class="topItemTitle" v-if="activeTop != ikey">{{item.type}}</text>
</view>
</view>
<view class="rightView">
<template
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>
</template>
<!--template> </view>
<view>
<cover-view class="{{scale=='4_3'?'nav__scale-4-3':scale=='16_9'?'nav__scale-16-9':'nav__scale-full'}}" style="height:{{navHeight}}rpx;">
<cover-image @click="changeScale" class="nav-scaleIcon" mode="aspectFit" src="/image/{{scale}}_{{iconColor}}.png"></cover-image>
<cover-image @click="changeDevicePosition" class="nav-switchIcon" mode="aspectFit" src="/image/switch_{{iconColor}}.png"></cover-image>
<cover-image @click="changeLight" class="nav-lightIcon" mode="aspectFit" src="/image/light_{{light}}_{{iconColor}}.png"></cover-image>
</cover-view>
<camera binderror="binderror" bindinitdone="bindinitdone" bindstop="bindstop" class="camera" devicePosition="{{devicePosition}}" flash="{{light}}" resolution="high" style="height:{{cameraHeight}}rpx;top:{{scale=='4_3'?navHeight:0}}rpx">
<cover-view class="watermark-box" style="color:{{watermarkFontColor}}; {{watermarkStyle}}">
<cover-view class="watermark-box__item" v-if="{{lonLat}}">经度:{{longitudeValue?longitudeValue:'正在获取...'}}</cover-view>
<cover-view class="watermark-box__item" v-if="{{lonLat}}">纬度:{{latitudeValue?latitudeValue:'正在获取...'}}</cover-view>
<cover-view class="watermark-box__item" v-if="{{address}}">地址:{{addressValue?addressValue:'正在获取...'}}</cover-view>
<cover-view class="watermark-box__item" v-if="{{time}}">时间:{{timeValue?timeValue:'正在获取...'}}</cover-view>
<cover-view class="watermark-box__item" v-if="{{altitude}}">海拔:{{altitudeValue?altitudeValue:'正在获取...'}}</cover-view>
<cover-view class="watermark-box__item" v-if="{{weather}}">天气:{{weatherValue?weatherValue:'正在获取...'}}</cover-view>
<cover-view class="weui-flex" v-if="{{remarkArr.length>0}}">
<cover-view>备注:</cover-view>
<cover-view class="weui-flex__item" style="margin-top:1rpx;">
<cover-view v-for="{{remarkArr}}">{{item}}</cover-view>
</cover-view>
</cover-view>
</cover-view>
<cover-image class="{{direction=='normal'?'logoNormal':direction=='left'?'logoLeft':'logoRight'}}" mode="heightFix" src="{{logo}}" style="opacity:{{1-logoTransparency*5/100}};" v-if="{{logoEnable}}"></cover-image>
<cover-image class="{{direction=='normal'?'liveWatermarkNormal':direction=='left'?'liveWatermarkLeft':'liveWatermarkRight'}}" mode="aspectFit" src="{{liveWatermarkValue}}" v-if="{{liveWatermark}}"></cover-image>
<cover-image class="{{direction=='normal'?'handWritingNormal':direction=='left'?'handWritingLeft':'handWritingRight'}}" mode="aspectFit" src="{{handWriting}}"></cover-image>
</camera>
<cover-view class="camera-photoalbumIconBox {{tempImagePath?'':'1hidden'}}">
<cover-image @click="bindPhotoalbum" class="camera-photoalbumIcon" mode="aspectFill" src="{{tempImagePath}}"></cover-image>
</cover-view>
<cover-image @click="bindTakePhoto" class="camera-takeIcon" id="take" mode="aspectFit" src="/image/take.png"></cover-image>
<cover-image @click="bindSetting" class="camera-settingIcon" mode="aspectFit" src="/image/setting_white.png"></cover-image>
</view> </view>
<canvas class="photoCanvas" id="photoCanvas" style="height:{{canvasHeight}}rpx;width:{{canvasWidth}}rpx;" type="2d"></canvas>
</template> </template>
<script> <script>
export default {
// import mp_dialog from '/miniprogram_npm/weui-miniprogram/dialog/dialog';
// import mp_con from '/miniprogram_npm/weui-miniprogram/icon/icon';
// import mp_form_page from '/miniprogram_npm/weui-miniprogram/form-page/form-page';
// import mp_form from '/miniprogram_npm/weui-miniprogram/form/form';
// import mp_cell from '/miniprogram_npm/weui-miniprogram/cell/cell';
// import mp_cells from '/miniprogram_npm/weui-miniprogram/cells/cells';
// import mp_slideview from '/miniprogram_npm/weui-miniprogram/slideview/slideview';
// import mp_toptips from '/miniprogram_npm/weui-miniprogram/toptips/toptips';
// import mp_actionSheet from '/miniprogram_npm/weui-miniprogram/actionsheet/actionsheet';
// import mp_halfScreenDialog from '/miniprogram_npm/weui-miniprogram/half-screen-dialog/half-screen-dialog';
// import mp_msg from '/miniprogram_npm/weui-miniprogram/msg/msg';
// import color_picker from '/miniprogram_npm/mini-color-picker/color-picker';
// export default {
// components: {
// "mp-dialog":mp_dialog,
// "mp-icon":mp_con,
// "mp-form-page":mp_form_page,
// "mp-form":mp_form,
// "mp-cell":mp_cell,
// "mp-cells":mp_cells,
// "mp-slideview":mp_slideview,
// "mp-toptips":mp_toptips,
// "mp-actionSheet":mp_actionSheet,
// "mp-halfScreenDialog":mp_halfScreenDialog,
// "mp-msg":mp_msg,
// "color-picker":color_picker
// },
data() { data() {
return { return {
navHeight: o.globalData.navHeight, topList:[],
scale: "4_3", topTitle:'',
iconColor: "white", activeTop:0,
devicePosition: "back", leftList:[],
light: "off", rightList:[],
canvasWidth: 750, product:'',
canvasHeight: 1e3, product_code:'',
cameraHeight: 1e3, brand:'',
watermarkStyle: "bottom:20rpx;left:20rpx;", brand_code:'',
direction: "normal", dataList:[],
liveWatermarkValue: "/image/live_mark.png",
baiduLocationTimer: null,
wxLocationTimer: null,
netTimeTimer: null,
localTimeTimer: null,
takePhotoTimer: 0,
originalWeather: !1,
a:'',
t:'',
i:'',
o:'',
n:'',
r:'',
l:'',
s:'',
h:''
} }
}, },
// var a onLoad(e) {
// t = require("../../@babel/runtime/helpers/interopRequireDefault"), getApp().trackPage('照片规范列表页')
// e = t(require("../../@babel/runtime/regenerator")), if(e && e.product){
// i = t(require("../../@babel/runtime/helpers/asyncToGenerator")), this.product = e.product
// o = getApp(), n = wx.getRealtimeLogManager(), }
// r = require("../../libs/bmap-wx.min.js"), l = require("../../utils/util.js"),
// s = !0,
// h = new r.BMapWX({
// ak: "rpVq5d3yxaRCoKzVwmFMo0o4iC524CAG"
// });
onLoad: function(a) {
this.listeningDeviceMotion(), this.originalWeather = o.globalData.weather, o.globalData.weather && this.baiduWeather(),
setTimeout(function() {
s = !1;
}, 2e3);
this.initabcde()
},
onReady: function() {},
onShow: function() {
wx.startDeviceMotionListening();
var a = o.globalData.remark, t = this.formatRemark(a);
o.globalData.remarkArr = t, this.setData({
lonLat: o.globalData.lonLat,
address: o.globalData.address,
time: o.globalData.time,
altitude: o.globalData.altitude,
weather: o.globalData.weather,
liveWatermark: o.globalData.liveWatermark,
remarkArr: o.globalData.remarkArr,
handWriting: o.globalData.handWriting,
logoEnable: o.globalData.logoEnable,
logo: o.globalData.logo,
latLonFormat: o.globalData.latLonFormat,
watermarkFont: o.globalData.watermarkFont,
watermarkFontColor: o.globalData.watermarkFontColor,
logoTransparency: o.globalData.logoTransparency
}), (o.globalData.lonLat || o.globalData.altitude) && (this.wxLocation(), wx.startLocationUpdate()),
o.globalData.address && this.baiduLocation(), o.globalData.time && this.netTime(),
o.globalData.weather && this.originalWeather != o.globalData.weather && this.baiduWeather(),
this.initWatermarkBoxHeightAndWidth();
},
onHide: function() {
wx.stopDeviceMotionListening().catch(function(a) {
console.log(a);
}), (o.globalData.lonLat || o.globalData.altitude) && wx.stopLocationUpdate().catch(function(a) {
console.log(a);
}), clearInterval(this.baiduLocationTimer), clearInterval(this.wxLocationTimer),
clearInterval(this.netTimeTimer), clearInterval(this.localTimeTimer);
},
onUnload: function() {
wx.stopDeviceMotionListening();
},
onPullDownRefresh: function() {},
onReachBottom: function() {},
onShareAppMessage: function() {},
bindinitdone: function(a) {},
bindstop: function(a) {},
binderror: function(a) {},
if(e && e.product_code){
methods: { this.product_code = e.product_code
}
initabcde: function() { if(e && e.brand){
var a this.brand = e.brand
t = require("../../@babel/runtime/helpers/interopRequireDefault"), uni.setNavigationBarTitle({
e = t(require("../../@babel/runtime/regenerator")), title: this.brand
i = t(require("../../@babel/runtime/helpers/asyncToGenerator")),
o = getApp(),
n = wx.getRealtimeLogManager(),
r = require("../../libs/bmap-wx.min.js"),
l = require("../../utils/util.js"),
s = !0,
h = new r.BMapWX({
ak: "rpVq5d3yxaRCoKzVwmFMo0o4iC524CAG"
}); });
}, }
initWatermarkBoxHeightAndWidth: function() { if(e && e.brand_code){
var a = this; this.brand_code = e.brand_code
wx.nextTick(function() { }
wx.createSelectorQuery().select(".watermark-box").boundingClientRect(function(t) {
a.watermarkBoxHeight = t.height, a.watermarkBoxWidth = t.width, a.changeWatermark();
}).exec();
});
},
listeningDeviceMotion: function() {
var a = this;
wx.onDeviceMotionChange(function(t) {
if ("ios" == o.globalData.platform) {
var e = parseFloat(t.alpha);
a.direction = e > 45 && e < 136 ? "left" : e > 225 && e < 316 ? "right" : "normal";
} else t.gamma < -40 && t.gamma > -130 ? a.direction = "right" : t.gamma > 40 && t.gamma < 130 ? a.direction = "left" : a.direction = "normal";
a.direction != a.lastDirection && (a.setData({
direction: a.direction
}), a.changeCanvas(), a.changeWatermark()), a.lastDirection = a.direction;
});
},
changeCanvas: function() {
var a = this, t = this.direction, e = this.data.canvasWidth, i = this.data.canvasHeight;
"normal" == t ? this.setData({
canvasHeight: Math.max(i, e),
canvasWidth: Math.min(i, e)
}) : this.setData({
canvasHeight: Math.min(i, e),
canvasWidth: Math.max(i, e)
}), wx.createSelectorQuery().select("#photoCanvas").fields({
node: !0,
size: !0
}).exec(function(t) {
a.canvas = t[0].node;
var e = t[0].width, i = t[0].height, n = o.globalData.pixelRatio;
a.canvas.width = e * n, a.canvas.height = i * n, a.canvas.getContext("2d").scale(n, n);
});
},
changeScale: function() {
var a, t = this, e = this.data.scale, i = this.direction, n = this.data.canvasWidth, r = this.data.canvasHeight;
"4_3" == e ? (this.setData({
scale: "16_9",
iconColor: "white",
cameraHeight: 16 / 9 * 750
}), a = 16 / 9 * 750) : "16_9" == e ? (this.setData({
scale: "full",
iconColor: "white",
cameraHeight: o.globalData.rpxScreenHeight
}), a = o.globalData.rpxScreenHeight) : (this.setData({
scale: "4_3",
iconColor: "white",
cameraHeight: 1e3
}), a = 1e3), "normal" == i ? this.setData({
canvasHeight: a,
canvasWidth: Math.min(r, n)
}) : this.setData({
canvasWidth: a,
canvasHeight: Math.min(r, n)
}), wx.nextTick(function() {
t.changeCanvas(), setTimeout(function() {
t.changeWatermark();
}, 500);
});
},
changeWatermark: function() {
var a, t = this.data.direction, e = Math.min(this.watermarkBoxWidth, this.watermarkBoxHeight), i = Math.max(this.watermarkBoxWidth, this.watermarkBoxHeight);
a = "left" == t ? [ "top:" + (20 - 2 * e + 10) + "rpx", "left:20rpx", "transform-origin: left bottom", "transform: rotate(90deg)" ].join(";") : "right" == t ? [ "bottom:" + 2 * i + "rpx", "right:20rpx", "transform-origin: right bottom", "transform: rotate(-90deg)" ].join(";") : [ "bottom:20rpx", "left:20rpx" ].join(";"),
this.setData({
watermarkStyle: a
});
},
formatRemark: function(a) {
for (var t = [], e = 0, i = 15; i < a.length; i += 15) t.push(a.substring(15 * e, i)),
e++;
return a.length % 15 != 0 && t.push(a.substring(15 * e, 15 * e + a.length % 15)),
t;
},
changeDevicePosition: function() {
"back" == this.data.devicePosition ? this.setData({
devicePosition: "front"
}) : this.setData({
devicePosition: "back"
});
},
changeLight: function() {
var a = this.data.light;
"torch" == a ? this.setData({
light: "off"
}) : "off" == a ? this.setData({
light: "on"
}) : "on" == a ? this.setData({
light: "auto"
}) : this.setData({
light: "torch"
});
},
bindPhotoalbum: function(a) {
wx.navigateTo({
url: "/pages/photoalbum/photoalbum?photoPath=" + this.data.tempImagePath
});
},
bindSetting: function() {
wx.navigateTo({
url: "/pages/settings/settings"
});
},
bindTakePhoto: function() {
var a = this;
if (!s && 0 == this.takePhotoTimer) {
this.takePhotoTimer = 1, setTimeout(function() {
a.takePhotoTimer = 0;
}, 1500), this.takePhotoAnimate();
wx.createCameraContext().takePhoto({
quality: "high"
}).then(function(t) {
a.drawPhoto(t.tempImagePath);
}).catch(function(a) {
n.error(a), console.log(a);
});
}
},
drawPhoto: (a = (0, i.default)(e.default.mark(function a(t) {
var i, n, r, l, s, h, c, g, u, d, m = this;
return e.default.wrap(function(a) {
for (;;) switch (a.prev = a.next) {
case 0:
return i = this.canvas.getContext("2d"), n = o.globalData.screenHeight / o.globalData.rpxScreenHeight,
r = this.data.canvasWidth * n, l = this.data.canvasHeight * n, a.next = 6, new Promise(function(a) {
var e = m.canvas.createImage();
e.onload = function() {
var t = r, o = l, n = m.data.direction;
"left" == n ? (i.translate(0, o), i.rotate(-Math.PI / 2), i.drawImage(e, 0, 0, o, t),
i.rotate(Math.PI / 2), i.translate(0, -o)) : "right" == n ? (i.translate(t, 0),
i.rotate(Math.PI / 2), i.drawImage(e, 0, 0, o, t), i.rotate(-Math.PI / 2), i.translate(-t, 0)) : i.drawImage(e, 0, 0, t, o),
console.log("已画照片"), a("已画照片");
}, e.onerror = function() {
console.log("照片加载失败"), a();
}, e.src = t;
});
case 6: this.topTitle = this.product + '-' + this.brand
if (!this.data.liveWatermark || !this.data.liveWatermarkValue || "" == this.data.liveWatermarkValue) { this.getListData()
a.next = 9;
break;
}
return a.next = 9, new Promise(function(a) {
var t = m.canvas.createImage();
t.onload = function() {
var e = 360 * n, o = 90 * n, s = r / 2 - e / 2, h = l / 2 - o / 2;
i.drawImage(t, s, h, e, o), console.log("已画现场水印"), a("已画现场水印");
}, t.onerror = function() {
console.log("现场水印加载失败"), a();
}, t.src = m.data.liveWatermarkValue;
});
case 9:
if (!this.data.handWriting || "" == this.data.handWriting) {
a.next = 12;
break;
}
return a.next = 12, new Promise(function(a) {
var t = m.canvas.createImage();
t.onload = function() {
var e = 150 * n, o = 150 * n, s = r - e - 10, h = l - 10;
i.translate(s, h), i.rotate(-Math.PI / 2), i.drawImage(t, 0, 0, e, o), i.rotate(Math.PI / 2),
i.translate(-s, -h), console.log("已画手写签名水印"), a("已画手写签名水印");
}, t.onerror = function() {
console.log("手写签名水印加载失败"), a();
}, t.src = m.data.handWriting;
});
case 12:
if (!this.data.logoEnable || !this.data.logo || "" == this.data.logo) {
a.next = 16;
break;
}
return console.log("画水印LOGO"), a.next = 16, new Promise(function(a) {
var t = m.canvas.createImage();
t.onload = function() {
var e = 150 * n, l = 150 * n, s = r - e - 10, h = 1 - 5 * o.globalData.logoTransparency / 100;
i.globalAlpha = h, i.drawImage(t, s, 10, e, l), i.globalAlpha = 1, console.log("已画水印LOGO"),
a("已画水印LOGO");
}, t.onerror = function() {
console.log("水印LOGO加载失败"), a();
}, t.src = m.data.logo;
});
case 16: },
if (console.log("画水印信息"), i.font = "14px", i.fillStyle = this.data.watermarkFontColor,
s = l - 14, h = 0, (c = this.data.remarkArr) && c.length > 0) { onShow() {
for (g = c.length - 1; g >= 1; g--) u = c[g], i.fillText(u, 52, s - 18 * h++); console.log('onShow 里的rightList:')
d = c[0], i.fillText("备注:" + d, 10, s - 18 * h++); console.log(this.rightList)
} },
this.data.weather && this.data.weatherValue && i.fillText("天气:" + this.data.weatherValue, 10, s - 18 * h++),
this.data.altitude && this.data.altitudeValue && i.fillText("海拔:" + this.data.altitudeValue, 10, s - 18 * h++), methods: {
this.data.time && this.data.timeValue && i.fillText("时间:" + this.data.timeValue, 10, s - 18 * h++),
this.data.address && this.data.addressValue && i.fillText("地址:" + this.data.addressValue, 10, s - 18 * h++),
this.data.lonLat && this.data.latitudeValue && this.data.longitudeValue && (i.fillText("纬度:" + this.data.latitudeValue, 10, s - 18 * h++),
i.fillText("经度:" + this.data.longitudeValue, 10, s - 18 * h++)), this.savaToTempFile();
case 31: getListData: function (){
case "end":
return a.stop(); console.log('getListData:')
} console.log('product_code' + this.product_code)
}, a, this); console.log('brand_code' + this.brand_code)
})), function(t) {
return a.apply(this, arguments); let that = this
}),
savaToTempFile: function() { this.$u.cloudApi.getGroupStandard({product_code:this.product_code,brand_code:this.brand_code}).then(res =>{
var a = this; console.log('获取规范标准数据:')
wx.canvasToTempFilePath({ console.log(res)
canvas: this.canvas if(res.result && res.result.length){
}).then(function(t) { that.handleData(res)
console.log(t), a.setData({ }
tempImagePath: t.tempFilePath })
}), a.saveToPhotosAlbum(t.tempFilePath);
}).catch(function(a) { },
n.error(a), console.log(a);
}); handleData: function (res){
},
saveToPhotosAlbum: function(a) { this.dataList = res.result
wx.getSetting({
success: function(t) { this.dataList.forEach(item => {
t.authSetting["scope.writePhotosAlbum"] ? wx.saveImageToPhotosAlbum({
filePath: a item.list.forEach(subItem => {
}) : wx.authorize({ subItem.isClicked = false
scope: "scope.writePhotosAlbum", })
success: function() {
wx.saveImageToPhotosAlbum({ })
filePath: a
}); console.log('添加 新字段 后的数组:')
}, console.log(this.dataList)
fail: function() {
n.error("已拒绝保存照片到本地相册授权"), console.log("已拒绝保存照片到本地相册授权"); var item = res.result[0]
} this.rightList = item.list
}); },
}
});
},
takePhotoAnimate: function() {
this.animate("#take", [ {
scale: [ 1, 1 ]
}, {
scale: [ .95, .95 ]
}, {
scale: [ 1, 1 ]
} ], 300, function() {
this.clearAnimation("#take");
}.bind(this));
},
baiduWeather: function() {
var a = this;
h.weather({
success: function(t) {
var e = t.currentWeather[0];
console.log("当前天气", e);
var i = e.temperature + " " + e.weatherDesc + " " + e.wind;
a.setData({
weatherValue: i
}), a.initWatermarkBoxHeightAndWidth();
},
fail: function(a) {
n.error(a), console.log(a);
}
});
},
baiduLocation: function() {
var a = this, t = function() {
var t = {
success: function(t) {
var e = t.wxMarkerData[0];
console.log("当前定位", e);
var i = e.address;
a.setData({
addressValue: i
}), o.globalData.addressValue = i, a.initWatermarkBoxHeightAndWidth();
},
fail: function(a) {
n.error(a), console.log(a);
}
};
if ((o.globalData.lonLat || o.globalData.altitude) && a.latitude && a.longitude) {
var e = a.latitude + "," + a.longitude;
t.location = e;
}
h.regeocoding(t);
};
t(), clearInterval(this.baiduLocationTimer), this.baiduLocationTimer = setInterval(t, 6e4);
},
wxLocation: function() {
var a = this;
wx.onLocationChange(function(t) {
a.latitude = t.latitude, a.longitude = t.longitude;
var e = l.formatLonLat(t.latitude, o.globalData.latLonFormat), i = l.formatLonLat(t.longitude, o.globalData.latLonFormat), n = "0米";
t.altitude && (n = t.altitude.toFixed(2) + "米"), a.setData({
latitudeValue: e,
longitudeValue: i,
altitudeValue: n
}), o.globalData.latitudeValue = e, o.globalData.longitudeValue = i, o.globalData.altitudeValue = n;
});
},
netTime: function() {
var a = this, t = function() {
wx.request({
url: "https://www.baidu.com",
success: function(t) {
var e = new Date(t.header.Date);
o.globalData.timestampValue = e.getTime();
var i = l.formatTime(e);
a.setData({
timeValue: i
}), o.globalData.timeValue = i, a.initWatermarkBoxHeightAndWidth();
}
});
};
t(), clearInterval(this.netTimeTimer), clearInterval(this.localTimeTimer), this.netTimeTimer = setInterval(t, 6e4),
this.localTimeTimer = setInterval(function() {
if (o.globalData.timestampValue) {
o.globalData.timestampValue += 1e3;
var t = l.formatTime(new Date(o.globalData.timestampValue));
a.setData({
timeValue: t
}), o.globalData.timeValue = t;
}
}, 1e3);
}
//顶部点击
topItemClick: function (ikey,item) {
this.activeTop = ikey
this.rightList = item.list
uni.pageScrollTo({scrollTop: 0, duration: 0});
},
//右侧点击
rightItemClick: function (item,ikey) {
// for (let i = 0; i < this.rightList.length; i++) {
// var subItem = this.rightList[i]
// if(i == ikey){
// subItem.isClicked = true
// }
// }
// item.clickable = true
this.$set(this.rightList[ikey],'clickable',true)
var current_image = item.images[0]
var current_count = 1
uni.navigateTo({
url:'/pages/photo/detail'
+'?current_image=' + current_image
+'&image_count=' + item.image_count
+'&current_count=' + current_count
+'&images=' + JSON.stringify(item.images)
+'&title=' + item.name,
})
},
} }
...@@ -513,215 +150,162 @@ ...@@ -513,215 +150,162 @@
</script> </script>
<style> <style>
.hidden { .backView{
display: none; background-color: #FAFAFA;
} position: absolute;
top: 0;
.camera { left: 0;
width: 100%; width: 100%;
height: 100vh; display: flex;
z-index: 1; flex-direction: column;
position: absolute; align-items: center;
} }
.nav__scale-4-3 { .topTitle{
background-color: #000; margin-top: 80rpx;
} font-size: 32rpx;
.nav__scale-4-3,.nav__scale-16-9 {
z-index: 5;
position: fixed;
top: 0;
left: 0;
right: 0;
} }
.nav__scale-16-9 { .centerBackView{
background-color: transparent; display: flex;
flex-direction: row;
margin-top: 80rpx;
width: 100%;
} }
.nav__scale-full { .leftView{
z-index: 5; background-color: #FFFFFF;
position: fixed; width: 20%;
top: 0; display: flex;
left: 0; flex-direction: column;
right: 0;
} }
.nav-scaleIcon { .leftItemView{
left: 5rpx; display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 80rpx;
border-bottom: 2rpx solid #F3F3F3;
} }
.nav-scaleIcon,.nav-switchIcon { .leftItemText{
z-index: 5; font-size: 28rpx;
width: 50rpx;
height: 50rpx;
position: absolute;
bottom: 0;
margin: 20rpx;
} }
.nav-switchIcon { .rightView{
left: 120rpx; background-color: #FFFFFF;
width: 100%;
display: flex;
flex-direction: column;
margin-top: 96rpx;
} }
.nav-lightIcon { .rightItemView{
left: 220rpx; width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
border-bottom: 20rpx solid #F3F3F3;
} }
.nav-lightIcon,.nav-moreIcon { .rightContentView{
z-index: 5; display: flex;
width: 50rpx; flex-direction: column;
height: 50rpx; border-left: 2rpx solid #F3F3F3;
position: absolute;
bottom: 0;
margin: 20rpx;
} }
.nav-moreIcon { .rightActiveContentView{
left: 320rpx; background-color: #4CD964;
display: flex;
flex-direction: column;
border-left: 2rpx solid #F3F3F3;
} }
.camera-photoalbumIconBox {
z-index: 5;
width: 80rpx;
height: 80rpx;
position: absolute;
bottom: 60rpx;
left: 25%;
margin-left: -80rpx;
background-color: hsla(0,0%,100%,0);
border: 1rpx solid #fff;
border-radius: 50%;
}
.camera-photoalbumIcon { .width_50{
z-index: 5; width: 480rpx;
} }
.camera-takeIcon { .width_100{
z-index: 5; width: 100%;
width: 150rpx;
height: 150rpx;
position: absolute;
bottom: 25rpx;
left: 50%;
margin-left: -75rpx;
} }
.camera-settingIcon { .rightTitle{
z-index: 5; font-size: 32rpx;
width: 80rpx; color: #4D87EA;
height: 80rpx;
position: absolute;
bottom: 60rpx;
left: 75%;
} }
.photoCanvas { .rightContent{
z-index: -1; font-size: 28rpx;
position: absolute; color: #333333;
left: 9999px; line-height: 40rpx;
} }
.watermark-box { .rightImageView{
z-index: 4; width: 300rpx;
position: absolute; height: 320rpx;
font-size: 14px; display: flex;
line-height: 18px; align-items: center;
color: #fff; justify-content: center;
} }
.watermark-box__item { .rightImage{
margin: 2px 0; background-color: #F3F3F3;
width: 240rpx;
height: 240rpx;
} }
.liveWatermarkNormal {
z-index: 3;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
width: 360rpx;
height: 90rpx;
z-index: 6;
}
.liveWatermarkRight { .topView{
transform-origin: 50% 50%; background-color: #FAFAFA;
transform: rotate(-90deg); width: 100%;
height: 96rpx;
position: fixed;
display: flex;
flex-direction: row;
} }
.liveWatermarkLeft,.liveWatermarkRight { .topItemView{
z-index: 3; width: 210rpx;
position: absolute; height: 96rpx;
left: 25%; display: flex;
top: calc(50% - 45rpx); align-items: center;
width: 360rpx; justify-content: center;
height: 90rpx;
z-index: 6;
} }
.liveWatermarkLeft { .whiteBackColor{
transform-origin: 50% 50%; background-color: #FFFFFF;
transform: rotate(90deg);
} }
.handWritingNormal { .FAbackColor{
transform-origin: 50% 50%; background-color: #FAFAFA;
transform: rotate(-90deg);
right: 20rpx;
} }
.handWritingLeft,.handWritingNormal { .topItemTitle{
z-index: 3; font-size: 32rpx;
position: absolute; color: #999999;
width: 150rpx; padding-left: 30rpx;
height: 150rpx;
bottom: 20rpx;
} }
.handWritingLeft {
transform-origin: 50% 50%;
left: 20rpx;
}
.handWritingRight { .topActiveItemTitle{
transform-origin: 50% 50%; font-size: 32rpx;
transform: rotate(180deg); font-weight: bold;
color: #333333;
padding-left: 30rpx;
} }
.handWritingRight,.logoNormal { .greenBackColor{
z-index: 3; background-color: #4CD964;
position: absolute;
width: 150rpx;
height: 150rpx;
top: 20rpx;
right: 20rpx;
} }
.logoNormal { .gray999Color{
transform-origin: 50% 50%; color: #999999;
} }
.logoLeft {
transform-origin: 50% 50%;
transform: rotate(90deg);
bottom: 20rpx;
right: 20rpx;
}
.logoLeft,.logoRight {
z-index: 3;
position: absolute;
width: 150rpx;
height: 150rpx;
}
.logoRight {
transform-origin: 50% 50%;
transform: rotate(-90deg);
top: 20rpx;
left: 20rpx;
}
</style> </style>
<template> <template>
<view class="container"> <view class="blackBackColor">
<camera device-position="back" flash="off" style='width:100%; height:100vh;'> <camera device-position="front" flash="on" style='width:100%; height:100vh; overflow: hidden;' @error="cameraRefuse">
<cover-view class="locationView"> <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-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">维度:{{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">地址:{{address}}</cover-view>
<cover-view class="locationText u-m-l-20 u-m-t-10">{{date}}</cover-view> <cover-view class="locationText u-m-l-20 u-m-t-10">时间:{{date}}</cover-view>
</cover-view> </cover-view>
<cover-image class="liveWatermarkNormal" mode="aspectFit" :src="liveWaterMarkImage"></cover-image> <cover-image class="liveWatermarkNormal" mode="aspectFit" :src="liveWaterMarkImage"></cover-image>
</camera> </camera>
<cover-view class="bottomView"> <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='switchIcon' :src='icon_switch_white' @click="switchClick()"> </cover-image-->
<cover-image class='takeIcon' :src='icon_take' @click="takePhoto()"> </cover-image> <cover-image class='takeIcon' :src='icon_take' @click="takePhoto()"> </cover-image>
<cover-image class="backIcon" :src="icon_arrow_down" mode="" @click="backClick"></cover-image>
<!--cover-image class='flashIcon' :src='icon_light_on_white' @click="flashClick()"> </cover-image--> <!--cover-image class='flashIcon' :src='icon_light_on_white' @click="flashClick()"> </cover-image-->
</cover-view> </cover-view>
<canvas class="showCanvas" canvas-id="photoCanvas" id="photoCanvas" :style="{width:canvas.sWidth + 'px',height:canvas.sHeight+ 'px'}"></canvas> <!--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> </view>
...@@ -25,6 +28,11 @@ ...@@ -25,6 +28,11 @@
</template> </template>
<script> <script>
let r = require("../../libs/bmap-wx.min.js");
let h = new r.BMapWX({
// ak: "rpVq5d3yxaRCoKzVwmFMo0o4iC524CAG",
ak: "lF1HoyXdiv4uZx6TrGQEZs48F5y8kEHI"
});
export default { export default {
data() { data() {
return { return {
...@@ -34,46 +42,138 @@ ...@@ -34,46 +42,138 @@
image: "", image: "",
showImage: false, showImage: false,
canvas: null, canvas: null,
longitude: '经度:正在获取中...', longitude: '正在获取中...',
latitude: '纬度:正在获取中...', latitude: '正在获取中...',
address: '地址:正在获取中...', address: '正在获取中...',
date: '时间:正在获取中...', date: '正在获取中...',
icon_location: 'https://qn-static.banshouhui.com/take_order/icon/location.png', icon_location: 'https://qn-static.banshouhui.com/take_order/icon/location.png',
scale: "4_3", scale: "4_3",
icon_take: 'https://qn-static.banshouhui.com/take.png', icon_take: 'https://qn-static.banshouhui.com/take.png',
icon_switch_white: 'https://qn-static.banshouhui.com/switch_white.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', icon_light_on_white: 'https://qn-static.banshouhui.com/light_on_white.png',
liveWaterMarkImage: require('@/static/live_mark.png'), liveWaterMarkImage: '/static/live_mark.png',
icon_arrow_down: 'https://qn-static.banshouhui.com/arrow_down.png', icon_arrow_down: 'https://qn-static.banshouhui.com/arrow_down.png',
icon_live_mark: 'https://qn-static.banshouhui.com/live_mark.png', icon_live_mark: 'https://qn-static.banshouhui.com/live_mark.png',
canvas: { width: '',
ctx: null, height: '',
sWidth: 750, markPath: '',
sHeight: 0, canvasWidth: 0,
}, canvasHeight: 0,
waterMarkerTemp:'' restuleImage: '',
authSetting: []
} }
}, },
onLoad(e) { onLoad(e) {
getApp().trackPage('拍照页') getApp().trackPage('拍照页')
this.ctx = uni.createCameraContext(); this.ctx = uni.createCameraContext();
this.date = '时间:' + this.getTime() this.date = this.getTime()
this.getLocation() this.getLocation()
this.getMarkPath()
this.getSystemInfo() this.getSystemInfo()
uni.setNavigationBarColor({ uni.setNavigationBarColor({
frontColor: '#FFFFFF', frontColor: '#FFFFFF',
backgroundColor: '#333333', backgroundColor: '#333333',
}) })
this.downloadImageH5(this.liveWaterMarkImage)
//this.address = '' //this.address = ''
}, },
onShow() {
// uni.authorize({
// scope: 'scope.writePhotosAlbum',
// success() {
// console.log('userLocation')
// // uni.getLocation()
// }
// })
},
methods: { 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();
switchClick() { 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() { backClick: function() {
uni.navigateBack({ uni.navigateBack({
...@@ -85,95 +185,261 @@ ...@@ -85,95 +185,261 @@
getLocation() { getLocation() {
let that = this let that = this
uni.getLocation({ uni.getLocation({
type: 'wgs84', type: 'gcj02',
success: function(res) { success: function(res) {
that.longitude = '经度:' + res.longitude console.log(res,'res')
that.latitude = '纬度:' + res.latitude that.longitude = parseFloat(res.longitude).toFixed(4)
console.log('当前位置的经度:' + res.longitude); that.latitude = parseFloat(res.latitude).toFixed(3)
console.log('当前位置的纬度:' + res.latitude); console.log(that.longitude,'that.longitude',that.latitude,'that.latitude')
console.log('当前位置的地址:' + res.address); 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() { takePhoto() {
this.getLocation()
return
let that = this
this.ctx.takePhoto({ this.ctx.takePhoto({
quality: 'high', quality: 'high',
success: (res) => { success: (res) => {
console.log('拍照成功')
console.log(res) console.log(res)
this.imageChange(res) //this.imageChange(res)
//this.getImageInfo(res.tempImagePath) this.getImageInfo(res.tempImagePath)
//this.saveToLocal(res.tempImagePath) //this.saveToLocal(res.tempImagePath)
} }
}); });
}, },
//获取图片信息
//第二步: 获取图片信息
getImageInfo(tempImagePath) { getImageInfo(tempImagePath) {
let that = this let that = this
uni.getImageInfo({ uni.getImageInfo({
src: tempImagePath, src: tempImagePath,
success(res) { success(res) {
//that.saveToLocal(res.) that.width = res.width + 'px';
that.height = res.height + 'px';
that.drawCanvas(tempImagePath, res)
} }
}) })
}, },
//保存到本地相册 //第三步: 绘制画布
saveToLocal(tempImagePath) { drawCanvas: function(tempImagePath, res) {
uni.saveImageToPhotosAlbum({ uni.showLoading({
filePath: tempImagePath, title: '数据处理中...',
success() { icon: 'loading'
console.log('保存本地相册 成功')
},
fail() {
console.log('保存本地相册 失败')
}
}) })
}, let canvasWidth = this.canvasWidth
getSystemInfo() { let canvasHeight = this.canvasHeight
// 获取设备信息 this.showImage = true
try { //将原图画到canvas上面
const res = uni.getSystemInfoSync(); this.canvas = uni.createCanvasContext("canvas", this)
this.canvas.sWidth = res.windowWidth this.canvas.rect(0, 0, canvasWidth, canvasHeight)
this.canvas.sHeight = res.windowHeight this.canvas.drawImage(tempImagePath, 0, 0, canvasWidth, canvasHeight)
console.log(res.windowWidth, 'res.windowWidth', res.windowHeight, 'res.windowHeight') // this.canvas.draw()
} catch (e) {
// error //加入 水印文字
} this.canvas.setFontSize(28)
}, this.canvas.setFillStyle('#f2f2f2')
let h = 1
downloadImageH5(image) { let txtHeight = 36
let self = this
console.log('downloadImageH5',image) this.canvas.fillText( '经度: ' + this.longitude, 20, canvasHeight - txtHeight * h++);
// 图片下载本地 this.canvas.fillText( '维度: ' + this.latitude, 20, canvasHeight - txtHeight * h++);
uni.downloadFile({ this.canvas.fillText( '地址: ' + this.address, 20, canvasHeight - txtHeight * h++);
url: image, //仅为示例,并非真实的资源 this.canvas.fillText( '时间: ' +this.date, 20, canvasHeight - txtHeight * h++);
success: (res) => { //加入 水印图片
console.log(res,'res-水印图片') this.canvas.drawImage(this.markPath, canvasWidth / 2 - 200, canvasHeight / 2 - 50, 400, 100)
if (res.statusCode === 200) {
self.waterMarkerTemp = res.tempFilePath this.canvasImage()
} // this.canvas.draw()
}
}); // uni.showLoading({
// title: '数据处理中...',
// icon: 'loading'
// })
// this.exportCanvasTempFilePath(res.width,res.height)
}, },
canvasImage() { canvasImage() {
let self = this let self = this
this.canvas.ctx.draw(false, setTimeout(() => { this.canvas.draw(false, setTimeout(() => {
setTimeout(() => { setTimeout(() => {
uni.canvasToTempFilePath({ uni.canvasToTempFilePath({
x: 0, // x: 0,
y: 0, // y: 0,
width: Number(this.canvas.sWidth), width: Number(this.canvasWidth),
height: Number(this.canvas.sHeight), height: Number(this.canvasHeight),
canvasId: 'photoCanvas', canvasId: 'canvas',
success: (res) => { 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); // this.$emit('canvasImage', res.tempFilePath);
// if (this.showPreview) { // if (this.showPreview) {
self.showPreviewFn(res.tempFilePath); // this.restultImage = res.tempFilePath
// self.showPreviewFn(res.tempFilePath);
// } // }
}, },
fail: (res) => { fail: (res) => {
...@@ -186,148 +452,157 @@ ...@@ -186,148 +452,157 @@
}, 500); }, 500);
})); }));
}, },
showPreviewFn (img) { showPreviewFn(img) {
uni.previewImage({ uni.previewImage({
current: 0, current: 0,
urls: [img] urls: [img]
}); });
}, },
//照片处理 //第五步: 保存到本地相册
imageChange(options) { saveToLocal(tempImagePath) {
let self = this let that = this
// let ctx = uni.createCanvasContext("photoCanvas") // canvas绘制对象 uni.saveImageToPhotosAlbum({
let ctx = uni.createCanvasContext('photoCanvas', this); filePath: tempImagePath,
let sWidth = this.canvas.sWidth //绘图宽度 success() {
let sHeight = this.canvas.sHeight // 绘图高度 uni.showToast({
this.canvas.ctx = ctx icon: 'none',
ctx.setStrokeStyle("#00ff00") title: '已将照片保存到本地相册'
ctx.setLineWidth(5) })
ctx.rect(0, 0, sWidth, sHeight) let timer = setTimeout(() => {
ctx.drawImage(options.tempImagePath, 0, 0, sWidth, sHeight) that.goBack()
ctx.setFontSize(20) }, 1500)
ctx.fillText('Hello', 20, 20)
ctx.fillText('MINA', 100, 100)
// if(this.waterMarkerTemp){
// ctx.drawImage(this.waterMarkerTemp, sWidth/2 - 100, sHeight/2 - 20, 200, 40)
// }
ctx.drawImage(options.tempImagePath, sWidth/2 - 100, sHeight/2 - 20, 200, 40);
self.canvasImage()
// self.path = options.tempImagePath
return
// uni.getImageInfo({
// src: that.path,
// success: function(res) {
// }
// })
var that = this
//原图片信息
var _width = options.width
var _height = options.height
that.path = options.tempImagePath
console.log('原照片信息')
console.log('宽:' + options.width)
console.log('高:' + options.height)
console.log('路径:' + options.tempImagePath)
//需要的图片信息
var image_x = parseInt(_width * 0.1);
var image_y = parseInt(_height * 0.09);
var image_width = parseInt(_width * 0.8);
var image_height = parseInt(_height * 0.87);
console.log('需要的图片信息')
console.log('x:' + image_x)
console.log('y:' + image_y)
console.log('宽:' + image_width)
console.log('高:' + image_height)
uni.getImageInfo({
src: that.path,
success: function(res) {
that.showImage = true
//将原图画到canvas上面
that.canvas = uni.createCanvasContext("canvas", that)
//that.canvas.drawImage(that.path, 0, 0, _width, _height)
that.canvas.drawImage(that.path, 0, 0, res.width * 3, res.height * 3)
},
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 = '保存本地相册失败'
// let ctx = uni.createCanvasContext('firstCanvas'); // 创建画布
// //将图片src放到cancas内,宽高为图片大小 uni.getSetting({
// ctx.drawImage(res.tempFilePaths[0], 0, 0, ress.width / 3, ress.height / 3) success(res) {
that.canvas.setFontSize(18) let authSetting = res.authSetting
// that.canvas.setFillStyle('#8a2929') if (!authSetting['scope.writePhotosAlbum']) {
// that.canvas.rotate(-Math.PI / 2); txt = '请打开相册权限'
let textToWidth = res.width / 3 * 0.5; }
let textToHeight = res.height / 3 * 0.3; uni.showToast({
that.canvas.fillText('我是水印', 10, 90) icon: 'none',
//. 除了上面的文字水印,这里也可以加入图片水印 title: txt
// ctx.drawImage('/static/watermark.png', 0, 0, res.width / 3, ress.height / 3) })
that.canvas.drawImage('/static/live_mark.png', 0, 0, 200, 200) }
//-----------------------------
*/
that.canvas.draw()
uni.showLoading({
title: '数据处理中...',
icon: 'loading',
duration: 10000
}) })
that.canvas.draw() */
setTimeout(function() { // wx.openSetting({
//导出自己需要的图片 // success (res) {
uni.canvasToTempFilePath({ // console.log(res.authSetting,'openSetting')
canvasId: "canvas", // // res.authSetting = {
x: image_x, // // "scope.userInfo": true,
y: image_y, // // "scope.userLocation": true
width: image_width, // // }
height: image_height, // }
destWidth: image_width, // })
destHeight: image_height, // uni.authorize({
success: function(ress) { // scope: 'scope.writePhotosAlbum',
that.image = ress.tempFilePath //处理好的图片 // success() {
uni.hideLoading() // console.log('userLocation')
console.log('处理图片 成功:') // uni.openSetting({
console.log(ress.tempFilePath) // success(res) {
// console.log(res,'openSetting')
uni.showToast({ // }
icon: 'none', // });
title: '处理成功' // }
}) // })
}
setTimeout(function() { })
},
that.saveToLocal(ress.tempFilePath)
uni.previewImage({
urls: [ress.tempFilePath], //相册 再次授权弹窗
current: 0 showAlbumAuthModal:function (){
}); let that = this
// uni.navigateTo({ uni.showModal({
// url:'/pages/photo/preview'+'?path=' + res.tempFilePath content:'拒绝授权照片将无法保存到本地相册,是否去设置打开?',
// }) confirmText: "确认",
}, 1000); cancelText: '取消',
success(res) {
if(res.confirm){
//TODO........
that.openAlbumSetting()
},
fail: function(e) { }
uni.hideLoading()
uni.showToast({ if(res.cancel){
title: '出错啦...', uni.navigateBack({
icon: 'loading'
}) })
console.log('处理图片 失败:') }
console.log(e) },
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)
} }
});
}, 1000); })
//that.reloadPage()
}else{
that.showAlbumAuthModal()
console.log('222222')
}
} }
}) })
}, },
//获取当前时间 //获取当前时间
getTime: function() { getTime: function() {
...@@ -343,21 +618,18 @@ ...@@ -343,21 +618,18 @@
var timer = year + '/' + month + '/' + day + ' ' + hour + ':' + minute + ':' + second; var timer = year + '/' + month + '/' + day + ' ' + hour + ':' + minute + ':' + second;
return timer; return timer;
}, },
} }
} }
</script> </script>
<style> <style>
.bottomView { .blackBackColor {
background-color: #000000; background-color: #000000;
overflow: hidden;
}
.bottomView {
background-color: #333333;
z-index: 5; z-index: 5;
width: 100%; width: 100%;
height: 200rpx; height: 200rpx;
...@@ -377,7 +649,7 @@ ...@@ -377,7 +649,7 @@
} }
.takeIcon { .takeIcon {
background-color: #000000; background-color: #333333;
width: 150rpx; width: 150rpx;
height: 150rpx; height: 150rpx;
} }
...@@ -435,18 +707,12 @@ ...@@ -435,18 +707,12 @@
position: fixed; position: fixed;
left: 60rpx; left: 60rpx;
bottom: 50rpx; bottom: 50rpx;
} border: 2rpx solid #aaa;
.container {
position: relative;
} }
.showCanvas { .showCanvas {
position: absolute;
left: 0;
/* top: 0; */
z-index: -1;
opacity: 0;
background-color: #007AFF; background-color: #007AFF;
width: 100%;
height: 100%;
} }
</style> </style>
...@@ -185,10 +185,12 @@ ...@@ -185,10 +185,12 @@
getLocation() { getLocation() {
let that = this let that = this
uni.getLocation({ uni.getLocation({
type: 'wgs84', type: 'gcj02',
success: function(res) { success: function(res) {
that.longitude = res.longitude console.log(res,'res')
that.latitude = res.latitude 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() that.baiduLocation()
}, },
fail() { fail() {
...@@ -342,7 +344,8 @@ ...@@ -342,7 +344,8 @@
//第一步: 拍照 //第一步: 拍照
takePhoto() { takePhoto() {
this.getLocation()
return
let that = this let that = this
this.ctx.takePhoto({ this.ctx.takePhoto({
quality: 'high', quality: 'high',
......
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