identify.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <app-layout :overflow='false'>
  3. <view class="identify">
  4. <!-- 输入信息 -->
  5. <view class="info">
  6. <text class="title">身份信息</text>
  7. <view class="input-grow first">
  8. <text class="input-label">您的姓名</text>
  9. <input class="input" placeholder="请输入您的姓名" v-model="card_name"></input>
  10. </view>
  11. <view class="input-grow">
  12. <text class="input-label">证件号码</text>
  13. <input class="input" placeholder="请输入证件号码" v-model="idcard"></input>
  14. </view>
  15. </view>
  16. <!-- 身份证图片 -->
  17. <view class="info picture">
  18. <text class="title">证件照片</text>
  19. <!-- 正面 -->
  20. <view class="picture-grow first">
  21. <view class="picture-box" @click="loadPicture(0)">
  22. <image v-if="!front_url" class="picture-img" src="/static/image/idcard_front.png" mode=""></image>
  23. <image v-if="front_url" class="picture-img" :src="front_url" mode=""></image>
  24. </view>
  25. <text class="tips">{{front_url ? '点击重新拍摄身份证人像面' : '点击拍摄身份证人像面'}}</text>
  26. </view>
  27. <!-- 反面 -->
  28. <view class="picture-grow first">
  29. <view class="picture-box" @click="loadPicture(1)">
  30. <image v-if="!back_url" class="picture-img" src="/static/image/idcard_back.png" mode=""></image>
  31. <image v-if="back_url" class="picture-img" :src="back_url" mode=""></image>
  32. </view>
  33. <text class="tips">{{back_url ? '点击重新拍摄身份证国徽像' : '点击拍摄身份证国徽面'}}</text>
  34. </view>
  35. </view>
  36. <!-- 按钮 -->
  37. <view class="btn" :style="{'backgroundColor':getTheme.background}" @click="doAuth">
  38. <text class="submit">立即认证</text>
  39. </view>
  40. <!-- tips -->
  41. <view class="bottom-tips">
  42. <text class="txt">*依据中华人民共和国法律规定,为保证电子合同的合法有效性,请您配合上传您的有效二代身份证正反面照片,并保证图片文字清晰,无反光、无遮挡。</text>
  43. </view>
  44. </view>
  45. </app-layout>
  46. </template>
  47. <script>
  48. import { mapState, mapGetters } from 'vuex';
  49. export default {
  50. data() {
  51. return {
  52. card_name: '',
  53. idcard: '',
  54. front_url: '',
  55. back_url: ''
  56. }
  57. },
  58. methods: {
  59. // 选择照片
  60. loadPicture(type) {
  61. const _this = this
  62. uni.chooseImage({
  63. count: 1,
  64. sizeType: ['original', 'compressed'],
  65. success: function (file) {
  66. console.log(file)
  67. uni.uploadFile({
  68. url: _this.$api.upload.file,
  69. filePath: file.tempFilePaths[0],
  70. name: 'file',
  71. formData: { file },
  72. success: (res) => {
  73. const data = JSON.parse(res.data)
  74. if (data.code === 0) {
  75. uni.showToast({
  76. icon: 'success',
  77. title: '上传成功',
  78. duration: 1000
  79. });
  80. if (type === 0) {
  81. _this.front_url = data.data.url
  82. } else if (type === 1) {
  83. _this.back_url = data.data.url
  84. }
  85. }
  86. },
  87. fail: () => {
  88. console.log('上传失败')
  89. }
  90. });
  91. },
  92. fail: function (err) {
  93. console.log(err)
  94. }
  95. });
  96. },
  97. doAuth () {
  98. // 是否输入,是否上传了照片
  99. if (!this.card_name || !this.idcard) {
  100. uni.showToast({
  101. icon: 'error',
  102. title: '请检查输入内容',
  103. duration: 1000
  104. });
  105. return
  106. } else if(!this.front_url || !this.back_url) {
  107. uni.showToast({
  108. icon: 'error',
  109. title: '请上传照片',
  110. duration: 1000
  111. });
  112. return
  113. }
  114. const data = {
  115. card_name: this.card_name,
  116. idcard: this.idcard,
  117. card_front_url: this.front_url,
  118. card_back_url: this.back_url
  119. }
  120. // 发送认证请求
  121. this.$showLoading({ text: '正在认证,请稍后' })
  122. const res = this.$request({
  123. url: this.$api.user.doAuth,
  124. method: 'post',
  125. data: data,
  126. }).then(res => {
  127. // 状态 1,验证不通过
  128. if (res.code === 1) {
  129. uni.showModal({
  130. title: '提示:验证未通过',
  131. content: res.msg,
  132. showCancel: false,
  133. success: function (res) {
  134. }
  135. })
  136. return
  137. }
  138. // 通过的操作:返回结算页面
  139. uni.showModal({
  140. title: '提示:验证通过',
  141. content: "点击确定立即返回结算页面",
  142. showCancel: false,
  143. success: function (res) {
  144. if (res.confirm) {
  145. uni.navigateBack({ delta: 1 })
  146. }
  147. }
  148. })
  149. }).catch(err => {
  150. console.log(err)
  151. }).finally(() => {
  152. this.$hideLoading()
  153. });
  154. }
  155. },
  156. computed:{
  157. ...mapState({
  158. tabBarHeight: (state) => {
  159. return state.gConfig.tabBarHeight;
  160. },
  161. iphoneHeight: (state) =>{
  162. return state.gConfig.iphoneHeight;
  163. },
  164. iphone: (state) => {
  165. return state.gConfig.iphone
  166. }
  167. }),
  168. ...mapGetters('iPhoneX', {
  169. BotHeight: 'getBotHeight',
  170. getEmpty: 'getEmpty',
  171. }),
  172. ...mapGetters('mallConfig', {
  173. getTheme: 'getTheme',
  174. }),
  175. ...mapGetters({
  176. userInfo: 'user/info',
  177. })
  178. },
  179. }
  180. </script>
  181. <style lang="scss" scoped>
  182. .identify {
  183. display: flex;
  184. flex-direction: column;
  185. align-items: center;
  186. .info {
  187. box-sizing: border-box;
  188. width: 100%;
  189. margin-top: 30rpx;
  190. padding: 20rpx 24rpx 10rpx;
  191. background-color: white;
  192. .title {
  193. font-size: 28rpx;
  194. font-weight: bold;
  195. }
  196. .input-grow {
  197. display: flex;
  198. align-items: center;
  199. padding: 10rpx 0;
  200. .input-label {
  201. font-size: 26rpx;
  202. line-height: 26rpx;
  203. }
  204. .input {
  205. flex: 1;
  206. height: 48rpx;
  207. margin-left: 20rpx;
  208. font-size: 26rpx;
  209. }
  210. &.first {
  211. margin-top: 16rpx;
  212. border-bottom: 1px solid #f6f5f7;
  213. }
  214. }
  215. }
  216. .picture {
  217. padding-bottom: 30rpx;
  218. .picture-grow {
  219. display: flex;
  220. flex-direction: column;
  221. align-items: center;
  222. .picture-box {
  223. width: 580rpx;
  224. height: 320rpx;
  225. background-color: transparent;
  226. border-radius: 20rpx;
  227. overflow: hidden;
  228. box-shadow: 0 0 20rpx #dddddd;
  229. .picture-img {
  230. width: 100%;
  231. height: 100%;
  232. }
  233. }
  234. .tips {
  235. font-size: 26rpx;
  236. margin-top: 10rpx;
  237. }
  238. &.first {
  239. margin-top: 30rpx;
  240. }
  241. }
  242. }
  243. .btn {
  244. position: fixed;
  245. bottom: 0;
  246. width: 100%;
  247. height: 80rpx;
  248. background-color: skyblue;
  249. text-align: center;
  250. .submit {
  251. width: 100%;
  252. height: 100%;
  253. margin-top: 30rpx;
  254. font-size: 30rpx;
  255. border-radius: 0;
  256. color: white;
  257. line-height: 80rpx;
  258. }
  259. }
  260. .bottom-tips {
  261. padding: 0 24rpx;
  262. margin-top: 40rpx;
  263. margin-bottom: 120rpx;
  264. .txt {
  265. font-size: 20rpx;
  266. color: #C2C2C2;
  267. line-height: 22rpx;
  268. }
  269. }
  270. }
  271. </style>