bindOld.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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.showModal({
  21. showCancel: true,
  22. content: '确定要解除绑定关系吗',
  23. success: (res) => {
  24. if (res.confirm) {
  25. wx.showLoading({
  26. title: '加载中',
  27. })
  28. wx.request({
  29. url: app.globalData.publicUrl + '/wxinfo/visitUnbind',
  30. method: "GET",
  31. data: {
  32. openId: id,
  33. fid: this.data.fid
  34. },
  35. success: res => {
  36. console.log(res)
  37. if (res.data.code == 0) {
  38. wx.showModal({
  39. showCancel: false,
  40. content: '已解除绑定',
  41. success: (res) => {
  42. wx.navigateTo({
  43. url: '/pages/visitFind/visitFind',
  44. })
  45. }
  46. })
  47. } else {
  48. wx.showModal({
  49. showCancel: false,
  50. content: res.data.message,
  51. })
  52. }
  53. },
  54. complete: () => {
  55. wx.hideLoading()
  56. }
  57. })
  58. }
  59. }
  60. });
  61. },
  62. /**
  63. * 生命周期函数--监听页面加载
  64. */
  65. onLoad: function () {
  66. let id = wx.getStorageSync('openId');
  67. wx.showLoading({
  68. title: '加载中',
  69. })
  70. wx.request({
  71. url: app.globalData.publicUrl + '/wxinfo/visitIsExist',
  72. method: "GET",
  73. data: {
  74. openId: id
  75. },
  76. success: res => {
  77. if (res.data.code == 1) {
  78. console.log("用户没绑定", res);
  79. wx.hideLoading()
  80. wx.navigateTo({
  81. url: '/pages/visitFind/visitFind',
  82. })
  83. } else if (res.data.code == 0) {
  84. console.log("用户已经绑定了", res);
  85. console.log(res.data.data._id)
  86. this.setData({
  87. fid: res.data.data._id
  88. })
  89. this.findFamilyInfo(res.data.data._id)
  90. } else {
  91. wx.hideLoading()
  92. wx.showModal({
  93. showCancel: false,
  94. content: res.data.message,
  95. })
  96. }
  97. }
  98. });
  99. },
  100. findFamilyInfo(_id) {
  101. wx.request({
  102. url: app.globalData.publicUrl + '/wxinfo/visitByFid',
  103. method: "GET",
  104. data: {
  105. fid: _id
  106. },
  107. success: res => {
  108. if (res.data.code == 0) {
  109. console.log(res.data.data, '我查到户的id了')
  110. this.setData({
  111. arr: res.data.data
  112. })
  113. } else {
  114. wx.showModal({
  115. showCancel: false,
  116. content: res.data.message,
  117. })
  118. }
  119. },
  120. complete: () => {
  121. wx.hideLoading()
  122. }
  123. });
  124. },
  125. /**
  126. * 生命周期函数--监听页面初次渲染完成
  127. */
  128. onReady: function () {
  129. },
  130. /**
  131. * 生命周期函数--监听页面显示
  132. */
  133. onShow: function () {
  134. },
  135. /**
  136. * 生命周期函数--监听页面隐藏
  137. */
  138. onHide: function () {
  139. },
  140. /**
  141. * 生命周期函数--监听页面卸载
  142. */
  143. onUnload: function () {
  144. },
  145. /**
  146. * 页面相关事件处理函数--监听用户下拉动作
  147. */
  148. onPullDownRefresh: function () {
  149. },
  150. /**
  151. * 页面上拉触底事件的处理函数
  152. */
  153. onReachBottom: function () {
  154. },
  155. /**
  156. * 用户点击右上角分享
  157. */
  158. onShareAppMessage: function () {
  159. }
  160. })