index.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. console.log(e)
  80. app.getPhone({
  81. data: {
  82. code: e.detail.code
  83. },
  84. header: {},
  85. success: () => { }
  86. })
  87. },
  88. face() {
  89. wx.navigateTo({
  90. url: "/pages/faceRecognition/index"
  91. })
  92. },
  93. faceVK(){
  94. wx.navigateTo({
  95. url: "/pages/faceRecognitionVk/index"
  96. })
  97. },
  98. tonamtve() {
  99. wx.navigateTo({
  100. url: "/pages/index/index"
  101. })
  102. },
  103. getVideo() {
  104. app.getVideo({
  105. success: (res: any) => {
  106. this.setData({
  107. videoSrc: res.url
  108. });
  109. wx.downloadFile({
  110. url: res.url,
  111. success: (res) =>{
  112. wx.saveVideoToPhotosAlbum({
  113. filePath: res.tempFilePath,
  114. success: () => {
  115. wx.showToast({
  116. title: "保存成功",
  117. icon: "none"
  118. })
  119. }
  120. })
  121. }
  122. })
  123. }
  124. })
  125. },
  126. })