getphone.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const app = getApp()
  2. const util = require('../../utils/util.js')
  3. Page({
  4. data: {},
  5. //事件处理函数
  6. bindViewTap: function() {
  7. wx.navigateTo({
  8. url: '../logs/logs'
  9. })
  10. },
  11. onLoad: function(options) {
  12. console.log(app.globalData.openid);
  13. // console.log(options)
  14. this.setData({
  15. navH: app.globalData.navHeight
  16. })
  17. },
  18. getPhoneNumber: function(e) {
  19. var that = this;
  20. if (e.detail.errMsg == 'getPhoneNumber:ok') {
  21. var that = this;
  22. util.postData('/getWxDecrypt', {
  23. encrypData: e.detail.encryptedData,
  24. ivData: e.detail.iv,
  25. openid: app.globalData.openid
  26. }).then(res => {
  27. console.log(res);
  28. if (res.purePhoneNumber !== undefined && res.purePhoneNumber != 'undefined') {
  29. app.globalData.userphone = res.purePhoneNumber;
  30. wx.setStorageSync('PHONE', res.purePhoneNumber);
  31. util.postData('/updateWXUser', {
  32. xu_openid: app.globalData.openid,
  33. xu_phone: res.purePhoneNumber,
  34. xu_countryCode: res.countryCode
  35. }).then(res2 => {
  36. console.log(res2);
  37. util.postData('/insertDcIntroduceLog', {
  38. xul_openid: app.globalData.openid,
  39. xul_phone: res.purePhoneNumber,
  40. xul_event: 2,
  41. xul_introducer_phone: app.globalData.introducer
  42. }).then(() => {
  43. wx.navigateBack();
  44. })
  45. })
  46. } else { //没有电话号
  47. wx.navigateBack();
  48. }
  49. })
  50. } else {
  51. wx.navigateBack();
  52. }
  53. }
  54. })