小知识

<input class="input_name" placeholder="请填写昵称" bindinput="bindinput" placeholder-class="placeholder" maxlength="20" value="{{userName}}"/>
 // input赋值
  bindinput: function (e) {
    this.setData({
      userName: e.detail.value
    })
    // console.log(e.detail.value)
  },

-----------------------------------------------------

<view class="myinfo_row" bindtap="chooseImage">
    <text>头像</text>
    <!-- {{imageUrl}} -->
    <view class="myinfo_image" style="background-image: url(../../assets/img/my/no-head.png)">
    <image class="myinfo_image img" src="{{imageUrl}}"/>
    </view>
    <image class="myinfo_right" src="../../assets/img/remind/right-arrow-hui.png" />
  </view>

 

//调起相机相册
  chooseImage(){
    let thiz = this;
     wx.showActionSheet({
       itemList: ['拍照','从相册中选择'],
       success(res) {
         console.log(res.tapIndex)
         if (res.tapIndex == 0) { //0是拍照
           wx.chooseImage({
             count: 1,
             sizeType: ['compressed'],
             sourceType: ['camera'],
             success: function (res) {
               thiz.setData({
                 imageUrl: res.tempFilePaths[0]
               })
              //  console.log(res.tempFilePaths[0]);
               //res.tempFilePaths[0] 这个是图片
               const tempFilePaths = res.tempFilePaths
              //  console.log(app.bccode, tempFilePaths)
               thiz.uploadFile(tempFilePaths)
             },
           })
         } else if (res.tapIndex == 1) {
           wx.chooseImage({
             count: 1,
             sizeType: ['compressed'],
             sourceType: ['album'],
             success: function (res) {
               thiz.setData({
                 imageUrl: res.tempFilePaths[0]
               })
              //  console.log(res.tempFilePaths[0]);
               const tempFilePaths = res.tempFilePaths
              //  console.log(app.bccode, tempFilePaths)
               thiz.uploadFile(tempFilePaths)
               //res.tempFilePaths[0] 这个是图片
             },
           })
         }
       }
     })
  },
  // 图片上传微信服务器
  uploadFile: function (tempFilePaths) {
    this.setData({ status: 0 })
    // app.$.showLoading()
    var _this = this
    wx.uploadFile({
      url: app.url + '/obd/veh/upminiimg',
      filePath: tempFilePaths[0],
      name: 'miniimg',
      formData: {
        'BCCode': app.bccode
      },
      header: {
        "Content-Type": "multipart/form-data"
      },
      success(res) {
        // _this.saveInfo(res.data)
        _this.setData({
          headimginfo: res.data
        })
        // _this.JudgeType(res.data)
      }
    })
  }

--------------------------------------

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值