authentication.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <!-- 会员实名认证 -->
  2. <template>
  3. <view class="loading_text" v-if="loading">加载中...</view>
  4. <view v-else style="padding-bottom: 100upx;" class="main_width">
  5. <view style="">
  6. <view class="mem_text">
  7. *认证通过后不可修改,请谨慎操作
  8. </view>
  9. <view class="img_box">
  10. <view style="padding: 30upx 0;margin-top: 30upx;" class="img_box_in">
  11. <view style="margin-bottom: 30upx;" v-if="allow_edit==1">
  12. <image @click="upload_img_cards('idcard')" style="width: 100upx;height: 100upx;"
  13. :src="serverUrlImg4">
  14. </image>
  15. <view style="color: #DBB78B;margin-top: 10upx;">请上传身份证人像面</view>
  16. </view>
  17. <view @click="change_show_ipt" v-if="!show_ipt"
  18. style="color: #01c6b5;display: flex;align-items: center;margin-top: 0upx;margin-bottom: 30upx;">
  19. <image style="width: 35upx;height: 20upx;margin-right: 20upx;" :src="serverUrlImg6"></image>
  20. 没带身份证?切换至手动输入
  21. </view>
  22. <view style="width: 100%;" v-else>
  23. <input style="" :disabled="allow_edit==0" class="auth_ipt" v-model="sub_data.true_name"
  24. @input="ipt_name" placeholder="身份证姓名" />
  25. <input style="margin-top: 15upx;" :disabled="allow_edit==0" class="auth_ipt"
  26. v-model="sub_data.idcard" @input="ipt_num" placeholder="身份证号" />
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <!-- 只在编辑状态显示 -->
  32. <view v-if="allow_edit==1">
  33. <view class="read main_width2">
  34. <checkbox-group @change="checkboxChange">
  35. <checkbox color="#48ccae" value="1" />
  36. </checkbox-group>
  37. <view style="margin-left: 10upx;">我们将严格按照<navigator url="../login/web?index=6"
  38. style="color: rgb(0, 199, 178);display: inline-block;">《用户协议》</navigator>和<navigator
  39. url="../login/web?index=7" style="color: rgb(0, 199, 178);display: inline-block;">《隐私政策》
  40. </navigator>
  41. <view>
  42. 保障您的信息安全
  43. </view>
  44. </view>
  45. </view>
  46. <view @click="sub" style="margin-top: 60upx;" class="main_btn_m">确定</view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import commonData from '../../commonData.js'
  52. import commonFun from '../../commonFun.js'
  53. export default {
  54. data() {
  55. return {
  56. serverUrlImg4: this.serverUrl + 'show/camera.png',
  57. allow_edit: 0, //是否允许编辑
  58. is_agree: [], //是否同意协议
  59. sub_data: {}, //提交信息
  60. type: 0, //认证类型:0-个人商家;1-企业商家
  61. loading: true,
  62. show_ipt:false,//是否显示身份证号输入框
  63. }
  64. },
  65. onLoad(e) {
  66. this.get_info()
  67. },
  68. onPullDownRefresh() {
  69. this.get_info()
  70. },
  71. methods: {
  72. change_show_ipt() {
  73. this.show_ipt = true
  74. },
  75. // 获取个人信息
  76. get_info() {
  77. this.loading = true
  78. uni.showLoading({
  79. title: '加载中...',
  80. mask: true,
  81. })
  82. commonFun.get_user_info(res => {
  83. let title = '' //设置当前页面标题
  84. if (res.status) {
  85. uni.hideLoading()
  86. this.sub_data = res.data.Result
  87. this.type = this.sub_data.catalog || 0
  88. if (!this.sub_data.idcard) {
  89. title = '未认证'
  90. this.allow_edit = 1
  91. } else {
  92. title = '已认证'
  93. this.show_ipt = true
  94. console.log(res.data.Result)
  95. this.sub_data = commonFun.formate_name_card_mem(res.data.Result)
  96. }
  97. uni.setNavigationBarTitle({
  98. title
  99. })
  100. console.log('实名认证页面获取个人信息')
  101. console.log(this.sub_data)
  102. }
  103. uni.stopPullDownRefresh()
  104. this.loading = false
  105. })
  106. },
  107. // 选中同意协议
  108. checkboxChange(e) {
  109. this.is_agree = e.detail.value
  110. },
  111. // 输入姓名
  112. ipt_name(e) {
  113. let sub_data = {
  114. ...this.sub_data
  115. }
  116. sub_data['true_name'] = e.target.value
  117. this.sub_data = sub_data
  118. },
  119. // 输入身份证号
  120. ipt_num(e) {
  121. let sub_data = {
  122. ...this.sub_data
  123. }
  124. sub_data['idcard'] = e.target.value
  125. this.sub_data = sub_data
  126. },
  127. // 上传身份证人像面或营业执照
  128. upload_img_cards(type) {
  129. let is_idcard = type == 'idcard'
  130. if (!this.allow_edit) {
  131. return
  132. }
  133. commonFun.uploadFileApiOSS(res => {
  134. if (res.status) {
  135. uni.showLoading({
  136. title: '加载中...',
  137. mask: true
  138. })
  139. let ImageUrl = res.data
  140. let params = {
  141. ocrParams: {
  142. ImageUrl,
  143. CardSide: 'FRONT'
  144. },
  145. bizCatalog: 'TXCLOUD_OCR',
  146. handleMode: is_idcard ? 'IDCardOCR' : 'BizLicenseOCR',
  147. }
  148. // console.log('上传身份证人像面或营业执照请求参数')
  149. // console.log(params)
  150. commonFun.requestUrl('&WsAjaxBiz=Trader&WsAjaxAction=entityDataHandle', params, res => {
  151. // console.log('上传身份证人像面或营业执照返回数据')
  152. // console.log(res)
  153. if (res.status) {
  154. uni.hideLoading()
  155. let sub_data = {
  156. ...this.sub_data
  157. }
  158. if (is_idcard) {
  159. sub_data.idcard_npic = ImageUrl
  160. sub_data.true_name = res.data.Result.Name
  161. sub_data.idcard = res.data.Result.IdNum
  162. }
  163. this.sub_data = sub_data
  164. this.show_ipt = true
  165. }
  166. })
  167. }
  168. }, 'image', false)
  169. },
  170. // 点击确定提交
  171. sub() {
  172. if (this.is_agree.length == 0) {
  173. uni.showModal({
  174. content: '请勾选隐私政策',
  175. showCancel: false,
  176. success: function(res) {}
  177. });
  178. return
  179. }
  180. let sub_data = {
  181. ...this.sub_data
  182. }
  183. console.log('实名认证提交的数据')
  184. console.log(sub_data)
  185. if (!sub_data.true_name || !sub_data.idcard) {
  186. uni.showModal({
  187. title: '请上传身份证人像面,或手输姓名和身份证号!',
  188. showCancel: false
  189. })
  190. return
  191. }
  192. uni.showModal({
  193. content: '确认提交后不可修改,请谨慎操作',
  194. success: (res) => {
  195. if (res.confirm) {
  196. uni.showLoading({
  197. title: '加载中...',
  198. mask: true
  199. })
  200. // 校验身份证号和姓名的真实性
  201. commonFun.requestUrl('&WsAjaxBiz=Worker&WsAjaxAction=entityDataHandle', {
  202. bizCatalog: 'WorkerEntity',
  203. handleMode: 'idCardCheck',
  204. trueName: sub_data.true_name,
  205. idCard: sub_data.idcard,
  206. },
  207. res => {
  208. if (res.status) {
  209. let params = {
  210. ...sub_data,
  211. catalog: this.is_upgrade ? 0 : this.type,
  212. biz_catalog: 0,
  213. }
  214. console.log('实名认证提交请求')
  215. console.log(params)
  216. commonFun.requestUrl('&WsAjaxBiz=Trader&WsAjaxAction=registerInfo',
  217. params,
  218. res => {
  219. console.log(res)
  220. if (res.status) {
  221. let params = {
  222. ...sub_data,
  223. catalog: this.type,
  224. biz_catalog: 0,
  225. }
  226. console.log('实名认证提交请求')
  227. console.log(params)
  228. commonFun.requestUrl(
  229. '&WsAjaxBiz=Worker&WsAjaxAction=registerInfo',
  230. params,
  231. res => {
  232. console.log(res)
  233. if (res.status) {
  234. uni.hideLoading()
  235. uni.showModal({
  236. content: '提交成功',
  237. showCancel: false,
  238. success: res => {
  239. if (res
  240. .confirm) {
  241. uni.navigateBack({
  242. delta: 1
  243. });
  244. }
  245. }
  246. })
  247. }
  248. })
  249. }
  250. })
  251. }
  252. })
  253. }
  254. }
  255. });
  256. },
  257. }
  258. }
  259. </script>
  260. <style>
  261. .auth_ipt {
  262. background-color: #f5f5f5;
  263. width: 80%;
  264. margin: 0upx auto;
  265. height: 70upx;
  266. }
  267. .mem_text {
  268. margin-top: 15upx;
  269. color: #FF0000;
  270. text-align: center;
  271. }
  272. .main_width2 {
  273. width: 96%;
  274. margin-left: 2%;
  275. }
  276. .read {
  277. color: #8E97AE;
  278. margin-top: 200upx;
  279. font-size: 28upx;
  280. display: flex;
  281. flex-direction: row;
  282. justify-content: center;
  283. align-items: center;
  284. }
  285. .up_img {
  286. width: 100%;
  287. }
  288. .img_box {
  289. width: 643upx;
  290. /* height: 350upx; */
  291. margin: 30upx auto 0;
  292. }
  293. .img_box_in {
  294. width: 100%;
  295. height: 100%;
  296. text-align: center;
  297. align-items: center;
  298. justify-content: center;
  299. display: flex;
  300. flex-direction: column;
  301. border: 2upx dotted #E8E8E8;
  302. border-radius: 10upx;
  303. }
  304. </style>