国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

微信小程序拍照頁面自定義demo

這篇具有很好參考價值的文章主要介紹了微信小程序拍照頁面自定義demo。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

api文檔文章來源地址http://www.zghlxwxcb.cn/news/detail-725304.html

<template>
  <div class="device-cameral">
    <div class="top-device">
      <image style="width: 100%" class="topHeight" :src="imageSrc" v-if="imageSrc">
      </image>
      <camera v-else :device-position="devicePosition" :flash="flash" @error="cameraError" style="width: 100%"
        class="topHeight">
      </camera>
      <i class="icon i-close-bold" @click="goBackPage"></i>
    </div>
    <div class="buttons flex justify-between align-center" v-if="!imageSrc">
      <div class="button" @click="openFlash">
        <image :src="flash === 'off'
          ? cameralImage.FLASH_IMAGE
          : cameralImage.FLASH_IMAGE
          " class="flash-image"></image>
      </div>
      <div class="button cameral flex align-center justify-center" @click="takePhoto">
        <div class="button-inner" :class="clickPhoto ? 'scale-button' : ''"></div>
      </div>
      <div class="button" @click="frontAndAfter">
        <image :src="cameralImage.DEVICEPOSITION_IMAGE" class="flash-image"></image>
      </div>
    </div>
    <div class="buttons flex justify-between align-center text-16 padding-btnTwo" v-else>
      <div class="resetPhoto buttonPhoto" @click="resetPhoto">重新拍照</div>
      <div class="confirmPhoto buttonPhoto" @click="confirmPhoto">確認(rèn)</div>
    </div>
    <div class="tap-photo" :class="showText ? '' : 'fade-opacity'">
      {{ textSteer }}
    </div>
  </div>
</template>
<script>
import meServiceApi from "@/service/me.js";
import cameralImage from "@/static/images/batteryImage.js";
import { imageFormat } from "@/utils/utils.js";

export default {
  data() {
    return {
      imageSrc: "",
      flash: "off",
      devicePosition: "back",
      cameralImage,
      textSteer: "輕觸拍照",
      showText: true,
      time: null,
      clickPhoto: false,
      item: '',
      itemIndex: '',
      type: '',
      imageFormat,
    };
  },
  onShow() {
    this.closeSteer();
  },
  onLoad(option) {
    this.item = JSON.parse(decodeURIComponent(option.item)),
      this.itemIndex = option.itemIndex
    this.type = option.type
  },
  methods: {
    goBackPage() {
      uni.navigateBack({
        delta: 1
      })
    },
    // 兩秒后關(guān)閉引導(dǎo)
    closeSteer() {
      clearTimeout(this.time);
      const that = this;
      that.time = setTimeout(() => {
        that.showText = false;
      }, 2000);
    },
    // 動態(tài)添加動畫類
    addAnimation() {
      this.showText = true;
      this.closeSteer();
    },
    takePhoto() {
      const ctx = wx.createCameraContext();
      const that = this;
      this.clickPhoto = true;
      ctx.takePhoto({
        quality: "high",
        success: (res) => {
          that.imageSrc = res.tempImagePath;
          this.clickPhoto = false;
          console.log("拍照的路徑", res.tempImagePath);
        },
      });
    },
    cameraError(e) {
      console.log(e.detail);
    },
    openFlash() {
      switch (this.flash) {
        case "off":
          this.flash = "on";
          this.textSteer = "閃光燈打開";
          this.addAnimation();
          break;

        default:
          this.flash = "off";
          this.textSteer = "閃光燈關(guān)閉";
          this.addAnimation();
          break;
      }
    },
    frontAndAfter() {
      switch (this.devicePosition) {
        case "back":
          this.devicePosition = "front";
          this.textSteer = "前置打開";
          this.addAnimation();
          break;

        default:
          this.devicePosition = "back";
          this.textSteer = "后置打開";
          this.addAnimation();
          break;
      }
    },
    async confirmPhoto() {
      // 上傳到服務(wù)器
      console.log(this.imageSrc, "this.imageSrc");
      const res = await meServiceApi.upFileImg(this.imageSrc);
      console.log("上傳的圖片", res, imageFormat(res.data), this.item, this.item.image);
      this.item.image = imageFormat(res.data)
      let newObject = { ...this.item, itemIndex: this.itemIndex, type: this.type }
      uni.$emit("confirmPhoto", newObject);
      uni.navigateBack({ delta: 1 })
    },
    resetPhoto() {
      this.imageSrc = "";
    },
  },
  mounted() { },
};
</script>
<style scoped lang='scss'>
.device-cameral {
  position: relative;

  .top-device {
    width: 100%;
    height: calc(100vh - 316rpx);

    .topHeight {
      height: calc(100vh - 316rpx);
      width: 100%;
    }

    .i-close-bold {
      position: absolute;
      top: 136rpx;
      left: 48rpx;
      z-index: 555;
    }
  }

  .tap-photo {
    position: absolute;
    color: #fff;
    bottom: 400rpx;
    left: 43%;
    opacity: 1;
  }

  .buttons {
    width: 100%;
    height: 316rpx;
    line-height: 316rpx;
    box-sizing: border-box;
    color: #fff;
    background-color: #000;
    padding: 0 88rpx;
  }

  .padding-btnTwo {
    padding: 20rpx 24rpx;
  }

  .flash-image {
    width: 68rpx;
    height: 68rpx;
  }

  .cameral {
    width: 140rpx;
    height: 140rpx;
    border-radius: 50%;
    border: 3px solid #f5222d;

    .button-inner {
      width: 120rpx;
      height: 120rpx;
      border-radius: 50%;
      background-color: #fff;
    }

    .scale-button {
      transition: transform 0.2s ease;
      /* 定義過渡效果 */
      transform: scale(0.9);
    }
  }

  .buttonPhoto {
    width: 336rpx;
    height: 88rpx;
    box-sizing: border-box;
    text-align: center;
    line-height: 88rpx;
    border-radius: 8rpx;
  }

  .resetPhoto {
    color: #f5222d;
    border: 2rpx solid #f5222d;
    background: #fff;
  }

  .confirmPhoto {
    background: #f5222d;
    color: #fff;
  }

  .fade-opacity {
    opacity: 0;
  }
}
</style>
  

到了這里,關(guān)于微信小程序拍照頁面自定義demo的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • uniapp微信小程序全局分享和自定義頁面分享

    uniapp?實現(xiàn)微信小程序的全局 轉(zhuǎn)發(fā)給好友/分享到朋友圈 的功能。主要使用?Vue.js 的 全局混入?概念。 1.在項目根目錄創(chuàng)建mixins文件夾,然后創(chuàng)建全局分享的 js 文件。mixins/share.js? 2.在項目的?main.js?文件中引入該 share.js 文件并使用?Vue.mixin()?方法將之全局混入: 3.自定義頁

    2024年02月13日
    瀏覽(96)
  • 原聲微信小程序自定義頂部導(dǎo)航欄 . 自定義navigationBar。 (單頁面設(shè)置)

    原聲微信小程序自定義頂部導(dǎo)航欄 . 自定義navigationBar。 (單頁面設(shè)置)

    本文實例為大家分享了微信小程序自定義導(dǎo)航欄的具體代碼,供大家參考,具體內(nèi)容如下 實現(xiàn)自定義大致需要以下?步驟: 1.在頁面.JSON文件進(jìn)行相關(guān)配置,以便去掉原生 備注: ?navigationStyle(導(dǎo)航欄樣式),參數(shù): default = 默認(rèn)樣式,custom = 自定義樣式。? 2.在頁面.js文件onLoad生命

    2024年02月09日
    瀏覽(38)
  • 微信小程序入門與實戰(zhàn)之電影頁面與實戰(zhàn)自定義組件

    微信小程序入門與實戰(zhàn)之電影頁面與實戰(zhàn)自定義組件

    Movie自定義組件包含三部分:圖片、標(biāo)題和圖片,評分可以再單獨寫一個組件。 實現(xiàn)代碼: css代碼中我們通過title里面的屬性設(shè)置文字省略效果,為了能夠直觀地感受到效果我們必須給container設(shè)置寬度,當(dāng)文字超過寬度的時候就會顯示省略號,效果如下圖所示: 首先在自定義

    2024年02月08日
    瀏覽(21)
  • 【微信小程序】自定義組件布局會議OA其他頁面(附源碼)

    【微信小程序】自定義組件布局會議OA其他頁面(附源碼)

    ????歡迎來到我的CSDN主頁!???? ??我是Java方文山,一個在CSDN分享筆記的博主。???? ??推薦給大家我的專欄《微信小程序開發(fā)實戰(zhàn)》。???? ??點擊這里,就可以查看我的主頁啦!???? Java方文山的個人主頁 ??如果感覺還不錯的話請給我點贊吧!???? ??期待你的

    2024年02月08日
    瀏覽(26)
  • 微信小程序隱私協(xié)議自定義頁面(彈窗)開發(fā)流程以及低版本兼容

    微信小程序隱私協(xié)議自定義頁面(彈窗)開發(fā)流程以及低版本兼容

    這里我選擇的是全局監(jiān)聽,進(jìn)入小程序就會監(jiān)控用戶有沒有同意,沒有則進(jìn)行彈窗,不同意則關(guān)閉,這個邏輯可以根據(jù)自己需要隨便修改。 發(fā)現(xiàn)有很多人根據(jù)自己調(diào)試基礎(chǔ)庫來排查自己涉不涉及,你的小程序是否涉及隱私協(xié)議整改,還是看有沒有調(diào)用涉及隱私接口,如果有,

    2024年01月16日
    瀏覽(34)
  • 微信小程序在data中定義頁面的數(shù)據(jù),以及數(shù)據(jù)如何使用

    微信小程序在data中定義頁面的數(shù)據(jù),以及數(shù)據(jù)如何使用

    以上代碼是一個小程序頁面的示例代碼,使用了 Page() 方法來定義頁面組件。在該頁面組件中,定義了一個名為 data 的對象,該對象中包含兩個屬性: info :表示一個字符串類型的數(shù)據(jù),其初始值為 \\\'init data\\\' 。 msgList :表示一個數(shù)組類型的數(shù)據(jù),其初始值為 [{msg: \\\'hello\\\'}, {ms

    2024年02月04日
    瀏覽(34)
  • 解決微信小程序自定義tabbar跳轉(zhuǎn)頁面圖標(biāo)閃動問題

    解決微信小程序自定義tabbar跳轉(zhuǎn)頁面圖標(biāo)閃動問題

    情況一? ? 如果你的tabbar對應(yīng)的頁面是component,那就在component下面加上 其中的selected是該tab頁面對應(yīng)的索引值 情況二? ? 如果你的tabbar對應(yīng)的頁面是page,那就將上面的if判斷寫在page的onshow里面 閃動問題就解決啦~

    2024年02月12日
    瀏覽(25)
  • 微信小程序拍照解數(shù)獨

    微信小程序拍照解數(shù)獨

    之前刷數(shù)獨玩,出于偷懶的思想,總想著用計算機去解決。算法沒少些,之前通過手工錄入的9x9數(shù)據(jù)解數(shù)獨,深度優(yōu)先遍歷算法,很容易。但總想更加方便一點,比如拍照直接解析一個數(shù)獨的表格,自動解出來。 正好前幾天休假,有空,就做了一些嘗試,然后基本上給做出來

    2024年02月10日
    瀏覽(17)
  • uniapp 微信小程序 純js文件中引入自定義modal組件(無需所有頁面手動引入組件)

    工具:uniapp 開發(fā)端:微信小程序 其他:uview 2.0 場景:接口請求統(tǒng)一封裝中需要對接口返回token失效的情況做modal顯示,引導(dǎo)用戶退出小程序,我的想法是將modal的默認(rèn)confirm按鈕替換成小程序自帶的退出方法: 這樣用戶點擊確認(rèn)按鈕就能退出小程序,因此uni.showModel不滿足需求

    2024年02月09日
    瀏覽(104)
  • 微信小程序TS項目使用mobx(頁面直接使用store和自定義組件中使用store)

    ?注意:下載完成后,需要刪除 miniprogram_npm 目錄后,重新構(gòu)建 npm。 注意:ts編寫的話,方法中使用this,需要在參數(shù)中定義this: any,否則會提示錯誤 引入onLoad()方法中引入createStoreBindings將store上的方法和屬性綁定到頁面中 在unOnLoad()方法中銷毀destroyStoreBindings() 頁面中使用:

    2024年02月16日
    瀏覽(20)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包