| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <template>
- <van-col span="6">
- <!-- <van-uploader :after-read="afterRead" upload-text="照片上传"/>-->
- <div class="uploaderImage">
- <p class="coverImg" @click="uploadImg">
- <van-icon class="photo ico" name="photograph" size="16px" color="#969696">
- </van-icon>
- <span>{{ imgText }}</span>
- </p>
- </div>
- </van-col>
- </template>
- <script>
- import {ImagePreview} from "vant";
- import {addPhotoK} from "@/api/clew";
- import axios from "axios";
- export default {
- name: 'uploadImg',
- props: {
- uploadid: {
- type: String,
- default: ''
- },
- imgText: {
- type: String,
- default: ''
- },
- indexImg:{
- type: Number,
- default: 0
- },
- visitsId: {
- type: String,
- default: ''
- },
- customId: {
- type: String | Number,
- default: ''
- },
- summaryId: {
- type: String | Number,
- default: ''
- },
- type: {
- type: Number,
- default: 1
- },
- imgArr: {
- type: String,
- default: ''
- },
- },
- data() {
- return {
- shows: false,
- url: ""
- }
- },
- methods: {
- deleteImgs(val) {
- ImagePreview([val]);
- },
- uploadImg(){
- let url = window.location.href;
- let that = this;
- let wx = this.wx
- let qiyeData
- const instance = axios.create();
- instance.defaults.headers.common['userId'] = localStorage.getItem("loginName");
- instance.get(process.env.VUE_APP_BASE_API + 'mobile/wx/ticket',
- {
- params: {
- url: url
- }
- }).then(response => {
- if (response.status == 200) {
- qiyeData = response.data.data;
- wx.config({
- beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
- debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
- appId: qiyeData.appId, // 必填,企业微信的corpID
- timestamp: qiyeData.timestamp, // 必填,生成签名的时间戳
- nonceStr: qiyeData.nonceStr, // 必填,生成签名的随机串
- signature: qiyeData.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
- jsApiList: ["ready", "chooseImage","uploadImage"] // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
- });
- wx.ready(function () {
- wx.chooseImage({
- count: 1,
- sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
- sourceType:['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
- defaultCameraMode: "normal", //表示进入拍照界面的默认模式,目前有normal与batch两种选择,normal表示普通单拍模式,batch表示连拍模式,不传该参数则为normal模式。从3.0.26版本开始支持front和batch_front两种值,其中front表示默认为前置摄像头单拍模式,batch_front表示默认为前置摄像头连拍模式。(注:用户进入拍照界面仍然可自由切换两种模式)
- isSaveToAlbum:0,
- success: function (res) {
- var localIds=""
- if(res.localIds!=undefined){
- localIds= res.localIds[0]
- }else{
- localIds=res.localId
- }
- wx.uploadImage({
- localId: localIds, // 需要上传的图片的本地ID,由chooseImage接口获得
- isShowProgressTips: 1, // 默认为1,显示进度提示
- success: function (res) {
- that.uploadImagev(res.serverId)
- }
- });
- }
- });
- })
- }
- });
- },
- uploadImagev(meidaId){
- var that = this;
- var form={
- mediaId:meidaId,
- customerClueId:that.customId,
- customerClueItemId:that.summaryId
- }
- var loind1 = that.$toast.loading({
- duration: 0,
- message: '上传中...',
- forbidClick: true,
- });
- addPhotoK(form).then(res=>{
- if (res.code == 200) {
- that.imgArr = res.data.url
- loind1.clear();
- that.$toast("上传成功!")
- that.$emit('newimgarr', {fileUrl: res.data.url,id:res.data.fileId,fileType:res.fileType,fileName:res.fileName, type: that.type,index:that.indexImg});
- } else {
- that.$toast("上传失败!")
- }
- })
- }
- },
- }
- </script>
- <style scoped>
- .uploaderImage {
- position: relative;
- height: 80px;
- width: 80px;
- border: 1px solid #ccc;
- border-radius: 5px;
- }
- .uploaderImage img {
- position: absolute;
- width: 100%;
- display: block;
- height: 40px;
- top: 0;
- }
- .imgPre {
- height: 164px;
- width: 100%;
- background-color: white;
- border-radius: 6px;
- overflow: hidden;
- }
- .photos1 {
- margin: 70px auto;
- left: 50%;
- margin-left: -14px;
- }
- .photobrowsing {
- position: absolute;
- padding: 4px;
- right: 0;
- top: 0;
- z-index: 99;
- background-color: rgba(255, 255, 255, 0.8);
- border-bottom-left-radius: 3px;
- border-top-left-radius: 3px
- }
- .uploaderImage .coverImg {
- text-align: center;
- position: absolute;
- top: 0;
- left: 0;
- height: 80px;
- margin: 0;
- width: 100%;
- }
- .uploaderImage .coverImg span{
- padding-top: 24px;
- display: block;text-align: center;
- }
- .uploaderImage .coverImg .ico {
- top: 30%;
- }
- #allmap{
- width: 10px;
- height: 10px;
- left: -1000px;
- position: relative;
- }
- </style>
|