myauth.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <view>
  3. <form v-if="userinfo.authstatus==1">
  4. <view class="bg-white padding-tb grid margin-bottom text-center col-2">
  5. <view class="bg-white">
  6. <avatar selWidth="660rpx" selHeight="440rpx" @upload="setIdcardZpic" :avatarSrc="userinfo.idcardzpic ? userinfo.idcardzpic : $getImageUrl('static/images/applet/idcardzpic.png')" noTab="true" avatarStyle="width: 330rpx; height: 220rpx; border-radius: 0rpx;"></avatar>
  7. <view class="text-sm text-grey padding-top-sm"> 上传身份证(头像页) </view>
  8. </view>
  9. <view class="bg-white">
  10. <avatar selWidth="660rpx" selHeight="440rpx" @upload="setIdcardFpic" :avatarSrc="userinfo.idcardfpic ? userinfo.idcardfpic : $getImageUrl('static/images/applet/idcardfpic.png')" noTab="true" avatarStyle="width: 330rpx; height: 220rpx; border-radius: 0rpx;"></avatar>
  11. <view class="text-sm text-grey padding-top-sm"> 上传身份证(国徽页) </view>
  12. </view>
  13. </view>
  14. <ocr-navigator @onSuccess="idCardSuccess" certificateType="idCard" :opposite="false">
  15. <button type="primary">点击识别身份证</button>
  16. </ocr-navigator>
  17. <view class="cu-list menu margin-top-sm">
  18. <view class="cu-item arrow" data-title="姓名" data-infobox="input" data-field="nickname" :data-value="userinfo.nickname" @click="showModal">
  19. <!-- <view class="cu-item"> -->
  20. <view class="content">
  21. <text>姓名</text>
  22. </view>
  23. <view class="action">
  24. <text class="text-grey">{{userinfo.nickname}}</text>
  25. </view>
  26. </view>
  27. <view class="cu-item arrow" data-title="身份证号" data-infobox="input" data-field="idcard" :data-value="userinfo.idcard" @click="showModal">
  28. <!-- <view class="cu-item"> -->
  29. <view class="content">
  30. <text>身份证号</text>
  31. </view>
  32. <view class="action">
  33. <text class="text-grey">{{userinfo.idcard}}</text>
  34. </view>
  35. </view>
  36. <view class="cu-item arrow">
  37. <view class="content">
  38. <text>性别</text>
  39. </view>
  40. <view class="action">
  41. <picker mode="selector" @change="genderChange" :value="userinfo.gender" :range="sex_list" :range-key="index">
  42. <view class="picker padding-tb text-right text-grey" style="width: 280rpx;line-height: 40rpx;">{{userinfo.gender ? sex_list[userinfo.gender - 1] : '请选择'}}</view>
  43. </picker>
  44. <!-- <text class="text-grey">{{userinfo.gender==1 ? '男' : '女'}}</text> -->
  45. </view>
  46. </view>
  47. <view class="cu-item arrow">
  48. <view class="content">
  49. <text>出生日期</text>
  50. </view>
  51. <view class="action">
  52. <picker mode="date" @change="birthdayChange">
  53. <view class="picker padding-tb text-right text-grey" style="width: 280rpx;line-height: 40rpx;">{{userinfo.birthday ? userinfo.birthday : '请选择'}}</view>
  54. </picker>
  55. </view>
  56. </view>
  57. <view v-if="userinfo.authremark" class="padding text-red">{{userinfo.authremark}}</view>
  58. </view>
  59. <view class="padding flex flex-direction">
  60. <button class="cu-btn bg-blue margin-tb-sm lg" @tap="setAuthStatus">提交审核</button>
  61. </view>
  62. </form>
  63. <view v-else>
  64. <view v-if="userinfo.authstatus==2" class="bg-white padding-tb grid text-center col-2 margin-bottom-sm">
  65. <view class="bg-white">
  66. <image mode="aspectFill" style="width: 330rpx; height: 220rpx;" :src="userinfo.idcardzpic"></image>
  67. <view class="text-sm text-grey padding-top-sm"> 身份证(头像页) </view>
  68. </view>
  69. <view class="bg-white">
  70. <image mode="aspectFill" style="width: 330rpx; height: 220rpx;" :src="userinfo.idcardfpic"></image>
  71. <view class="text-sm text-grey padding-top-sm"> 身份证(国徽页) </view>
  72. </view>
  73. </view>
  74. <view class="cu-list menu">
  75. <view class="cu-item">
  76. <view class="content">
  77. <text>姓名</text>
  78. </view>
  79. <view class="action">
  80. <text class="text-grey">{{userinfo.nickname}}</text>
  81. </view>
  82. </view>
  83. <view class="cu-item">
  84. <view class="content">
  85. <text>身份证号</text>
  86. </view>
  87. <view class="action">
  88. <text class="text-grey">{{userinfo.idcard}}</text>
  89. </view>
  90. </view>
  91. <view class="cu-item">
  92. <view class="content">
  93. <text>性别</text>
  94. </view>
  95. <view class="action">
  96. <text class="text-grey">{{userinfo.gender==1 ? '男' : '女'}}</text>
  97. </view>
  98. </view>
  99. <view class="cu-item">
  100. <view class="content">
  101. <text>出生日期</text>
  102. </view>
  103. <view class="action">
  104. <text class="text-grey">{{userinfo.birthday}}</text>
  105. </view>
  106. </view>
  107. <view v-if="userinfo.authstatus==2" class="padding text-red">实名认证信息已提交审核,请耐心等待。</view>
  108. <view v-if="userinfo.authstatus==3" class="padding text-green">实名认证信息已通过审核。</view>
  109. </view>
  110. </view>
  111. <view class="cu-modal" :class="forminfo.isshow">
  112. <view class="cu-dialog">
  113. <view class="cu-bar bg-white justify-end">
  114. <view class="content">输入 {{forminfo.title}}</view>
  115. <view class="action" @tap="hideModal">
  116. <text class="cuIcon-close text-grey"></text>
  117. </view>
  118. </view>
  119. <view class="padding-xl bg-white text-left solid-top solid-bottom">
  120. <input :placeholder="'请输入'+forminfo.title+'...'" @input="bindInput" :value="forminfo.value"></input>
  121. </view>
  122. <view class="cu-bar bg-white justify-end">
  123. <view class="action">
  124. <button class="cu-btn line-grey text-grey" @tap="hideModal">取消</button>
  125. <button class="cu-btn bg-green margin-left" @tap="subModal">确定</button>
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. <view class="padding"></view>
  131. </view>
  132. </template>
  133. <script>
  134. var _this;
  135. import avatar from "@/components/yq-avatar/yq-avatar.vue";
  136. export default {
  137. components: {
  138. avatar
  139. },
  140. data() {
  141. return {
  142. userinfo: {},
  143. forminfo: {
  144. isshow: "",
  145. title: "",
  146. field: "",
  147. value: ""
  148. },
  149. sex_list: ['男','女'],
  150. }
  151. },
  152. onLoad: function() {
  153. _this = this;
  154. _this.userinfo = _this.checkLogin("/pages/my/myinfo");
  155. },
  156. methods: {
  157. idCardSuccess: function(e) {
  158. console.log(e);
  159. var card_info = {};
  160. if (e.detail) {
  161. card_info = e.detail;
  162. } else {
  163. card_info = e.result;
  164. }
  165. console.log(card_info);
  166. var info = {
  167. nickname: card_info.name.text,
  168. idcard: card_info.id.text,
  169. gender: card_info.gender.text == '男' ? 1 : 2,
  170. birthday: card_info.birth.text
  171. };
  172. _this.$req.ajax({
  173. path: "my/editIdCard",
  174. data: {
  175. userid: _this.userinfo.id,
  176. data: info
  177. }
  178. }).then((data) => {
  179. _this.userinfo = data;
  180. uni.setStorageSync('userinfo', data);
  181. }).catch((err) => {
  182. uni.showModal({
  183. title: '信息提示',
  184. content: err,
  185. showCancel: false
  186. });
  187. });
  188. },
  189. // 填写字段
  190. hideModal: function() {
  191. _this.forminfo = {
  192. isshow: "",
  193. title: "",
  194. field: "",
  195. value: ""
  196. };
  197. },
  198. showModal: function(e) {
  199. _this.forminfo.title = e.currentTarget.dataset.title;
  200. _this.forminfo.field = e.currentTarget.dataset.field;
  201. _this.forminfo.value = e.currentTarget.dataset.value;
  202. _this.forminfo.isshow = "show";
  203. },
  204. bindInput: function(e) {
  205. _this.forminfo.value = e.detail.value;
  206. },
  207. subModal: function() {
  208. _this.editFiled( _this.forminfo.field, _this.forminfo.value );
  209. },
  210. // 上传身份证
  211. setIdcardZpic: function(rsp) {
  212. _this.$req.ajaxFile({
  213. path: "attachment/tplfieldimage",
  214. title:'正在上传',
  215. filePath: rsp.path,
  216. fileName:'file',
  217. }).then((filedata) => {
  218. var data = JSON.parse(filedata.data);
  219. _this.editFiled('idcardzpic', data.data.src);
  220. }).catch((err) => {
  221. uni.showModal({
  222. title: '信息提示',
  223. content: err,
  224. showCancel: false
  225. });
  226. });
  227. },
  228. setIdcardFpic: function(rsp) {
  229. _this.$req.ajaxFile({
  230. path: "attachment/tplfieldimage",
  231. title:'正在上传',
  232. filePath: rsp.path,
  233. fileName:'file',
  234. }).then((filedata) => {
  235. var data = JSON.parse(filedata.data);
  236. _this.editFiled('idcardfpic', data.data.src);
  237. }).catch((err) => {
  238. uni.showModal({
  239. title: '信息提示',
  240. content: err,
  241. showCancel: false
  242. });
  243. });
  244. },
  245. // 更新用户字段
  246. editFiled: function (field, value) {
  247. _this.$req.ajax({
  248. path: "my/edituserinfo",
  249. data: {
  250. userid: _this.userinfo.id,
  251. field: field,
  252. value: value
  253. }
  254. }).then((data) => {
  255. _this.userinfo = data;
  256. uni.setStorageSync('userinfo', data);
  257. _this.hideModal();
  258. }).catch((err) => {
  259. uni.showModal({
  260. title: '信息提示',
  261. content: err,
  262. showCancel: false
  263. });
  264. });
  265. },
  266. // 提交审核
  267. setAuthStatus: function () {
  268. _this.$req.ajax({
  269. path: "my/setauthstatus",
  270. data: {
  271. userid: _this.userinfo.id,
  272. }
  273. }).then((data) => {
  274. _this.userinfo = data;
  275. uni.setStorageSync('userinfo', data);
  276. uni.showModal({
  277. title:'提示',
  278. content: '提交成功,请等待审核!',
  279. showCancel: false,
  280. success: (res) => {
  281. uni.navigateBack();
  282. }
  283. });
  284. }).catch((err) => {
  285. uni.showModal({
  286. title: '信息提示',
  287. content: err,
  288. showCancel: false
  289. });
  290. });
  291. },
  292. genderChange: function(e) {
  293. _this.userinfo.gender = e.detail.value - 0 + 1;
  294. _this.editFiled( 'gender', _this.userinfo.gender );
  295. },
  296. birthdayChange: function(e) {
  297. _this.userinfo.birthday = e.detail.value
  298. _this.editFiled( 'birthday', _this.userinfo.birthday );
  299. }
  300. }
  301. }
  302. </script>
  303. <style>
  304. </style>