|
@@ -9,33 +9,30 @@
|
|
|
<uni-forms-item label="联系电话" name="phone">
|
|
|
<uni-easyinput type="number" v-model="form.phone" placeholder="请输入联系电话" />
|
|
|
</uni-forms-item>
|
|
|
- <uni-forms-item label="地图选点" v-if="is_wx==true">
|
|
|
+ <uni-forms-item label="地图选点">
|
|
|
<button type="default" size="mini" class="toLoacl" @click="toLocaltion()">地图选点</button>
|
|
|
</uni-forms-item>
|
|
|
- <uni-forms-item label="所在省份" name="province">
|
|
|
+ <uni-forms-item label="所在省份">
|
|
|
<picker class="picker" mode="selector" :range="provinceList" @change="proChange" range-key="value">
|
|
|
<view>{{form.province||'请选择所在省份'}}</view>
|
|
|
</picker>
|
|
|
</uni-forms-item>
|
|
|
- <uni-forms-item label="所在市" name="city">
|
|
|
+ <uni-forms-item label="所在市">
|
|
|
<picker class="picker" mode="selector" :range="cityList" @change="cityChange" range-key="value">
|
|
|
<view>{{form.city||'请选择所在市'}}</view>
|
|
|
</picker>
|
|
|
</uni-forms-item>
|
|
|
- <uni-forms-item label="所在区" name="area">
|
|
|
+ <uni-forms-item label="所在区">
|
|
|
<picker class="picker" mode="selector" :range="areaList" @change="areaChange" range-key="value">
|
|
|
<view>{{form.area||'请选择所在区'}}</view>
|
|
|
</picker>
|
|
|
</uni-forms-item>
|
|
|
<uni-forms-item label="详细地址" name="address">
|
|
|
- <uni-easyinput type="textarea" v-model="form.address" placeholder="请输入详细地址" />
|
|
|
- </uni-forms-item>
|
|
|
- <uni-forms-item label="是否默认" name="is_default">
|
|
|
- <switch color="#FB1438" :checked="form.is_default=='1'?true:false" @change="defaChange" />
|
|
|
+ <uni-easyinput type="textarea" v-model="form.address" placeholder="请输入所在小区/大厦/学校" />
|
|
|
</uni-forms-item>
|
|
|
</uni-forms>
|
|
|
<view class="btn">
|
|
|
- <button type="primary" size="mini" @click="onSubmit('form')">提交保存</button>
|
|
|
+ <button type="primary" @click="onSubmit('form')" size="small">提交保存</button>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -43,51 +40,38 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+ const chooseLocation = requirePlugin('chooseLocation');
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- is_wx: true,
|
|
|
- user: {},
|
|
|
id: '',
|
|
|
form: {},
|
|
|
rules: {
|
|
|
- name: {
|
|
|
- rules: [{
|
|
|
- required: true,
|
|
|
- errorMessage: '请输入收货人',
|
|
|
- }]
|
|
|
- },
|
|
|
- phone: {
|
|
|
- rules: [{
|
|
|
- required: true,
|
|
|
- errorMessage: '请输入联系电话',
|
|
|
- tel: true
|
|
|
- }]
|
|
|
- },
|
|
|
- province: {
|
|
|
- rules: [{
|
|
|
- required: true,
|
|
|
- errorMessage: '请选择所在省'
|
|
|
- }]
|
|
|
- },
|
|
|
- city: {
|
|
|
- rules: [{
|
|
|
- required: true,
|
|
|
- errorMessage: '请选择所在市'
|
|
|
- }]
|
|
|
- },
|
|
|
- area: {
|
|
|
- rules: [{
|
|
|
- required: false,
|
|
|
- errorMessage: '请选择所在区'
|
|
|
- }]
|
|
|
- },
|
|
|
- address: {
|
|
|
- rules: [{
|
|
|
- required: true,
|
|
|
- errorMessage: '请输入详细地址'
|
|
|
- }]
|
|
|
- },
|
|
|
+ // name: {
|
|
|
+ // rules: [{
|
|
|
+ // required: true,
|
|
|
+ // errorMessage: '请输入收货人',
|
|
|
+ // }]
|
|
|
+ // },
|
|
|
+ // phone: {
|
|
|
+ // rules: [{
|
|
|
+ // required: true,
|
|
|
+ // errorMessage: '请输入联系电话',
|
|
|
+ // tel: true
|
|
|
+ // }]
|
|
|
+ // },
|
|
|
+ // deptname: {
|
|
|
+ // rules: [{
|
|
|
+ // required: true,
|
|
|
+ // errorMessage: '请输入机构名称'
|
|
|
+ // }]
|
|
|
+ // },
|
|
|
+ // address: {
|
|
|
+ // rules: [{
|
|
|
+ // required: true,
|
|
|
+ // errorMessage: '请输入详细地址'
|
|
|
+ // }]
|
|
|
+ // },
|
|
|
},
|
|
|
provinceList: [ //所在省份
|
|
|
{
|
|
@@ -137,46 +121,26 @@
|
|
|
onLoad: function(e) {
|
|
|
const that = this;
|
|
|
that.$set(that, `id`, e && e.id || '');
|
|
|
- that.watchLogin();
|
|
|
+ that.search()
|
|
|
},
|
|
|
onShow: function() {
|
|
|
const that = this;
|
|
|
- that.searchplatform();
|
|
|
- that.searchLocal();
|
|
|
+ that.searchLocal()
|
|
|
},
|
|
|
onUnload: function() {
|
|
|
- const chooseLocation = requirePlugin('chooseLocation');
|
|
|
chooseLocation.setLocation(null);
|
|
|
},
|
|
|
methods: {
|
|
|
- // 监听用户是否登录
|
|
|
- watchLogin() {
|
|
|
+ // 查询详细信息
|
|
|
+ async search() {
|
|
|
const that = this;
|
|
|
- uni.getStorage({
|
|
|
- key: 'token',
|
|
|
- success: async function(res) {
|
|
|
- let user = that.$jwt(res.data);
|
|
|
- if (user) {
|
|
|
- that.$set(that, `user`, user);
|
|
|
- if (that.id) {
|
|
|
- let arr = await that.$api(`/address/${that.id}`, 'GET')
|
|
|
- if (arr.errcode == '0') {
|
|
|
- that.$set(that, `form`, arr.data)
|
|
|
- }
|
|
|
- } else {
|
|
|
- that.$set(that, `form`, {
|
|
|
- name: user.name || '',
|
|
|
- phone: user.phone || ''
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- fail: function(err) {
|
|
|
- uni.reLaunch({
|
|
|
- url: '/pages/login/index'
|
|
|
- })
|
|
|
+ if (that.id) {
|
|
|
+ let res = await that.$api(`/address/${that.id}`, 'GET')
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ console.log(res.data);
|
|
|
+ that.$set(that, `form`, res.data)
|
|
|
}
|
|
|
- })
|
|
|
+ }
|
|
|
},
|
|
|
// 定位
|
|
|
toLocaltion() {
|
|
@@ -188,15 +152,8 @@
|
|
|
});
|
|
|
},
|
|
|
searchLocal() {
|
|
|
- const that = this;
|
|
|
- const chooseLocation = requirePlugin('chooseLocation');
|
|
|
const location = chooseLocation.getLocation();
|
|
|
- if (location) {
|
|
|
- that.$set(that.form, `province`, location.province || '');
|
|
|
- that.$set(that.form, `city`, location.city || '');
|
|
|
- that.$set(that.form, `area`, location.district || '');
|
|
|
- that.$set(that.form, `address`, location.address || '');
|
|
|
- }
|
|
|
+ console.log(location);
|
|
|
},
|
|
|
// 选择省份
|
|
|
proChange(e) {
|
|
@@ -222,52 +179,15 @@
|
|
|
that.$set(that.form, `city`, data.value)
|
|
|
}
|
|
|
},
|
|
|
- // 是否默认
|
|
|
- defaChange(e) {
|
|
|
- const that = this;
|
|
|
- let value = e.detail.value == true ? '1' : '0';
|
|
|
- that.$set(that.form, `is_default`, value)
|
|
|
- },
|
|
|
// 提交保存
|
|
|
- onSubmit(ref) {
|
|
|
+ onSubmit() {
|
|
|
const that = this;
|
|
|
- let id = that.id;
|
|
|
- let user = that.user;
|
|
|
- that.$refs[ref].validate().then(async params => {
|
|
|
- params.customer = user.id;
|
|
|
- let res;
|
|
|
- if (id) res = await that.$api(`/address/${id}`, 'POST', params)
|
|
|
- else res = await that.$api(`/address`, 'POST', params);
|
|
|
- if (res.errcode == '0') {
|
|
|
- uni.showToast({
|
|
|
- title: '维护信息成功',
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- uni.navigateBack({
|
|
|
- delta: 1
|
|
|
- })
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- title: res.errmsg,
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ let data = that.form;
|
|
|
+ data = {
|
|
|
+ ...data,
|
|
|
+ check: that.check
|
|
|
+ }
|
|
|
},
|
|
|
- // 查询平台
|
|
|
- searchplatform() {
|
|
|
- const that = this;
|
|
|
- uni.getStorage({
|
|
|
- key: 'system',
|
|
|
- success: function(res) {
|
|
|
- if (res.data.uniPlatform == 'mp-weixin') {
|
|
|
- that.$set(that, `is_wx`, true)
|
|
|
- } else {
|
|
|
- that.$set(that, `is_wx`, false)
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
@@ -291,16 +211,6 @@
|
|
|
border-radius: 5px;
|
|
|
padding: 2vw;
|
|
|
}
|
|
|
-
|
|
|
- .btn {
|
|
|
- text-align: center;
|
|
|
-
|
|
|
- button {
|
|
|
- width: 30%;
|
|
|
- font-size: 14px;
|
|
|
- background-color: var(--f35BColor);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|