index.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. // pages/home/index.ts
  2. const app = getApp<IAppOption>();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. height: 0,
  9. videoSrc: ""
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad() {
  15. },
  16. /**
  17. * 生命周期函数--监听页面初次渲染完成
  18. */
  19. onReady() {
  20. },
  21. /**
  22. * 生命周期函数--监听页面显示
  23. */
  24. onShow() {
  25. },
  26. /**
  27. * 生命周期函数--监听页面隐藏
  28. */
  29. onHide() {
  30. },
  31. /**
  32. * 生命周期函数--监听页面卸载
  33. */
  34. onUnload() {
  35. },
  36. /**
  37. * 页面相关事件处理函数--监听用户下拉动作
  38. */
  39. onPullDownRefresh() {
  40. },
  41. /**
  42. * 页面上拉触底事件的处理函数
  43. */
  44. onReachBottom() {
  45. },
  46. /**
  47. * 用户点击右上角分享
  48. */
  49. onShareAppMessage() {
  50. },
  51. loadimage(e: WechatMiniprogram.CustomEvent) {
  52. const width: number = e.detail.width;
  53. const height: number = e.detail.height;
  54. this.setData({
  55. height: 750 * (height / width)
  56. })
  57. },
  58. getPay() {
  59. app.createOrder({
  60. success: (res: any) => {
  61. console.log('支付:', res);
  62. wx.requestPayment({
  63. timeStamp: res.timeStamp,
  64. nonceStr: res.nonceStr,
  65. package: res.package,
  66. paySign: res.paySign,
  67. signType: res.signType,
  68. success(res) {
  69. console.log("pay--->", res);
  70. },
  71. fail(err) {
  72. console.log("err---> ", err);
  73. }
  74. })
  75. },
  76. })
  77. },
  78. getPhoneNumber(e: WechatMiniprogram.CustomEvent) {
  79. app.getPhone({
  80. data: {
  81. code: e.detail.code
  82. },
  83. header: {},
  84. success: () => { }
  85. })
  86. },
  87. face() {
  88. wx.navigateTo({
  89. url: "/pages/faceRecognition/index"
  90. })
  91. },
  92. faceVK(){
  93. wx.navigateTo({
  94. url: "/pages/faceRecognitionVk/index"
  95. })
  96. },
  97. tonamtve() {
  98. wx.navigateTo({
  99. url: "/pages/index/index"
  100. })
  101. },
  102. getVideo() {
  103. app.getVideo({
  104. success: (res: any) => {
  105. this.setData({
  106. videoSrc: res.url
  107. });
  108. wx.downloadFile({
  109. url: res.url,
  110. success: (res) =>{
  111. wx.saveVideoToPhotosAlbum({
  112. filePath: res.tempFilePath,
  113. success: () => {
  114. wx.showToast({
  115. title: "保存成功",
  116. icon: "none"
  117. })
  118. }
  119. })
  120. }
  121. })
  122. }
  123. })
  124. },
  125. isVideo() {
  126. app.createVideo({
  127. success: (res: any) => {
  128. console.log('是否生成视频:', res.data);
  129. }
  130. })
  131. }
  132. })