myOrderDetail.js 3.1 KB
// pages/person/myOrderDetail/myOrderDetail.js
const app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderid:'',
    ordertail:'',
    check:false,
    reveal:false,
    telshop:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)

    this.setData({
      orderid: options.orderid
    })

    this.getordertail()

  },

  getordertail(){
    let that=this;
    var url = '/api/portal/Mine/myOrderDetail';
    var params = {
      token: wx.getStorageSync('token'),
      orderId: that.data.orderid

    }
    app.post(url, params).then((res) => {
      console.log(res)
     
      if(res.list[0].is_service==1){
        that.setData({
         check:true
        })
      } else if (res.list[0].is_service == 2){
        that.setData({
          check:false
        })
      }

      that.setData({
        ordertail:res.list
      })

      console.log(that.data.ordertail);

    }).catch((err) => {

    })

  },

  backmoney(){
    this.setData({
      reveal:true
    })
    this.showphone()
  },
  //显示商家电话
  showphone() {
   
    this.setData({
      reveal: true
    })
   
    var url = '/api/portal/Mine/compareTel';
    var params = {
      token: wx.getStorageSync('token'),
      orderId: this.data.orderid

    }
    app.post(url, params).then((res) => {
      console.log(res);

      this.setData({
        telshop: res
      })



    }).catch((err) => {

    })


  },

  //关闭商家电话
  close() {
    this.setData({
      reveal: false
    })
  },
  boda() {
    let that=this;
    wx.makePhoneCall({
      phoneNumber: that.data.telshop //仅为示例,并非真实的电话号码
    })
  },
  gopay(){
    let that = this;
    var url = '/api/portal/Compare/pay';
    var params = {
      orderId: that.data.orderid
    }
    app.post(url, params).then((res) => {
      console.log(res);
      that.payment(res)



    }).catch((err) => {

    })
  },
  payment(res) {
    wx.requestPayment({
      timeStamp: res.timeStamp,
      nonceStr: res.nonceStr,
      package: res.package,
      signType: res.signType,
      paySign: res.paySign,
      success(res) {
        console.log(res)
        wx.navigateBack({
          checked: true
        })

        if (res.errMsg == 'requestPayment:ok') {
          // wx.switchTab({
          //   url: '../../order/order',
          // })
          wx.navigateTo({
            url: '../myOrder/myOrder',
          })
        }
      },
      fail(res) { }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})