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.

form.vue 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. <template>
  2. <view class="oderPage">
  3. <view class="addr-box">
  4. <view class="addr-box-left">
  5. <view class="text-image">{{form.consignee.charAt(0)}} </view>
  6. <view class="content">
  7. <view class="">
  8. <text class="item1">{{form.consignee}}</text>
  9. <text class="item2">{{form.consigneeTel}}</text>
  10. <text class="item3" v-if="form.defaultAddress ==1">默认</text>
  11. </view>
  12. <view class=""> {{form.region +form.address}}</view>
  13. </view>
  14. </view>
  15. <view class="edit" @click="address.show = true">
  16. <image :src="`${$imgUrl}applyCard/edit.png`" mode=""></image>
  17. </view>
  18. </view>
  19. <u-form ref="myForm">
  20. <view class="from">
  21. <u-form-item prop="cardState">
  22. <view class="from_item">
  23. <text><text style="color: red">*</text>是否寄回设备:</text>
  24. <!-- <u-radio-group v-model="form.sendStatusName">
  25. <u-radio :customStyle="{ marginBottom: '8px' }" activeColor="#2CE242"
  26. v-for="(item, index) in radiolist1" :key="index" :label="item.disabled"
  27. :name="item.name">
  28. {{ item.name }}
  29. </u-radio>
  30. </u-radio-group> -->
  31. <radio-group @change="sendChange" class="radios">
  32. <block v-for="(item, index) in radiolist1" :key="item.val">
  33. <view class="radio-box">
  34. <radio :value="item.val" :checked="form.sendStatus == item.val" color="#13e7c1"
  35. style="transform:scale(0.75)" />
  36. <view>{{item.name}}</view>
  37. </view>
  38. </block>
  39. </radio-group>
  40. </view>
  41. </u-form-item>
  42. <u-form-item prop="logistics" v-if="form.sendStatusName == '寄回'">
  43. <view class="from_item">
  44. <text><text style="color: red">*</text>退货物流公司:</text>
  45. <view style="display: flex">
  46. <u-input v-model="form.courierCompany" class="input" @click="showPicker" placeholder="请选择"
  47. disabled="disabled" />
  48. <u-icon name="arrow-right" style="margin-left: 10px;display: flex;"></u-icon>
  49. </view>
  50. </view>
  51. </u-form-item>
  52. <u-form-item prop="returnNum" v-if="form.sendStatusName == '寄回'">
  53. <view class="from_item">
  54. <text><text style="color: red"></text>退货单号:</text>
  55. <u-input v-model="form.courierOrderId" class="input" />
  56. </view>
  57. </u-form-item>
  58. <u-form-item prop="cardState">
  59. <view class="from_item">
  60. <text><text style="color: red">*</text>收货方式:</text>
  61. <!-- <u-radio-group v-model="form.receiveMethodName">
  62. <u-radio :customStyle="{ marginBottom: '8px' }" activeColor="#2CE242"
  63. v-for="(item, index) in radiolist2" :key="index" :label="item.disabled"
  64. :name="item.name">
  65. {{ item.name }}
  66. </u-radio>
  67. </u-radio-group> -->
  68. <radio-group @change="receiveChange" class="radios">
  69. <block v-for="(item, index) in radiolist2" :key="item.val">
  70. <view class="radio-box">
  71. <radio :value="item.val" :checked="form.receiveMethod == item.val" color="#13e7c1"
  72. style="transform:scale(0.75)" />
  73. <view>{{item.name}}</view>
  74. </view>
  75. </block>
  76. </radio-group>
  77. </view>
  78. </u-form-item>
  79. <u-form-item prop="remark">
  80. <view class="from_item">
  81. <text><text style="color: red"></text>注销原因:</text>
  82. <view style="display: flex">
  83. <u-input v-model="form.applyRes" @click="showApplyResPicker()" class="input" disabled
  84. placeholder="请选择" />
  85. <u-icon name="arrow-right" style="margin-left: 10px;display: flex;"></u-icon>
  86. </view>
  87. </view>
  88. </u-form-item>
  89. </view>
  90. </u-form>
  91. <!-- 物流弹窗 -->
  92. <view>
  93. <!-- 物流 -->
  94. <u-select v-model="show" mode="single-column" :list="list" @confirm="confirm"></u-select>
  95. <!-- 原因 -->
  96. <u-select v-model="showApplyRes" mode="single-column" :list="applyResList" @confirm="applyResConfirm">
  97. </u-select>
  98. </view>
  99. <button class="submit" @click="submit">下一步</button>
  100. </view>
  101. <!-- 地址弹窗 -->
  102. <u-popup mode="bottom" v-model="address.show">
  103. <view class="address-line">
  104. <view v-if="address.list" v-for="(item, index) in address.list" :key="index" @click="addressSelected(item)"
  105. style="margin-bottom: 40rpx" class="flex-bettwen">
  106. <view class="flex">
  107. <view class="xing">
  108. {{ item.consignee.charAt(0) }}
  109. </view>
  110. <view class="content">
  111. <view class="flex">
  112. <view class="name">
  113. {{ item.consignee }}
  114. </view>
  115. <view class="phone">
  116. {{ item.consigneeTel }}
  117. </view>
  118. </view>
  119. <view class="address">
  120. {{ item.region + item.address }}
  121. </view>
  122. </view>
  123. </view>
  124. <view @click.stop="editAddress(item)" style="margin-left: 80rpx" class="picture">
  125. <image :showLoading="true" :src="`${$imgUrl}applyCard/edit.png`"
  126. style="width: 48rpx; height: 48rpx"></image>
  127. </view>
  128. </view>
  129. <view :style="address.list ? 'margin-top: 60rpx;' : ''" class="action-bottom">
  130. <button type="default" class="button" @click="goToAddAddress()">
  131. 添加收货地址
  132. </button>
  133. </view>
  134. </view>
  135. </u-popup>
  136. </template>
  137. <script setup lang="ts">
  138. // import navBar from "../ETCcancellation/components/nav-bar.vue";
  139. import {
  140. reactive,
  141. ref
  142. } from "vue";
  143. import {
  144. onLoad,
  145. onShow,
  146. onReady
  147. } from "@dcloudio/uni-app";
  148. import {
  149. navTo,
  150. checkStr
  151. } from "@/utils/utils";
  152. import {
  153. request
  154. } from "@/utils/network/request.js";
  155. import {
  156. getLogistics,
  157. addressQuery,
  158. changeCardInfo
  159. } from "@/utils/network/api.js";
  160. import {
  161. stringToJson
  162. } from "@/utils/network/encryption.js";
  163. import {
  164. getItem,
  165. StorageKeys
  166. } from "@/utils/storage";
  167. import {
  168. wechatPayConfigId,
  169. } from "@/utils/network/api";
  170. import {
  171. msg
  172. } from "@/utils/utils";
  173. const list = reactive([]); //物流数据
  174. const address = reactive({
  175. list: [],
  176. show: false
  177. }); //地址list
  178. const form = reactive({
  179. consignee: '',
  180. consigneeTel: '',
  181. address: '',
  182. region: '',
  183. sendStatusName: '寄回',
  184. sendStatus: '1', //0 --- 不邮寄 1 --- 邮寄
  185. courierCompany: '',
  186. courierOrderId: '',
  187. receiveMethod: '1',
  188. postCode: '',
  189. receiveMethodName: '邮寄', //0 --- 不邮寄 1 --- 邮寄
  190. applyRes: '',
  191. defaultAddress: 2
  192. });
  193. //入参
  194. const params = reactive({
  195. /* cardId: '',
  196. obuId: '', */
  197. orderId: '',
  198. id: '',
  199. });
  200. const applyResList = reactive([{
  201. //原因
  202. value: "损坏",
  203. label: "损坏",
  204. },
  205. {
  206. value: "其它",
  207. label: "其它",
  208. },
  209. ]);
  210. // 单选数据列表
  211. const radiolist1 = reactive([{
  212. name: "寄回",
  213. val: "1",
  214. },
  215. {
  216. name: "不寄回",
  217. val: "0",
  218. },
  219. ]);
  220. const radiolist2 = reactive([{
  221. name: "邮寄",
  222. val: "1",
  223. },
  224. {
  225. name: "不邮寄",
  226. val: "0",
  227. },
  228. ]);
  229. const goToAddAddress = () => {
  230. uni.navigateTo({
  231. url: "/subpackage/orders/addAddress",
  232. });
  233. };
  234. const editAddress = (val) => {
  235. uni.navigateTo({
  236. url: `/subpackage/orders/editAddress?content=` + JSON.stringify(val),
  237. });
  238. };
  239. const addressSelected = (val : any) => {
  240. console.log(val);
  241. // state.data = {
  242. // ...state.data,
  243. // ...val,
  244. // };
  245. // state.show = false;
  246. form.consignee = val.consignee
  247. form.consigneeTel = val.consigneeTel
  248. form.address = val.address
  249. form.region = val.region
  250. form.postCode = val.postalCode
  251. form.defaultAddress = val.defaultAddress
  252. address.show = false
  253. console.log("form.address", form.region, form.address)
  254. };
  255. // 寄回单选
  256. const sendChange = (e : any) => {
  257. console.log(e);
  258. form.sendStatus = e.detail.value
  259. };
  260. // 邮寄单选
  261. const receiveChange = (e : any) => {
  262. console.log(e);
  263. form.receiveMethod = e.detail.value
  264. };
  265. let showApplyRes = ref(false);
  266. // 打开物流先择器
  267. const showApplyResPicker = function () {
  268. showApplyRes.value = true;
  269. };
  270. const applyResConfirm = (e) => {
  271. form.applyRes = e[0].value;
  272. console.log(e[0].value);
  273. };
  274. let show = ref(false);
  275. // 打开物流先择器
  276. const showPicker = function () {
  277. show.value = true;
  278. };
  279. const confirm = (e) => {
  280. form.courierCompany = e[0].value;
  281. console.log(e[0].value);
  282. };
  283. onLoad((option) => {
  284. params.orderId = option.orderId
  285. params.id = option.id
  286. getexpresslist();
  287. getAddressList();
  288. });
  289. onShow(() => {
  290. getexpresslist();
  291. getAddressList();
  292. });
  293. const getexpresslist = () => {
  294. //参数说明
  295. let options = {
  296. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  297. data: {
  298. // opId: getItem("openId"),
  299. // source: "WECHAT",
  300. // tabIndex: "0",
  301. }, //请求参数
  302. method: "POST", //提交方式(默认POST)
  303. showLoading: true, //是否显示加载中(默认显示)
  304. };
  305. //调用方式
  306. request(getLogistics, options)
  307. .then((res) => {
  308. // stringToJson(res.bizContent)
  309. stringToJson(res.bizContent).forEach((item) => {
  310. list.push({
  311. value: item,
  312. label: item,
  313. });
  314. });
  315. })
  316. .catch((err) => {
  317. console.log(err);
  318. });
  319. };
  320. const getAddressList = () => {
  321. var data = {
  322. openId: getItem(StorageKeys.OpenId),
  323. };
  324. const options = {
  325. type: 2,
  326. data: data,
  327. method: "POST",
  328. showLoading: true,
  329. };
  330. request(addressQuery, options).then((res) => {
  331. const data = stringToJson(res.bizContent);
  332. address.list = data.data;
  333. if (address.list.length > 0) {
  334. var defaultAddress = address.list[0]
  335. form.consignee = defaultAddress.consignee
  336. form.consigneeTel = defaultAddress.consigneeTel
  337. form.address = defaultAddress.address
  338. form.region = defaultAddress.region
  339. form.postCode = defaultAddress.postalCode
  340. form.defaultAddress = defaultAddress.defaultAddress
  341. }
  342. console.log("form.address", form.address)
  343. });
  344. };
  345. const submit = () => {
  346. // if (form.sendStatusName === '寄回') {
  347. // form.sendStatus = '1'
  348. // } else {
  349. // form.sendStatus = '0'
  350. // }
  351. // if (form.receiveMethodName === '邮寄') {
  352. // form.receiveMethod = '1'
  353. // } else {
  354. // form.receiveMethod = '0'
  355. // }
  356. queryCckChangejzCardInfo().then(val => {
  357. console.log(val)
  358. navTo(
  359. `/subpackage/after-sale/replace-equipment/result`
  360. )
  361. })
  362. };
  363. const queryCckChangejzCardInfo = () => {
  364. if (!form.address) {
  365. msg("请编辑收货详细地址");
  366. return;
  367. }
  368. var data = {
  369. id: params.id,
  370. sendStatus: form.sendStatus,
  371. configId: wechatPayConfigId,
  372. courierCompany: form.courierCompany,
  373. courierOrderId: form.courierOrderId,
  374. receiveMethod: form.receiveMethod,
  375. consignee: form.consignee,
  376. consigneeTel: form.consigneeTel,
  377. address: form.address,
  378. region: form.region,
  379. postCode: form.postCode,
  380. applyRes: form.applyRes
  381. };
  382. const options = {
  383. type: 2,
  384. data: data,
  385. method: "POST",
  386. showLoading: true,
  387. };
  388. return new Promise(async (resolve, reject) => {
  389. const res = await request(changeCardInfo, options);
  390. const data = stringToJson(res.bizContent);
  391. resolve(data);
  392. }).catch((error) => {
  393. reject(error);
  394. });
  395. }
  396. </script>
  397. <style>
  398. page {
  399. width: 100%;
  400. height: 100%;
  401. display: flex;
  402. flex-direction: column;
  403. background-color: #f3f3f3;
  404. }
  405. </style>
  406. <style lang="scss" scoped>
  407. .radios {
  408. display: flex;
  409. }
  410. .radio-box {
  411. display: flex;
  412. align-items: center;
  413. padding-left: 20rpx;
  414. }
  415. .oderPage {
  416. flex: 1;
  417. width: 100%;
  418. .addr-box {
  419. margin-top: 20rpx;
  420. display: flex;
  421. background: #fff;
  422. padding: 30rpx;
  423. justify-content: space-between;
  424. align-items: center;
  425. .addr-box-left {
  426. display: flex;
  427. .text-image {
  428. width: 68rpx;
  429. height: 68rpx;
  430. background: #00b38b;
  431. border-radius: 50%;
  432. text-align: center;
  433. font-size: 26rpx;
  434. font-family: Microsoft YaHei;
  435. font-weight: 400;
  436. color: #ffffff;
  437. line-height: 68rpx;
  438. margin-right: 30rpx;
  439. }
  440. .content {
  441. view {
  442. font-size: 26rpx;
  443. font-family: Microsoft YaHei;
  444. font-weight: 400;
  445. color: #333333;
  446. .item1 {
  447. font-size: 30rpx;
  448. font-family: Microsoft YaHei;
  449. font-weight: 400;
  450. color: #333333;
  451. }
  452. .item2 {
  453. font-size: 24rpx;
  454. font-family: Microsoft YaHei;
  455. font-weight: 400;
  456. color: #999999;
  457. margin-left: 10rpx;
  458. }
  459. .item3 {
  460. width: 71rpx;
  461. height: 37rpx;
  462. background: #ffffff;
  463. border: 1px solid #ff8000;
  464. border-radius: 6rpx;
  465. font-size: 22rpx;
  466. font-family: Microsoft YaHei;
  467. font-weight: 400;
  468. color: #ff8000;
  469. padding: 3rpx 6rpx;
  470. margin-left: 10rpx;
  471. }
  472. }
  473. }
  474. }
  475. .edit {
  476. image {
  477. width: 50rpx;
  478. height: 50rpx;
  479. }
  480. }
  481. }
  482. .from {
  483. background-color: #fff;
  484. margin-top: 30rpx;
  485. padding: 0 30rpx;
  486. ::v-deep .u-form-item {
  487. padding: 0;
  488. line-height: normal;
  489. .u-form-item__message {
  490. margin-bottom: 12rpx;
  491. }
  492. }
  493. .from_item {
  494. display: flex;
  495. flex-wrap: nowrap;
  496. justify-content: space-between;
  497. align-items: center;
  498. height: 80rpx;
  499. border-bottom: 1rpx solid #dcdcdc;
  500. .btn {
  501. font-size: 24rpx;
  502. font-family: Microsoft YaHei;
  503. font-weight: 400;
  504. color: #ffffff;
  505. background: #00b38b;
  506. border-radius: 10rpx;
  507. padding: 10rpx 15rpx;
  508. }
  509. ::v-deep .input {
  510. text-align: right;
  511. flex: 1;
  512. background: transparent;
  513. input {
  514. text-align: right;
  515. }
  516. }
  517. }
  518. .from_item1 {
  519. display: flex;
  520. flex-wrap: nowrap;
  521. flex-direction: column;
  522. justify-content: space-between;
  523. padding: 30rpx 0;
  524. border-bottom: #dcdcdc 1px solid;
  525. input {
  526. text-align: right;
  527. }
  528. .textarea {
  529. background-color: #f1f1f1;
  530. width: 100%;
  531. border-radius: 20rpx;
  532. margin-top: 10rpx;
  533. text-indent: 1rem;
  534. height: 180rpx;
  535. padding: 20rpx;
  536. box-sizing: border-box;
  537. }
  538. }
  539. }
  540. }
  541. .address-line {
  542. padding: 20px;
  543. .flex-bettwen {
  544. display: flex;
  545. align-items: center;
  546. justify-content: space-between;
  547. }
  548. .xing {
  549. width: 68rpx;
  550. height: 68rpx;
  551. background: rgba(0, 179, 139, 0.2);
  552. border-radius: 50%;
  553. font-size: 26rpx;
  554. font-weight: 400;
  555. color: #00b38b;
  556. line-height: 68rpx;
  557. text-align: center;
  558. }
  559. .content {
  560. margin-left: 20px;
  561. .name {
  562. font-size: 30rpx;
  563. font-family: Microsoft YaHei;
  564. font-weight: 500;
  565. color: #333333;
  566. }
  567. .phone {
  568. margin-left: 10rpx;
  569. font-size: 24rpx;
  570. font-family: Microsoft YaHei;
  571. font-weight: 400;
  572. color: #999999;
  573. line-height: 36rpx;
  574. }
  575. .address {
  576. margin-top: 10rpx;
  577. font-size: 26rpx;
  578. font-family: Microsoft YaHei;
  579. font-weight: 400;
  580. color: #333333;
  581. line-height: 36rpx;
  582. }
  583. .picture {
  584. width: 48rpx;
  585. height: 48rpx;
  586. }
  587. .editIcon {
  588. width: 48rpx;
  589. height: 48rpx;
  590. }
  591. }
  592. }
  593. .action {
  594. padding-bottom: 100rpx;
  595. .button {
  596. height: 80rpx;
  597. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  598. border-radius: 40rpx;
  599. font-size: 32rpx;
  600. font-weight: 400;
  601. color: #ffffff;
  602. line-height: 80rpx;
  603. }
  604. }
  605. .action-bottom {
  606. padding-bottom: 30rpx;
  607. .button {
  608. height: 80rpx;
  609. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  610. border-radius: 40rpx;
  611. font-size: 32rpx;
  612. font-weight: 400;
  613. color: #ffffff;
  614. line-height: 80rpx;
  615. }
  616. }
  617. .flex {
  618. display: flex;
  619. align-items: center;
  620. }
  621. .submit {
  622. width: 670rpx;
  623. height: 80rpx;
  624. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  625. box-shadow: 0rpx 4rpx 11rpx 1rpx rgba(223, 223, 223, 0.5);
  626. border-radius: 40rpx;
  627. font-size: 32rpx;
  628. font-family: Microsoft YaHei;
  629. font-weight: 400;
  630. color: #ffffff;
  631. line-height: 80rpx;
  632. margin-top: 60rpx;
  633. }
  634. </style>