send.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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 busy=false;
  30. var app = getApp()
  31. Page({
  32. data: {
  33. hash_key:"",
  34. start:false,
  35. text:"",
  36. is_mine:false,
  37. videoSrc:"",
  38. video_hidden:true,
  39. nicker_name:"",
  40. animationData: {},
  41. num:""
  42. },
  43. Interval:function(){
  44. var self=this;
  45. this.data.intervarID= setInterval(function(){
  46. self.animation.scale(2, 2).step()
  47. self.animation.scale(1, 1).step()
  48. self.setData({
  49. animationData: self.animation.export()
  50. })
  51. self.setData({
  52. num:self.data.num-1,
  53. });
  54. if(self.data.num == 0){
  55. clearInterval(self.data.intervarID);
  56. setTimeout(function(){
  57. wx.switchTab({
  58. url: '/pages/index/index'
  59. })
  60. }, 1000);
  61. }
  62. },1000);
  63. },
  64. onLoad: function (e) {
  65. console.log('onLoad');
  66. if(busy){
  67. return;
  68. }
  69. busy=true;
  70. this.setData({
  71. hash_key:e.hash_key
  72. })
  73. var self=this;
  74. app.getUserInfo(function(userInfo){
  75. console.log(userInfo);
  76. qcloud.request({
  77. // 要请求的地址
  78. url: config.service.apiUrl+'messages/'+self.data.hash_key,
  79. success(result) {
  80. console.log(result);
  81. if(result.statusCode==200){
  82. if(result.data.success==true){
  83. if(result.data.message_data.dead==0){
  84. if(result.data.is_mine==true){
  85. self.setData({
  86. is_mine:true
  87. });
  88. }else{
  89. self.setData({
  90. is_mine:false
  91. });
  92. }
  93. self.setData({
  94. start:true,
  95. videoSrc:result.data.message_data.image_url });
  96. }else{
  97. if(result.data.message_data.is_qun==1){
  98. wx.hideToast();
  99. wx.showModal({
  100. title:'提示信息',
  101. content: '你来晚了,本密件已经被销毁',
  102. showCancel: false,
  103. success: function(res) {
  104. if (res.confirm) {
  105. wx.switchTab({
  106. url: '/pages/person/index/index'
  107. })
  108. }
  109. }
  110. });
  111. }else{
  112. wx.switchTab({
  113. url: '/pages/person/index/index'
  114. })
  115. }
  116. }
  117. }else{
  118. wx.hideToast();
  119. wx.showModal({
  120. title:'提示信息',
  121. content: result.data.message,
  122. showCancel: false,
  123. success: function(res) {
  124. if (res.confirm) {
  125. wx.switchTab({
  126. url: '/pages/person/index/index'
  127. })
  128. }
  129. }
  130. });
  131. }
  132. }else{
  133. wx.switchTab({
  134. url: '/pages/person/index/index'
  135. })
  136. }
  137. },
  138. fail(error) {
  139. console.log('request fail', error);
  140. },
  141. complete() {
  142. busy=false;
  143. console.log('request complete');
  144. }
  145. });
  146. });
  147. },
  148. onShow: function () {
  149. console.log('onShow');
  150. var animation = wx.createAnimation({
  151. duration: 100,
  152. timingFunction: 'ease',
  153. })
  154. this.animation = animation
  155. var self=this;
  156. },
  157. play:function(e){
  158. console.log(e);
  159. },
  160. videoPlay:function(){
  161. this.setData({
  162. video_hidden:false
  163. });
  164. this.videoContext = wx.createVideoContext('myVideo');
  165. var self=this;
  166. setTimeout(function(){
  167. self.videoContext.play();
  168. }, 500);
  169. },
  170. timeUpdate: function(e){
  171. console.log(e);
  172. var self=this;
  173. var num=Math.floor(e.detail.duration)-Math.floor(e.detail.currentTime);
  174. if(num!==self.data.num){
  175. self.animation.scale(2, 2).step()
  176. self.animation.scale(1, 1).step()
  177. self.setData({
  178. animationData: self.animation.export()
  179. })
  180. self.setData({
  181. num:num,
  182. });
  183. }
  184. },
  185. ended:function(e){
  186. var self=this;
  187. if(self.data.is_mine==false){
  188. setTimeout(function(){
  189. wx.switchTab({
  190. url: '/pages/person/index/index'
  191. })
  192. }, 1000);
  193. }
  194. }
  195. })