send.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. // 引入 QCloud 小程序增强 SDK
  2. var qcloud = require('../../../../vendor/qcloud-weapp-client-sdk/index');
  3. // 引入配置
  4. var config = require('../../../../config');
  5. // 显示繁忙提示
  6. var showBusy = text => wx.showToast({
  7. title: text,
  8. icon: 'loading',
  9. duration: 10000
  10. });
  11. // 显示成功提示
  12. var showSuccess = text => {
  13. wx.hideToast();
  14. wx.showToast({
  15. title: text,
  16. icon: 'success'
  17. });
  18. };
  19. // 显示失败提示
  20. var showModel = (title, content) => {
  21. wx.hideToast();
  22. wx.showModal({
  23. title,
  24. content: JSON.stringify(content),
  25. showCancel: false
  26. });
  27. };
  28. //获取应用实例
  29. var app = getApp()
  30. Page({
  31. data: {
  32. hash_key:"",
  33. start:false,
  34. text:"",
  35. is_mine:false,
  36. videoSrc:"",
  37. video_hidden:true,
  38. nicker_name:"",
  39. animationData: {},
  40. num:""
  41. },
  42. Interval:function(){
  43. var self=this;
  44. this.data.intervarID= setInterval(function(){
  45. self.animation.scale(2, 2).step()
  46. self.animation.scale(1, 1).step()
  47. self.setData({
  48. animationData: self.animation.export()
  49. })
  50. self.setData({
  51. num:self.data.num-1,
  52. });
  53. if(self.data.num == 0){
  54. clearInterval(self.data.intervarID);
  55. setTimeout(function(){
  56. wx.redirectTo({
  57. url: '/pages/index/index'
  58. })
  59. }, 1000);
  60. }
  61. },1000);
  62. },
  63. onLoad: function (e) {
  64. console.log('onLoad');
  65. this.setData({
  66. hash_key:e.hash_key
  67. })
  68. app.getUserInfo(function(userInfo){
  69. console.log(userInfo);
  70. });
  71. var self=this;
  72. qcloud.request({
  73. // 要请求的地址
  74. url: config.service.apiUrl+'messages/'+self.data.hash_key,
  75. success(result) {
  76. console.log(result);
  77. if(result.statusCode==200){
  78. if(result.data.success==true){
  79. if(result.data.message_data.dead==0){
  80. if(result.data.is_mine==true){
  81. self.setData({
  82. is_mine:true
  83. });
  84. }else{
  85. self.setData({
  86. is_mine:false
  87. });
  88. }
  89. self.setData({
  90. start:true,
  91. videoSrc:result.data.message_data.image_url });
  92. }else{
  93. if(result.data.message_data.is_qun==1){
  94. wx.hideToast();
  95. wx.showModal({
  96. title:'提示信息',
  97. content: '你来晚了,本密件已经被销毁',
  98. showCancel: false,
  99. success: function(res) {
  100. if (res.confirm) {
  101. wx.switchTab({
  102. url: '/pages/person/index/index'
  103. })
  104. }
  105. }
  106. });
  107. }else{
  108. wx.switchTab({
  109. url: '/pages/person/index/index'
  110. })
  111. }
  112. }
  113. }else{
  114. wx.hideToast();
  115. wx.showModal({
  116. title:'提示信息',
  117. content: result.data.message,
  118. showCancel: false,
  119. success: function(res) {
  120. if (res.confirm) {
  121. wx.switchTab({
  122. url: '/pages/person/index/index'
  123. })
  124. }
  125. }
  126. });
  127. }
  128. }else{
  129. wx.switchTab({
  130. url: '/pages/person/index/index'
  131. })
  132. }
  133. },
  134. fail(error) {
  135. console.log('request fail', error);
  136. },
  137. complete() {
  138. console.log('request complete');
  139. }
  140. });
  141. },
  142. onShow: function () {
  143. console.log('onShow');
  144. var animation = wx.createAnimation({
  145. duration: 100,
  146. timingFunction: 'ease',
  147. })
  148. this.animation = animation
  149. var self=this;
  150. },
  151. play:function(e){
  152. console.log(e);
  153. },
  154. videoPlay:function(){
  155. this.setData({
  156. video_hidden:false
  157. });
  158. this.videoContext = wx.createVideoContext('myVideo');
  159. var self=this;
  160. setTimeout(function(){
  161. self.videoContext.play();
  162. }, 500);
  163. },
  164. timeUpdate: function(e){
  165. console.log(e);
  166. var self=this;
  167. var num=Math.floor(e.detail.duration)-Math.floor(e.detail.currentTime);
  168. if(num!==self.data.num){
  169. self.animation.scale(2, 2).step()
  170. self.animation.scale(1, 1).step()
  171. self.setData({
  172. animationData: self.animation.export()
  173. })
  174. self.setData({
  175. num:num,
  176. });
  177. }
  178. },
  179. ended:function(e){
  180. var self=this;
  181. if(self.data.is_mine==false){
  182. setTimeout(function(){
  183. wx.switchTab({
  184. url: '/pages/person/index/index'
  185. })
  186. }, 1000);
  187. }
  188. }
  189. })