Realname.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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.save_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. }
  123. });
  124. }
  125. })
  126. },
  127. // 正面页
  128. sfztxyclick: function (e) {
  129. var _this = this;
  130. wx.chooseImage({
  131. count: 1,
  132. sizeType: ['original', 'compressed'],
  133. sourceType: ['album', 'camera'],
  134. success(res) {
  135. let tempFilesSize = res.tempFiles[0].size;
  136. if (tempFilesSize > 1024 * 1024 * 3) {
  137. wx.showModal({
  138. title: '提示',
  139. content: '图片不得超过3MB',
  140. showCancel: false,
  141. })
  142. return;
  143. }
  144. wx.showToast({
  145. title: '上传中...',
  146. icon: 'loading'
  147. });
  148. // 头部信息
  149. let dt_url = 'my/images/tempimages';
  150. let dt_filePath = res.tempFilePaths[0];
  151. app.Multigraph(dt_url, dt_filePath, function (res) {
  152. if (res.code == 201) {
  153. // console.log(res.data.img_name);
  154. _this.setData({
  155. sfztxyImages: dt_filePath,
  156. sfztxyImagesNum: true,
  157. sfztxyimg: false,
  158. positive: res.data.img_name,
  159. });
  160. wx.showToast({
  161. title: '上传成功',
  162. icon: 'none', // 不显示图标
  163. duration: 2000
  164. })
  165. }
  166. });
  167. }
  168. })
  169. },
  170. // 反面页
  171. sfzfmclick: function (e) {
  172. var _this = this;
  173. wx.chooseImage({
  174. count: 1,
  175. sizeType: ['original', 'compressed'],
  176. sourceType: ['album', 'camera'],
  177. success(res) {
  178. // console.log(res.tempFilePaths[0]);
  179. // tempFilePath可以作为img标签的src属性显示图片
  180. let tempFilesSize = res.tempFiles[0].size;
  181. if (tempFilesSize > 1024 * 1024 * 3) {
  182. wx.showModal({
  183. title: '提示',
  184. content: '图片不得超过3MB',
  185. showCancel: false,
  186. })
  187. return;
  188. }
  189. wx.showToast({
  190. title: '上传中...',
  191. icon: 'loading'
  192. });
  193. // 头部信息
  194. let dt_url = 'my/images/tempimages';
  195. let dt_filePath = res.tempFilePaths[0];
  196. app.Multigraph(dt_url, dt_filePath, function (res) {
  197. if (res.code == 201) {
  198. // console.log(res.data.img_name);
  199. _this.setData({
  200. sfzfmImages:dt_filePath,
  201. sfzfmImagesNum: true,
  202. sfzfmimg: false,
  203. opposite:res.data.img_name,
  204. });
  205. wx.showToast({
  206. title: '上传成功',
  207. icon: 'none', // 不显示图标
  208. duration: 2000
  209. })
  210. }
  211. });
  212. }
  213. })
  214. },
  215. //最后提交认证
  216. Submission: function (e) {
  217. var _this =this;
  218. console.log(this.data.name)
  219. console.log(this.data.number)
  220. console.log(this.data.hold)
  221. console.log(this.data.positive)
  222. console.log(this.data.opposite)
  223. if (this.data.name == '') {
  224. var _name = '请填写您的真实姓名'
  225. Tips(_name)
  226. } else if (this.data.number == '') {
  227. var _number = '请填写本人身份证号码'
  228. Tips(_number)
  229. } else if (this.data.hold == '') {
  230. var _hold = '请上传手持身份证'
  231. Tips(_hold)
  232. } else if (this.data.positive == '') {
  233. var _positive = '请上传身份证头像页'
  234. Tips(_positive)
  235. } else if (this.data.opposite == '') {
  236. var _opposite = '请上传身份证反面页'
  237. Tips(_opposite)
  238. } else {
  239. let income_url = 'my/authentication/ididentity';
  240. let income_data = {
  241. name: this.data.name, //姓名
  242. number: this.data.number, //证件号码
  243. hold: this.data.hold, //手持身份证
  244. positive: this.data.positive, //身份证正面
  245. opposite: this.data.opposite, //身份证反面
  246. };
  247. app.postRequest(income_url, income_data, function (res) {
  248. console.log(res)
  249. if (res.code == 201) {
  250. wx.showToast({
  251. title: '提交成功',
  252. icon: 'success',
  253. duration: 2000
  254. })
  255. _this.onLoad();
  256. return
  257. }
  258. // console.log(res.data.name)
  259. // console.log(res.data.number)
  260. if (res.data.name){
  261. _this.setData({
  262. text1: res.data.name,
  263. isShow: true,
  264. });
  265. }
  266. if (res.data.number) {
  267. _this.setData({
  268. text2: res.data.number,
  269. isShow: true,
  270. });
  271. }
  272. setTimeout(function () {
  273. _this.setData({
  274. text1: '',
  275. text2: '',
  276. isShow: false,
  277. });
  278. }, 2000)
  279. })
  280. }
  281. },
  282. })
  283. // 提示框
  284. function Tips(text) {
  285. wx.showToast({
  286. title: text,
  287. icon: 'none', // 不显示图标
  288. duration: 2500
  289. })
  290. }