Cheshourenzheng.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <view>
  3. <customNav :shownav="true" :title="$t('user.cheshourenzh')" tinColor="#006AFF" jiantou="0"></customNav>
  4. <view class="contentColumnC">
  5. <view class="contentColumn grupCont" style="justify-content: flex-start;">
  6. <text>{{$t('user.shenfenzh')}}</text>
  7. <input class="noinputVcode" style="width: 100%;" type="text" :placeholder="$t('user.qingshursfzh')" :value="idNumber" @input="idNumberinput">
  8. </view>
  9. <view class="contentColumn grupCont" @click="selectImg(5)">
  10. <text>{{$t('user.shenfenzh')}} A</text>
  11. <netImage width="650" height="650" :mysrc="passportPhA" mymode="scaleToFill"></netImage>
  12. </view>
  13. <view class="contentColumn grupCont" @click="selectImg(55)">
  14. <text>{{$t('user.shenfenzh')}} B</text>
  15. <netImage width="650" height="650" :mysrc="passportPhB" mymode="scaleToFill"></netImage>
  16. </view>
  17. <view class="contentInRowL grupCont">
  18. <text>{{$t('user.chepaihao')}}</text>
  19. <input class="noinputVcode" type="text" :value="licensePlate" :placeholder="$t('user.qsrchepaihao')" @input="chepaihao">
  20. </view>
  21. <view class="contentColumn grupCont" @click="selectImg(1)">
  22. <text>{{$t('user.jiashizhe')}}</text>
  23. <netImage width="650" height="650" :mysrc="driversLicense" mymode="scaleToFill"></netImage>
  24. </view>
  25. <view class="contentColumn grupCont" @click="selectImg(11)">
  26. <text>{{$t('user.shifajlzm')}}</text>
  27. <netImage width="650" height="650" :mysrc="shifajlzm" mymode="scaleToFill"></netImage>
  28. </view>
  29. <view class="contentColumn grupCont" @click="selectImg(2)">
  30. <text>{{$t('user.xingshizh')}}</text>
  31. <netImage width="650" height="650" :mysrc="drivingLicense" mymode="scaleToFill"></netImage>
  32. </view>
  33. <view class="contentColumn grupCont" @click="selectImg(3)">
  34. <text>{{$t('user.cheliangtp')}}</text>
  35. <netImage width="650" height="650" :mysrc="vehiclePhotos" mymode="scaleToFill"></netImage>
  36. </view>
  37. </view>
  38. <view class="contentColumnC" style="margin-top: 60rpx;">
  39. <text class="tijiaoBT" @click="tijiao">{{$t('index.tijiao')}}</text>
  40. </view>
  41. <view style="height: 80rpx;"></view>
  42. <yhdslCropper ref="yhdslCropper" :quality="1" mode="free" @uploadImg="uploadImg" :scale="scale"></yhdslCropper>
  43. </view>
  44. </template>
  45. <script>
  46. import {
  47. UploadImage
  48. } from '@/pages/api/basic.js';
  49. import {
  50. updataUserMsg,
  51. } from '@/pages/api/login';
  52. import yhdslCropper from '@/components/yhdsl-cropper/yhdsl-cropper.vue';
  53. export default {
  54. components: {
  55. yhdslCropper
  56. },
  57. data() {
  58. return {
  59. userInfo:null,
  60. idNumber:'',
  61. licensePlate:'',
  62. driversLicense:'',
  63. shifajlzm:'',
  64. drivingLicense:'',
  65. vehiclePhotos:'',
  66. passportPhA:'',
  67. passportPhB:'',
  68. scale:1.8,
  69. index:-1
  70. }
  71. },
  72. onLoad() {
  73. this.userInfo = uni.getStorageSync('userInfo');
  74. console.log(this.userInfo)
  75. this.licensePlate=this.userInfo.licensePlate;
  76. var temp=[];
  77. if(this.userInfo.driversLicense){
  78. temp = this.userInfo.driversLicense.split(",");
  79. if(temp.length>0){
  80. this.driversLicense = temp[0];
  81. }
  82. if(temp.length>1){
  83. this.shifajlzm = temp[1];
  84. }
  85. }
  86. if(this.userInfo.drivingLicense){
  87. this.drivingLicense=this.userInfo.drivingLicense;
  88. }
  89. if(this.userInfo.vehiclePhotos){
  90. this.vehiclePhotos=this.userInfo.vehiclePhotos;
  91. }
  92. if(this.userInfo.passportPhoto){
  93. temp = this.userInfo.passportPhoto.split(",");
  94. if(temp.length==2){
  95. this.passportPhA = temp[0];
  96. this.passportPhB = temp[1];
  97. }
  98. }
  99. this.idNumber = this.userInfo.idNumber;
  100. },
  101. methods: {
  102. idNumberinput(e){
  103. this.idNumber = e.detail.value;
  104. },
  105. chepaihao(e){
  106. this.licensePlate = e.detail.value;
  107. },
  108. selectImg(index){
  109. this.index = index;
  110. console.log('userIconkl');
  111. this.selectImage();
  112. },
  113. selectImage(){
  114. var that = this;
  115. uni.chooseImage({
  116. count: 1, // 图片数量
  117. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  118. sourceType: ['album'], //从相册选择或者拍照
  119. success: (res) => {
  120. const tempFilePaths = res.tempFilePaths;
  121. uni.showLoading({
  122. mask:true
  123. })
  124. uni.uploadFile({
  125. url: this.$baseurl+UploadImage, //上传图片api
  126. filePath: tempFilePaths[0],
  127. name: 'file',
  128. header:{
  129. //"Authorization": userinfo.token
  130. },
  131. success: (res) => {
  132. uni.hideLoading();
  133. let group = JSON.parse(res.data);
  134. console.log(group);
  135. if(that.index==1){
  136. that.driversLicense=group.data;
  137. }
  138. if(that.index==2){
  139. that.drivingLicense=group.data;
  140. }
  141. if(that.index==3){
  142. that.vehiclePhotos=group.data;
  143. }
  144. if(that.index==11){
  145. that.shifajlzm=group.data;
  146. }
  147. if(that.index==5){
  148. that.passportPhA=group.data;
  149. }
  150. if(that.index==55){
  151. that.passportPhB=group.data;
  152. }
  153. },
  154. fail() {
  155. uni.hideLoading();
  156. }
  157. });
  158. }
  159. });
  160. },
  161. uploadImg(e) {
  162. console.log('------------uploadImg:',e)
  163. uni.showLoading({
  164. mask:true
  165. })
  166. var that = this;
  167. uni.uploadFile({
  168. url: this.$baseurl+UploadImage, //上传图片api
  169. filePath: e,
  170. name: 'file',
  171. header:{
  172. //"Authorization": userinfo.token
  173. },
  174. success: (res) => {
  175. uni.hideLoading();
  176. let group = JSON.parse(res.data);
  177. console.log(group);
  178. if(that.index==1){
  179. that.driversLicense=group.data;
  180. }
  181. if(that.index==2){
  182. that.drivingLicense=group.data;
  183. }
  184. if(that.index==3){
  185. that.vehiclePhotos=group.data;
  186. }
  187. if(that.index==11){
  188. that.shifajlzm=group.data;
  189. }
  190. if(that.index==5){
  191. that.passportPhA=group.data;
  192. }
  193. if(that.index==55){
  194. that.passportPhB=group.data;
  195. }
  196. },
  197. fail() {
  198. uni.hideLoading();
  199. }
  200. });
  201. },
  202. tijiao(){
  203. var that = this;
  204. uni.showModal({
  205. cancelText: that.$t('index.quxiao'), // 取消按钮的文字
  206. confirmText: that.$t('index.queren'), // 确认按钮的文字
  207. title: that.$t('api.message'),
  208. content: that.$t('index.tijiao')+'?',
  209. success: function (res) {
  210. if (res.confirm) { //这里是点击了确定以后
  211. that.updataUserMsg();
  212. } else { //这里是点击了取消以后
  213. console.log('用户点击取消')
  214. }
  215. }
  216. })
  217. },
  218. updataUserMsg(){
  219. var that = this;
  220. var temp1=[];
  221. var temp2=[];
  222. var temp3=[];
  223. var temp5=[];
  224. temp1.push(this.driversLicense);
  225. temp1.push(this.shifajlzm);
  226. temp2.push(this.drivingLicense);
  227. temp3.push(this.vehiclePhotos);
  228. temp5.push(this.passportPhA);
  229. temp5.push(this.passportPhB);
  230. this.licensePlate
  231. var usdata = {
  232. "licensePlate":that.licensePlate,
  233. "driversLicense":temp1+'',
  234. "drivingLicense":temp2+'',
  235. "vehiclePhotos":temp3+'',
  236. "passportPhoto":temp5+'',
  237. "idNumber":this.idNumber
  238. };
  239. console.log(usdata);
  240. uni.showLoading({
  241. mask:true
  242. })
  243. this.$http.post(`${updataUserMsg}`,usdata,true)
  244. .then(r => {
  245. uni.hideLoading();
  246. console.log('updataUserMsg',r)
  247. if(r.data.code==200){
  248. uni.navigateBack();
  249. }
  250. else{
  251. uni.showToast({
  252. title:r.data.msg,
  253. icon: 'none',
  254. duration: 2500
  255. })
  256. }
  257. })
  258. .catch(err => {
  259. uni.hideLoading();
  260. console.log(err)
  261. })
  262. }
  263. }
  264. }
  265. </script>
  266. <style>
  267. .grupCont{
  268. width: 90%;
  269. margin-top: 40rpx;
  270. align-items: center;
  271. }
  272. .noinputVcode{
  273. margin-left: 10rpx;
  274. width: 70%;
  275. height: 80rpx;
  276. line-height: 80rpx;
  277. border-radius: 10rpx;
  278. border: 2rpx solid #F2F3F7;
  279. background-color: #F2F3F7;
  280. }
  281. .tijiaoBT{
  282. width: 80%;
  283. text-align: center;
  284. line-height: 70rpx;
  285. font-size: 30rpx;
  286. color: white;
  287. background-color: #006AFF;
  288. border-radius: 8rpx;
  289. }
  290. </style>