bindOld.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. // pages/bindOld/bindOld.js
  2. const app = require('../../utils/util.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. arr: []
  9. },
  10. go(e) {
  11. console.log(e)
  12. let idNumber = e.currentTarget.dataset.item
  13. wx.navigateTo({
  14. url: '/pages/visitList/visitList?id=' + idNumber,
  15. })
  16. },
  17. // 解除绑定
  18. nobindNumber() {
  19. let id = wx.getStorageSync('openId');
  20. wx.request({
  21. url: app.globalData.publicUrl + '/applet/appletVisitUnbind',
  22. method: "GET",
  23. data: {
  24. appletId: id,
  25. fid: this.data.fid
  26. },
  27. success: res => {
  28. console.log(res)
  29. if (res.data.code == 0) {
  30. console.log('我解除绑定了', res)
  31. wx.showModal({
  32. showCancel: false,
  33. content: '已解除绑定',
  34. success: (res) => {
  35. wx.navigateTo({
  36. url: '/pages/visitFind/visitFind',
  37. })
  38. }
  39. })
  40. } else {
  41. wx.showModal({
  42. showCancel: false,
  43. content: res.data.message,
  44. })
  45. }
  46. }
  47. });
  48. },
  49. /**
  50. * 生命周期函数--监听页面加载
  51. */
  52. onLoad: function () {
  53. let id = wx.getStorageSync('openId');
  54. wx.request({
  55. url: app.globalData.publicUrl + '/applet/appletVisitIsExist',
  56. method: "GET",
  57. data: {
  58. appletId: id
  59. },
  60. success: res => {
  61. if (res.data.code == 1) {
  62. console.log("用户没绑定", res);
  63. wx.navigateTo({
  64. url: '/pages/visitFind/visitFind',
  65. })
  66. } else if (res.data.code == 0) {
  67. console.log("用户已经绑定了", res);
  68. console.log(res.data.data._id)
  69. this.setData({
  70. fid: res.data.data._id
  71. })
  72. this.findFamilyInfo(res.data.data._id)
  73. } else {
  74. wx.showModal({
  75. showCancel: false,
  76. content: res.data.message,
  77. })
  78. }
  79. }
  80. });
  81. },
  82. findFamilyInfo(_id) {
  83. wx.request({
  84. url: app.globalData.publicUrl + '/wxinfo/visitByFid',
  85. method: "GET",
  86. data: {
  87. fid: _id
  88. },
  89. success: res => {
  90. if (res.data.code == 0) {
  91. console.log(res.data.data, '我查到户的id了')
  92. this.setData({
  93. arr: res.data.data
  94. })
  95. } else {
  96. wx.showModal({
  97. showCancel: false,
  98. content: res.data.message,
  99. })
  100. }
  101. }
  102. });
  103. },
  104. /**
  105. * 生命周期函数--监听页面初次渲染完成
  106. */
  107. onReady: function () {
  108. },
  109. /**
  110. * 生命周期函数--监听页面显示
  111. */
  112. onShow: function () {
  113. },
  114. /**
  115. * 生命周期函数--监听页面隐藏
  116. */
  117. onHide: function () {
  118. },
  119. /**
  120. * 生命周期函数--监听页面卸载
  121. */
  122. onUnload: function () {
  123. },
  124. /**
  125. * 页面相关事件处理函数--监听用户下拉动作
  126. */
  127. onPullDownRefresh: function () {
  128. },
  129. /**
  130. * 页面上拉触底事件的处理函数
  131. */
  132. onReachBottom: function () {
  133. },
  134. /**
  135. * 用户点击右上角分享
  136. */
  137. onShareAppMessage: function () {
  138. }
  139. })