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 16KB

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