completeInfo.vue 12 KB

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