// pages/productDetail/productDetail.ts
const app = getApp()
import request from '../../utils/request'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    data: null,
    imgUrl: "",
    currentQrCode: "",
    showImage: false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {
    this.getImageUrl()
  },

  getImageUrl() {
    const that = this
    request.get({
      url: '/api/chat/link'
    }).then(res => {
      console.log(res, 'chatLink');

      that.setData({
        data: res.data
      })
    }).catch(err => {
      console.log(err, 'err');
    })
  },

  checkImage(e) {
    this.setData({
      currentQrCode: e.currentTarget.dataset.qrcode,
      showImage: true
    })
  },

  closeImage() {
    this.setData({
      showImage: false
    })
  },

  makePhoneCall(e) {
    wx.makePhoneCall({
      phoneNumber: e.currentTarget.dataset.phone
    })
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

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

  },

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

  },

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

  },

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

  },

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

  },

  onShareAppMessage() {
    const promise = new Promise(resolve => {
      setTimeout(() => {
        resolve({
          title: '小闲聊'
        })
      }, 500)
    })
    return {
      title: '小闲聊',
      promise
    }
  },
  onShareTimeline() {
    const promise = new Promise(resolve => {
      setTimeout(() => {
        resolve({
          title: '小闲聊'
        })
      }, 500)
    })
    return {
      title: '小闲聊',
      promise
    }
  }
})