- goCamera: function() {
- let that = this
- // #ifdef APP-PLUS
- uni.chooseImage({
- count: 1, //默认9
- sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
- sourceType: ['album', 'camera'], //从相册选择
- success: function(res) {
- console.log(res,"app")
- console.log(res.tempFilePaths);
- // debugger
- that.shop.img = res.tempFilePaths[0]
- console.log(that.shop.img)
- that.url = res.tempFilePaths[0]
- const tempFilePaths = res.tempFilePaths;
- }
- });
- // #endif
- // #ifdef MP-WEIXIN
- wx.showActionSheet({
- itemList: ['拍照', '从相册中选择'],
- success(res) {
- console.log(res.tapIndex,"weixin")
- let sourceType = 'camera'
- if (res.tapIndex == 0) {
- sourceType = 'camera'
- } else if (res.tapIndex == 1) {
- sourceType = 'album'
- }
- wx.chooseImage({
- count: 1,
- sizeType: ['compressed'],
- sourceType: [sourceType],
- success: function(res) {
- console.log(res.tempFilePaths)
- const tempFilePaths = res.tempFilePaths[0]
- that.url = res.tempFilePaths[0]
- console.log(that.url)
- // uni.uploadFile({
- // url: http.baseUrl + '/uploads/upload-supplier-shop-head-portrait/' + uni.getStorageSync('shopId'),
- // methods: "post",
- // filePath: tempFilePaths,
- // name: 'upload',
- // success: function(uploadFileRes) {
- // console.log(JSON.parse(uploadFileRes.data).data);
- // // _this.imgList = [..._this.imgList, uploadFileRes.data]
- // that.shopDetail.shopHeadImgUrl = JSON.parse(uploadFileRes.data).data
- // }
- // });
- // this.tui.href('../cropper-default?src=' + that.url);
- console.log("yaotiaole")
- uni.navigateTo({
- url:"./cropper-default?src=" + that.url +"&uploadtype=touxiang&shopId=" + that.shopId + "&shopName=" + that.shopName + "&sourceType=" + sourceType ,
- success: (r) => {
- console.log(r)
- }
- })
- },
- })
- },
- })