goldDetail.js 4.3 KB
// pages/index/goldDetail/goldDetail.js
const app=getApp();
var wxParse = require("../../../wxParse/wxParse.js")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    temshow:false,
    listdata:[],
    myinfo:[],
    price:'',//会员价格
    state:0//弹框控制
  
  },
 temshowno() {
  this.setData({
   temshow: false
  })
 },
 settemshow() {
  this.setData({
   temshow: true
  })
 },
  getdata(id){
    let that=this;
    let url ='Show/getShow3Detail';
    app.post(url,{id:id}).then((res)=>{
      console.log(res)
      if(res.data.code==1){
        that.setData({
          listdata:res.data.data
        })
        wxParse.wxParse('content', 'html', res.data.data.content, that, 5);
        wx.setNavigationBarTitle({
          title: res.data.data.title
        })
      }
    }).catch((errMsg)=>{
      console.log(errMsg)
    })
  },
  //获取个人信息判断是否开通会员
  getMyMessage() {
    let that = this;
    let url = 'Mine/getMyMessage';
    let params = {
      token: wx.getStorageSync("token")
    }
    app.post(url, params).then((res) => {
      if (res.data.code == 1) {
        that.setData({
          myinfo: res.data.data
        })
      }
    }).catch((errMsg) => {
      console.log(errMsg)
    })
  },
  //是否能观看视频
  videoplay() {
    let that = this;
    let myinfo = that.data.myinfo;
    // if (that.data.myinfo.is_member) {
    //  console.log('1111111111111111');
    // } else {
    //  console.log('2222222222222222222');
    //   that.videoContext.pause()
    //   wx.showModal({
    //     title: '提示',
    //     content: '您还不是会员,不能观看,是否开通',
    //     success: function (res) {
    //       if (res.confirm) {
    //        that.setData({
    //          // state:1
    //         temshow:true
    //        })
    //       } else if (res.cancel) {
    //       }
    //     }
    //   })
    // }

  }, 
  setstate0() {
    let that = this;
    that.setData({
      state: 0
    })
  },
  voidfun() {

  },
  //获取会员价格
  getPrice() {
    let that = this;
    let url = 'Mine/getPrice';
    app.post(url, {}).then((res) => {
      if (res.data.code == 1) {
        that.setData({
          price: res.data.data
        })
      }
    })
  },
  //确认开通
  confirmOpen() {
   this.setData({
    temshow: false
   })
    let that = this;
    let url = 'Mine/memberOrder';
    let params = {
      token: wx.getStorageSync('token')
    }
    app.post(url, params).then((res) => {
      if (res.data.code == 1) {
        wx.requestPayment({
          'timeStamp': res.data.data.timeStamp,
          'nonceStr': res.data.data.nonceStr,
          'package': res.data.data.package,
          'signType': 'HMAC-SHA256',
          'paySign': res.data.data.paySign,
          'success': function (res) {
            wx.showToast({
              title: '开通成功',
              icon: 'success',
              duration: 2000,
            })
            that.setData({
              state: 0,
              vipstate: 1,
            })
            that.getMyMessage();
          },
          'fail': function (res) {
            wx.showToast({
              title: '开通失败',
              icon: 'success',
              duration: 2000,
            })
          }
        })

      }
    }).catch((errMsg) => {
      console.log(errMsg)
    })
  },
  //取消开通
  cancelOpen() {
    this.setData({
      state: 0,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that=this;
    that.getdata(options.id);
    that.getMyMessage();
    that.getPrice();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    this.videoContext = wx.createVideoContext('myVideo');
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getMyMessage();
  },

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

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

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

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

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