地址重现失败清空,调整样式

youmengting-dev
游梦婷 2 years ago
parent a07d1a827b
commit 1a3a5cc65f
  1. 24
      components/pick-regions/pick-regions.vue
  2. 231
      physical-merchants/address/addNewAddress/addNewAddress.vue
  3. 4
      physical-merchants/classify/goodsDetail/goodsDetail.vue
  4. 3
      physical-merchants/classify/order/wuliuPupup/wuliuPupup.vue
  5. 8
      uni.scss

@ -150,23 +150,25 @@
this.$emit('getRegion',address) this.$emit('getRegion',address)
}, },
handleDefaultRegion(region){ handleDefaultRegion(region){
// console.log(region) console.log(region,"region")
const isCode = !Array.isArray(region) const isCode = !Array.isArray(region)
this.isInitMultiArray = false; this.isInitMultiArray = false;
let children = this.CHINA_REGIONS let children = this.CHINA_REGIONS;
let num =0;
for(let i=0;i<3;i++){ for(let i=0;i<3;i++){
for(let j=0;j<children.length;j++){ for(let j=0;j<children.length;j++){
let condition; let condition;
if(i==2){ if(i==2){
condition = isCode?String(children[j].code).slice(0)==region.slice(0):children[j].name.includes(region[i]); condition = isCode?String(children[j].code).slice(0)==region.slice(0):children[j].name.includes(region[i]);
// console.log(String(children[j].code).slice(0),region.slice(0)) console.log(String(children[j].code).slice(0),region.slice(0))
}else{ }else{
condition = isCode?String(children[j].code).slice(0,(i+1)*2)==region.slice(0,(i+1)*2):children[j].name.includes(region[i]); condition = isCode?String(children[j].code).slice(0,(i+1)*2)==region.slice(0,(i+1)*2):children[j].name.includes(region[i]);
// console.log(String(children[j].code).slice(0,(i+1)*2)==region.slice(0,(i+1)*2))
console.log(String(children[j].code).slice(0,(i+1)*2),region.slice(0,(i+1)*2))
} }
if(condition){ if(condition){
num++;
// //
// console.log(i,j,children.length-1); // console.log(i,j,children.length-1);
// children = children[j].childs; // children = children[j].childs;
@ -192,7 +194,7 @@
break; break;
}else{ }else{
// //
// console.log(i,j,children.length-1); console.log(i,j,children.length-1,"匹配失败");
if(i==0 && j==(children.length-1)){ if(i==0 && j==(children.length-1)){
this.isInitMultiArray = true; this.isInitMultiArray = true;
} }
@ -201,9 +203,15 @@
} }
} }
if(num == 3){
let address = [this.CHINA_REGIONS[this.multiIndex[0]],this.cityArr[this.multiIndex[1]],this.districtArr[this.multiIndex[2]]];
this.$emit('getRegion',address)
}else{
this.$emit('failureRegion')
}
let address = [this.CHINA_REGIONS[this.multiIndex[0]],this.cityArr[this.multiIndex[1]],this.districtArr[this.multiIndex[2]]];
this.$emit('getRegion',address)
} }
}, },

@ -1,7 +1,7 @@
<template> <template>
<view class="page-bottom-fixed backcor9" > <view class="page-bottom-fixed backcor9">
<form @submit="form_submit" class="form-container"> <form @submit="form_submit" class="form-container">
<view class="pd-main border-box height100" :style="'overflow-y: auto;transform: translateY(-0px);'" > <view class="pd-main border-box height100" :style="'overflow-y: auto;transform: translateY(-0px);'">
<view class="form-gorup backcolorfff"> <view class="form-gorup backcolorfff">
<view class="dis-flex"> <view class="dis-flex">
<view class="form-gorup-title marRight10">收货人: <view class="form-gorup-title marRight10">收货人:
@ -28,7 +28,8 @@
<view class="form-gorup backcolorfff"> <view class="form-gorup backcolorfff">
<view class=""> <view class="">
<pick-regions :defaultRegion="defaultRegionCode" @getRegion="handleGetRegion"> <pick-regions @failureRegion="failureRegion" :defaultRegion="defaultRegionCode"
@getRegion="handleGetRegion">
<view class="dis-flex "> <view class="dis-flex ">
<view class=" form-gorup-title">所在地区:</view> <view class=" form-gorup-title">所在地区:</view>
<view class="dis-flex flex-1 flex-end"> <view class="dis-flex flex-1 flex-end">
@ -47,26 +48,29 @@
<!-- <view style="clear: both;"> --> <!-- <view style="clear: both;"> -->
<view class="dis-flex scrol-t mart10"> <view class="dis-flex scrol-t mart10">
<view class="form-gorup-title marRight10 align-self" style="padding: 0;">详细地址:</view> <view class="form-gorup-title marRight10 align-self" style="padding: 0;">详细地址:</view>
<uni-combox :height="height" @focus="focusMethod" @blur="blurMethod" :cursorSpacing="50" placeholderClass="corf6" :candidates="candidates" class="flex-1" :isAddress="true" :isShowIcon="false" placeholder="请输入详细地址" v-model="userAddress.address"> <uni-combox :height="height" @focus="focusMethod" @blur="blurMethod" :cursorSpacing="50"
placeholderClass="corf6" :candidates="candidates" class="flex-1" :isAddress="true"
<view class="selector-item" v-for="(item,index) in candidates" :key="index" @click="getSelect(item)"> :isShowIcon="false" placeholder="请输入详细地址" v-model="userAddress.address">
<view class="text1 name">
{{item.name}} <view class="selector-item" v-for="(item,index) in candidates" :key="index"
</view> @click="getSelect(item)">
<view class="text1 address mart5"> <view class="text1 name">
{{item.address}} {{item.name}}
</view> </view>
</view> <view class="text1 address mart5">
{{item.address}}
</view>
</uni-combox> </view>
<!-- <input type="text" name="address" v-model="userAddress.address" maxlength="40"
</uni-combox>
<!-- <input type="text" name="address" v-model="userAddress.address" maxlength="40"
placeholder-class="corf6" :class="'fcor666 bs-bb flex-1'" placeholder="详细地址1~40个字符"> --> placeholder-class="corf6" :class="'fcor666 bs-bb flex-1'" placeholder="详细地址1~40个字符"> -->
</view> </view>
<!-- </view> --> <!-- </view> -->
@ -77,7 +81,7 @@
<text class="font18">设为默认地址</text> <text class="font18">设为默认地址</text>
</view> </view>
</view> </view>
<view class="bottom-fixed "> <view class="bottom-fixed ">
@ -91,7 +95,7 @@
<script> <script>
import pickRegions from '@/components/pick-regions/pick-regions.vue' import pickRegions from '@/components/pick-regions/pick-regions.vue'
import UniCombox from '@/components/uni-combox/components/uni-combox/uni-combox.vue' import UniCombox from '@/components/uni-combox/components/uni-combox/uni-combox.vue'
import { import {
insertDeliveryAddress, insertDeliveryAddress,
findDeliveryAddressById, findDeliveryAddressById,
@ -108,7 +112,7 @@
region: '', region: '',
address: "", address: "",
is_default: false, is_default: false,
}, },
dataParams: null, dataParams: null,
// //
@ -117,15 +121,15 @@
// //
// defaultRegion: ['', '', ''], // defaultRegion: ['', '', ''],
defaultRegionCode: '', defaultRegionCode: '',
candidates:[ candidates: [
// {"name": "-","address": "189",}, // {"name": "-","address": "189",},
// {"name": "-","address": "189",}, // {"name": "-","address": "189",},
// {"name": "-","address": "189",} // {"name": "-","address": "189",}
], ],
top:0, top: 0,
top1:0, top1: 0,
height:0, height: 0,
}; };
@ -133,7 +137,7 @@
components: { components: {
pickRegions, pickRegions,
"uni-combox":UniCombox "uni-combox": UniCombox
}, },
@ -177,49 +181,48 @@
}, },
async mounted() { async mounted() {
await this.getRect('.scrol-t').then(res => { await this.getRect('.scrol-t').then(res => {
this.top = res.top; this.top = res.top;
}) })
await this.getRect('.bottom-fixed').then(res => { await this.getRect('.bottom-fixed').then(res => {
this.top1 = res.top; this.top1 = res.top;
}) })
this.height = this.top1 - this.top - 120; this.height = this.top1 - this.top - 120;
// console.log(this.top1,this.top,this.height) // console.log(this.top1,this.top,this.height)
}, },
methods: { methods: {
focusMethod(){ focusMethod() {
}, },
blurMethod(){ blurMethod() {
this.baiduApiMap(this.userAddress.address) this.baiduApiMap(this.userAddress.address)
}, },
getRect(selector, all) { getRect(selector, all) {
return new Promise(resolve => { return new Promise(resolve => {
uni.createSelectorQuery() uni.createSelectorQuery()
.in(this) .in(this)[all ? 'selectAll' : 'select'](selector)
[all ? 'selectAll' : 'select'](selector) .boundingClientRect(rect => {
.boundingClientRect(rect => { if (all && Array.isArray(rect) && rect.length) {
if (all && Array.isArray(rect) && rect.length) { resolve(rect);
resolve(rect); }
} if (!all && rect) {
if (!all && rect) { resolve(rect);
resolve(rect); }
} })
}) .exec();
.exec(); });
}); },
},
findAddressById(id) { findAddressById(id) {
let params = { let params = {
id: id id: id
@ -251,7 +254,7 @@
// //
handleGetRegion(region) { handleGetRegion(region) {
// let region = JSON.parse(JSON.stringify(reg)) // let region = JSON.parse(JSON.stringify(reg))
this.region = region; this.region = region;
this.regionId = this.region[2].code; this.regionId = this.region[2].code;
@ -267,59 +270,71 @@
init() { init() {
}, },
// //onInput // //onInput
// location(n){ // location(n){
// // this.userAddress.address = this.userAddress.address.replace(/\s+/g, "") // // this.userAddress.address = this.userAddress.address.replace(/\s+/g, "")
// }, // },
baiduApiMap(query){ baiduApiMap(query) {
query = query.replace(/\s+/g, "") query = query.replace(/\s+/g, "")
let params={ let params = {
query:query query: query
} }
uni.showLoading({ uni.showLoading({
title: '加载中', title: '加载中',
mask:true, mask: true,
}); });
// console.log(params,"params") // console.log(params,"params")
baiduApiMapSearch(params).then(res=>{ baiduApiMapSearch(params).then(res => {
uni.hideLoading(); uni.hideLoading();
console.log(res) console.log(res)
if (res.return_code == '000000') { if (res.return_code == '000000') {
if(res.return_data&&res.return_data.length>0){ if (res.return_data && res.return_data.length > 0) {
this.candidates = res.return_data; this.candidates = res.return_data;
}else{ } else {
this.candidates=[] this.candidates = []
} }
}else{ } else {
this.candidates=[] this.candidates = []
uni.showToast({ uni.showToast({
title: res.return_msg, title: res.return_msg,
icon: 'none', icon: 'none',
duration: 2000 duration: 2000
}) })
} }
}) })
}, },
// //
getSelect(desc){ getSelect(desc) {
// console.log(desc) // console.log(desc)
this.defaultRegionCode = desc.adcode ; this.defaultRegionCode = desc.adcode;
this.userAddress.address =desc.name + desc.address; this.userAddress.address = desc.name + desc.address;
uni.showToast({ uni.showToast({
icon:'none', icon: 'none',
title:"所在地区同步修改" title: "所在地区同步修改",
duration:2000
})
},
failureRegion() {
this.defaultRegionCode = "";
this.regionId ="";
this.userAddress.region = "";
this.region = [];
uni.hideToast();
uni.showToast({
icon: 'none',
title: "地区同步修改失败,请手动选择",
duration:3000
}) })
}, },
// //
defaultChange(e) { defaultChange(e) {
this.userAddress.is_default = !this.userAddress.is_default this.userAddress.is_default = !this.userAddress.is_default
@ -500,6 +515,7 @@
/*表单*/ /*表单*/
.form-container { .form-container {
height: 100%; height: 100%;
/* display: flex; /* display: flex;
flex-direction: column; */ flex-direction: column; */
.form-gorup { .form-gorup {
@ -542,31 +558,32 @@
font-size: 24rpx; font-size: 24rpx;
color: #f00; color: #f00;
} }
.selector-item { .selector-item {
font-size: 16px; font-size: 16px;
text-align: center; text-align: center;
border-bottom: solid 1px #DDDDDD; border-bottom: solid 1px #DDDDDD;
padding: 10px; padding: 10px;
cursor: pointer; cursor: pointer;
text-align: left; text-align: left;
.name{
.name {
height: 18px; height: 18px;
line-height: 18px; line-height: 18px;
color: #3da7e7; color: #3da7e7;
font-size: 16px; font-size: 16px;
font-weight: bold; font-weight: bold;
} }
.address{
.address {
font-size: 14px; font-size: 14px;
height: 16px; height: 16px;
line-height: 16px; line-height: 16px;
color: #666666; color: #666666;
} }
} }
</style> </style>

@ -26,7 +26,7 @@
<!-- 选择参数 --> <!-- 选择参数 -->
<view class="br bg-white parameter width100 " @click="showPopup(1)"> <view class="br bg-white parameter width100 " @click="showPopup(1)">
<view class=" "> <view class=" font16">
选择 选择
</view> </view>
<view class="color999 font14"> <view class="color999 font14">
@ -36,7 +36,7 @@
</view> </view>
<!-- 保障 --> <!-- 保障 -->
<view class="br bg-white parameter width100 " @click="showPopup(2)"> <view class="br bg-white parameter width100 " @click="showPopup(2)">
<view class=" "> <view class="font16 ">
保障 保障
</view> </view>
<view class="color999 font14"> <view class="color999 font14">

@ -1,6 +1,6 @@
<template> <template>
<wybPopup @touchmove.stop ref="popup" zIndex="999" type="bottom" width="500" height="500" :scrollY="true" radius="0" :showCloseIcon="true"> <wybPopup @touchmove.stop ref="popup" zIndex="999" type="bottom" width="500" height="500" :scrollY="true" radius="0" :showCloseIcon="true">
<view class="pd-main wuliupop height100 border-box backcor9"> <view class="pd-main wuliupop border-box backcor9">
<view class="pop-title fontwig6 backcor9"><text>物流信息</text></view> <view class="pop-title fontwig6 backcor9"><text>物流信息</text></view>
<view class="pd-main backcolorfff border-8r font14" > <view class="pd-main backcolorfff border-8r font14" >
<view class="dis-flex flex-sp mart10 marb10 paddbotm10 border-b"> <view class="dis-flex flex-sp mart10 marb10 paddbotm10 border-b">
@ -286,6 +286,7 @@
.wuliupop{ .wuliupop{
padding: 50px 10px 10px; padding: 50px 10px 10px;
min-height: 100%;
} }
.pop-title{ .pop-title{
text-align: center; text-align: center;

@ -794,7 +794,9 @@ $uni-font-size-paragraph:30upx;
.paddbotm20 { .paddbotm20 {
padding-bottom: 20px; padding-bottom: 20px;
} }
.paddbotm60 {
padding-bottom: 60px;
}
/*内边距*/ /*内边距*/
.pd-main{ .pd-main{
@ -803,6 +805,10 @@ $uni-font-size-paragraph:30upx;
.pd-lr{ .pd-lr{
padding:0 20rpx; padding:0 20rpx;
} }
.pd-h{
padding-left: 20rpx;
padding-right: 20rpx;
}
/* 左悬浮 */ /* 左悬浮 */
.flleft { .flleft {
float: left; float: left;

Loading…
Cancel
Save