completeInfo.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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">
  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" @click="uploadPhoto" /></u-avatar>
  12. </view>
  13. <view class="data-input">
  14. <u-form :model="form" ref="uForm" >
  15. <u-form-item label-position="top" label="昵称"><u-input v-model="form.nickName" placeholder="请填写昵称"/></u-form-item>
  16. </u-form>
  17. </view>
  18. <p class="car-num" @tap="keyShow=!keyShow" >车牌号码<span style="color: #9e9e9e;float: right;padding-right: 10px;">(点击唤起键盘)</span></p>
  19. <p class="car-num" style="padding: 10px 0 0 40px;" >根据平台要求,车牌号码输入后暂时<span style="color:red">不可以修改</span>,后续修改需要联系客服人员,请认真填写</p>
  20. <view class="key-input"
  21. @tap="keyShow=!keyShow">
  22. <u-message-input :focus="true" :value="form.carNum" :maxlength="maxlength" :disabled-keyboard="true"></u-message-input>
  23. </view>
  24. <view class="default" >
  25. <u-checkbox-group>
  26. <u-checkbox class="tips" v-model="form.defaultFlag" @change="checkboxChange()" shape="circle" >设为默认车辆</u-checkbox>
  27. </u-checkbox-group>
  28. </view>
  29. <u-button class="login-btn" v-show="!keyShow"
  30. @click="keepCar"
  31. type="success" shape="circle" >完成</u-button>
  32. <ucarkeyboard ref="uKeyboard"
  33. style=" z-index: 999;"
  34. :style="!keyShow?'display: none':''"
  35. mode="car" :confirmBtn="false" :mask-close-able="false" :tooltip="false" v-show="keyShow" @change="valChange" @backspace="backspace">
  36. <view style="
  37. text-align: center;
  38. font-size: 18px;
  39. ">
  40. <span>车牌号:{{form.carNum}}</span>
  41. <span
  42. @tap="keyShow=!keyShow"
  43. style="
  44. float: right;
  45. padding-right: 10px;
  46. color: #41a863;
  47. " >确定</span>
  48. </view>
  49. </ucarkeyboard>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import * as userApi from '@/apis/user.js'
  55. import ucarkeyboard from '@/components/Ucarkeyboard.vue'
  56. import * as loginApi from '@/apis/login.js'
  57. export default {
  58. components: {
  59. ucarkeyboard
  60. },
  61. data() {
  62. return {
  63. maxlength:8,
  64. keyShow: false,
  65. isLogin:false,
  66. code:"",
  67. codeId:"",
  68. form: {
  69. nickName: '',
  70. headImg: '',
  71. carNum: '鄂',
  72. defaultFlag: true,
  73. },
  74. }
  75. },
  76. onLoad(op) {
  77. if (op.jpcode) {
  78. var str1 = op.jpcode.slice(0, 19);
  79. var str2 = op.jpcode.slice(20, 21);
  80. var str3 = op.jpcode.slice(22);
  81. if (str1 == 'jp_team51_charge_id') {
  82. if (str2 == 'A') {
  83. this.code = str2;
  84. this.codeId = str3;
  85. }
  86. }
  87. }
  88. if(op.login){
  89. this.isLogin=true;
  90. }
  91. },
  92. onReady() {
  93. this.$refs.uKeyboard.changeCarInputMode();
  94. this.getUserInfo();
  95. },
  96. methods: {
  97. getUserInfo() {
  98. uni.showLoading({
  99. title: "加载中",
  100. mask: true,
  101. })
  102. loginApi.findByOpenId({
  103. openId: this.carhelp.getOpenId()
  104. }).then((res) => {
  105. uni.hideLoading();
  106. this.form.nickName = res.data.regUser.nickName;
  107. this.form.headImg = res.data.regUser.headImg;
  108. }).catch(error => {
  109. uni.showToast({
  110. title: error,
  111. icon: "none"
  112. })
  113. })
  114. },
  115. uploadPhoto() {
  116. let _self = this;
  117. const crop = {
  118. quality: 100,
  119. width: 600,
  120. height: 600,
  121. resize: true
  122. };
  123. // 上传图片
  124. uni.chooseImage({
  125. count: 1,
  126. crop,
  127. success: async (res) => {
  128. //(res);
  129. let tempFile = res.tempFiles[0],
  130. avatar_file = {
  131. // #ifdef H5
  132. extname: tempFile.name.split('.')[tempFile.name.split('.').length - 1],
  133. // #endif
  134. // #ifndef H5
  135. extname: tempFile.path.split('.')[tempFile.path.split('.').length - 1]
  136. // #endif
  137. },
  138. filePath = res.tempFilePaths[0]
  139. // #ifndef APP-PLUS
  140. //(`filePath=${filePath}`)
  141. //非app端用前端组件剪裁头像,app端用内置的原生裁剪
  142. let fileData = await new Promise((callback) => {
  143. uni.navigateTo({
  144. url: '/pages/user/cropImage?path=' + filePath +
  145. `&options=${JSON.stringify(crop)}`,
  146. animationType: "fade-in",
  147. events: {
  148. success: url => {
  149. callback(url)
  150. }
  151. }
  152. });
  153. })
  154. // #endif
  155. //返回 base64 图片
  156. //(fileData);
  157. var token = _self.carhelp.getToken()
  158. uni.showLoading({
  159. title: '上传中'
  160. });
  161. uni.request({
  162. url: process.car.BASE_URL + "uploadBase64",
  163. method: 'POST',
  164. data: {
  165. photoBase64Data: fileData
  166. },
  167. header: {
  168. 'Authorization': token,
  169. 'content-type': 'application/x-www-form-urlencoded'
  170. },
  171. success: (res) => {
  172. let jsonData = res.data;
  173. _self.form.headImg = jsonData.data;
  174. uni.hideLoading();
  175. }
  176. });
  177. }
  178. });
  179. },
  180. gotoLink(){
  181. if (this.code == 'A') {
  182. uni.redirectTo({
  183. url: '/pages/searchPile/stationAndPile/chargingPileDetails?id=' + this.codeId
  184. })
  185. } else if (this.isLogin){
  186. uni.redirectTo({
  187. url: '/pages/index/index'
  188. })
  189. }else {
  190. uni.navigateBack({
  191. url: '/pages/user/car/index'
  192. })
  193. }
  194. },
  195. checkboxChange() {
  196. this.form.defaultFlag = !this.form.defaultFlag;
  197. },
  198. // 按键被点击(点击退格键不会触发此事件)
  199. valChange(val) {
  200. if(this.form.carNum.length>=this.maxlength){
  201. return
  202. }
  203. // 将每次按键的值拼接到form.carNum变量中,注意+=写法
  204. this.form.carNum += val;
  205. //(this.form.carNum);
  206. if(this.form.carNum.length == 1) {
  207. this.$refs.uKeyboard.changeCarInputMode();
  208. }
  209. },
  210. // 退格键被点击
  211. backspace() {
  212. // 删除form.carNum的最后一个字符
  213. if (this.form.carNum.length) this.form.carNum = this.form.carNum.substr(0, this.form.carNum.length - 1);
  214. //(this.form.carNum);
  215. var aaa = this.$refs.uKeyboard.changeCarInputValue();
  216. if(this.form.carNum.length == 0 && aaa) {
  217. this.$refs.uKeyboard.changeCarInputMode();
  218. }
  219. },
  220. keepCar() {
  221. if(this.form.carNum.length != 8) {
  222. uni.showToast({
  223. title:"请填写新能源车牌"
  224. })
  225. return
  226. }
  227. //(this.form)
  228. uni.showLoading({
  229. title: "加载中",
  230. mask: true,
  231. })
  232. userApi.perfectPersonInformation(this.form).then((res) => {
  233. uni.hideLoading();
  234. this.gotoLink()
  235. }).catch(error => {
  236. uni.showToast({
  237. title: error,
  238. icon: "none"
  239. })
  240. })
  241. }
  242. }
  243. }
  244. </script>
  245. <style>
  246. page{
  247. background: #fff;
  248. }
  249. </style>
  250. <style lang="scss" scoped>
  251. .u-char-item{
  252. width: 29px !important;
  253. }
  254. .skip{
  255. margin-left: 81.3%;
  256. }
  257. .data-icon{
  258. height: 28px;
  259. width: 28px;
  260. background-color: #00B962;
  261. border-radius: 14px;
  262. border: 2px solid #fff;
  263. text-align: center;
  264. line-height: 24px;
  265. position: absolute;
  266. z-index: 999;
  267. right: 0;
  268. bottom:0px
  269. }
  270. .data-img{
  271. margin: 30px auto;
  272. height: 108px;
  273. width: 108px;
  274. position: relative;
  275. }
  276. .data-input{
  277. margin: 0 40px;
  278. }
  279. .login-btn {
  280. margin: 28px ;
  281. background-color:#00B962!important;
  282. border-color: #00B962!important;
  283. color:#fff!important;
  284. }
  285. .car-num{
  286. padding: 40px 0 0 40px;
  287. line-height: 18px;
  288. }
  289. .key-input {
  290. padding-top: 19px;
  291. }
  292. .default {
  293. margin: 16px 28px;
  294. }
  295. /deep/.u-char-item {
  296. width: 30px !important;
  297. height: 40px !important;
  298. font-size: 18px !important;
  299. }
  300. </style>