// 引入 QCloud 小程序增强 SDK var qcloud = require('../../../../vendor/qcloud-weapp-client-sdk/index'); // 引入配置 var config = require('../../../../config'); // 显示繁忙提示 var showBusy = text => wx.showToast({ title: text, icon: 'loading', duration: 10000 }); // 显示成功提示 var showSuccess = text => { wx.hideToast(); wx.showToast({ title: text, icon: 'success' }); }; // 显示失败提示 var showModel = (title, content) => { wx.hideToast(); wx.showModal({ title, content: JSON.stringify(content), showCancel: false }); }; //获取应用实例 var busy=false; var app = getApp() Page({ data: { hash_key:"", start:false, text:"", is_mine:false, videoSrc:"", video_hidden:true, nicker_name:"", animationData: {}, num:"" }, Interval:function(){ var self=this; this.data.intervarID= setInterval(function(){ self.animation.scale(2, 2).step() self.animation.scale(1, 1).step() self.setData({ animationData: self.animation.export() }) self.setData({ num:self.data.num-1, }); if(self.data.num == 0){ clearInterval(self.data.intervarID); setTimeout(function(){ wx.switchTab({ url: '/pages/index/index' }) }, 1000); } },1000); }, onLoad: function (e) { console.log('onLoad'); if(busy){ return; } busy=true; this.setData({ hash_key:e.hash_key }) var self=this; app.getUserInfo(function(userInfo){ console.log(userInfo); qcloud.request({ // 要请求的地址 url: config.service.apiUrl+'messages/'+self.data.hash_key, success(result) { console.log(result); if(result.statusCode==200){ if(result.data.success==true){ if(result.data.message_data.dead==0){ if(result.data.is_mine==true){ self.setData({ is_mine:true }); }else{ self.setData({ is_mine:false }); } self.setData({ start:true, videoSrc:result.data.message_data.image_url }); }else{ if(result.data.message_data.is_qun==1){ wx.hideToast(); wx.showModal({ title:'提示信息', content: '你来晚了,本密件已经被销毁', showCancel: false, success: function(res) { if (res.confirm) { wx.switchTab({ url: '/pages/person/index/index' }) } } }); }else{ wx.switchTab({ url: '/pages/person/index/index' }) } } }else{ wx.hideToast(); wx.showModal({ title:'提示信息', content: result.data.message, showCancel: false, success: function(res) { if (res.confirm) { wx.switchTab({ url: '/pages/person/index/index' }) } } }); } }else{ wx.switchTab({ url: '/pages/person/index/index' }) } }, fail(error) { console.log('request fail', error); }, complete() { busy=false; console.log('request complete'); } }); }); }, onShow: function () { console.log('onShow'); var animation = wx.createAnimation({ duration: 100, timingFunction: 'ease', }) this.animation = animation var self=this; }, play:function(e){ console.log(e); }, videoPlay:function(){ this.setData({ video_hidden:false }); this.videoContext = wx.createVideoContext('myVideo'); var self=this; setTimeout(function(){ self.videoContext.play(); }, 500); }, timeUpdate: function(e){ console.log(e); var self=this; var num=Math.floor(e.detail.duration)-Math.floor(e.detail.currentTime); if(num!==self.data.num){ self.animation.scale(2, 2).step() self.animation.scale(1, 1).step() self.setData({ animationData: self.animation.export() }) self.setData({ num:num, }); } }, ended:function(e){ var self=this; if(self.data.is_mine==false){ setTimeout(function(){ wx.switchTab({ url: '/pages/person/index/index' }) }, 1000); } } })