123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- <template>
- <view class="content">
- <view class="row b-b">
- <input class="input" type="text" @click="changeshow" v-model="addressData.addressName" placeholder="省,城市,区县" placeholder-class="placeholder" />
- </view>
-
- <view class="row b-b">
- <input class="input" type="text" v-model="addressData.area" placeholder="详细地址,如街道,楼牌号等" placeholder-class="placeholder" />
- </view>
-
- <view class="row b-b">
- <input class="input" type="text" v-model="addressData.name" placeholder="姓名" placeholder-class="placeholder" />
- </view>
- <view class="row b-b">
- <input class="input" type="number" v-model="addressData.mobile" placeholder="电话" placeholder-class="placeholder" />
- </view>
- <button class="add-btn" @click="confirm">保存</button>
- <van-area v-if="show" class="overadress" @confirm="choseCity" @cancel="cancelCity" :area-list="areaList" />
- <view v-if="show" class="over"></view>
- </view>
- </template>
- <script>
- import mpvueCityPicker from '@/component/mpvue-citypicker/mpvueCityPicker.vue'
- export default {
- components: {
- mpvueCityPicker
- },
- data() {
- return {
- addressData: {
- name: '',
- mobile: '',
- address: '',
- area: '',
- default: false
- },
- show: false,
- areaList:{
- province_list: {
- 110000: '北京市',
- 120000: '天津市'
- },
- city_list: {
- 110100: '北京市',
- 110200: '县',
- 120100: '天津市',
- 120200: '县'
- },
- county_list: {
- 110101: '东城区',
- 110102: '西城区',
- 110105: '朝阳区',
- 110106: '丰台区',
- 120101: '和平区',
- 120102: '河东区',
- 120103: '河西区',
- 120104: '南开区',
- 120105: '河北区'
- }
- }
- }
- },
- onLoad(option){
- let title = '新增收货地址';
- if(option.type==='edit'){
- title = '编辑收货地址'
-
- this.addressData = JSON.parse(option.data)
- }
- this.manageType = option.type;
- uni.setNavigationBarTitle({
- title
- })
- },
- methods: {
- switchChange(e){
- this.addressData.default = e.detail;
- },
- changeshow() {
- this.show = !this.show;
- },
- cancelCity() {
- this.show = false;
- },
- choseCity(e) {
- console.log(e);
- this.show = false;
- },
-
- //提交
- confirm(){
- let data = this.addressData;
- if(!data.name){
- this.$api.msg('请填写收货人姓名');
- return;
- }
- if(!/(^1[3|4|5|7|8][0-9]{9}$)/.test(data.mobile)){
- this.$api.msg('请输入正确的手机号码');
- return;
- }
- if(!data.address){
- this.$api.msg('请在地图选择所在位置');
- return;
- }
- if(!data.area){
- this.$api.msg('请填写门牌号信息');
- return;
- }
-
- //this.$api.prePage()获取上一页实例,可直接调用上页所有数据和方法,在App.vue定义
- this.$api.prePage().refreshList(data, this.manageType);
- this.$api.msg(`地址${this.manageType=='edit' ? '修改': '添加'}成功`);
- setTimeout(()=>{
- uni.navigateBack()
- }, 800)
- },
- }
- }
- </script>
- <style lang="scss">
- page{
- background: $page-color-base;
- padding-top: 16upx;
- }
- .row{
- display: flex;
- align-items: center;
- position: relative;
- padding:0 30upx;
- height: 110upx;
- background: #fff;
-
- .tit{
- flex-shrink: 0;
- width: 120upx;
- font-size: 30upx;
- color: $font-color-dark;
- }
- .input{
- flex: 1;
- font-size: 30upx;
- color: $font-color-dark;
- }
- .icon-shouhuodizhi{
- font-size: 36upx;
- color: $font-color-light;
- }
- }
- .default-row{
- margin-top: 16upx;
- .tit{
- flex: 1;
- }
- switch{
- transform: translateX(16upx) scale(.9);
- }
- }
- .add-btn{
- display: flex;
- align-items: center;
- justify-content: center;
- width: 690upx;
- height: 80upx;
- margin: 60upx auto;
- font-size: $font-lg;
- color: #fff;
- background-color: #D9332E;
- border-radius: 10upx;
- box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
- }
- .over {
- position:absolute;left:0px;top:0px;
- background:rgba(0, 0, 0, 0.4);
- width:100%; /*宽度设置为100%,这样才能使隐藏背景层覆盖原页面*/
- height:100%;
- filter:alpha(opacity=60); /*设置透明度为60%*/
- opacity:0.6; /*非IE浏览器下设置透明度为60%*/
- z-Index:100;
- }
- .overadress {
- position: fixed;
- bottom: 0;
- left: 0;
- z-index: 999;
- width: 100%;
- }
- </style>
|