chatbot.js 1.3 KB
// components/userinfo/chatbot.js
var plugin = requirePlugin("chatbot");
import util from '../../utils/util'
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    params:Object,
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    userinfo(e){
      if(this.hasToChat) return;
      this.hasToChat=true
      let wechat=e.detail
      wechat.openid=wechat.openid||getApp().openid
      console.log('userinfo',wechat)
      plugin.init({
        appid: "sjAZRgrwD86PlVtpMnW16LR1TYy9hi",
        openid: wechat.openid, // 小程序的openid,必填项
        success: () => {
          wx.navigateTo({
            url: util.http_build_query(this.data.params,'/pages/me/chat'),
            success:()=>{
              this.hasToChat=false
            },
          });
        },
        fail: (error) => {this.hasToChat=false},
        guideList: [],
        textToSpeech: false, //默认为ture打开状态
        background: "rgba(247,251,252,1)",
        guideCardHeight: 40,
        operateCardHeight: 60,
        history: true,
        navHeight: 64,
        //robotHeader:"http://nosqn.colorcun.com/logo.png",
        userHeader: wechat.avatarUrl,
        userName: wechat.nickName,
        hideMovableButton: false,
      });
    }
  }
})