收藏
回答

wx.cloud.downloadFile图片后,addPhoneContact中如何引用?

wx.cloud.downloadFile下载云存储图片后,在addPhoneContact中photoFilePath如何引用

回答关注问题邀请回答
收藏

1 个回答

  • o0o有脾气的酸奶
    o0o有脾气的酸奶
    2019-11-22

    xxxx: async function(){

        let res = await wx.cloud.downloadFile({....})

        wx.saveFile({

            tempFilePath: res.tempFilePath,

            success(e) {

                wx.addPhoneContact({

                    photoFilePath:e.savedFilePath

                    ...

                })

            }

        })

        

    }

    2019-11-22
    有用
    回复 2
    • 李洋
      李洋
      2019-11-25
      我在data中也设置了tempFilePath:'', 但是报错,恳请帮忙协助一下,万分感谢
      报错全文:saveFile:fail parameter error: parameter.tempFilePath should be String instead of Undefined;

      代码全文

      addPhone: async function () {

      let res = await wx.cloud.downloadFile({

      fileID: 'cloud://hansh-aeg0m.6861-hansh-aeg0m-1300681430/logo.png',

      success: res => {

      // get temp file path

      console.log(res.tempFilePath)

      },

      fail: err => {

      // handle error

      }

      });



      wx.saveFile({



      tempFilePath: res.tempFilePath,



      success(e) {



      wx.addPhoneContact({



      photoFilePath: e.savedFilePath,

      firstName: this.data.date_List[0]['name'],//联系人姓名

      mobilePhoneNumber: this.data.date_List[0]['phone'],//联系人手机号

      organization: this.data.date_List[0]['company'],

      workAddressStreet: this.data.date_List[0]['address'],

      title: this.data.date_List[0]['post'],

      success: function () {

      console.log('添加成功')

      }

      })



      }



      })




      }
      2019-11-25
      回复
    • o0o有脾气的酸奶
      o0o有脾气的酸奶
      2019-11-25回复李洋
      2019-11-25
      回复
登录 后发表内容
问题标签