yurong/.svn/pristine/80/809e31e240cd8faee0f4b46022e...

126 lines
3.8 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view>
<!-- <uni-nav-bar @clickLeft="goBack" left-icon="arrowleft" color="#000" :border="false" :title="buttonText" /> -->
<view class="ml-55 w-640 mt-30">
<view class="rows fs-28 col333 pb-30" style="border-bottom: 1rpx solid #eee;">
<text class="f-2">收货人:</text>
<input class="w90 f-7 fs-28" v-model="info.name" placeholder="请输入姓名" placeholder-class="colddd" type="text"/>
</view>
<view class="rows mt-30 fs-28 col333 pb-30" style="border-bottom: 1rpx solid #eee;">
<text class="f-2">手机号码:</text>
<input maxlength="11" class="w90 f-7 fs-28" v-model="info.mobile" placeholder="请输入手机号码" placeholder-class="colddd" type="number"/>
</view>
<wangdingPickerAddress @change="addressChange($event)">
<view class="rows mt-30 fs-28 col333 pb-30" style="border-bottom: 1rpx solid #eee;">
<text class="f-2">省市区:</text>
<text class="f-7 col999 fs-28 tlt">{{info.areas===''?'请选择省市区':info.areas}}</text>
</view>
</wangdingPickerAddress>
<view class="rows mt-30 fs-28 col333 pb-30" style="border-bottom: 1rpx solid #eee;">
<text class="f-2">详细地址:</text>
<input class="w90 f-7 fs-28" v-model="info.address" placeholder="详细地址例如3号楼5层501室" placeholder-class="colddd" type="text"/>
</view>
<view class="rows rowsm mt-20 fs-28 col333 pb-20" style="border-bottom: 1rpx solid #eee;">
<text class="f-2">设为默认地址:</text>
<switch @change="swtichChange($event)" :checked="info.default == 1" color="#fc4a45" style="transform:scale(0.6)"></switch>
</view>
<view @tap="newAddress()" class="w-630 h-100 lh-100 mt-50 tct colfff br-50 bg">
{{buttonText}}
</view>
</view>
</view>
</template>
<script>
import wangdingPickerAddress from '@/components/wangding-pickerAddress/wangding-pickerAddress.vue';
export default {
data() {
return {
info: {
type: 1,
name: '',
mobile: '',
areas: '',
address: '',
default: '1'
},
buttonText: '新增地址'
}
},
components: {
wangdingPickerAddress
},
onLoad(option) {
if (option.id) {
uni.setNavigationBarTitle({
title: '修改地址'
})
this.buttonText = '修改地址'
this.getAddress(option.id)
}
if (option.type == '1') {
this.$tools.showtt('请先填写地址再下单')
}
},
methods: {
chooseLocation() {//选择收货地址
let that = this
uni.chooseLocation({
success(res) {
console.log(res)
that.info.lon = res.longitude;
that.info.lat = res.latitude;
}
})
},
newAddress() {//点击新增地址
let that = this
function ifNull() {//判断对象的值是否为空
for (let val in that.info) {
return that.info[val] !== ''
}
}
if (ifNull()&&that.$tools.isPhone(that.info.mobile)) {
let path = 'user/add_address'
if (this.buttonText == '修改地址') path = 'index/edit_address'
that.axiosFromToken('POST',path,this.info,'请稍等').then(res => {
if(res.code == 1) {
this.goBack(1)
this.showtt(res.msg,'succesc')
}
this.showtt(res.msg)
})
} else {
that.showtt('请检查信息是否填写并正确')
}
},
addressChange(e) {//选择省市区
this.info.areas = e.data.join()
},
swtichChange(e) {//滑块点击
this.info.default = e.detail.value?'1':'0'
},
//获取地址列表
getAddress(id) {
this.$tools.axiosFromToken('POST','user/sel_address',{type:2}, '加载中').then(res => {
let arr = res.data.filter(val => val.id == id)
this.info = arr[0]
this.info.id = id
})
}
}
}
</script>
<style>
page {
background: #fff;
}
</style>