completeInfo.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. <template>
  2. <view>
  3. <ujp-navbar title="完善信息">
  4. <view slot="right" @click="gotoLink" style=" margin-right: 20rpx;"> 跳过</view>
  5. </ujp-navbar>
  6. <view class="data">
  7. <view class="data-img" v-show="!keyShow">
  8. <view class="data-icon">
  9. <u-icon name="camera-fill" custom-prefix="custom-icon" color="#fff" size="32"></u-icon>
  10. </view>
  11. <u-avatar :src="form.headImg+'?x-oss-process=image/resize,m_fill,w_256,h_256'" size="216"
  12. @click="uploadPhoto" /></u-avatar>
  13. </view>
  14. <view class="data-input">
  15. <u-form :model="form" ref="uForm">
  16. <u-form-item label-position="top" label="昵称"><u-input v-model="form.nickName"
  17. placeholder="请填写昵称" /></u-form-item>
  18. </u-form>
  19. </view>
  20. <p class="car-num" >车牌号码
  21. <span @click="gotoLink"
  22. style="color: rgb(63, 189, 112);float: right;">临时车牌,点击快速充电</span>
  23. </p>
  24. <view class="key-input" @tap="keyShow=true">
  25. <umessageInput :focus="true" @selectIndex="getSelectIndex" :value="form.carNum" :maxlength="maxlength"
  26. :disabled-keyboard="true"></umessageInput>
  27. <!-- <u-message-input :focus="true" :value="form.carNum" :maxlength="maxlength" :disabled-keyboard="true"></u-message-input>
  28. -->
  29. </view>
  30. <p class="car-num" ><span @tap="keyShow=!keyShow"
  31. style="float: right;color: #9e9e9e;">点击输入框{{keyShow?'收起':'唤起'}}键盘</span></p>
  32. <p class="car-num" v-show="!keyShow">车辆用途</p>
  33. <view class="car-type" v-show="!keyShow">
  34. <view class="card" v-for="(item,i) in carlist" :key="i"
  35. @click="usage=item.value"
  36. >
  37. <view class="cardin" :class="{
  38. cardselect:usage==item.value,
  39. cardno:usage!=item.value
  40. }" >
  41. <view class="cardgo" >
  42. <view class="cardinfo">
  43. <img
  44. src="@/assets/img/riFill-check-fill.svg" alt="">
  45. </view>
  46. </view>
  47. <view class="title">{{item.name}}</view>
  48. <p class="carimgp">
  49. <img class="carimg"
  50. :src="item.img" alt="">
  51. </p>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="default" v-show="!keyShow">
  56. <view style="width: 350px;">
  57. <u-checkbox-group>
  58. <u-checkbox class="tips" active-color="green" v-model="value" shape="circle"
  59. @change="checkboxChange()"></u-checkbox>
  60. </u-checkbox-group>
  61. <span>我已阅读并同意</span>
  62. <span @click="gotoUrl('pages/article/details?code=GRXXCLSQS')"
  63. style="color: #3fbd70;">《个人信息处理授权书》</span>
  64. </view>
  65. <u-button class="login-btn" @click="keepCar" type="success" shape="circle">完成</u-button>
  66. </view>
  67. <ucarkeyboard ref="uKeyboard" style=" z-index: 999;" :style="!keyShow?'display: none':''" mode="car"
  68. :confirmBtn="false" :mask-close-able="false" :tooltip="false" v-show="keyShow" @change="valChange"
  69. @backspace="backspace">
  70. <view style="
  71. text-align: center;
  72. font-size: 18px;
  73. ">
  74. <span style="color: #fff;">车牌号:{{form.carNum}}</span>
  75. <span @tap="keyShow=!keyShow" style="
  76. float: right;
  77. padding-right: 10px;
  78. color: #41a863;
  79. ">确定</span>
  80. </view>
  81. </ucarkeyboard>
  82. </view>
  83. </view>
  84. </template>
  85. <script>
  86. import * as userApi from '@/apis/user.js'
  87. import ucarkeyboard from '@/components/Ucarkeyboard.vue'
  88. import * as loginApi from '@/apis/login.js'
  89. import umessageInput from '@/components/UmessageInput.vue'
  90. var car1=require("@/assets/img/cartype/car1.png")
  91. var car2=require("@/assets/img/cartype/car2.png")
  92. var car3=require("@/assets/img/cartype/car3.png")
  93. var car4=require("@/assets/img/cartype/car4.png")
  94. export default {
  95. components: {
  96. ucarkeyboard,
  97. umessageInput
  98. },
  99. data() {
  100. return {
  101. value: false,
  102. selectIndex: -1,
  103. maxlength: 8,
  104. keyShow: false,
  105. isLogin: false,
  106. code: "",
  107. codeId: "",
  108. form: {
  109. nickName: '',
  110. headImg: '',
  111. carNum: '鄂',
  112. defaultFlag: true,
  113. },
  114. usage:"",
  115. carlist:[
  116. {
  117. value:1,
  118. name:"出租车",
  119. img:car1
  120. },
  121. {
  122. value:2,
  123. name:"专快车",
  124. img:car2
  125. },
  126. {
  127. value:3,
  128. name:"物流车/商用车",
  129. img:car3
  130. },
  131. {
  132. value:4,
  133. name:"私家车",
  134. img:car4
  135. }
  136. ]
  137. }
  138. },
  139. onLoad(op) {
  140. if (op.jpcode) {
  141. var str1 = op.jpcode.slice(0, 19);
  142. var str2 = op.jpcode.slice(20, 21);
  143. var str3 = op.jpcode.slice(22);
  144. if (str1 == 'jp_team51_charge_id') {
  145. if (str2 == 'A') {
  146. this.code = str2;
  147. this.codeId = str3;
  148. }
  149. }
  150. }
  151. if (op.login) {
  152. this.isLogin = true;
  153. }
  154. },
  155. onReady() {
  156. this.$refs.uKeyboard.changeCarInputMode();
  157. this.getUserInfo();
  158. },
  159. methods: {
  160. getUserInfo() {
  161. uni.showLoading({
  162. title: "加载中",
  163. mask: true,
  164. })
  165. loginApi.findByOpenId({
  166. openId: this.carhelp.getOpenId()
  167. }).then((res) => {
  168. uni.hideLoading();
  169. this.form.nickName = res.data.regUser.nickName;
  170. this.form.headImg = res.data.regUser.headImg;
  171. }).catch(error => {
  172. uni.showToast({
  173. title: error,
  174. icon: "none"
  175. })
  176. })
  177. },
  178. uploadPhoto() {
  179. let _self = this;
  180. const crop = {
  181. quality: 100,
  182. width: 600,
  183. height: 600,
  184. resize: true
  185. };
  186. // 上传图片
  187. uni.chooseImage({
  188. count: 1,
  189. crop,
  190. success: async (res) => {
  191. //(res);
  192. let tempFile = res.tempFiles[0],
  193. avatar_file = {
  194. // #ifdef H5
  195. extname: tempFile.name.split('.')[tempFile.name.split('.').length - 1],
  196. // #endif
  197. // #ifndef H5
  198. extname: tempFile.path.split('.')[tempFile.path.split('.').length - 1]
  199. // #endif
  200. },
  201. filePath = res.tempFilePaths[0]
  202. // #ifndef APP-PLUS
  203. //(`filePath=${filePath}`)
  204. //非app端用前端组件剪裁头像,app端用内置的原生裁剪
  205. let fileData = await new Promise((callback) => {
  206. uni.navigateTo({
  207. url: '/pages/user/cropImage?path=' + filePath +
  208. `&options=${JSON.stringify(crop)}`,
  209. animationType: "fade-in",
  210. events: {
  211. success: url => {
  212. callback(url)
  213. }
  214. }
  215. });
  216. })
  217. // #endif
  218. //返回 base64 图片
  219. //(fileData);
  220. var token = _self.carhelp.getToken()
  221. uni.showLoading({
  222. title: '上传中'
  223. });
  224. uni.request({
  225. url: process.car.BASE_URL + "uploadBase64",
  226. method: 'POST',
  227. data: {
  228. photoBase64Data: fileData
  229. },
  230. header: {
  231. 'Authorization': token,
  232. 'content-type': 'application/x-www-form-urlencoded'
  233. },
  234. success: (res) => {
  235. let jsonData = res.data;
  236. _self.form.headImg = jsonData.data;
  237. uni.hideLoading();
  238. }
  239. });
  240. }
  241. });
  242. },
  243. gotoLink() {
  244. if (this.code == 'A') {
  245. uni.redirectTo({
  246. url: '/pages/searchPile/stationAndPile/chargingPileDetails?id=' + this.codeId
  247. })
  248. } else if (this.isLogin) {
  249. uni.redirectTo({
  250. url: '/pages/index/index'
  251. })
  252. }
  253. },
  254. checkboxChange() {
  255. this.value = !this.value;
  256. },
  257. getSelectIndex(i) {
  258. this.selectIndex = i;
  259. if (i == 0) {
  260. var aaa = this.$refs.uKeyboard.changeCarInputValue();
  261. if (aaa) {
  262. this.$refs.uKeyboard.changeCarInputMode();
  263. }
  264. }
  265. },
  266. // 按键被点击(点击退格键不会触发此事件)
  267. valChange(val) {
  268. if (this.form.carNum.length >= this.maxlength && this.selectIndex == -1) {
  269. return
  270. }
  271. if (this.selectIndex == -1) {
  272. this.form.carNum += val;
  273. } else {
  274. const replaceStr = (str, index, char) => {
  275. const strAry = str.split('');
  276. if (index < strAry.length) {
  277. strAry[index] = char;
  278. }
  279. return strAry.join('');
  280. }
  281. this.form.carNum = replaceStr(this.form.carNum, this.selectIndex, val);
  282. this.selectIndex = -1;
  283. }
  284. // 将每次按键的值拼接到form.carNum变量中,注意+=写法
  285. //(this.form.carNum);
  286. var aaa = this.$refs.uKeyboard.changeCarInputValue();
  287. if ((this.form.carNum.length == 0) && aaa) {
  288. this.$refs.uKeyboard.changeCarInputMode();
  289. } else if (!aaa) {
  290. this.$refs.uKeyboard.changeCarInputMode();
  291. }
  292. },
  293. // 退格键被点击
  294. backspace() {
  295. // 删除form.carNum的最后一个字符
  296. if (this.form.carNum.length) {
  297. if (this.selectIndex == -1) {
  298. this.form.carNum = this.form.carNum.substr(0, this.form.carNum.length - 1);
  299. } else {
  300. const replaceStr = (str, index, char) => {
  301. const strAry = str.split('');
  302. if (index < strAry.length) {
  303. strAry[index] = char;
  304. }
  305. return strAry.join('');
  306. }
  307. this.form.carNum = replaceStr(this.form.carNum, this.selectIndex, '');
  308. //this.selectIndex=-1;
  309. }
  310. }
  311. //(this.form.carNum);
  312. var aaa = this.$refs.uKeyboard.changeCarInputValue();
  313. if (this.form.carNum.length == 0 && aaa) {
  314. this.$refs.uKeyboard.changeCarInputMode();
  315. }
  316. },
  317. keepCar() {
  318. if (this.form.carNum.length != 8) {
  319. uni.showToast({
  320. title: "请填写新能源车牌"
  321. })
  322. return
  323. }
  324. if (!this.usage) {
  325. uni.showToast({
  326. title: "请选择车辆用途"
  327. })
  328. return
  329. }
  330. if (!this.value) {
  331. uni.showToast({
  332. title: "请阅读并同意《个人信息处理授权书》"
  333. })
  334. return
  335. }
  336. //(this.form)
  337. this.form.usage=this.usage;
  338. uni.showLoading({
  339. title: "加载中",
  340. mask: true,
  341. })
  342. userApi.perfectPersonInformation(this.form).then((res) => {
  343. uni.hideLoading();
  344. this.gotoLink()
  345. }).catch(error => {
  346. uni.showToast({
  347. title: error,
  348. icon: "none"
  349. })
  350. })
  351. }
  352. }
  353. }
  354. </script>
  355. <style>
  356. page {
  357. background: #fff;
  358. }
  359. </style>
  360. <style lang="scss" scoped>
  361. .u-char-item {
  362. width: 29px !important;
  363. }
  364. .skip {
  365. margin-left: 81.3%;
  366. }
  367. .data-icon {
  368. height: 28px;
  369. width: 28px;
  370. background-color: #00B962;
  371. border-radius: 14px;
  372. border: 2px solid #fff;
  373. text-align: center;
  374. line-height: 24px;
  375. position: absolute;
  376. z-index: 999;
  377. right: 0;
  378. bottom: 0px
  379. }
  380. .data-img {
  381. margin: 10px auto;
  382. height: 108px;
  383. width: 108px;
  384. position: relative;
  385. }
  386. .data-input {
  387. margin: 0 60rpx;
  388. }
  389. .login-btn {
  390. margin-top: 12px;
  391. background-color: #00B962 !important;
  392. border-color: #00B962 !important;
  393. color: #fff !important;
  394. }
  395. .car-num {
  396. padding: 20rpx 60rpx 0 60rpx;
  397. line-height: 18px;
  398. }
  399. .key-input {
  400. padding-top: 19px;
  401. }
  402. .default {
  403. margin: 30rpx 60rpx;
  404. }
  405. /deep/.u-char-item {
  406. width: 30px !important;
  407. height: 40px !important;
  408. font-size: 18px !important;
  409. }
  410. .car-type{
  411. display: flex;
  412. flex-direction: row;
  413. margin: 0 40rpx;
  414. flex-wrap: wrap;
  415. }
  416. .cardone{
  417. // margin-right: 20rpx;
  418. }
  419. .card{
  420. width: 50%;
  421. padding: 0 10rpx;
  422. .cardin {
  423. // margin-left: 5px;
  424. overflow: hidden;
  425. padding: 20rpx;
  426. margin-top: 20rpx;
  427. height: 150rpx;
  428. .title{
  429. font-weight: bold;
  430. }
  431. .carimgp{
  432. float: right;
  433. }
  434. .carimg{
  435. width: 180rpx;
  436. height: 64rpx;
  437. }
  438. }
  439. }
  440. .cardselect {
  441. border-radius: 8px;
  442. border: 2px solid rgba(0, 185, 98, 1);
  443. .title{
  444. color:#00B962;
  445. font-weight: bold;
  446. }
  447. .cardgo{
  448. position: relative;
  449. .cardinfo{
  450. background-color: #57ad55;
  451. width: 36rpx;
  452. height: 36rpx;
  453. position: absolute;
  454. top: -12px;
  455. right: -12px;
  456. border-radius: 0 0 0 4px;
  457. img{
  458. width: 36rpx;
  459. }
  460. }
  461. }
  462. }
  463. .cardno {
  464. border: 2px solid #f6f6f6;
  465. border-radius: 8px;
  466. background-color: #f6f6f6;
  467. .title{
  468. font-weight: bold;
  469. }
  470. .cardgo{
  471. position: relative;
  472. .cardinfo{
  473. background-color: #f6f6f6;
  474. width: 36rpx;
  475. height: 36rpx;
  476. position: absolute;
  477. top: -12px;
  478. right: -12px;
  479. border-radius: 0 0 0 4px;
  480. img{
  481. width: 36rpx;
  482. }
  483. }
  484. }
  485. }
  486. </style>