You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

essential-information.vue 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. <template>
  2. <navBar title="九州ETC" :scrollTop="scrollTop"></navBar>
  3. <navBgCar></navBgCar>
  4. <view class="content-wrap">
  5. <!-- 车牌输入 -->
  6. <view class="car-input">
  7. <view class="title">请输入申办车牌</view>
  8. <car-number-input @numberInputResult="carNumber"></car-number-input>
  9. </view>
  10. <!-- 车牌颜色 -->
  11. <view class="chepai-lane">
  12. <view class="title">选择车牌颜色</view>
  13. <numberplate-color
  14. :numberplate="state.data.vehiclePlateNumber"
  15. :numberplateCor="{ id: 0 }"
  16. :type="state.data.type"
  17. @numberplateResult="checkNumberplateColor"
  18. >
  19. </numberplate-color>
  20. </view>
  21. <block >
  22. <!-- 收货地址 -->
  23. <view v-if="!state.data.address" class="address-lane">
  24. <view class="title">请选择或新增收货地址</view>
  25. <view style="margin-top: 30rpx" class="action">
  26. <button type="default" class="button" @click="state.show = true">
  27. 添加收货地址
  28. </button>
  29. </view>
  30. </view>
  31. <view v-if="state.data.address" class="address-lane">
  32. <view class="title">收货地址</view>
  33. <view
  34. @click="state.show = true"
  35. class="address-content"
  36. style="margin-top: 30rpx"
  37. >
  38. <view class="flex">
  39. <image
  40. :showLoading="true"
  41. :src="`${$imgUrl}applyCard/location.png`"
  42. style="width: 48rpx; height: 48rpx"
  43. >
  44. </image>
  45. <view style="margin-left: 18rpx" class="">
  46. <view class="address">
  47. {{ state.data.region + state.data.address }}
  48. </view>
  49. <view style="margin-top: 15rpx" class="flex">
  50. <view class="name">
  51. {{ state.data.consignee }}
  52. </view>
  53. <view class="phone">
  54. {{ state.data.consigneeTel }}
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="arror">
  60. <image
  61. :src="`${$imgUrl}common/arror-right.png`"
  62. class="icon"
  63. ></image>
  64. </view>
  65. </view>
  66. <view style="margin-top: 30rpx" class="action">
  67. <button type="default" class="button" @click="nextAction()">
  68. 下一步
  69. </button>
  70. </view>
  71. </view>
  72. </block>
  73. <!-- <block v-else>
  74. <view class="address-lane">
  75. <view style="margin-top: 30rpx" class="action">
  76. <button type="default" class="button" @click="nextAction()">
  77. 下一步
  78. </button>
  79. </view>
  80. </view>
  81. </block> -->
  82. </view>
  83. <!-- 地址弹窗 -->
  84. <u-popup mode="bottom" v-model="state.show">
  85. <view class="address-line">
  86. <view
  87. v-if="state.addressArray"
  88. v-for="(item, index) in state.addressArray"
  89. :key="index"
  90. @click="addressSelected(item)"
  91. style="margin-bottom: 60rpx"
  92. class="flex-bettwen"
  93. >
  94. <view class="flex">
  95. <view class="xing">
  96. {{ item.consignee.charAt(0) }}
  97. </view>
  98. <view class="content">
  99. <view class="flex">
  100. <view class="name">
  101. {{ item.consignee }}
  102. </view>
  103. <view class="phone">
  104. {{ item.consigneeTel }}
  105. </view>
  106. </view>
  107. <view class="address">
  108. {{ item.region + item.address }}
  109. </view>
  110. </view>
  111. </view>
  112. <view
  113. @click.stop="editAddress(item)"
  114. style="margin-left: 80rpx"
  115. class="picture"
  116. >
  117. <image
  118. :showLoading="true"
  119. :src="`${$imgUrl}applyCard/edit.png`"
  120. style="width: 48rpx; height: 48rpx"
  121. ></image>
  122. </view>
  123. </view>
  124. <view
  125. :style="state.addressArray ? 'margin-top: 60rpx;' : ''"
  126. class="action-bottom"
  127. >
  128. <button type="default" class="button" @click="goToAddAddress()">
  129. 添加收货地址
  130. </button>
  131. </view>
  132. </view>
  133. </u-popup>
  134. </template>
  135. <script setup lang="ts">
  136. /*导航*/
  137. import navBgCar from "./components/nav-bg-car2";
  138. import carNumberInput from "@/components/car-number-input/car-number-input.vue";
  139. import numberplateColor from "./components/layout-numberplate-color";
  140. import { getItem, StorageKeys } from "@/utils/storage";
  141. import { stringToJson } from "@/utils/network/encryption";
  142. import navBar from "@/components/nav-bar/nav-bar2.vue";
  143. import { onLoad, onShow, onPageScroll,onUnload } from "@dcloudio/uni-app";
  144. import {
  145. addressQuery,
  146. etcCreatOrder,
  147. etcVehiclePlateVer,
  148. searchOrder,
  149. productReCode,
  150. } from "@/utils/network/api.js";
  151. import { request } from "@/utils/network/request.js";
  152. import { reactive, ref } from "vue";
  153. import { msg } from "@/utils/utils";
  154. // import amap from "../../lib/amap-wx.130.js";//引入高德地图小程序插件
  155. const scrollTop = ref(0);
  156. const state = reactive({
  157. data: {
  158. vehiclePlate: undefined, //车牌号
  159. vehiclePlateNumber: "", //车牌号
  160. vehiclePlateColor: 0, //车盘颜色
  161. type: "0", //车牌类型
  162. userType: 1,
  163. whetherToMail: getItem(StorageKeys.OpenId) ? 0 : "", //是否需要邮寄 小程序默认邮寄 0邮寄||1不邮寄 不登录为1
  164. orderSource: "WECHAT",
  165. opId: "",
  166. consignee: "", //收货人
  167. consigneeTel: "", //收货电话
  168. region: "",
  169. address: "",
  170. postalCode: "",
  171. promoteId:"",
  172. longitude:"",
  173. latitude:"",
  174. detailedAddress:'', //通过经纬度转的地址
  175. },
  176. show: false,
  177. addressArray: [],
  178. isSign:''
  179. });
  180. /* 选择车牌颜色 */
  181. const checkNumberplateColor = (item: any) => {
  182. state.data.vehiclePlateColor = item.id;
  183. };
  184. const goToAddAddress = () => {
  185. uni.navigateTo({
  186. url: "/subpackage/orders/addAddress",
  187. });
  188. };
  189. const editAddress = (val) => {
  190. console.log("val",val)
  191. uni.navigateTo({
  192. url: `/subpackage/orders/editAddress?content=` + JSON.stringify(val),
  193. });
  194. };
  195. const carNumber = (val: any) => {
  196. state.data.vehiclePlate = val;
  197. state.data.vehiclePlateNumber = val;
  198. };
  199. const addressSelected = (val: any) => {
  200. console.log("val",val)
  201. state.data = {
  202. ...state.data,
  203. ...val,
  204. };
  205. console.log("state.data.address",state.data.address)
  206. state.show = false;
  207. };
  208. const nextAction = () => {
  209. if (!state.data.vehiclePlate) {
  210. msg("请输入申办车牌");
  211. return;
  212. }
  213. state.data.vehiclePlate = state.data.vehiclePlate.trim();
  214. console.log(state.data.vehiclePlate);
  215. console.log(state.data.vehiclePlate.length);
  216. if (state.data.vehiclePlate.length < 7) {
  217. msg("请输入正确的申办车牌");
  218. return;
  219. }
  220. //1.优先车牌校验 2.在进行订单创建
  221. var vehicleData = {
  222. vehiclePlate: state.data.vehiclePlate,
  223. vehiclePlateColor: state.data.vehiclePlateColor,
  224. };
  225. const options = {
  226. type: 2,
  227. data: vehicleData,
  228. method: "POST",
  229. showLoading: true,
  230. };
  231. request(etcVehiclePlateVer, options).then((res) => {
  232. var data = state.data;
  233. const options = {
  234. type: 2,
  235. data: data,
  236. method: "POST",
  237. showLoading: true,
  238. };
  239. request(etcCreatOrder, options).then((res) => {
  240. console.log(res);
  241. if (res.statusCode === 600) {
  242. orderGoAction();
  243. } else {
  244. const data = stringToJson(res.bizContent);
  245. console.log(data);
  246. //提交产品信息
  247. productReCodeAction(data.orderId).then((result)=>{
  248. console.log(state.data);
  249. console.log(result);
  250. if (state.data.userType == 1) {
  251. uni.navigateTo({
  252. url: `/subpackage/orders/opening-account-people?orderId=${data.orderId}&&vehiclePlateColor=${state.data.vehiclePlateColor}&isSign=${state.isSign}&type=${state.data.type}`,
  253. });
  254. } else {
  255. uni.navigateTo({
  256. url: `/subpackage/orders/opening-account-unit?orderId=${data.orderId}&&vehiclePlateColor=${state.data.vehiclePlateColor}&isSign=${state.isSign}&type=${state.data.type}`,
  257. });
  258. }
  259. })
  260. // uni.navigateTo({
  261. // url: `/subpackage/orders/choice-product?orderId=${data.orderId}&userType=${state.data.userType}&vehiclePlateColor=${state.data.vehiclePlateColor}`,
  262. // })
  263. // uni.redirectTo({
  264. // url: `/subpackage/orders/choice-product?orderId=${data.orderId}&userType=${state.data.userType}&vehiclePlateColor=${state.data.vehiclePlateColor}`,
  265. // });
  266. }
  267. });
  268. });
  269. };
  270. //按照订单阶段去跳转
  271. const orderGoAction = () => {
  272. var orderParmas = {
  273. vehicleId: state.data.vehiclePlate + "_" + state.data.vehiclePlateColor,
  274. opId: getItem(StorageKeys.OpenId),
  275. source: "WECHAT",
  276. };
  277. const options = {
  278. type: 2,
  279. data: orderParmas,
  280. method: "POST",
  281. showLoading: true,
  282. };
  283. request(searchOrder, options).then((res) => {
  284. const data = stringToJson(res.bizContent);
  285. console.log(data);
  286. orderStepGoActon(data);
  287. });
  288. };
  289. //订单状态舔砖
  290. const orderStepGoActon = (val: any) => {
  291. console.log(val);
  292. //完成填写基本信息
  293. if (val.orderStep === 1) {
  294. if (state.data.userType === 1) {
  295. uni.redirectTo({
  296. url: `/subpackage/orders/opening-account-people?orderId=${val.orderId}&&vehiclePlateColor=${val.vehiclePlateColor}`,
  297. });
  298. } else {
  299. uni.redirectTo({
  300. url: `/subpackage/orders/opening-account-unit?orderId=${val.orderId}&&vehiclePlateColor=${val.vehiclePlateColor}`,
  301. });
  302. }
  303. } else if (val.orderStep === 2) {
  304. uni.redirectTo({
  305. url: `/subpackage/orders/car-release?orderId=${val.orderId}&&vehiclePlateColor=${val.vehiclePlateColor}`,
  306. });
  307. } else if (val.orderStep === 3) {
  308. uni.redirectTo({
  309. url: `/subpackage/orders/choice-product?orderId=${val.orderId}`,
  310. });
  311. }else if (val.orderStep === 4) {
  312. uni.redirectTo({
  313. url: `/subpackage/orders/product-detail?orderId=${val.orderId}&&clientFee=${val.product.clientFee}&&id=${val.productId}`,
  314. });
  315. } else if (val.orderStep === 26 || val.orderStep === 27) {
  316. uni.redirectTo({
  317. url: `/subpackage/orders/product-detail?orderId=${val.orderId}&&clientFee=${val.product.clientFee}&&id=${val.productId}`,
  318. });
  319. }
  320. };
  321. onLoad((option: any) => {
  322. state.data.opId = getItem(StorageKeys.OpenId);
  323. state.data.type = option.type; //客车
  324. state.data.userType = option.userType;
  325. state.data.promoteId = option.promoteId;
  326. state.isSign=option.isSign
  327. console.log("订单选择推广发行产品接口",option)
  328. uni.getLocation({
  329. type: 'wgs84',
  330. success: function (res) {
  331. state.data.longitude=res.longitude;
  332. state.data.latitude=res.latitude;
  333. console.log("成功回调",res)
  334. uni.request({
  335. url: 'https://apis.map.qq.com/ws/geocoder/v1/',
  336. data: {
  337. location: (res.latitude + "," + res.longitude),
  338. key: 'U3EBZ-EITC3-SRW3P-3PKVC-LWFD6-SJBAE',
  339. },
  340. success: function(res) {
  341. console.log("成功回调",res)
  342. state.data.detailedAddress = res.data.result.address; // 详细地址信息
  343. // 处理获取到的地址信息
  344. },
  345. fail: function(error) {
  346. // 请求失败的处理
  347. }
  348. });
  349. }
  350. });
  351. });
  352. //监听页面滚动
  353. onPageScroll((e) => {
  354. scrollTop.value = e.scrollTop;
  355. });
  356. onShow((option) => {
  357. var data = {
  358. openId: getItem(StorageKeys.OpenId),
  359. };
  360. if (getItem(StorageKeys.OpenId)) {
  361. const options = {
  362. type: 2,
  363. data: data,
  364. method: "POST",
  365. showLoading: true,
  366. };
  367. request(addressQuery, options).then((res) => {
  368. const data = stringToJson(res.bizContent);
  369. console.log("111",data);
  370. state.addressArray = data.data ?? [];
  371. });
  372. }
  373. uni.$on('updateData',function(data){
  374. var arr=[];
  375. arr.push(data)
  376. state.addressArray=arr
  377. console.log("dizhi",arr)
  378. })
  379. // 删除地址
  380. if(option){
  381. if(option.del==1){
  382. state.addressArray=[];
  383. }
  384. }
  385. });
  386. onUnload(()=>{
  387. uni.$off('updateData');
  388. })
  389. const productReCodeAction = (orderId) => {
  390. // var data = {
  391. // productId: state.data.productId,
  392. // orderId: orderId,
  393. // };
  394. var data = {
  395. promoteId: state.data.promoteId,
  396. orderId: orderId,
  397. };
  398. const options = {
  399. type: 2,
  400. data: data,
  401. method: "POST",
  402. showLoading: true,
  403. };
  404. return new Promise(async (resolve, reject) => {
  405. const res = await request(productReCode, options);
  406. const data = stringToJson(res.bizContent);
  407. console.log("111")
  408. resolve(data);
  409. }).catch((error) => {
  410. console.log("222")
  411. reject(error);
  412. });
  413. };
  414. </script>
  415. <style lang="scss" scoped>
  416. .flex {
  417. display: flex;
  418. align-items: center;
  419. }
  420. .content-wrap {
  421. position: relative;
  422. margin-top: -50rpx;
  423. padding: 0rpx 30rpx;
  424. .title {
  425. font-size: 30rpx;
  426. font-family: Noto Sans S Chinese;
  427. font-weight: 400;
  428. color: #000000;
  429. line-height: 30rpx;
  430. margin-bottom: 30rpx;
  431. }
  432. .car-input {
  433. }
  434. .chepai-lane {
  435. margin-top: 60rpx;
  436. margin-bottom: 20rpx;
  437. }
  438. .address-lane {
  439. margin-bottom: 30rpx;
  440. .title {
  441. font-size: 30rpx;
  442. font-weight: 400;
  443. color: #000000;
  444. line-height: 30rpx;
  445. }
  446. }
  447. }
  448. .address-content {
  449. display: flex;
  450. align-items: center;
  451. justify-content: space-between;
  452. padding-bottom: 30rpx;
  453. border-bottom: 1rpx solid #dcdcdc;
  454. .name {
  455. font-size: 26rpx;
  456. font-family: Microsoft YaHei;
  457. font-weight: 400;
  458. color: #999999;
  459. font-size: 26rpx;
  460. }
  461. .phone {
  462. font-size: 26rpx;
  463. font-family: Microsoft YaHei;
  464. font-weight: 400;
  465. color: #999999;
  466. line-height: 26rpx;
  467. margin-left: 20rpx;
  468. }
  469. .arror .icon {
  470. width: 36rpx;
  471. height: 36rpx;
  472. }
  473. .address {
  474. font-size: 32rpx;
  475. font-family: Microsoft YaHei;
  476. font-weight: 400;
  477. color: #333333;
  478. line-height: 32rpx;
  479. }
  480. }
  481. .address-line {
  482. padding: 20px;
  483. .flex-bettwen {
  484. display: flex;
  485. align-items: center;
  486. justify-content: space-between;
  487. }
  488. .xing {
  489. width: 68rpx;
  490. height: 68rpx;
  491. background: rgba(0, 179, 139, 0.2);
  492. border-radius: 50%;
  493. font-size: 26rpx;
  494. font-weight: 400;
  495. color: #00b38b;
  496. line-height: 68rpx;
  497. text-align: center;
  498. }
  499. .content {
  500. margin-left: 20px;
  501. .name {
  502. font-size: 30rpx;
  503. font-family: Microsoft YaHei;
  504. font-weight: 500;
  505. color: #333333;
  506. }
  507. .phone {
  508. margin-left: 10rpx;
  509. font-size: 24rpx;
  510. font-family: Microsoft YaHei;
  511. font-weight: 400;
  512. color: #999999;
  513. line-height: 36rpx;
  514. }
  515. .address {
  516. margin-top: 10rpx;
  517. font-size: 26rpx;
  518. font-family: Microsoft YaHei;
  519. font-weight: 400;
  520. color: #333333;
  521. line-height: 36rpx;
  522. }
  523. .picture {
  524. width: 48rpx;
  525. height: 48rpx;
  526. }
  527. .editIcon {
  528. width: 48rpx;
  529. height: 48rpx;
  530. }
  531. }
  532. }
  533. .action {
  534. padding-bottom: 100rpx;
  535. .button {
  536. height: 80rpx;
  537. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  538. border-radius: 40rpx;
  539. font-size: 32rpx;
  540. font-weight: 400;
  541. color: #ffffff;
  542. line-height: 80rpx;
  543. }
  544. }
  545. .action-bottom {
  546. padding-bottom: 30rpx;
  547. .button {
  548. height: 80rpx;
  549. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  550. border-radius: 40rpx;
  551. font-size: 32rpx;
  552. font-weight: 400;
  553. color: #ffffff;
  554. line-height: 80rpx;
  555. }
  556. }
  557. :deep(.numberplates .numberplate-bg) {
  558. width: 190rpx;
  559. }
  560. :deep(.numberplates .numberplate){
  561. margin-right: 0rpx !important;
  562. width: 190rpx;
  563. }
  564. :deep(.numberplates){
  565. justify-content: space-between;
  566. }
  567. </style>