帮你贷的小程序

getPhone.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // pages/logs_to/logs_to.js
  2. var app = getApp();
  3. Page({
  4. data: {
  5. from: '',
  6. preid: ''
  7. },
  8. onLoad: function (options) {
  9. // console.log(options.from);
  10. var that = this;
  11. if (options.preid) {
  12. that.setData({from: options.from, preid: options.preid});
  13. }else{
  14. that.setData({from: options.from});
  15. }
  16. // console.log(that.data.from, options.preid);
  17. },
  18. getPhoneNumber: function(e) {
  19. var that = this;
  20. if (e.detail.errMsg == 'getPhoneNumber:fail user deny') {
  21. console.log(e.detail.errMsg === 'getPhoneNumber:fail user deny');
  22. app.noticeModal('不绑定手机号的话就不能申请了哦');
  23. }else{
  24. let token = wx.getStorageSync('user').token;
  25. that.telHost(token, e.detail.iv, e.detail.encryptedData)
  26. }
  27. },
  28. goSignup () {
  29. var that = this;
  30. var id = that.data.preid;
  31. wx.redirectTo({
  32. url: '/pages/signup/signup?from='+that.data.from+'&preid='+ that.data.preid
  33. })
  34. },
  35. telHost (token, iv, encryptedData) {
  36. var that = this;
  37. wx.request({
  38. url: app.globalData.HOST + '/user/wx/getUserPhone',
  39. method: 'POST',
  40. data: {token: token, iv: iv, encryptedData: encryptedData},
  41. success: function (res) {
  42. var data = res.data
  43. // console.log(data);
  44. if (data.errno == '0'){
  45. var tel = data.rst.phone_number;
  46. wx.setStorage({key:"tel", data: tel})
  47. if (that.data.from === 'mine') {
  48. wx.redirectTo({
  49. url: '/pages/application/application?tel=' + tel
  50. })
  51. }else if(that.data.from === 'mineFeedback'){
  52. wx.redirectTo({
  53. url: '/pages/feedback/feedback?tel=' + tel
  54. })
  55. }else{
  56. // if(that.data.from === 'card' && that.data.preid)
  57. wx.redirectTo({
  58. url: '/pages/getIt/getIt?from='+that.data.from+'&preid='+ that.data.preid +'&tel=' + tel
  59. })
  60. }
  61. }else{
  62. // app.noticeModal(data.err);
  63. }
  64. }
  65. });
  66. },
  67. onReady: function () {
  68. },
  69. onShow: function () {
  70. },
  71. onHide: function () {
  72. },
  73. onUnload: function () {
  74. }
  75. })