unapp寫微信小程序封裝水印相機組件怎么實現?

<template><view><!-- <cu-custom bgColor="bg-gradual-blue" :isBack="true"><block slot="backText">返回</block><block slot="content">編輯資料</block></cu-custom> --><view><camera :device-position="device" :flash="flash" @error="error":style="{ width: '100%', position: 'relative', height: getHeight + 'px' }"><cover-view class="topBox"><cover-view class="topItem text-bold text-xl">你的美麗你知道!</cover-view><cover-view class="topItem">{{ nowTime2 }}</cover-view><cover-view class="topItem">{{ nowTime }}</cover-view><cover-view class="topItem">{{ address }}</cover-view></cover-view><cover-image @click="xzBtn" class="xzImg" src="https://cdn.zhoukaiwen.com/xz.png"></cover-image><cover-image @click="sgdBtn" class="sgdImg" :src="sgdUrl"></cover-image><cover-view class="cameraBtn" @click="takePhoto"><cover-view class="cameraBtn2"></cover-view></cover-view><cover-view class="bottomBtn" v-if="imgList.length < 1"><cover-view @click="history" class="btn">歷史</cover-view><cover-view class="btn" @click="goBack">取消</cover-view></cover-view><cover-view class="bottomBg" v-if="imgList.length > 0"><cover-view><cover-view @click="ViewImage(index)" class="imgBox" v-for="(item, index) in imgList":key="index"><cover-image class="imgItem" :src="item.src" mode="aspectFill"></cover-image><cover-view class="cu-tag" @tap.stop="DelImg" :data-index="index"><cover-image class="iconClose" src="https://cdn.zhoukaiwen.com/icon_close.png"mode="aspectFill"></cover-image></cover-view></cover-view></cover-view><cover-view @click="reportBtn" class="report">上報({{ imgList.length }})</cover-view></cover-view><cover-view v-if="rreportShow" class="reportBox animation-slide-bottom"><cover-view class="text-lg margin-left-sm margin-bottom-sm"style="height:78rpx;line-height: 78rpx;">請選擇照片備注內容</cover-view><cover-view class="listBox"><cover-view class="item active">韓系淡妝</cover-view><cover-view class="item">幼態短中庭</cover-view><cover-view class="item">淡顏減齡</cover-view><cover-view class="item">證件照裝</cover-view><cover-view class="item">國泰民安</cover-view><cover-view class="item">陽光青梅</cover-view><cover-view class="item">韓系女主</cover-view><cover-view class="item">貴氣中國風</cover-view></cover-view><cover-view @click="endBtn" class="repBtn">上傳</cover-view></cover-view></camera><view style="position: absolute;top: -999999px;"><view><canvas :style="{ width: w, height: h }" canvas-id="firstCanvas"></canvas></view></view></view></view></template><script>
import QQMapWX from "../../common/qqmap-wx-jssdk.js";
export default {data() {return {getHeight: '200',device: 'back', //前置或后置攝像頭,值為front, backflash: 'off', //閃光燈,值為auto, on, offnowTime: '', //日期nowTime2: '', //時間address: '',	//當前地址信息sgdUrl: 'https://cdn.zhoukaiwen.com/sgd.png',imgList: [// {// 	src: "https://cdn.zhoukaiwen.com/angular.jpg"// }],imgListData: '',rreportShow: false, //選擇照片備注內容彈窗src: '',w: '',h: ''}},onLoad() {const that = this;var qqmapsdk;uni.getSystemInfo({success: function (res) {that.getHeight = res.windowHeight;}});uni.showModal({title: '你的美麗你知道!',content: '留下你的美🌹,世界因你而美麗!🌍',showCancel: false,confirmText: '最美不過我自己,🌺!',confirmColor: '#3056F6',success: function (res) {if (res.confirm) {console.log('用戶點擊確定');}}});this.getTime();uni.getLocation({type: 'wgs84',success: function (res) {console.log('當前位置的經度:' + res.longitude);console.log('當前位置的緯度:' + res.latitude);qqmapsdk = new QQMapWX({key: "HMUBZ-PQLEG-6I3QM-Q67MV-7FXK3-FTF6H" //自己申請的key});qqmapsdk.reverseGeocoder({location: {latitude: res.latitude,longitude: res.longitude},success(addressRes) {console.log(addressRes)that.address = addressRes.result.formatted_addresses.standard_address;console.log('當前位置的詳細地址:' + addressRes.result.formatted_addresses.standard_address);},fail(res) { }});}});},methods: {// 上報:最終上報endBtn() {this.rreportShow = false;this.imgList = [];},// 上報:選擇類型reportBtn() {this.rreportShow = true;var str = this.imgListData;var newImgData = this.imgListData.substr(0, this.imgListData.length - 1);console.log(newImgData,'上報的圖片')},xzBtn() {if (this.device == 'front') {this.device = 'back'} else {this.device = 'front'}},sgdBtn() {if (this.flash == 'off') {this.flash = 'on'this.sgdUrl = 'https://cdn.zhoukaiwen.com/sgd_on.png'} else {this.flash = 'off'this.sgdUrl = 'https://cdn.zhoukaiwen.com/sgd.png'}},DelImg(e) {uni.showModal({// title: '異常照片',content: '確定要刪除這張照片嗎?',cancelText: '取消',confirmText: '確認',success: res => {if (res.confirm) {console.log(e)this.imgList.splice(e.currentTarget.dataset.index, 1)console.log(this.imgList)var arr = this.imgList;var str = '';for (var i = 0; i < arr.length; i++) {str += arr[i].src + ",";}this.imgListData = str;console.log(this.imgListData)}}})},// 查看照片ViewImage(index) {const imgList = [this.imgList[index].src];console.log(imgList,'拍的照片查看')uni.previewImage({urls: imgList});},// 點擊拍照takePhoto() {var that = this;if (this.imgList.length < 1) {const ctx = uni.createCameraContext();ctx.takePhoto({quality: 'high',success: (res) => {var tempImagePath = res.tempImagePath;// 獲取圖片信息uni.getImageInfo({src: res.tempImagePath,success: ress => {that.w = ress.width / 3 + 'px';that.h = ress.height / 3.01 + 'px';let ctx = uni.createCanvasContext('firstCanvas'); /** 創建畫布 *///將圖片src放到cancas內,寬高為圖片大小ctx.drawImage(res.tempImagePath, 0, 0, ress.width / 3, ress.height / 3);ctx.setFontSize(12);ctx.setFillStyle('#FFFFFF');// ctx.rotate(30 * Math.PI / 180);let textToWidth = (ress.width / 3) * 0.03;let textToHeight = (ress.height / 3) * 0.9;ctx.fillText('最美我自己!🌹', textToWidth, textToHeight);ctx.setFontSize(10);let textToHeight2 = (ress.height / 3) * 0.94;ctx.fillText(that.nowTime + ' ' + that.nowTime2, textToWidth, textToHeight2);let textToHeight3 = (ress.height / 3) * 0.98;ctx.fillText(that.address, textToWidth, textToHeight3);ctx.draw(false, () => {setTimeout(() => {uni.canvasToTempFilePath({canvasId: 'firstCanvas',success: res1 => {tempImagePath = res1.tempFilePath;console.log('----------', tempImagePath);this.imgList.push({src: tempImagePath})console.log(this.imgList,'拍的圖片數組');var arr = this.imgListvar str = '';for (var i = 0; i < arr.length; i++) {str += arr[i].src + ",";}this.imgListData = str;console.log(this.imgListData,"拍的圖片")}});}, 1000);});}});}});} else {uni.showToast({title: '最大上傳1張照片',duration: 2000,icon: 'none'});}},error(e) {console.log(e.detail);},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 + '日';var timer2 = hour + ':' + minute + ':' + second;this.nowTime = timer;this.nowTime2 = timer2;console.log(this.nowTime);console.log(this.nowTime2);},goBack() {uni.navigateBack({delta: 1});},history() {uni.navigateTo({url: 'timeline'})}}
}
</script><style lang="scss">
.topBox {width: 750rpx;box-sizing: border-box;padding: 30rpx;color: #EEEEEE;font-size: 34rpx;.topItem {width: 100%;white-space: pre-wrap;margin-bottom: 15rpx;}
}.cameraBtn {width: 120rpx;height: 120rpx;line-height: 120rpx;border: 6rpx #FFFFFF solid;border-radius: 50%;padding: 8rpx;position: absolute;left: calc(50% - 60rpx);bottom: 210rpx;
}.cameraBtn2 {width: 100%;height: 100%;border-radius: 50%;background-color: #FFFFFF;text-align: center;color: #007AFF;
}.xzImg {width: 52rpx;height: auto;position: absolute;right: 44rpx;bottom: 580rpx;
}.sgdImg {width: 40rpx;height: auto;position: absolute;right: 50rpx;bottom: 450rpx;
}.bottomBtn {width: 100%;height: 150rpx;padding-bottom: 15rpx;position: absolute;bottom: 0;left: 0;text-align: center;display: flex;justify-content: space-between;.btn {width: 30%;height: 150rpx;font-size: 34rpx;color: #FFFFFF;line-height: 150rpx;}
}.bottomBg {width: 100%;height: 170rpx;box-sizing: border-box;padding: 20rpx 30rpx 40rpx;position: absolute;bottom: 0;left: 0;background-color: rgba(0, 0, 0, .8);display: flex;justify-content: space-between;align-items: center;.imgBox {width: 110rpx;height: 110rpx;float: left;margin-right: 40rpx;position: relative;.cu-tag {position: absolute;right: 0;top: 0;border-bottom-left-radius: 2px;padding: 3px 5px;height: auto;background-color: rgba(0, 0, 0, 0.5);font-size: 10px;vertical-align: middle;font-family: Helvetica Neue, Helvetica, sans-serif;white-space: nowrap;color: #ffffff;}}.imgItem {width: 110rpx;height: 110rpx;}
}.report {height: 68rpx;line-height: 68rpx;text-align: center;color: #FFFFFF;box-sizing: border-box;padding: 0rpx 20rpx;border-radius: 10rpx;background-color: #2157FF;
}.iconClose {width: 20rpx;height: 20rpx;
}.reportBox {width: 750rpx;height: auto;box-sizing: border-box;padding: 10rpx 20rpx;background-color: #FFFFFF;position: absolute;bottom: 0;
}.listBox {display: flex;flex-wrap: wrap;justify-content: space-around;}.item {width: 160rpx;height: 68rpx;line-height: 68rpx;text-align: center;background: #F7F7F9;margin-bottom: 40rpx;color: #888888;}.active {background-color: #F1F7FF;color: #025ADD;
}.repBtn {width: 680rpx;height: 78rpx;line-height: 78rpx;background-color: #025ADD;color: #FFFFFF;font-size: 33rpx;text-align: center;border-radius: 10rpx;margin: 5rpx auto 20rpx;
}
</style>

?

上述組件中首先我用到了定位,大家可以在騰訊地圖控制臺中配置相關所需,具體配置的大家可以查看我往期的文檔我都有編寫,這里只是給大家分享一個組件,具體的功能還得大家自己實現、

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/13312.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/13312.shtml
英文地址,請注明出處:http://en.pswp.cn/web/13312.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Docker學習(10)搭建kubernetes集群

搭建kubernetes集群 1、官方部署方式&#xff1a; Minikube工具安裝 Minikube是一種能夠在計算機或者虛擬機(VM)內輕松運行單節點Kubernetes 集群的工具&#xff0c;可實現一鍵部署。這種方式安裝的系統在企業中大多被當作測試系統使用。 使用yum安裝 通過直接使用 epel-r…

三步在 vite 中配置 tailwindcss

前言 tailwindcss 是一個原子化的 css 工具&#xff0c;可以讓你免于寫 css&#xff0c;只寫 html 即可原理&#xff1a;利用你寫的 html 的 class 名稱來生成 css 樣式&#xff0c;理解為一個 postcss 插件或 loader 第一步&#xff1a;安裝 tailwindcss npm i -D tailwind…

圖片恢復的實用指南,為你拯救遺失的記憶!

隨著科技的日新月異&#xff0c;我們的生活已被照片填滿。它們記錄著我們的喜怒哀樂&#xff0c;見證著每一個重要的時刻。但我們往往會因為各種原因將手機圖片遺失&#xff0c;有什么方法可以恢復呢&#xff1f;本文將提供一份實用的圖片恢復指南&#xff0c;幫助你找回那些遺…

山西大學化學化工學院朱鳳祥教授簡介

男&#xff0c;1989年出生&#xff0c;河南安陽人&#xff0c;2019年1月于山西大學化學化工學院任特聘教授&#xff0c;主要研究方向為有機催化&#xff0c;曾獲國家自然科學基金資助&#xff08;2020-2023&#xff09;&#xff0c;迄今在國際高級雜志發表SCI論文20余篇。 200…

llama使用tutorial微調(windows版本)

Llama3-Tutorial/docs/assistant.md at main SmartFlowAI/Llama3-Tutorial GitHub 有一些命令需要修改 前期的安裝還是要按照教程搞的 streamlit run ~/Llama3-Tutorial/tools/internstudio_web_demo.py \ ~/model/Meta-Llama-3-8B-Instruct 改為了 streamlit run .\Ll…

ArrayList和LinkedList的使用

ArrayList List<> list new ArrayList<>(); LinkedList

SQL注入漏洞常用繞過方法

SQL注入漏洞 漏洞描述 Web 程序代碼中對于用戶提交的參數未做過濾就直接放到 SQL 語句中執行&#xff0c;導致參數中的特殊字符打破了原有的SQL 語句邏輯&#xff0c;黑客可以利用該漏洞執行任意 SQL 語句&#xff0c;如查詢數據、下載數據、寫入webshell 、執行系統命令以及…

WPF使用ItemsControl顯示Object的所有屬性值

對于上位機開發&#xff0c;我們有時候有這樣的需求&#xff1a;如何顯示所有的IO點位&#xff1f;比如有10個IO點位&#xff0c;那我們要寫10個TextBlock去綁定這10個點位的屬性&#xff08;本文暫時不考慮顯示的樣式&#xff0c;當然也可以考慮&#xff09;&#xff0c;當點位…

springboot整合swagger,jpa遇到的問題

1.整合jpa&#xff0c;版本問題導致Archive for required library: ‘C:/Users/Administrator/.m2/repository/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar’ in project ‘money-server’ cannot be read or is not a valid ZIP file money-server Build path…

Leetcode 257:二叉樹的所有路徑

給你一個二叉樹的根節點 root &#xff0c;按 任意順序 &#xff0c;返回所有從根節點到葉子節點的路徑。 葉子節點 是指沒有子節點的節點。 思路&#xff1a; 先編輯所有節點&#xff0c;記錄每一個節點的路徑&#xff1b; 判斷當前節點是否為葉子節點&#xff0c;如果是&…

霍庭格TruPlasma MF 7100 7050電源現貨50KW

霍庭格TruPlasma MF 7100 7050電源現貨50KW

mysql json 數組怎么搜索

在MySQL中&#xff0c;可以使用JSON_CONTAINS函數來搜索JSON數組中的元素。這里有一個簡單的例子&#xff1a; 假設有一個名為items的表&#xff0c;其中有一個名為attributes的列&#xff0c;包含JSON數組。 CREATE TABLE items (id INT AUTO_INCREMENT PRIMARY KEY,attribu…

SQLSERVER 怎樣使查詢不占鎖

對一些相對不怎么敏感的數據&#xff0c;不需要太及時性的數據&#xff0c;不需要占鎖。 要在SQL Server中執行查詢而不占用鎖&#xff0c;可以采取以下幾個策略&#xff1a; 1、使用NOLOCK提示&#xff1a; 最直接但風險較高的方法是在查詢中使用WITH (NOLOCK)提示。這樣&am…

練習題(2024/5/16)

1輪轉數組 給定一個整數數組 nums&#xff0c;將數組中的元素向右輪轉 k 個位置&#xff0c;其中 k 是非負數。 示例 1: 輸入: nums [1,2,3,4,5,6,7], k 3 輸出: [5,6,7,1,2,3,4] 解釋: 向右輪轉 1 步: [7,1,2,3,4,5,6] 向右輪轉 2 步: [6,7,1,2,3,4,5] 向右輪轉 3 步: [5,…

【C語言深度解剖】:(11)函數指針、函數指針數組、指向函數指針數組的指針、回調函數

&#x1f921;博客主頁&#xff1a;醉竺 &#x1f970;本文專欄&#xff1a;《C語言深度解剖》《精通C指針》 &#x1f63b;歡迎關注&#xff1a;感謝大家的點贊評論關注&#xff0c;祝您學有所成&#xff01; ??&#x1f49c;&#x1f49b;想要學習更多C語言深度解剖點擊專欄…

AVDemo漏洞平臺黑盒測試

信息收集 說明一下&#xff1a; 因為是本地的環境&#xff0c;端口這些就不掃描了&#xff0c; 還有這個是某個dalao寫的平臺&#xff0c;也就檢測不到什么cms了&#xff0c; 信息收集&#xff0c;端口&#xff0c;cms這些是必做的&#xff0c; 首先&#xff0c;這里先簡單的…

web3 ETF軟件開發難點

開發一個涉及到 Web3 ETF&#xff08;Exchange-Traded Fund&#xff0c;交易所交易基金&#xff09;的軟件可能會面臨一些挑戰和難點&#xff0c;特別是在整合 Web3 技術和金融服務方面。以下是一些可能的難點。北京木奇移動技術有限公司&#xff0c;專業的軟件外包開發公司&am…

記一次:mysql統計的CAST函數與json字段中的某個字段

前言&#xff1a;因為需求的問題&#xff0c;會遇到將某個json存入到一個字段中&#xff0c;但在統計的時候&#xff0c;又需要將這個json中的某個字段作為條件來統計&#xff0c;所以整理了一下cast函數和json中某個字段的條件判斷 一、淺談mysql的json 1.1 上例子 SELECTli…

植物大戰僵尸雜交版(含下載方式)

最近時間&#xff0c;一款很火的植物大戰僵尸雜交版火爆出圈&#xff0c;在玩家之間瘋狂擴散。各種奇特的雜交組合讓游戲變得更加有趣。 游戲介紹 植物大戰僵尸雜交版是一款將《植物大戰僵尸》和植物雜交概念結合在一起的獨特塔防策略游戲。它將《植物大戰僵尸》中的植物與進行…

什么是析構函數?

在編程語言C中&#xff0c;析構函數是一個特別重要的組件&#xff0c;它主要負責在對象生命周期結束時釋放資源和執行清理任務。析構函數的正確實現對于資源管理尤為關鍵&#xff0c;尤其是在處理動態分配內存、文件句柄、網絡連接或其他系統資源時。本文將詳細介紹析構函數的基…