123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- // 引入 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
- });
- };
- function formatDate(now) {
- var year=now.getFullYear();
- var month=now.getMonth()+1;
- if(month<10){
- month='0'+month.toString();
- }
- var date=now.getDate();
- if(date<10){
- date='0'+date.toString();
- }
- var hour=now.getHours();
- if(hour<10){
- hour='0'+hour.toString();
- }
- var minute=now.getMinutes();
- if(minute<10){
- minute='0'+minute.toString();
- }
- var second=now.getSeconds();
- return month+"-"+date+" "+hour+":"+minute;
- }
- //获取应用实例
- var app = getApp()
- Page({
- data: {
- "hash_key":"",
- "videoSrc":"",
- "height":"",
- "is_qun":false,
- "share":false,
- "video_hidden":true,
- "share_txt":"",
- "expire_time":"",
- "text":""
- },
- onLoad: function (e) {
- console.log('onLoad');
- app.getUserInfo(function(userInfo){
- console.log(userInfo);
- });
- this.setData({
- hash_key:e.hash_key
- })
- var self=this
- try {
- var res = wx.getSystemInfoSync();
- self.setData({
- height:(res.windowWidth)*0.8
- });
- } catch (e) {
- // Do something when catch error
- }
- qcloud.request({
- // 要请求的地址
- url: config.service.apiUrl+'messages/'+self.data.hash_key,
- success(result) {
- console.log(result);
- if(result.data.success==true){
- if(result.data.message_data.type!==3){
- wx.switchTab({
- url: '/pages/perosn/image/view/view?hash_key='+self.data.hash_key
- })
- }
- self.setData({
- videoSrc:result.data.message_data.image_url
- });
- if(result.data.message_data.is_qun==0){
- self.setData({
- is_qun:false,
- expire_time:"",
- share_txt:'密件已经准备好了,你可以将本页发给你的朋友了,对方观看一次后立即销毁',
- });
- }else{
- var expire=result.data.message_data.expire_time;
- var d=new Date(expire*1000);
- self.setData({
- is_qun:true,
- expire_time:formatDate(d),
- share_txt:'密件已经准备好了,你可以将本页发到群中了。6小时后本密件自动销毁',
- });
- }
- }else{
- wx.switchTab({
- url: '/pages/person/index/index'
- })
- }
- },
- fail(error) {
- console.log('request fail', error);
- },
- complete() {
- console.log('request complete');
- }
- });
- },
- onShow: function () {
- console.log('onShow');
- },
- edit:function(){
- wx.switchTab({
- url: '/pages/person/index/index'
- })
- },
- share:function(){
- this.setData({
- share:true
- })
- var self=this
- setTimeout(function(){
- self.setData({
- share:false
- })
- }, 500);
- },
- play:function(){
- this.setData({
- video_hidden:false
- });
- this.videoContext = wx.createVideoContext('myVideo');
- var self=this;
- setTimeout(function(){
- self.videoContext.play();
- }, 500);
- },
- ended:function(e){
- this.setData({
- video_hidden:true
- });
- },
- onShareAppMessage: function () {
- return {
- title: '密件-只有我们知道',
- path: 'pages/person/video/send/send?hash_key='+this.data.hash_key
- }
- }
- })
|