addlocation.vue 17 KB

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