当前位置: 首页 > article >正文

【微信小程序】上传头像 微信小程序内接小程序客服

这里写目录标题

  • 微信小程序上传头像
    • 使用button按钮包裹img
  • 微信小程序内接小程序客服
    • 使用button按钮跳转客服

微信小程序上传头像

在这里插入图片描述

使用button按钮包裹img

原本思路是只使用image标签再加上chooseImg,但发现使用button标签上传头像这种方法更实用。微信小程序文档上,button的 open-type 功能有很多
在这里插入图片描述
在这里插入图片描述

  <button
      style="border-radius: 50%;"
      open-type="chooseAvatar"
      bindchooseavatar="getPropertyPortrait"
  >
   <image style="margin: 0rpx;" src="{{headimg?headimg:'https://ys.zye.com/upload/touxiang.png' }}"></image>
  </button>
  // 上传头像
  
  getPropertyPortrait(e){
    var that = this;
    var image =  e.detail.avatarUrl;
    // 调用上传函数
    imageUpload.uploadImage('/api/upload/headimg', image, 'file', {}).then((response) => {
      console.log('上传成功', response);
      that.setData({
        headimg: 'https://ys.zye.com' + response.data.pic_path
      })
      //上传之后在调用修改头像函数
      that.updePropertyPortrait('https://ys.zye.com' + response.data.pic_path);
    })
        .catch((error) => {
          console.error('上传失败', error);
          toast.showError(error.errMsg);
        });

  },
  // 修改头像
  updePropertyPortrait(pic_path){
    var that = this;
    var data = {
      token:app.globalData.token,
      headimg:pic_path
    }
    api.post('/api/member/moheadimg', JSON.stringify(data))
        .then((response) => {
          console.log('修改头像==》',response);
          if(response.code == 0){
            that.getPropertyDetails();
          }else{
            toast.showError(response.message);
          }
        })
        .catch((error) => {
          toast.showError(error.errMsg);
        });

  },

微信小程序内接小程序客服

内接公司内部的小程序客服,先在微信公众平台设置小程序客服,然后使用button的open-type设置成contact,再进行事件对接。

在这里插入图片描述

使用button按钮跳转客服

  <button class="containedwhd"
          open-type="contact"
          send-message-title="客服"
          show-message-card="true"
          bindcontact="contactEvent"
  >
    <image class="left_ls" src="https://ys.ziye.com/upload/iocn/kefu.png"></image>
    <view class="keda">客服</view>
  </button>
Page({
     // 客服
  contactEvent(e){
  
	console.log(e,'客服===>')
	console.log(e.detail.path)
    console.log(e.detail.query)
    
  }, 
})

http://www.kler.cn/news/156164.html

相关文章:

  • C++ day51 买卖股票最佳时期
  • 计算机网络——习题
  • 【PTA-C语言】编程练习3 - 循环结构Ⅱ
  • 安装配置JDK1.8
  • 单例模式的实现
  • 字符串转换整数
  • 一个完整的手工构建的cuda动态链接库工程 03记
  • SQL Server 2016(创建数据表)
  • qt-C++笔记之识别点击鼠标右键、点击位置以及Qt坐标系详解
  • flutter-web中使用js工具类
  • Linux系统配置深度学习环境之cudnn安装
  • 40 mysql join 的实现
  • jmeter下载地址
  • [Java] 模拟Jdk 以及 CGLib 代理原理
  • 网络接口规范
  • springBoot整合task
  • uniapp中uni.navigateBack返回后刷新页面数据
  • 线程池大小设置多少,比较合适?
  • 如何从 Jira 成功迁移到极狐GitLab,看这个就够了!
  • [leetcode 哈希表] 模版
  • AtCoder Beginner Contest 331 题解 A-E
  • postgreSQL 查询所有模式的语句
  • 算法设计与实现--动态规划篇
  • Matlab和python详解数独谜题问题
  • 2、设计在链式存储结构上交换二叉树中所有结点左右子树的算法。
  • MySQL进阶部分
  • C语言--每日选择题--Day34
  • (C)一些题6
  • 如何快速看懂市场行情?
  • 视频生成的发展史及其原理解析:从Gen2、Emu Video到PixelDance、SVD、Pika 1.0