index.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // pages/entry/index.ts
  2. const app = getApp<IAppOption>();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. nickName: "",
  9. phoneNumber: "",
  10. inputed: false
  11. },
  12. phoneinput(e:WechatMiniprogram.CustomEvent){
  13. this.setData({
  14. phoneNumber: e.detail.value
  15. })
  16. },
  17. bindKeyInput(e:WechatMiniprogram.CustomEvent){
  18. this.setData({
  19. nickName: e.detail.value
  20. })
  21. },
  22. toFace(){
  23. if (!this.data.phoneNumber) {
  24. return wx.showToast({
  25. "icon": "none",
  26. "title": "未获取手机号",
  27. duration: 2000
  28. })
  29. }
  30. app.seaveUserData({
  31. data:{
  32. "name": this.data.nickName,
  33. "phone": this.data.phoneNumber
  34. },
  35. method: "POST",
  36. success: () =>{
  37. // 进入人脸识别
  38. wx.navigateTo({
  39. url: "/pages/faceRecognition/index"
  40. })
  41. }
  42. })
  43. },
  44. getPhoneNumber(e: WechatMiniprogram.CustomEvent) {
  45. app.getPhone({
  46. data: {
  47. code: e.detail.code
  48. },
  49. header: {},
  50. success: (res:any) => {
  51. if(!res.purePhoneNumber) {
  52. app.globalData.phone = "";
  53. wx.setStorageSync("userphone", "");
  54. wx.showToast({
  55. icon:"none",
  56. title: "未获取手机号,请手动输入",
  57. duration: 2000
  58. })
  59. return;
  60. }
  61. app.globalData.phone = res.purePhoneNumber;
  62. this.setData({
  63. phoneNumber: res.purePhoneNumber
  64. })
  65. wx.setStorageSync("userphone", res.purePhoneNumber);
  66. this.setData({
  67. inputed: true
  68. })
  69. }
  70. })
  71. },
  72. /**
  73. * 生命周期函数--监听页面加载
  74. */
  75. onLoad() {
  76. if(app.globalData.phone){
  77. this.setData({
  78. phoneNumber: app.globalData.phone,
  79. inputed: true
  80. })
  81. }
  82. },
  83. /**
  84. * 生命周期函数--监听页面初次渲染完成
  85. */
  86. onReady() {
  87. },
  88. /**
  89. * 生命周期函数--监听页面显示
  90. */
  91. onShow() {
  92. },
  93. /**
  94. * 生命周期函数--监听页面隐藏
  95. */
  96. onHide() {
  97. },
  98. /**
  99. * 生命周期函数--监听页面卸载
  100. */
  101. onUnload() {
  102. },
  103. /**
  104. * 页面相关事件处理函数--监听用户下拉动作
  105. */
  106. onPullDownRefresh() {
  107. },
  108. /**
  109. * 页面上拉触底事件的处理函数
  110. */
  111. onReachBottom() {
  112. },
  113. /**
  114. * 用户点击右上角分享
  115. */
  116. onShareAppMessage() {
  117. }
  118. })
  119. export {}