123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <template>
- <view :style="{ minHeight: sys.windowHeight + 'px' }"
- :class="[$tm.vx.state().tmVuetify.black ? 'black' : ' ']">
- <tm-menubars title="入库" :shadow="0" :showback="true"></tm-menubars>
- <tm-message ref="toast"></tm-message>
- <tm-button theme="white" @click="shangchuan()">上传</tm-button>
- <image block class="zhanshi" mode="widthFix" :src="src"></image>
- <tm-button theme="bg-gradient-blue-accent" @click="paizhao()" block>拍照</tm-button>
- </view>
- </template>
- <script>
- import{myRequest} from '@/api/request.js'
- import { pathToBase64, base64ToPath } from '@/js_sdk/mmmm-image-tools/index.js'
- export default {
- data() {
- return {
- src:'',
- imgpath : [],
- tag : 0,
- imgbase64 : []
- };
- },
- onLoad() {
-
- },
- created() {
- this.sys = uni.getSystemInfoSync();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
- methods: {
- shangchuan(){
- var that=this;
- uni.chooseImage({
- count: 1,
- sizeType: ['original', 'compressed'],
- sourceType: ['album','camera'],
- success: function (res) {
- var imgpath = res.tempFilePaths[0]
- myRequest({
- url: "/common/uploads/upload",
- method:'post',
- data:{
- file:imgpath
- }
- }).then(res => {
- if (res.data.code == 200) {
- that.$refs.toast.show({model:'success',label:res.data.msg})
- }else{
- that.$refs.toast.show({model:'error',label:res.data.msg})
- }
- })
- }
- })
-
- },
- paizhao(){
- var that=this;
- uni.chooseImage({
- count: 1,
- sizeType: ['original', 'compressed'],
- sourceType: ['album','camera'],
- success: function (res) {
- that.imgpath = res.tempFilePaths[0]
- console.log(that.imgpath)
- that.getBase64Image(that.imgpath);
- }
- })
- },
- getBase64Image(path){
- var that=this;
- console.log(" 开始转换")
- pathToBase64(path)
- .then(base64 => {
- that.shibie(base64)
- })
- .catch(error => {
- console.error(error)
- })
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
- shibie(src){
- var that=this;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- uni.request({
- url: 'https://dect.market.alicloudapi.com/imgdect',
- method : "post",
- header: {
- 'Authorization':'APPCODE e4b9accfb1f246cb8c0766a54efe8730',
- "Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"
- },
- data:{
- src:src
- },
- success : function(data) {
- console.log(data)
-
- },
- error : function(e) {
- alert("网络异常,请重试");
- }
- });
- }
- },
- }
- </script>
- <style lang="scss">
- /deep/ .tm-menubars .body{
- background-color: #1b1b1b !important;
- }
- </style>
|