xcxServiceChat.js 2.55 KB
// packageF/pages/xcxServiceChat/xcxServiceChat.js
var t = getApp(),
a = t.request,
o = t.globalData.setting
Page({

  /**
   * 页面的初始数据
   */
  data: {
    url: o.imghost,
    imgUrl:'',
    userinfo:{},
    window_info:{},
    imgBoxOffw:true,
    imgBoxOffh:true,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let window_info = wx.getWindowInfo()
    console.error(window_info);
    console.log(window_info);
    this.getad()
    wx.setNavigationBarTitle({
      title: '联系客服'
    })
    this.setData({
        userinfo: getApp().globalData.userInfo,
        window_info,
    });

  },
  //获取客服广告
  async getad(){
        //---首页广告-------
        await getApp().request.promiseGet("/api/weshop/ad/page?pids=1209&store_id=" + o.stoid, {
          data: {}
        }).then(res => {
          if (res.data.code == 0 && res.data.data.pageData && res.data.data.pageData.length > 0) {
            let a = res.data.data.pageData[0];
            let imgUrl = this.data.url + a.ad_code
            wx.getImageInfo({
              src: imgUrl,
              success: res=>{
                let imgBoxOffw = true
                let imgBoxOffh = true
                if (res.width > this.data.window_info.screenWidth) {
                  imgBoxOffw = false
                }
                if (res.height > this.data.window_info.screenWidth) {
                  imgBoxOffh = false
                }

                this.setData({
                  imgUrl,
                  imgBoxOffw,
                  imgBoxOffh
                })
              }
            })

          }
        })
  },
  //联系客服
  con_weixin () {
    console.log(123456);
    console.log(this.data.sys_switch);
    // getApp().con_wx(this);
    var url=this.data.sys_switch.weapp_customertype_url;
    var id=this.data.sys_switch.weapp_customertype_appid;
    wx.openCustomerServiceChat({
        extInfo: {url: url},
        corpId: id,
        success(res) {}
    })
 },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})