editaddress.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. <template>
  2. <view style="position: relative;">
  3. <!-- 胶囊 -->
  4. <mvBar :mysNavConfig="mysNavConfig"></mvBar>
  5. <view :style="{marginTop:navH}"></view>
  6. <view>
  7. <!-- 修改个人信息完善 -->
  8. <view style="margin: 0 20rpx;">
  9. <uni-forms :rules="rules" :modelValue="formData" ref="form" validate-trigger="bind"
  10. err-show-type="undertext">
  11. <uni-forms-item name="name" required label="姓名">
  12. <uni-easyinput type="text" :inputBorder="true" v-model="formData.receiver_name" placeholder="请输入收件人">
  13. </uni-easyinput>
  14. </uni-forms-item>
  15. <uni-forms-item name="phone" required label="电话">
  16. <uni-easyinput type="number" maxlength="11" :inputBorder="true" v-model="formData.phone_number"
  17. placeholder="请输入联系电话">
  18. </uni-easyinput>
  19. </uni-forms-item>
  20. <uni-forms-item name="region_code" required label="地区">
  21. <picker class="picker" mode="multiSelector" :range="region" range-key="name"
  22. :value="regionIndex" @change="pickerChange" @columnchange="pickerColumnchange">
  23. <view class="pbox" :class="{'pbox_hover':regionStr != '请选择省市区'}">
  24. <view>{{regionStr}}</view>
  25. <text class="iconfont icon-you"></text>
  26. </view>
  27. </picker>
  28. </uni-forms-item>
  29. <uni-forms-item name="detail_addr" required label="详细地址">
  30. <uni-easyinput type="text" :inputBorder="true" v-model="formData.detail_addr"
  31. placeholder="请输入详细地址(省/市/县/镇/)">
  32. </uni-easyinput>
  33. </uni-forms-item>
  34. </uni-group>
  35. </uni-forms>
  36. <button class="btn1" @click="submitForm('form')">保存</button>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import region from '@/components/pca-code.json';
  43. import mvBar from "@/components/mys_navBar/mysNavBar";
  44. export default {
  45. components: {
  46. mvBar,
  47. },
  48. data() {
  49. return {
  50. navH: getApp().globalData.navHeight,
  51. taskId: '',
  52. // 地区原数组
  53. oldRegion: region,
  54. // 处理后的数组
  55. region: [
  56. [],
  57. [],
  58. []
  59. ],
  60. // 选择省市区的下标Index 传则默认选中传递的
  61. regionIndex: [0, 0, 0],
  62. regionStr: '请选择省市区',
  63. mysNavConfig: {
  64. /* 开启单页显示首页图标 */
  65. isHome: true,
  66. /* 固定导航 */
  67. navFixed: true,
  68. /* 标题 (屏幕中心居中 两边图标中心居中使用slot center1) */
  69. navTitle: {
  70. text: "编辑收货地址",
  71. color: "",
  72. fontSize: "32rpx", // px upx rpx
  73. fontWeight: "normal", // 100 - 700
  74. },
  75. btnType: "type2",
  76. onLeftClick: '',
  77. /* type2 按钮 */
  78. type2Config: {
  79. // 左图标
  80. leftPath: "/static/img/png2.png",
  81. // 右图标
  82. rightPath: "/static/img/png4.png",
  83. // 圆角
  84. radius: "40rpx",
  85. },
  86. },
  87. formData: {
  88. receiver_name: '',
  89. phone_number: '',
  90. detail_addr: '',
  91. region_code: '',
  92. setdefault: false,
  93. },
  94. index: 0,
  95. index1: 0,
  96. data: {},
  97. show: false,
  98. rules: {
  99. detail_addr: {
  100. rules: [{
  101. required: true,
  102. errorMessage: '请输入详细地址'
  103. }, ]
  104. },
  105. name: {
  106. rules: [{
  107. required: true,
  108. errorMessage: '请输入收件人'
  109. }, ]
  110. },
  111. phone: {
  112. rules: [{
  113. required: true,
  114. errorMessage: '请输入联系电话',
  115. }, ]
  116. },
  117. region_code: {
  118. rules: [{
  119. required: true,
  120. errorMessage: '请选择所在地区'
  121. }, ]
  122. },
  123. },
  124. address_id: '',
  125. };
  126. },
  127. onLoad() {
  128. uni.showLoading()
  129. setTimeout(() => {
  130. uni.hideLoading()
  131. }, 500)
  132. },
  133. onReady() {
  134. this.initRegion()
  135. this.$refs.form.setRules(this.rules)
  136. },
  137. onLoad(options) {
  138. let data = options.textObj.replace(/""/g, "");
  139. data = JSON.parse(decodeURIComponent(data))
  140. this.formData = data.address
  141. this.taskId = data.taskId
  142. let a = this.formData.region_code.toString().slice(0, 2)
  143. let b = this.formData.region_code.toString().slice(0, 4)
  144. let c = 0
  145. for (var i = 0; i < region.length; i++) {
  146. if (region[i].code == a) {
  147. a = region[i].name
  148. for (var j = 0; j < region[i].children.length; j++) {
  149. if (region[i].children[j].code == b) {
  150. b = region[i].children[j].name
  151. for (var o = 0; o < region[i].children[j].children.length; o++) {
  152. if (region[i].children[j].children[o].code == this.formData.region_code) {
  153. c = region[i].children[j].children[o].name
  154. }
  155. }
  156. }
  157. }
  158. }
  159. }
  160. this.regionStr = a + ' ' + b + ' ' + c
  161. },
  162. methods: {
  163. initRegion() {
  164. // 声明城市数组
  165. let cityArr = [];
  166. let countyArr = [];
  167. // 设置下标
  168. this.regionIndex = [0, 0, 0];
  169. // 改变城市列表
  170. this.region[1] = this.oldRegion[0].children.map(item => {
  171. cityArr.push({
  172. name: item.name,
  173. code: item.code
  174. });
  175. })
  176. this.$set(this.region, 1, cityArr);
  177. // 改变县区列表
  178. this.oldRegion[0].children[0].children.map(item => {
  179. countyArr.push({
  180. name: item.name,
  181. code: item.code
  182. });
  183. })
  184. this.$set(this.region, 2, countyArr);
  185. },
  186. /**
  187. * 手动提交
  188. * @param {Object} form
  189. */
  190. submitForm(form) {
  191. // console.log(this.formData);
  192. this.$refs.form.validate().then(res => {
  193. const iphoneReg1 = /^1[0-9]{10}$/
  194. if (!iphoneReg1.test(this.formData.phone_number)) {
  195. uni.showToast({
  196. title: '电话号码格式不正确',
  197. icon: 'none'
  198. })
  199. return
  200. }
  201. uni.showToast({
  202. title: '提交成功'
  203. })
  204. this.$https.post('/youngee/c/t/p/update-logistics-address', {
  205. task_id: this.taskId,
  206. region_code: this.formData.region_code,
  207. detail_addr: this.formData.detail_addr,
  208. phone_number: this.formData.phone_number,
  209. receiver_name: this.formData.receiver_name,
  210. })
  211. .then(res => {
  212. console.log(res)
  213. uni.navigateBack()
  214. })
  215. }).catch(err => {
  216. console.error('验证失败:', errors)
  217. uni.showToast({
  218. title: '请填写所有信息',
  219. icon: 'none'
  220. })
  221. })
  222. },
  223. //城市选择
  224. pickerChange(e) {
  225. // console.log(e, '1');
  226. console.log("pickerChange e.detail.value: ", e.detail.value)
  227. this.regionIndex = e.detail.value;
  228. this.regionStr = this.region[0][this.regionIndex[0]].name + ' ' + this.region[1][this.regionIndex[1]]
  229. .name + ' ' +
  230. this.region[2][this.regionIndex[2]].name;
  231. // 组件传值
  232. this.$emit('region', [this.region[0][this.regionIndex[0]].code, this.region[1][this.regionIndex[1]].code,
  233. this.region[
  234. 2][this.regionIndex[2]].code
  235. ]);
  236. this.formData.region_code = this.region[2][this.regionIndex[2]].code;
  237. console.log(this.formData.region_code)
  238. },
  239. pickerColumnchange(e) {
  240. if (e.detail.column === 0) {
  241. // 声明城市数组
  242. let cityArr = [];
  243. let countyArr = [];
  244. // 设置下标
  245. this.regionIndex = [e.detail.value, 0, 0];
  246. // 改变城市列表
  247. this.region[1] = this.oldRegion[e.detail.value].children.map(item => {
  248. cityArr.push({
  249. name: item.name,
  250. code: item.code
  251. });
  252. })
  253. this.$set(this.region, 1, cityArr);
  254. // 改变县区列表
  255. this.oldRegion[e.detail.value].children[0].children.map(item => {
  256. countyArr.push({
  257. name: item.name,
  258. code: item.code
  259. });
  260. })
  261. this.$set(this.region, 2, countyArr);
  262. }
  263. if (e.detail.column === 1) {
  264. this.regionIndex[1] = e.detail.value;
  265. this.regionIndex[2] = 0;
  266. let countyArr = [];
  267. this.oldRegion[this.regionIndex[0]].children[this.regionIndex[1]].children.map(item => {
  268. countyArr.push({
  269. name: item.name,
  270. code: item.code
  271. });
  272. })
  273. this.$set(this.region, 2, countyArr);
  274. }
  275. if (e.detail.column === 2) {
  276. this.regionIndex[2] = e.detail.value;
  277. }
  278. }
  279. },
  280. created() {
  281. let provinceArr = [];
  282. let cityArr = [];
  283. this.oldRegion.map((item, index) => {
  284. this.region[0].push({
  285. name: item.name,
  286. code: item.code
  287. });
  288. if (this.previnceId == item.code) {
  289. provinceArr = item.children;
  290. this.regionIndex[0] = index;
  291. }
  292. })
  293. // console.log(provinceArr);
  294. provinceArr.map((item, index) => {
  295. this.region[1].push({
  296. name: item.name,
  297. code: item.code
  298. });
  299. if (this.cityId == item.code) {
  300. cityArr = item.children;
  301. this.regionIndex[1] = index;
  302. }
  303. })
  304. cityArr.map((item, index) => {
  305. this.region[2].push({
  306. name: item.name,
  307. code: item.code
  308. });
  309. if (this.countyId == item.code)
  310. this.regionIndex[2] = index;
  311. })
  312. if (this.isRevise)
  313. this.regionStr = this.region[0][this.regionIndex[0]].name + ' ' + this.region[1][this.regionIndex[1]]
  314. .name + ' ' + this.region[2][this.regionIndex[2]].name;
  315. else
  316. this.regionStr = '请选择省市区';
  317. }
  318. };
  319. </script>
  320. <style>
  321. picker {
  322. position: relative;
  323. display: block;
  324. cursor: pointer;
  325. padding-left: 20rpx !important;
  326. /* padding-top: 14rpx !important;
  327. color: grey !important; */
  328. }
  329. /deep/.uni-forms-item__inner {
  330. border-bottom: none !important;
  331. margin-bottom: 0 !important;
  332. }
  333. </style>
  334. <style lang="scss" scoped>
  335. @charset "UTF-8";
  336. /* 头条小程序组件内不能引入字体 */
  337. /* #ifdef MP-TOUTIAO */
  338. @font-face {
  339. font-family: uniicons;
  340. font-weight: normal;
  341. font-style: normal;
  342. src: url("~@/static/uni.ttf") format("truetype");
  343. }
  344. /* #endif */
  345. /* #ifndef APP-NVUE */
  346. page {
  347. display: flex;
  348. flex-direction: column;
  349. box-sizing: border-box;
  350. background-color: #FFFFFF;
  351. min-height: 100%;
  352. height: auto;
  353. }
  354. view {
  355. font-size: 14px;
  356. line-height: inherit;
  357. }
  358. .menu {
  359. position: fixed;
  360. top: 180rpx;
  361. background-color: #FFFFFF;
  362. justify-content: space-around;
  363. height: 5%;
  364. width: 100%;
  365. display: flex;
  366. z-index: 10;
  367. margin-bottom: 10rpx;
  368. }
  369. .menu-item p {
  370. font-weight: 600;
  371. font-size: 90%;
  372. &.lor {
  373. border-bottom: 5rpx solid #F0D232;
  374. color: #F0D232;
  375. padding-bottom: 15rpx;
  376. }
  377. }
  378. .setdeault {
  379. display: flex;
  380. justify-content: space-between;
  381. }
  382. .btn1 {
  383. margin: 30rpx;
  384. font-size: 35rpx;
  385. color: #000;
  386. background-color: #F0D232;
  387. border: none;
  388. border-radius: 0;
  389. }
  390. .example {
  391. padding: 0 15px 15px;
  392. }
  393. .example-info {
  394. padding: 15px;
  395. color: #3b4144;
  396. background: #ffffff;
  397. }
  398. .example-body {
  399. /* #ifndef APP-NVUE */
  400. display: flex;
  401. /* #endif */
  402. flex-direction: row;
  403. flex-wrap: wrap;
  404. justify-content: center;
  405. padding: 0;
  406. font-size: 14px;
  407. background-color: #ffffff;
  408. }
  409. /* #endif */
  410. .example {
  411. padding: 0 15px;
  412. }
  413. .example-info {
  414. /* #ifndef APP-NVUE */
  415. display: block;
  416. /* #endif */
  417. padding: 15px;
  418. color: #3b4144;
  419. background-color: #ffffff;
  420. font-size: 14px;
  421. line-height: 20px;
  422. }
  423. .example-info-text {
  424. font-size: 14px;
  425. line-height: 20px;
  426. color: #3b4144;
  427. }
  428. .example-body {
  429. flex-direction: column;
  430. padding: 15px;
  431. background-color: #ffffff;
  432. }
  433. .word-btn-white {
  434. font-size: 18px;
  435. color: #FFFFFF;
  436. }
  437. .word-btn {
  438. /* #ifndef APP-NVUE */
  439. display: flex;
  440. /* #endif */
  441. flex-direction: row;
  442. align-items: center;
  443. justify-content: center;
  444. border-radius: 6px;
  445. height: 48px;
  446. margin: 15px;
  447. background-color: #007AFF;
  448. }
  449. .word-btn--hover {
  450. background-color: #4ca2ff;
  451. }
  452. .example {
  453. padding: 0 10px 10px;
  454. }
  455. .uni-input-border,
  456. .uni-textarea-border {
  457. flex: 1;
  458. font-size: 14px;
  459. color: #666;
  460. border: 1px #FFFFFF solid;
  461. border-radius: 5px;
  462. /* #ifndef APP-NVUE */
  463. box-sizing: border-box;
  464. /* #endif */
  465. }
  466. .uni-input-border {
  467. padding: 0 10px;
  468. height: 35px;
  469. }
  470. .uni-textarea-border {
  471. padding: 10px;
  472. height: 80px;
  473. }
  474. .label-box {
  475. margin-right: 10px;
  476. }
  477. .transform-scale {
  478. transform: scale(0.7);
  479. }
  480. .butto {
  481. text-align: center;
  482. }
  483. .option {
  484. padding: 20rpx;
  485. }
  486. .uni-margin-wrap {
  487. width: 690rpx;
  488. width: 100%;
  489. ;
  490. }
  491. .swiper {
  492. height: 300rpx;
  493. }
  494. .swiper-item {
  495. display: block;
  496. height: 300rpx;
  497. line-height: 300rpx;
  498. text-align: center;
  499. }
  500. .swiper-list {
  501. margin-top: 40rpx;
  502. margin-bottom: 0;
  503. }
  504. .uni-common-mt {
  505. margin-top: 60rpx;
  506. position: relative;
  507. }
  508. .info {
  509. position: absolute;
  510. right: 20rpx;
  511. }
  512. .uni-padding-wrap {
  513. width: 550rpx;
  514. padding: 0 100rpx;
  515. }
  516. .signup {
  517. box-shadow: 0rpx 5rpx 40rpx #ccc;
  518. width: 100%;
  519. position: fixed;
  520. bottom: 0rpx;
  521. display: flex;
  522. height: 90rpx;
  523. padding-top: 2%;
  524. background-color: #FFFFFF;
  525. justify-content: space-around;
  526. }
  527. .signuptext {
  528. text-align: center;
  529. margin-top: 2%;
  530. }
  531. .signuptext p {
  532. font-size: 60%;
  533. color: #333333;
  534. }
  535. .signupbut {
  536. text-align: center;
  537. margin-top: 2%;
  538. }
  539. .but1 {
  540. width: 120%;
  541. text-align: center;
  542. background-color: #FCCF41;
  543. border-radius: 10rpx;
  544. color: #464100;
  545. font-size: 28rpx;
  546. line-height: 156%;
  547. font-weight: 500;
  548. height: 65%;
  549. }
  550. /deep/.uni-searchbar__box {
  551. border-color: #267CFF !important;
  552. border-width: 2rpx !important;
  553. }
  554. /deep/.uni-searchbar__box {
  555. background-color: #FFFFFF !important;
  556. }
  557. /deep/.uni-searchbar__text-placeholder {
  558. font-size: 30rpx !important;
  559. }
  560. /deep/.segmented-control__text {
  561. font-size: 34rpx !important;
  562. }
  563. /deep/.uni-data-checklist {
  564. padding-left: 20upx;
  565. }
  566. uni-picker {
  567. position: relative;
  568. display: block;
  569. cursor: pointer;
  570. padding-left: 20rpx !important;
  571. // padding-top: 14rpx !important;
  572. // color: grey !important;
  573. }
  574. /deep/.uni-date-x--border {
  575. border: 0px solid #dcdfe6 !important;
  576. }
  577. /deep/.is-input-border {
  578. border: 0px solid #c8c7cc !important;
  579. }
  580. /deep/.uni-progress-info {
  581. font-size: 25rpx !important;
  582. }
  583. /deep/.uni-error-message {
  584. position: absolute;
  585. bottom: -20rpx !important;
  586. left: 20rpx !important;
  587. text-align: left;
  588. }
  589. /deep/.uni-forms-item__inner {
  590. padding-bottom: 0rpx !important;
  591. margin-bottom: 30rpx !important;
  592. border-bottom: 0.5rpx solid #CCCCCC;
  593. }
  594. /deep/.uni-group__title {
  595. background-color: #FFFFFF !important;
  596. }
  597. /deep/.uni-list-item__content-title {
  598. font-size: 30rpx !important;
  599. color: #111111 !important;
  600. }
  601. /deep/.uni-progress-bar {
  602. border-radius: 10rpx !important;
  603. }
  604. /deep/.uni-progress-inner-bar {
  605. border-radius: 10rpx !important;
  606. }
  607. /deep/.is-input-border {
  608. border-radius: 20px !important;
  609. background-color: #fff;
  610. }
  611. .uni-easyinput__content-input {
  612. font-size: 30upx !important;
  613. }
  614. .content-clear-icon {
  615. font-size: 40upx !important;
  616. }
  617. /deep/.input-box {
  618. padding: 50upx;
  619. font-size: 30upx;
  620. .input-item {
  621. display: flex;
  622. border: 1upx solid #F8F8F8;
  623. line-height: 90upx;
  624. height: 90upx;
  625. margin-top: 20upx;
  626. background: #F8F8F8;
  627. border-radius: 48upx;
  628. .input-label {
  629. width: 150upx;
  630. text-align: center;
  631. }
  632. .input-body {
  633. position: relative;
  634. height: 100upx;
  635. width: calc(100% - 150upx);
  636. .input {
  637. line-height: 90upx;
  638. height: 90upx;
  639. position: relative;
  640. font-size: 28upx;
  641. }
  642. .eye {
  643. position: absolute;
  644. height: 50upx;
  645. width: 50upx;
  646. right: 20upx;
  647. top: 50%;
  648. transform: translateY(-50%);
  649. }
  650. .btn-code {
  651. position: absolute;
  652. right: 0upx;
  653. top: 50%;
  654. transform: translateY(-50%);
  655. background: none;
  656. color: #205592;
  657. width: 160upx;
  658. font-size: 24upx;
  659. box-sizing: border-box;
  660. text-align: center;
  661. padding: 0;
  662. height: 100upx;
  663. line-height: 100upx;
  664. }
  665. }
  666. }
  667. .select {
  668. // padding-top: 40upx;
  669. display: flex;
  670. justify-content: space-between;
  671. color: #003B67;
  672. }
  673. }
  674. /deep/.title-left {
  675. width: 3px;
  676. height: 16px;
  677. background: #267CFF;
  678. display: inline-block;
  679. border-radius: 3px;
  680. margin-top: 3px;
  681. vertical-align: top;
  682. margin-right: 10px;
  683. }
  684. </style>