grxxxg.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. // pages/minePages/grxxxg/grxxxg.js
  2. import {
  3. xcxPhoneNumber,
  4. xcxsmbd
  5. } from "../../../apis/index"
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. checked: false,
  12. userType: [{
  13. type: "个人身份",
  14. value: 0
  15. }, {
  16. type: "企业身份",
  17. value: 1
  18. }],
  19. userTypeShow: false,
  20. enterpriceType: [],
  21. enterpriceTypeShow: false,
  22. form: {
  23. name: "",
  24. userType: "",
  25. enterpriceType: "",
  26. idcard: "",
  27. phone: ""
  28. },
  29. },
  30. /**
  31. * 生命周期函数--监听页面加载
  32. */
  33. onLoad(options) {
  34. let that = this
  35. that.init()
  36. },
  37. init() {
  38. let that = this
  39. let userInfo = wx.getStorageSync('USERINFO')
  40. that.setData({
  41. 'form.name': userInfo.name,
  42. 'form.idcard': userInfo.idcard,
  43. 'form.phone': userInfo.phone
  44. })
  45. },
  46. close() {
  47. let that = this
  48. that.setData({
  49. userTypeShow: false,
  50. enterpriceTypeShow: false
  51. })
  52. },
  53. userType() {
  54. let that = this
  55. that.setData({
  56. userTypeShow: true
  57. })
  58. },
  59. enterpriceType() {
  60. let that = this
  61. that.setData({
  62. enterpriceTypeShow: true
  63. })
  64. },
  65. name(e) {
  66. let that = this
  67. let value = e.detail.value
  68. that.setData({
  69. 'form.name': value
  70. })
  71. },
  72. selectUserType(e) {
  73. let that = this
  74. let item = e.currentTarget.dataset.item
  75. that.setData({
  76. 'form.userType': item.type,
  77. userTypeShow: false,
  78. enterpriceTypeShow: false
  79. })
  80. },
  81. selectEnterprice(e) {
  82. let that = this
  83. let item = e.currentTarget.dataset.item
  84. that.setData({
  85. 'form.enterpriceType': item.nsrmc,
  86. userTypeShow: false,
  87. enterpriceTypeShow: false
  88. })
  89. },
  90. idcard(e) {
  91. let that = this
  92. let value = e.detail.value
  93. that.setData({
  94. 'form.idcard': value
  95. })
  96. },
  97. getPhoneNumber(e) {
  98. let that = this
  99. if (!e.detail.code) {
  100. wx.showToast({
  101. title: '用户拒绝',
  102. icon: "none",
  103. duration: 3000
  104. })
  105. } else {
  106. wx.showLoading({
  107. title: '正在修改...',
  108. })
  109. xcxPhoneNumber({
  110. code: e.detail.code
  111. }).then((res) => {
  112. wx.hideLoading()
  113. if (res.code == 200) {
  114. that.setData({
  115. 'form.phone': res.message
  116. })
  117. } else {
  118. wx.showToast({
  119. title: res.msg || res.message,
  120. icon: "none",
  121. duration: 5000
  122. })
  123. }
  124. })
  125. }
  126. },
  127. xiugai() {
  128. let that = this
  129. let publicId = wx.getStorageSync('PUBLIC_ID')
  130. let form = that.data.form
  131. if (form.name.length > 1 && form.idcard.length == 18) {
  132. wx.showLoading({
  133. title: '正在修改...',
  134. })
  135. let forms = {
  136. xcxId: publicId.openid,
  137. unionid: publicId.unionid,
  138. sfzjhm: form.idcard,
  139. sjh: form.phone,
  140. xm: form.name
  141. }
  142. xcxsmbd(forms).then((res) => {
  143. wx.hideLoading()
  144. if (res.code == 200) {
  145. wx.showToast({
  146. title: res.msg || res.message,
  147. icon: "none",
  148. duration: 3000
  149. })
  150. let userInfo = wx.getStorageSync('USERINFO')
  151. userInfo.name = that.data.form.name
  152. userInfo.idcard = that.data.form.idcard
  153. userInfo.phone = that.data.form.phone
  154. wx.setStorageSync('USERINFO', userInfo)
  155. wx.navigateBack()
  156. } else {
  157. wx.showToast({
  158. title: res.msg || res.message,
  159. icon: "none",
  160. duration: 5000
  161. })
  162. }
  163. })
  164. } else {
  165. wx.showToast({
  166. title: '请检查身份证或姓名是否正确',
  167. icon: "none",
  168. duration: 5000
  169. })
  170. }
  171. },
  172. /**
  173. * 生命周期函数--监听页面初次渲染完成
  174. */
  175. onReady() {
  176. },
  177. /**
  178. * 生命周期函数--监听页面显示
  179. */
  180. onShow() {
  181. },
  182. /**
  183. * 生命周期函数--监听页面隐藏
  184. */
  185. onHide() {
  186. },
  187. /**
  188. * 生命周期函数--监听页面卸载
  189. */
  190. onUnload() {
  191. },
  192. /**
  193. * 页面相关事件处理函数--监听用户下拉动作
  194. */
  195. onPullDownRefresh() {
  196. },
  197. /**
  198. * 页面上拉触底事件的处理函数
  199. */
  200. onReachBottom() {
  201. },
  202. /**
  203. * 用户点击右上角分享
  204. */
  205. onShareAppMessage() {
  206. }
  207. })