Auth.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <member-base :show="false"><view class="div member-auth">
  3. <view class="div common-header-wrap">
  4. <view :style="'height:'+navHeight+'px'"></view>
  5. <view class="common-header-holder"></view>
  6. <view class="common-header-fixed">
  7. <title-header />
  8. <uni-nav-bar title="实名认证" class="common-header" left-icon="back" @clickLeft="goBack()">
  9. </uni-nav-bar>
  10. </view>
  11. </view>
  12. <view class="div form main-content">
  13. <view class="div form-wrapper">
  14. <flex-line v-if="user.member_auth_state!=1 && user.member_auth_state!=3" class="field-line menu-item" :show-border="true"><text class="span field-name">真实姓名:</text><view class="div field-line-right" slot="right"><input class="field-input" v-model="realname" /></view></flex-line>
  15. <flex-line v-else :show-border="true"><text class="span line-name">真实姓名:</text><text class="span" slot="right">{{realname}}</text></flex-line>
  16. <flex-line v-if="user.member_auth_state!=1 && user.member_auth_state!=3" class="field-line menu-item" :show-border="true"><text class="span field-name">身份证号:</text><view class="div field-line-right" slot="right"><input class="field-input" v-model="idcard" /></view></flex-line>
  17. <flex-line v-else :show-border="true"><text class="span line-name">身份证号:</text><text class="span" slot="right">{{idcard}}</text></flex-line>
  18. </view>
  19. <view class="div idcard-wrapper pt-10">
  20. <view class="div title">手持身份证照片</view>
  21. <view class="div idcard-item">
  22. <view class="div img">
  23. <view class="div user-avatar">
  24. <uni-file-picker
  25. class="common-avatar"
  26. v-model="imageValue['member_idcard_image1']"
  27. fileMediatype="image"
  28. mode="grid"
  29. :readonly="user.member_auth_state==1 || user.member_auth_state==3"
  30. :limit="1"
  31. :auto-upload="false"
  32. :image-styles="{
  33. width:'200px',
  34. height:'160px',
  35. }"
  36. @select="uploadSelectImg('member_idcard_image1',$event)"
  37. @delete="dropImage('member_idcard_image1')"
  38. >
  39. </uni-file-picker>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="div title">身份证正面照片</view>
  44. <view class="div idcard-item">
  45. <view class="div img">
  46. <view class="div user-avatar">
  47. <uni-file-picker
  48. class="common-avatar"
  49. v-model="imageValue['member_idcard_image2']"
  50. fileMediatype="image"
  51. mode="grid"
  52. :readonly="user.member_auth_state==1 || user.member_auth_state==3"
  53. :limit="1"
  54. :auto-upload="false"
  55. :image-styles="{
  56. width:'200px',
  57. height:'160px',
  58. }"
  59. @select="uploadSelectImg('member_idcard_image2',$event)"
  60. @delete="dropImage('member_idcard_image2',$event)"
  61. >
  62. </uni-file-picker>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="div title">身份证反面照片</view>
  67. <view class="div idcard-item">
  68. <view class="div img">
  69. <view class="div user-avatar">
  70. <uni-file-picker
  71. class="common-avatar"
  72. v-model="imageValue['member_idcard_image3']"
  73. fileMediatype="image"
  74. mode="grid"
  75. :readonly="user.member_auth_state==1 || user.member_auth_state==3"
  76. :limit="1"
  77. :auto-upload="false"
  78. :image-styles="{
  79. width:'200px',
  80. height:'160px',
  81. }"
  82. @select="uploadSelectImg('member_idcard_image3',$event)"
  83. @delete="dropImage('member_idcard_image3' ,$event)"
  84. >
  85. </uni-file-picker>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. <view class="div pb-10 pt-10">
  91. <view class="div common-btn ds-button-large" @click="submitInformation" v-if="user.member_auth_state!=1 && user.member_auth_state!=3">保存</view>
  92. </view>
  93. </view>
  94. <uni-popup background-color="#fff" ref="isshow" class="popup" >
  95. <image mode="aspectFit" class="img" :src="showimage" :style="getBannerStyle" @click="hidePopup('isshow')">
  96. </uni-popup>
  97. <!-- <tui-picture-cropper v-if="cropperOption.imgUrl" :width="cropperOption.autoCropWidth" :height="cropperOption.autoCropHeight" :imageUrl="cropperOption.img" @ready="cropReady" @cropper="useCrop" @back="cropBack"></tui-picture-cropper> -->
  98. </view>
  99. <uni-popup background-color="#fff" ref="confirm" type="dialog">
  100. <uni-popup-dialog :mode="dialog.mode" :title="dialog.title" :content="dialog.content" :placeholder="dialog.content" @confirm="confirmDialog" @close="closeDialog"></uni-popup-dialog>
  101. </uni-popup>
  102. </member-base>
  103. </template>
  104. <script>
  105. import {getFontSize} from '@/util/common'
  106. import TitleHeader from '../../TitleHeader'
  107. import MemberBase from '../MemberBase'
  108. // import tuiPictureCropper from "@/components/thorui/tui-picture-cropper/tui-picture-cropper"
  109. import { mapState, mapMutations } from 'vuex'
  110. import { uploadAuth, dropAuth, updateMemberAuth } from '../../../api/member'
  111. import flexLine from '../../flexLine'
  112. export default {
  113. name:'MemberProfileSet',
  114. data(){
  115. return {
  116. navHeight: 0,
  117. imageValue:{},
  118. dialog:{},
  119. screenWidth:0,
  120. screenHeight:0,
  121. cropperOption: {
  122. img: '',
  123. canMove: false,
  124. autoCrop: true,
  125. autoCropWidth: 100,
  126. autoCropHeight: 100,
  127. maxImgSize: 500,
  128. outputType: 'png'
  129. },
  130. cropType: '',
  131. if_confirm: false,
  132. showimage: '',
  133. realname: '',
  134. idcard: '',
  135. member_ww: ''
  136. }
  137. },
  138. mounted(){
  139. // #ifdef MP-WEIXIN
  140. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  141. // #endif
  142. const res = uni.getSystemInfoSync()
  143. this.screenWidth = res.windowWidth
  144. this.screenHeight = res.windowHeight
  145. },
  146. components:{
  147. TitleHeader,
  148. MemberBase,
  149. flexLine
  150. // tuiPictureCropper
  151. },
  152. computed:{
  153. fontSize(){
  154. return getFontSize()
  155. },
  156. ...mapState({
  157. user: state => state.member.info
  158. }),
  159. getBannerStyle: function () {
  160. var width = this.screenWidth
  161. var height = this.screenHeight
  162. let itemWidth = width
  163. let itemHeight = height
  164. return "max-width:"+itemWidth +"px;max-height:"+itemHeight +"px"
  165. }
  166. },
  167. created: function () {
  168. if (this.user) {
  169. this.realname = this.user.member_truename
  170. this.idcard = this.user.member_idcard
  171. if(this.user.member_idcard_image1_url){
  172. this.imageValue['member_idcard_image1']=[{
  173. name:'member_idcard_image1',
  174. extname:'jpg',
  175. url:this.user.member_idcard_image1_url
  176. }]
  177. }
  178. if(this.user.member_idcard_image2_url){
  179. this.imageValue['member_idcard_image2']=[{
  180. name:'member_idcard_image2',
  181. extname:'jpg',
  182. url:this.user.member_idcard_image2_url
  183. }]
  184. }
  185. if(this.user.member_idcard_image3_url){
  186. this.imageValue['member_idcard_image3']=[{
  187. name:'member_idcard_image3',
  188. extname:'jpg',
  189. url:this.user.member_idcard_image3_url
  190. }]
  191. }
  192. }
  193. },
  194. methods:{
  195. closeDialog(){
  196. },
  197. confirmDialog(value){
  198. switch(this.dialog.condition){
  199. case 1:
  200. this.confirmSumit()
  201. break
  202. case 2:
  203. dropAuth(this.dialog.data).then(res => {
  204. this.user[this.dialog.data + '_url'] = ''
  205. var temp = {}
  206. temp[this.dialog.data + '_url'] = ''
  207. this.memberEdit(temp)
  208. }).catch(function (error) {
  209. uni.showToast({icon:'none',title: error.message})
  210. })
  211. break
  212. }
  213. },
  214. showPopup(id){
  215. this.$refs[id].open()
  216. },
  217. hidePopup(id){
  218. this.$refs[id].close()
  219. },
  220. goBack(){uni.navigateBack({delta:1})},
  221. ...mapMutations({
  222. memberEdit: 'memberEdit',
  223. memberUpdate: 'memberUpdate',
  224. }),
  225. submitInformation () {
  226. // if (!this.if_confirm) {
  227. // this.confirmSumit()
  228. // return
  229. // }
  230. const that = this
  231. uni.showModal({
  232. title: '提示',
  233. content: '请仔细核对信息,确认上传后除非管理员审核否则无法再次上传',
  234. success: function (res) {
  235. if (res.confirm) {
  236. that.confirmSumit()
  237. } else if (res.cancel) {
  238. console.log('用户点击取消');
  239. }
  240. }
  241. });
  242. // this.dialog={condition:1,content:'请仔细核对信息,确认上传后除非管理员审核否则无法再次上传'}
  243. // this.$refs.confirm.open()
  244. },
  245. confirmSumit () {
  246. updateMemberAuth(this.realname, this.idcard, true).then(res => {
  247. this.memberEdit({ member_truename: this.realname, member_idcard: this.idcard, member_auth_state: 1 })
  248. uni.showToast({icon:'none',title: res.message})
  249. }).catch(function (error) {
  250. uni.showToast({icon:'none',title: error.message})
  251. })
  252. },
  253. openImage (src) {
  254. this.showimage = src
  255. this.showPopup('isshow')
  256. },
  257. dropImage (id ,e) {
  258. // this.dialog={condition:1,content:'请仔细核对信息,确认上传后除非管理员审核否则无法再次上传'}
  259. // this.$refs.confirm.open()
  260. // this.dialog={condition:2, content:'确定要删除该图片吗?', data:id}
  261. dropAuth(id).then(res => {
  262. this.user[this.dialog.data + '_url'] = ''
  263. var temp = {}
  264. temp[id + '_url'] = ''
  265. this.memberEdit(temp)
  266. }).catch(function (error) {
  267. uni.showToast({icon:'none',title: error.message})
  268. })
  269. },
  270. // useCrop (res) {
  271. // let index = this.cropType
  272. // var formdata={
  273. // filePath:res.url,
  274. // name:index,
  275. // id:index
  276. // }
  277. // uploadAuth(formdata).then(res => {
  278. // this.user[index + '_url'] = res.result.file_path
  279. // this.imageValue[index]=[{
  280. // name:index,
  281. // extname:'jpg',
  282. // url:res.result.file_path
  283. // }]
  284. // var temp = {}
  285. // temp[index + '_url'] = res.result.file_path
  286. // this.memberEdit(temp)
  287. // this.cropperOption.imgUrl=''
  288. // this.$forceUpdate()
  289. // uni.hideLoading()
  290. // }).catch(function (error) {
  291. // uni.showToast({icon:'none',title: error.message})
  292. // uni.hideLoading()
  293. // this.cropperOption.imgUrl=''
  294. // this.$forceUpdate()
  295. // })
  296. // },
  297. // cropReady(){
  298. // this.cropperOption.img = this.cropperOption.imgUrl
  299. // },
  300. // cropBack(){
  301. // console.log('this.cropperOptio' , this.cropperOption)
  302. // this.cropperOption.imgUrl=''
  303. // this.$forceUpdate()
  304. // },
  305. // 直接上传
  306. uploadSelectImg(index, event){
  307. const file = event.tempFiles[0]
  308. const formdata = {
  309. filePath:file.path,
  310. name:index,
  311. id:index
  312. }
  313. uploadAuth(formdata).then(res => {
  314. this.user[index + '_url'] = res.result.file_path
  315. this.imageValue[index]=[{
  316. name:index,
  317. extname:'jpg',
  318. url:res.result.file_path
  319. }]
  320. var temp = {}
  321. temp[index + '_url'] = res.result.file_path
  322. this.memberEdit(temp)
  323. this.cropperOption.imgUrl=''
  324. this.$forceUpdate()
  325. uni.hideLoading()
  326. }).catch(function (error) {
  327. uni.showToast({icon:'none',title: error.message})
  328. uni.hideLoading()
  329. this.cropperOption.imgUrl=''
  330. this.$forceUpdate()
  331. })
  332. },
  333. // uploadInformPic (index, event) {
  334. // let that = this
  335. // this.cropType = index
  336. // if(index === 'member_idcard_image1'){ // 直接上传
  337. // this.uploadSelectImg(index, event)
  338. // }else{
  339. // let file = event.tempFiles[0]
  340. // that.cropperOption.imgUrl = file.path
  341. // that.cropperOption.autoCropWidth = uni.getSystemInfoSync().windowWidth
  342. // that.cropperOption.autoCropHeight = uni.getSystemInfoSync().windowWidth
  343. // that.cropperOption.maxImgSize = uni.getSystemInfoSync().windowHeight - 40
  344. // that.$forceUpdate()
  345. // }
  346. // }
  347. }
  348. }
  349. </script>
  350. <style lang="scss" scoped>
  351. .common-header{
  352. .btn{background: #000;color: #fff;box-shadow: 0px 2px 4px #d2d2d2;}
  353. }
  354. .ds-button-large{margin:0 $pageSpace}
  355. .member-auth {
  356. background: #fff;
  357. .main-content{padding: 0 $pageSpace;box-sizing: border-box;}
  358. .form{
  359. .form-wrapper{
  360. position: relative;
  361. box-shadow: 0px 4px 4px #f7f7f7;
  362. z-index: 2;
  363. }
  364. .title{
  365. font-size:$subFontSize;
  366. font-weight: 700;
  367. }
  368. }
  369. .idcard-wrapper{
  370. .idcard-item{
  371. background: #fff;
  372. padding: 1rem 0;
  373. .del-btn{
  374. position: absolute;
  375. font-size: 1.5rem;
  376. top: -.75rem;
  377. right: -.75rem;
  378. }
  379. }
  380. }
  381. }
  382. </style>
  383. <style lang="scss">
  384. .member-auth .mint-cell-title{flex:unset;width:7rem}
  385. .member-auth .mint-cell-value{flex:1}
  386. </style>