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

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