Realname.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. const app = getApp();
  2. Page({
  3. data: {
  4. //身份证手持页
  5. // 上传的案例图片集合
  6. scsfzImages: [],
  7. // 案例图片数目是否达到了最大数目
  8. scsfzImagesNum: false, //加号图标 显示
  9. scsfzimg: true, //上传图片 隐藏
  10. scsfzinitial: true, //初始图片 隐藏
  11. // 身份证头像页
  12. sfztxyImages: [],
  13. sfztxyImagesNum: false, //加号图标 显示
  14. sfztxyimg: true, //上传图片隐藏
  15. // sfztxyinitial: true, //初始图片 隐藏
  16. // 身份证反面页
  17. sfzfmImages: [],
  18. sfzfmImagesNum: false, //加号图标 显示
  19. sfzfmimg: true, //上传图片 隐藏
  20. // sfzfminitial: true, //初始图片 隐藏
  21. // 设置上传案例图片的最大数目
  22. maxImages: 1,
  23. loadingHidden: false, //加载中
  24. name: '', //姓名
  25. number: '', //证件号码
  26. hold: '', //手持身份证
  27. positive: '', //身份证正面
  28. opposite: '', //身份证反面
  29. initial: [], //头部信息
  30. SubmissionHidden: true, //提交隐藏显示
  31. isShow: false,
  32. },
  33. /**
  34. * 生命周期函数--监听页面加载
  35. */
  36. onLoad: function (options) {
  37. var that = this;
  38. // 获取信息
  39. let initial_url = 'my/authentication/ididentitychange';
  40. let initial_data = {
  41. };
  42. app.postRequest(initial_url, initial_data, function (res) {
  43. if (res.code == 201) {
  44. console.log(res.data.hold);
  45. that.setData({
  46. initial: res.data, // 初始数据
  47. initialcode: res, //获取未上传状态
  48. name: res.data.name, //姓名
  49. number: res.data.number, //证件号码
  50. })
  51. }
  52. if (res.data.status == 2){ //如果审核通过 隐藏掉提交按钮
  53. that.setData({
  54. SubmissionHidden: false
  55. })
  56. } else if (res.code != 201) {
  57. that.setData({
  58. SubmissionHidden: false
  59. })
  60. }else{
  61. that.setData({
  62. SubmissionHidden: true
  63. })
  64. }
  65. })
  66. },
  67. //获取姓名
  68. ObtainName: function (e) {
  69. var name = e.detail.value;
  70. console.log(name);
  71. this.setData({
  72. name: name
  73. });
  74. },
  75. //获取身份证
  76. Obtainsfz: function (e) {
  77. var number = e.detail.value;
  78. console.log(number);
  79. this.setData({
  80. number: number
  81. });
  82. },
  83. // 上传手持身份证
  84. scsfzclick: function (e) {
  85. var _this = this;
  86. wx.chooseImage({
  87. count: 1,
  88. sizeType: ['original', 'compressed'],
  89. sourceType: ['album', 'camera'],
  90. success(res) {
  91. let tempFilesSize = res.tempFiles[0].size;
  92. if (tempFilesSize > 1024 * 1024 * 3){
  93. wx.showModal({
  94. title: '提示',
  95. content: '图片不得超过3MB',
  96. showCancel: false,
  97. })
  98. return;
  99. }
  100. wx.showToast({
  101. title: '上传中...',
  102. icon: 'loading'
  103. });
  104. // 头部信息
  105. let dt_url = 'my/images/tempimages';
  106. let dt_filePath = res.tempFilePaths[0];
  107. app.Multigraph(dt_url, dt_filePath,function(res){
  108. if (res.code==201){
  109. // console.log(res.data.img_name);
  110. _this.setData({
  111. scsfzImages: dt_filePath,
  112. scsfzImagesNum: true,
  113. scsfzimg: false,
  114. hold:res.data.img_name, //手持身份证
  115. });
  116.  
  117. wx.showToast({
  118. title: '上传成功',
  119. icon: 'none', // 不显示图标
  120. duration: 2000
  121. })
  122. return;
  123. }
  124. app.Tips(res.msg);
  125. });
  126. }
  127. })
  128. },
  129. // 正面页
  130. sfztxyclick: function (e) {
  131. var _this = this;
  132. wx.chooseImage({
  133. count: 1,
  134. sizeType: ['original', 'compressed'],
  135. sourceType: ['album', 'camera'],
  136. success(res) {
  137. let tempFilesSize = res.tempFiles[0].size;
  138. if (tempFilesSize > 1024 * 1024 * 3) {
  139. wx.showModal({
  140. title: '提示',
  141. content: '图片不得超过3MB',
  142. showCancel: false,
  143. })
  144. return;
  145. }
  146. wx.showToast({
  147. title: '上传中...',
  148. icon: 'loading'
  149. });
  150. // 头部信息
  151. let dt_url = 'my/images/tempimages';
  152. let dt_filePath = res.tempFilePaths[0];
  153. app.Multigraph(dt_url, dt_filePath, function (res) {
  154. if (res.code == 201) {
  155. // console.log(res.data.img_name);
  156. _this.setData({
  157. sfztxyImages: dt_filePath,
  158. sfztxyImagesNum: true,
  159. sfztxyimg: false,
  160. positive: res.data.img_name,
  161. });
  162. wx.showToast({
  163. title: '上传成功',
  164. icon: 'none', // 不显示图标
  165. duration: 2000
  166. })
  167. return;
  168. }
  169. app.Tips(res.msg);
  170. });
  171. }
  172. })
  173. },
  174. // 反面页
  175. sfzfmclick: function (e) {
  176. var _this = this;
  177. wx.chooseImage({
  178. count: 1,
  179. sizeType: ['original', 'compressed'],
  180. sourceType: ['album', 'camera'],
  181. success(res) {
  182. // console.log(res.tempFilePaths[0]);
  183. // tempFilePath可以作为img标签的src属性显示图片
  184. let tempFilesSize = res.tempFiles[0].size;
  185. if (tempFilesSize > 1024 * 1024 * 3) {
  186. wx.showModal({
  187. title: '提示',
  188. content: '图片不得超过3MB',
  189. showCancel: false,
  190. })
  191. return;
  192. }
  193. wx.showToast({
  194. title: '上传中...',
  195. icon: 'loading'
  196. });
  197. // 头部信息
  198. let dt_url = 'my/images/tempimages';
  199. let dt_filePath = res.tempFilePaths[0];
  200. app.Multigraph(dt_url, dt_filePath, function (res) {
  201. if (res.code == 201) {
  202. // console.log(res.data.img_name);
  203. _this.setData({
  204. sfzfmImages:dt_filePath,
  205. sfzfmImagesNum: true,
  206. sfzfmimg: false,
  207. opposite:res.data.img_name,
  208. });
  209. wx.showToast({
  210. title: '上传成功',
  211. icon: 'none', // 不显示图标
  212. duration: 2000
  213. })
  214. return;
  215. }
  216. app.Tips(res.msg);
  217. });
  218. }
  219. })
  220. },
  221. //最后提交认证
  222. Submission: function (e) {
  223. var _this =this;
  224. console.log(this.data.name)
  225. console.log(this.data.number)
  226. console.log(this.data.hold)
  227. console.log(this.data.positive)
  228. console.log(this.data.opposite)
  229. if (this.data.name == '') {
  230. var _name = '请填写您的真实姓名'
  231. Tips(_name)
  232. } else if (this.data.number == '') {
  233. var _number = '请填写本人身份证号码'
  234. Tips(_number)
  235. } else if (this.data.hold == '') {
  236. var _hold = '请上传手持身份证'
  237. Tips(_hold)
  238. } else if (this.data.positive == '') {
  239. var _positive = '请上传身份证头像页'
  240. Tips(_positive)
  241. } else if (this.data.opposite == '') {
  242. var _opposite = '请上传身份证反面页'
  243. Tips(_opposite)
  244. } else {
  245. let income_url = 'my/authentication/ididentity';
  246. let income_data = {
  247. name: this.data.name, //姓名
  248. number: this.data.number, //证件号码
  249. hold: this.data.hold, //手持身份证
  250. positive: this.data.positive, //身份证正面
  251. opposite: this.data.opposite, //身份证反面
  252. };
  253. app.postRequest(income_url, income_data, function (res) {
  254. console.log(res)
  255. if (res.code == 201) {
  256. wx.showToast({
  257. title: '提交成功',
  258. icon: 'success',
  259. duration: 2000
  260. })
  261. _this.onLoad();
  262. return
  263. }
  264. // console.log(res.data.name)
  265. // console.log(res.data.number)
  266. if (res.data.name){
  267. _this.setData({
  268. text1: res.data.name,
  269. isShow: true,
  270. });
  271. }
  272. if (res.data.number) {
  273. _this.setData({
  274. text2: res.data.number,
  275. isShow: true,
  276. });
  277. }
  278. setTimeout(function () {
  279. _this.setData({
  280. text1: '',
  281. text2: '',
  282. isShow: false,
  283. });
  284. }, 2000)
  285. })
  286. }
  287. },
  288. })
  289. // 提示框
  290. function Tips(text) {
  291. wx.showToast({
  292. title: text,
  293. icon: 'none', // 不显示图标
  294. duration: 2500
  295. })
  296. }