myinfo.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. // pages/mine/mydc/mydc.js
  2. const app = getApp()
  3. const util = require('../../../utils/util.js')
  4. Page({
  5. data: {
  6. bank_card_number: "请拍照上传银行卡号",
  7. valid_date: '',
  8. bank_name: '',
  9. stauts: '',
  10. avatarUrl: '',
  11. nickName: '',
  12. wv_account_name: '',
  13. loaddisplay: true,
  14. loading: false
  15. },
  16. onLoad: function (options) {
  17. if (options.accountnumber != null && options.accountnumber != '' && options.accountnumber != 'null') {
  18. this.setData({
  19. bank_card_number: options.accountnumber
  20. })
  21. }
  22. if (options.wv_account_name != null && options.wv_account_name != '' && options.wv_account_name != 'null') {
  23. this.setData({
  24. wv_account_name: options.wv_account_name
  25. })
  26. }
  27. console.log(app.globalData)
  28. if (app.globalData.usertype == 2) {
  29. this.setData({
  30. nickName: app.globalData.userInfo.nickName,
  31. avatarUrl: app.globalData.userInfo.avatarUrl,
  32. link: true,
  33. loaddisplay: 'none'
  34. })
  35. } else {
  36. this.setData({
  37. nickName: app.globalData.nickName,
  38. avatarUrl: 'https://yuesuo.yueguanjia.com/MiniProgram/images/head.png',
  39. loaddisplay: 'none'
  40. })
  41. }
  42. var that = this
  43. wx.request({
  44. url: app.globalData.url + '/checkDcIntroducers',
  45. method: 'get',
  46. data: {
  47. wv_phone: app.globalData.userphone
  48. },
  49. success: function (res) {
  50. if (res.data != "") {
  51. that.setData({
  52. wv_account_number: res.data.wv_account_number,
  53. wv_account_name: res.data.wv_account_name
  54. })
  55. }
  56. },
  57. fail() {
  58. app.timeOut()
  59. }
  60. })
  61. let _this = this;
  62. _this.setData({
  63. navH: app.globalData.navHeight
  64. })
  65. },
  66. /**
  67. * 生命周期函数--监听页面初次渲染完成
  68. */
  69. onReady: function () {
  70. },
  71. /**
  72. * 生命周期函数--监听页面显示
  73. */
  74. onShow: function () {
  75. },
  76. /**
  77. * 生命周期函数--监听页面隐藏
  78. */
  79. onHide: function () {
  80. },
  81. /**
  82. * 生命周期函数--监听页面卸载
  83. */
  84. onUnload: function () {
  85. },
  86. /**
  87. * 页面相关事件处理函数--监听用户下拉动作
  88. */
  89. onPullDownRefresh: function () {
  90. },
  91. /**
  92. * 页面上拉触底事件的处理函数
  93. */
  94. onReachBottom: function () {
  95. },
  96. phoneInput: function(e) {
  97. if (e.detail.value !== null && e.detail.value !== '') {
  98. wx.request({
  99. url: app.globalData.url + '/updateAccountNumber',
  100. method: 'POST',
  101. header: { "Content-Type": "application/x-www-form-urlencoded" },
  102. data: {
  103. wv_account_name: e.detail.value,
  104. wv_phone: app.globalData.userphone
  105. },
  106. success: function (res) {
  107. },
  108. fail() {
  109. app.timeOut()
  110. }
  111. })
  112. }
  113. },
  114. /**
  115. * 用户点击右上角分享
  116. */
  117. onShareAppMessage: function () {
  118. },
  119. getBankCard: function() {
  120. var that = this
  121. wx.chooseImage({
  122. count: 1,
  123. sizeType: ['original', 'compressed'],
  124. sourceType: ['album', 'camera'],
  125. success(res) {
  126. var tempFilesSize = res.tempFiles[0].size
  127. if (tempFilesSize <= 5000000) {
  128. that.setData({
  129. loading: true,
  130. stauts: "",
  131. bank_card_number: ""
  132. })
  133. const tempFilePaths = res.tempFilePaths
  134. wx.uploadFile({
  135. url: app.globalData.url + '/getAccountNumber',
  136. filePath: tempFilePaths[0],
  137. name: 'file',
  138. formData: {
  139. 'phone': app.globalData.userphone
  140. },
  141. success(res) {
  142. let restemp = JSON.parse(res.data)
  143. if (res.data == "0") {
  144. that.setData({
  145. stauts: "识别失败!",
  146. loading: false,
  147. bank_card_number: "请上传清晰的银行卡照片"
  148. })
  149. } else {
  150. that.setData({
  151. stauts: "识别成功!所属银行:" + restemp.result.bank_name + ",有效期:" + restemp.result.valid_date,
  152. bank_card_number: restemp.result.bank_card_number,
  153. loading: false
  154. })
  155. }
  156. },
  157. fail() {
  158. app.timeOut()
  159. }
  160. })
  161. } else {
  162. wx.showToast({
  163. title: '上传照片请不要大于5M!',
  164. icon: 'none'
  165. })
  166. }
  167. },
  168. fail() {
  169. app.timeOut()
  170. }
  171. })
  172. }
  173. })