bindingHomePile.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. <template>
  2. <view >
  3. <ujp-navbar title="绑定家充桩" v-if="current!='map'" ></ujp-navbar>
  4. <ujp-navbar title="绑定家充桩" v-if="current=='map'" :custom-back="customback" ></ujp-navbar>
  5. <selectMap ref="amap" @onload="mapdown"
  6. @onMoveEnd="moveEnd" @okBtn="okBtn"
  7. v-show="current=='map'" ></selectMap>
  8. <view class="main1" v-if="current==0">
  9. <view class="steps" >
  10. <u-steps :list="numList" mode="number" :current="current" un-active-color="#999999"></u-steps>
  11. </view>
  12. <view class="content" v-if="current==0" >
  13. <view class="infosGroup">
  14. <view class="item">
  15. <view class="itemTitle">
  16. 绑定识别号
  17. </view>
  18. <view class="itemValue" @click="getScanCode" style=" color: #999999;">
  19. {{subForm.deviceNo?subForm.deviceNo:'请扫码优电设备绑定识别号'}}
  20. </view>
  21. <view class="itemIcon" @click="getScanCode" >
  22. <img src="../../assets/img/riLine-qr-scan-2-line@3x.png" alt="" />
  23. </view>
  24. </view>
  25. </view>
  26. <view class="infosGroup">
  27. <view class="item">
  28. <view class="itemTitle">
  29. <span>*</span>桩主姓名
  30. </view>
  31. <view class="itemValue">
  32. <input type="text" @input="userNameInput"
  33. v-model="subForm.userName"
  34. placeholder="请填写桩主真实姓名" />
  35. </view>
  36. </view>
  37. <view class="item">
  38. <view class="itemTitle">
  39. <span>*</span>联系电话
  40. </view>
  41. <view class="itemValue">
  42. <input type="text" v-model="subForm.phone"
  43. placeholder="请填写桩主联系电话" />
  44. </view>
  45. <view class="itemIcon" v-if="0">
  46. <img src="../../assets/img/md-cancel Copy@3x.png" alt="" />
  47. </view>
  48. </view>
  49. </view>
  50. <view class="infosGroup">
  51. <view class="item">
  52. <view class="itemTitle">
  53. <span>*</span>电桩名称
  54. </view>
  55. <view class="itemValue">
  56. <input type="text" v-model="subForm.chargingName"
  57. placeholder="如:沙市张三的个人桩" />
  58. </view>
  59. </view>
  60. <view class="item">
  61. <view class="itemTitle">
  62. 电桩类型
  63. </view>
  64. <view class="itemValue">
  65. 交流慢充
  66. </view>
  67. <view class="itemIcon">
  68. <!-- <u-icon name="arrow-right" color="#b3b3b3"></u-icon> -->
  69. </view>
  70. </view>
  71. <view class="item">
  72. <view class="itemTitle">
  73. <span>*</span>电桩位置
  74. </view>
  75. <view class="itemValue" >
  76. <textarea style="width: 100%;"
  77. v-model="subForm.address" placeholder="请填写电桩位置"></textarea>
  78. </view>
  79. <view class="itemIcon" @click="current='map'">
  80. <img src="../../assets/img/md-my_location@3x.png" alt="" />
  81. </view>
  82. </view>
  83. <view class="item">
  84. <view class="itemTitle">
  85. 车位号
  86. </view>
  87. <view class="itemValue">
  88. <input type="text" v-model="subForm.parkNum" placeholder="请填写车位号(选填)" />
  89. </view>
  90. </view>
  91. <view class="item">
  92. <view class="itemTitle">
  93. 位置描述
  94. </view>
  95. <view class="itemValue">
  96. <input type="text" v-model="subForm.remark" placeholder="请详细描述电桩位置信息" />
  97. </view>
  98. </view>
  99. <view class="pictures" >
  100. <view class="picturesTitle">
  101. <span>*</span>充电桩照片
  102. </view>
  103. <view class="picturesValue">
  104. <view class="upload">
  105. <u-upload max-count="1" name="photoFile"
  106. ref="uUpload"
  107. :form-data="formData" :header="header" :action="action"
  108. :file-list="listPic" ></u-upload>
  109. </view>
  110. </view>
  111. </view>
  112. </view>
  113. </view>
  114. <view class="bottom" @click="submit()" >
  115. <view class="button" >
  116. 提交申请
  117. </view>
  118. </view>
  119. </view>
  120. <u-modal v-model="show" content="确认是否提交申请?" @confirm="submitApi()" :show-cancel-button="true"
  121. confirm-color="#00b962"></u-modal>
  122. <view class="main2" v-if="current==1||current==2" >
  123. <view class="steps">
  124. <u-steps :list="numList" mode="number" :current="current" un-active-color="#999999"></u-steps>
  125. </view>
  126. <view class="content1" v-if="current==1" >
  127. <img src="../../assets/img/antFill-clock-circle@3x.png" alt="" />
  128. <view class="text1">
  129. 等待审核中
  130. </view>
  131. <view class="text2">
  132. 绑定申请已提交,等待后台审核完成建站
  133. </view>
  134. <view class="button" @click="back()">
  135. 返  回
  136. </view>
  137. </view>
  138. <view class="content1" v-if="current==2" >
  139. <img src="../../assets/img/antFill-check-circle@3x.png" alt="" />
  140. <view class="text1">
  141. 完成建站
  142. </view>
  143. <view class="text2">
  144. 充电桩安装成功,快来体验充电吧~
  145. </view>
  146. <view class="button button2" @click="gotoInfo()">
  147. 前往充电
  148. </view>
  149. </view>
  150. </view>
  151. </view>
  152. </template>
  153. <script>
  154. import * as API from '@/apis/apply.js'
  155. import * as WxJsApi from '@/utils/wxJsApi'
  156. import MapLoader from '@/utils/AMap'
  157. import selectMap from '@/components/SelectMap.vue';
  158. export default {
  159. components: {
  160. selectMap,
  161. },
  162. data() {
  163. return {
  164. show:false,
  165. current:0,
  166. numList: [{
  167. name: '绑定家桩'
  168. }, {
  169. name: '等待审核'
  170. }, {
  171. name: '完成建站'
  172. }],
  173. listPic: [],
  174. action:"",
  175. formData:{
  176. },
  177. header:{
  178. },
  179. subForm:{
  180. longitude: "",
  181. latitude: "",
  182. applyType:'1',
  183. type:"2",
  184. },
  185. obj:{
  186. applyChargingStation:null,
  187. chargingDevice:{},
  188. ready:false,
  189. },
  190. isReady:false,
  191. applyList:[],
  192. gunNo:"",
  193. }
  194. },
  195. onLoad() {
  196. this.action=process.car.BASE_URL+"uploadPicture"
  197. this.formData.subFolder="/team51/bindingHomePile"
  198. var token=this.carhelp.getToken()
  199. this.header={
  200. 'Authorization':token
  201. }
  202. //获取微信配置
  203. WxJsApi.getWxConfig(['scanQRCode','getLocation','addEventListener']).then((res)=>{
  204. this.isReady=true;
  205. //(res)
  206. this.getPoint()
  207. }).catch(error => {
  208. //(res)
  209. })
  210. this.personInfo = this.carhelp.getPersonInfo()
  211. if(this.personInfo){
  212. this.subForm.phone=this.personInfo.phone
  213. }
  214. this.getList()
  215. },
  216. onReady() {
  217. this.$refs.amap.init();
  218. },
  219. methods: {
  220. userNameInput(e){
  221. var c=e.detail.value;
  222. this.subForm.chargingName=c+'的私人充电桩'
  223. },
  224. customback(){
  225. this.current=0;
  226. },
  227. okBtn(e){
  228. console.log(e)
  229. this.subForm.latitude = e.latitude
  230. this.subForm.longitude = e.longitude
  231. this.subForm.address=e.address
  232. this.current=0
  233. this.$forceUpdate()
  234. },
  235. moveEnd(e) {
  236. //('moveEnd')
  237. let posCenter = this.$refs.amap.logMapInfo();
  238. ////('posCenter'+JSON.stringify(posCenter))
  239. if (this.latitude == e.center.lat && this.longitude == e.center.lng) {
  240. return
  241. }
  242. this.subForm.latitude = e.center.lat
  243. this.subForm.longitude = e.center.lng
  244. this.getPositionByLonLats()
  245. },
  246. mapdown() {
  247. //this.isReady = true;
  248. //this.$refs.amap.getLocation ();
  249. //let state = {};
  250. uni.getSystemInfo({
  251. success: (res) => {
  252. let scrollH = res.windowHeight; // - uni.upx2px(88) - navbarH
  253. let scrollW = res.windowWidth;
  254. this.$refs.amap.setMyStyle("height:" + (scrollH - 88 - 50) + "px;width:" + scrollW +
  255. "px;");
  256. }
  257. })
  258. },
  259. back(){
  260. window.history.back()
  261. },
  262. submit(){
  263. let files = [];
  264. // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作)
  265. files = this.$refs.uUpload.lists.filter(val => {
  266. return val.progress == 100;
  267. })
  268. // 如果您不需要进行太多的处理,直接如下即可
  269. // files = this.$refs.uUpload.lists;
  270. //(files);
  271. var imgUrl=files.map(item=>{
  272. return item.response.data;
  273. })
  274. //(imgUrl);
  275. this.subForm.imgUrl = imgUrl.join(',');
  276. if(!this.subForm.deviceNo){
  277. uni.showToast({
  278. title:"请扫码优电设备绑定识别号"
  279. })
  280. return
  281. }
  282. if(!this.subForm.userName){
  283. uni.showToast({
  284. title:"请填写桩主真实姓名"
  285. })
  286. return
  287. }
  288. if(!this.subForm.phone){
  289. uni.showToast({
  290. title:"请填写桩主联系电话"
  291. })
  292. return
  293. }
  294. if(!this.subForm.chargingName){
  295. uni.showToast({
  296. title:"请填写电桩名称"
  297. })
  298. return
  299. }
  300. if(!this.subForm.address){
  301. uni.showToast({
  302. title:"请定位电桩位置"
  303. })
  304. return
  305. }
  306. if(files.length==0){
  307. uni.showToast({
  308. title:"请上传充电桩照片"
  309. })
  310. return
  311. }
  312. this.show=true
  313. //this.submitApi()
  314. },
  315. submitApi(){
  316. uni.showLoading({
  317. title: "加载中",
  318. mask: true,
  319. })
  320. API.apply(this.subForm).then((res) => {
  321. //this.obj = res.data
  322. this.current=1
  323. uni.hideLoading()
  324. }).catch(error => {
  325. uni.showToast({
  326. title: error
  327. })
  328. })
  329. },
  330. getList(){
  331. uni.showLoading({
  332. title: "加载中",
  333. mask: true,
  334. })
  335. API.myApplyList({
  336. }).then((res) => {
  337. //this.obj = res.data
  338. this.applyList=res.data.applyList;
  339. if(this.applyList.length){
  340. var item=this.applyList[0]
  341. if(item.status==0){
  342. this.current=1
  343. }else{
  344. this.current=2
  345. this.gunNo=item.gunNo
  346. // uni.redirectTo({
  347. // url:'pages/searchPile/stationAndPile/chargingPileDetails?isback=1&id='+item.gunId
  348. // })
  349. }
  350. }
  351. uni.hideLoading()
  352. }).catch(error => {
  353. uni.showToast({
  354. title: error
  355. })
  356. })
  357. },
  358. gotoInfo(){
  359. uni.redirectTo({
  360. url:'/pages/searchPile/stationAndPile/chargingPileDetails?isback=1&id='+this.gunNo
  361. })
  362. },
  363. //获取定位地址
  364. getPositionByLonLats() {
  365. var _this = this;
  366. MapLoader().then(AMap => {
  367. var lnglatXY = [_this.subForm.longitude, _this.subForm.latitude];
  368. AMap.service('AMap.Geocoder', function() {
  369. let geocoder = new AMap.Geocoder({});
  370. geocoder.getAddress(lnglatXY, function(status, result) {
  371. console.log(lnglatXY);
  372. console.log(status, result);
  373. if (status === 'complete' && result.info === 'OK') {
  374. var address = result.regeocode.formattedAddress;
  375. console.log(address);
  376. _this.subForm.address = address;
  377. _this.$forceUpdate()
  378. } else {
  379. _this.subForm.address = '';
  380. uni.showToast({
  381. title:"无法获取定位"
  382. })
  383. }
  384. });
  385. });
  386. }).catch(error => {
  387. console.log(error)
  388. })
  389. },
  390. getPoint() {
  391. WxJsApi.getLocation().then((res) => {
  392. var latitude = parseFloat(res.latitude);
  393. var longitude = parseFloat(res.longitude);
  394. this.subForm.latitude = latitude;
  395. this.subForm.longitude = longitude;
  396. this.$refs.amap.setCenter({
  397. longitude:longitude,
  398. latitude:latitude
  399. })
  400. this.getPositionByLonLats()
  401. }).catch(error => {
  402. uni.showToast({
  403. title:JSON.stringify(error)
  404. })
  405. })
  406. },
  407. getInfo(code){
  408. if(code&&code.indexOf('bind:')==0){
  409. var id=code.substring(5)
  410. uni.showLoading({
  411. title: "加载中",
  412. mask: true,
  413. })
  414. API.findDeviceByNo({
  415. deviceNo:id
  416. }).then((res) => {
  417. if(res.data.ready){
  418. this.subForm.deviceNo=id;
  419. this.$forceUpdate()
  420. uni.showToast({
  421. title: "扫码成功"
  422. })
  423. }else{
  424. uni.showToast({
  425. title: "当前设备不可绑定"
  426. })
  427. }
  428. uni.hideLoading()
  429. }).catch(error => {
  430. uni.showToast({
  431. title: error
  432. })
  433. })
  434. }else{
  435. uni.showToast({
  436. title: "设备识别号不正确"
  437. })
  438. }
  439. },
  440. getScanCode(){
  441. if(process.env.NODE_ENV === "development"){
  442. this.subForm.longitude= 112.276527,
  443. this.subForm.latitude=30.306427,
  444. this.$refs.amap.setCenter({
  445. longitude:this.subForm.longitude,
  446. latitude:this.subForm.latitude
  447. })
  448. this.getInfo("bind:20241230001")
  449. this.getPositionByLonLats()
  450. }else{
  451. WxJsApi.scanQRCode(1).then(res => {
  452. this.getInfo(res)
  453. }).catch(error => {
  454. })
  455. }
  456. },
  457. }
  458. }
  459. </script>
  460. <style lang="scss" scoped>
  461. .steps {
  462. padding: 32rpx;
  463. height: 160rpx;
  464. }
  465. .main1{
  466. padding-bottom: 220rpx;
  467. }
  468. .main2{
  469. display: flex;
  470. flex-direction: column;
  471. height: calc(100vh - 88rpx);
  472. .content1{
  473. background-color: #fff;
  474. padding: 80rpx;
  475. flex: 1;
  476. text-align: center;
  477. img{
  478. width: 128rpx;
  479. height: 128rpx;
  480. }
  481. .text1{
  482. color: rgba(16, 16, 16, 1);
  483. font-size: 40rpx;
  484. margin-top: 42rpx;
  485. font-weight: bold;
  486. }
  487. .text2{
  488. color: rgba(102, 102, 102, 1);
  489. margin-top: 16rpx;
  490. }
  491. .button{
  492. margin-top: 48rpx;
  493. height: 88rpx;
  494. line-height: 88rpx;
  495. border-radius: 50px;
  496. background-color: rgba(24, 144, 255, 1);
  497. color: rgba(255, 255, 255, 1);
  498. font-size: 36rpx;
  499. }
  500. .button2{
  501. background: linear-gradient(134.04deg, rgba(0,185,98,1) 42.39%,rgba(22,119,255,1) 98.58%);
  502. }
  503. }
  504. }
  505. .infosGroup {
  506. padding: 0 32rpx;
  507. margin-bottom: 24rpx;
  508. background-color: #fff;
  509. .item {
  510. display: flex;
  511. align-items: center;
  512. font-size: 32rpx;
  513. padding: 28rpx 0;
  514. border-bottom: 1px solid #E5E7EA;
  515. }
  516. .item:last-of-type {
  517. border-bottom: none;
  518. }
  519. .itemTitle {
  520. color: #999999;
  521. min-width: 140rpx;
  522. span {
  523. color: #FF3A3A;
  524. }
  525. }
  526. .itemValue {
  527. width: 420rpx;
  528. margin-left: 36rpx;
  529. line-height: 32rpx;
  530. uni-input {
  531. color: #777777;
  532. }
  533. .uni-input-placeholder {
  534. color: #acacac;
  535. }
  536. }
  537. .itemIcon {
  538. margin-left: auto;
  539. display: flex;
  540. align-items: center;
  541. img {
  542. width: 40rpx;
  543. height: 40rpx;
  544. }
  545. }
  546. .pictures {
  547. padding: 26rpx 0 32rpx;
  548. .picturesTitle {
  549. color: #999999;
  550. min-width: 140rpx;
  551. span {
  552. color: #FF3A3A;
  553. }
  554. }
  555. .picturesValue {
  556. margin-top: 28rpx;
  557. }
  558. }
  559. }
  560. .bottom{
  561. position: fixed;
  562. left: 0;
  563. right: 0;
  564. bottom: 0;
  565. padding: 24rpx 32rpx;
  566. background-color: #fff;
  567. z-index: 999;
  568. .button{
  569. height: 80rpx;
  570. line-height: 80rpx;
  571. border-radius: 50px;
  572. background-color: rgba(0, 185, 98, 1);
  573. color: rgba(255, 255, 255, 1);
  574. font-size: 18px;
  575. text-align: center;
  576. }
  577. }
  578. </style>