completeInfo.vue 12 KB

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