sq.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. const url = require('../../utils/httpUrl')
  2. var app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. ApppId:'wx1d994f0e42ec45c9',
  9. AppSecret :'3c2aa6a1950d75f8a656155fe30b7887',
  10. sq:'授权',
  11. avatarUrl:'',
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. *
  16. */
  17. onLoad: function (options) {
  18. },
  19. // 获取手机号
  20. getPhoneNumber (e) {
  21. var that = this;
  22. wx.login({
  23. complete: (res) => {
  24. wx.request({
  25. url: app.coreUrl+'PostPhoneNumber',
  26. data: {
  27. encryptedData: e.detail.encryptedData,
  28. iv: e.detail.iv,
  29. code:res.code
  30. },
  31. method: "post",
  32. success: function (resphone) {
  33. if(res.data==''){
  34. wx.showModal({
  35. title: '提示',
  36. content: '未获取,再起点击授权',
  37. showCancel:true,
  38. success (res) {
  39. if (res.confirm) {
  40. } else if (res.cancel) {
  41. }
  42. }
  43. })
  44. }
  45. else{
  46. if(resphone.data.phoneNumber!=undefined&&resphone.data.phoneNumber!=''&&resphone.data.phoneNumber!=null){
  47. wx.setStorageSync(
  48. 'phone',resphone.data.phoneNumber+','+that.data.avatarUrl
  49. )
  50. wx.request({
  51. url: app.coreUrl+'updateOwnerUrl',
  52. data:{
  53. tel:resphone.data.phoneNumber,
  54. url:that.data.avatarUrl
  55. },
  56. method: "post",
  57. success:function(e){
  58. if(e!="微信头像更新成功"){
  59. return;
  60. }
  61. }
  62. })
  63. }
  64. wx.navigateBack({
  65. delta: 1
  66. })
  67. }
  68. }
  69. })
  70. },
  71. })
  72. },
  73. /**
  74. * 生命周期函数--监听页面初次渲染完成
  75. */
  76. onReady: function () {
  77. },
  78. /**
  79. * 生命周期函数--监听页面显示
  80. */
  81. onShow: function () {
  82. },
  83. /**
  84. * 生命周期函数--监听页面隐藏
  85. */
  86. onHide: function () {
  87. },
  88. /**
  89. * 生命周期函数--监听页面卸载
  90. */
  91. onUnload: function () {
  92. },
  93. /**
  94. * 页面相关事件处理函数--监听用户下拉动作
  95. */
  96. onPullDownRefresh: function () {
  97. },
  98. })