微信小程序
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

147 rindas
3.8 KiB

  1. // pages/index/index.js
  2. import * as UTIL from '../../../utils/util.js';
  3. import * as API from '../../../utils/API.js';
  4. import * as STORAGE from '../../../utils/storage'
  5. const APP = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. isIPhoneX:false,
  12. privacyCheck:true //用户协议
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. this.setData({
  19. isIPhoneX:UTIL.isIPhoneX()
  20. })
  21. },
  22. /**
  23. * 生命周期函数--监听页面初次渲染完成
  24. */
  25. onReady: function () {
  26. },
  27. /**
  28. * 生命周期函数--监听页面显示
  29. */
  30. onShow: function () {
  31. },
  32. /**
  33. * 生命周期函数--监听页面隐藏
  34. */
  35. onHide: function () {
  36. },
  37. /**
  38. * 生命周期函数--监听页面卸载
  39. */
  40. onUnload: function () {
  41. },
  42. /**
  43. * 页面相关事件处理函数--监听用户下拉动作
  44. */
  45. onPullDownRefresh: function () {
  46. },
  47. /**
  48. * 页面上拉触底事件的处理函数
  49. */
  50. onReachBottom: function () {
  51. },
  52. /**
  53. * 用户点击右上角分享
  54. */
  55. onShareAppMessage: function () {
  56. },
  57. checkboxChange: function(res) {
  58. let checkStatus = false;
  59. if(res.detail.value.length!=0){
  60. checkStatus = true;
  61. }else{
  62. checkStatus = false;
  63. }
  64. this.setData({
  65. privacyCheck:checkStatus
  66. })
  67. },
  68. getPhoneNumber: function(res) {
  69. let that = this;
  70. let {
  71. detail
  72. } = res;
  73. if (!detail.encryptedData) {
  74. //允许授权
  75. APP.showToast("未获取到手机号码,注册失败!");
  76. return;
  77. }else if(this.data.privacyCheck == false){
  78. APP.showToast("请阅读并同意用户协议和隐私政策!");
  79. return;
  80. }
  81. let sendData = {
  82. sessionKey:STORAGE.getSessionKey(),
  83. iv:detail.iv,
  84. encryptedData:detail.encryptedData
  85. }
  86. UTIL.httpRequest(API.URL_POST_DECRYPTEDWXDATA, sendData,{
  87. success: (res) => {
  88. if (res._code == API.SUCCESS_CODE) {
  89. // UTIL.showToastNoneIcon("数据共:" + res._data.length + "条");
  90. } else {
  91. //待删
  92. wx.navigateTo({
  93. url: '/pages/index/index',
  94. })
  95. UTIL.showToastNoneIcon(res.msg)
  96. }
  97. },
  98. fail: (res) => {
  99. UTIL.showToastNoneIcon(API.MSG_FAIL_HTTP)
  100. },
  101. complete: (res) => {
  102. }
  103. });
  104. //     if (res.detail.userInfo) {
  105. //       //用户按了允许授权按钮
  106. //       var that = this;
  107. //       // 获取到用户的信息了,打印到控制台上看下
  108. //       console.log("用户的信息如下:");
  109. //       console.log(res.detail);
  110. //       //授权成功后,通过改变 isHide 的值,让实现页面显示出来,把授权页面隐藏起来
  111. //       that.setData({
  112. //         isHide: false
  113. //       });
  114. //     } else {
  115. //       //用户按了拒绝按钮
  116. //       wx.showModal({
  117. //         title: '警告',
  118. //         content: '您点击了拒绝授权,将无法进入小程序,请授权之后再进入!!!',
  119. //         showCancel: false,
  120. //         confirmText: '返回授权',
  121. //         success: function(res) {
  122. //           // 用户没有授权成功,不需要改变 isHide 的值
  123. //           if (res.confirm) {
  124. //             console.log('用户点击了“返回授权”');
  125. //           }
  126. //         }
  127. //       });
  128. //     }
  129. }
  130. })