|
|
@@ -0,0 +1,245 @@
|
|
|
+<config>
|
|
|
+{
|
|
|
+ "navigationBarTitleText": "新增地址",
|
|
|
+ "navigationBarBackgroundColor": "#ffffff",
|
|
|
+ "navigationBarTextStyle": "black",
|
|
|
+ "backgroundTextStyle":"light"
|
|
|
+}
|
|
|
+</config>
|
|
|
+<template>
|
|
|
+ <div class="container">
|
|
|
+ <van-cell-group>
|
|
|
+ <van-field
|
|
|
+ :value="form.name"
|
|
|
+ @input="form.name = $event.detail"
|
|
|
+ placeholder="请填写您的姓名"
|
|
|
+ label="联系人"
|
|
|
+ />
|
|
|
+ <van-field
|
|
|
+ type="number"
|
|
|
+ :value="form.phone"
|
|
|
+ @input="form.phone = $event.detail"
|
|
|
+ placeholder="请填写您的手机号码"
|
|
|
+ label="手机号"
|
|
|
+ />
|
|
|
+ <van-field
|
|
|
+ @click="$refs.area.init()"
|
|
|
+ :value="showCity"
|
|
|
+ readonly
|
|
|
+ is-link
|
|
|
+ placeholder="请选择省市区"
|
|
|
+ label="地区"
|
|
|
+ />
|
|
|
+ <van-field
|
|
|
+ :value="form.detail"
|
|
|
+ @input="form.detail = $event.detail"
|
|
|
+ placeholder="请填写您的详细地址"
|
|
|
+ label="详细地址"
|
|
|
+ type="textarea"
|
|
|
+ autosize
|
|
|
+ />
|
|
|
+ </van-cell-group>
|
|
|
+ <div class="box-but">
|
|
|
+ <div class="default">
|
|
|
+ <van-checkbox :checked-color="$colors.info" :value="form.enabled" @change="form.enabled = $event.detail"
|
|
|
+ >设为默认地址</van-checkbox
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="box-but-con">
|
|
|
+ <van-button :color="$colors.prim" :disabled="!canSubmit" block @click="addRess">确认</van-button>
|
|
|
+ <div class="container-cancel" @click="refWx">获取微信地址</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <area-select
|
|
|
+ ref="area"
|
|
|
+ :province.sync="form.province"
|
|
|
+ :city.sync="form.city"
|
|
|
+ :region.sync="form.district"
|
|
|
+ ></area-select>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import areaSelect from '../components/areaSelect.vue';
|
|
|
+export default {
|
|
|
+ name: 'detail',
|
|
|
+ components: { areaSelect },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ form: {
|
|
|
+ enabled: false,
|
|
|
+ name: '',
|
|
|
+ phone: '',
|
|
|
+ city: '',
|
|
|
+ detail: '',
|
|
|
+ province: '',
|
|
|
+ district: ''
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ showCity() {
|
|
|
+ return this.form.province + this.form.city + this.form.district;
|
|
|
+ },
|
|
|
+ canSubmit() {
|
|
|
+ if (this.form.name && this.form.phone && this.form.city && this.form.detail) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ addRess() {
|
|
|
+ if (!this.form.name) {
|
|
|
+ wx.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '收货人不能为空'
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!/^1[3-9]\d{9}$/.test(this.form.phone)) {
|
|
|
+ this.toast('请输入正确手机号');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.form.city) {
|
|
|
+ wx.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '地区不能为空'
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.form.detail) {
|
|
|
+ wx.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '详细地址不能为空'
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // let form = { ...this.form };
|
|
|
+ // if (!form.id) {
|
|
|
+ // form.userId = this.$store.state.userInfo.id;
|
|
|
+ // }
|
|
|
+ // this.$http
|
|
|
+ // .post('/address/save', form, { body: 'json' })
|
|
|
+ // .then(res => {
|
|
|
+ // console.log(res);
|
|
|
+ // wx.hideLoading();
|
|
|
+ // wx.showToast({
|
|
|
+ // title: '保存成功'
|
|
|
+ // });
|
|
|
+ // setTimeout(() => {
|
|
|
+ // this.navigateBack();
|
|
|
+ // }, 1500);
|
|
|
+ // })
|
|
|
+ // .catch(e => {
|
|
|
+ // wx.hideLoading();
|
|
|
+ // wx.showToast({
|
|
|
+ // icon: 'none',
|
|
|
+ // title: e.error
|
|
|
+ // });
|
|
|
+ // });
|
|
|
+ },
|
|
|
+ refWx() {
|
|
|
+ wx.chooseAddress({
|
|
|
+ success: res => {
|
|
|
+ this.form = {
|
|
|
+ enabled: false,
|
|
|
+ name: res.userName,
|
|
|
+ phone: res.telNumber,
|
|
|
+ city: res.cityName,
|
|
|
+ detail: res.detailInfo,
|
|
|
+ province: res.provinceName,
|
|
|
+ district: res.countyName
|
|
|
+ };
|
|
|
+ },
|
|
|
+ fail: function(err) {
|
|
|
+ console.log(JSON.stringify(err));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onLoad(options) {
|
|
|
+ // if (options.id) {
|
|
|
+ // wx.setNavigationBarTitle({
|
|
|
+ // title: '编辑地址'
|
|
|
+ // });
|
|
|
+ // this.$http.get('/address/get/' + options.id).then(res => {
|
|
|
+ // this.form = res;
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="less" scoped>
|
|
|
+/deep/ .van-cell {
|
|
|
+ --cell-vertical-padding: 23px;
|
|
|
+ --cell-horizontal-padding: 20px;
|
|
|
+ --field-label-color: #000000;
|
|
|
+ --cell-text-color: #000;
|
|
|
+ .van-field__label,
|
|
|
+ .van-cell__title {
|
|
|
+ font-weight: bold;
|
|
|
+ width: 70px;
|
|
|
+ max-width: 70px !important;
|
|
|
+ min-width: 70px !important;
|
|
|
+ flex-shrink: 0;
|
|
|
+ margin-right: 10px !important;
|
|
|
+ }
|
|
|
+ .van-cell__value {
|
|
|
+ text-align: left;
|
|
|
+ }
|
|
|
+
|
|
|
+ &::after {
|
|
|
+ left: 100px !important;
|
|
|
+ }
|
|
|
+}
|
|
|
+/deep/ .van-button {
|
|
|
+ background: #159eff !important;
|
|
|
+ border-color: #159eff !important;
|
|
|
+}
|
|
|
+.container {
|
|
|
+ .box-but {
|
|
|
+ background: #f5f7fa;
|
|
|
+ width: 100%;
|
|
|
+ height: 500px;
|
|
|
+ .box-img {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ padding: 16px 0 0 20px;
|
|
|
+ img {
|
|
|
+ width: 16px;
|
|
|
+ height: 16px;
|
|
|
+ margin-right: 10px;
|
|
|
+ }
|
|
|
+ p {
|
|
|
+ height: 18px;
|
|
|
+ font-size: 13px;
|
|
|
+ font-weight: 400;
|
|
|
+ color: #000000;
|
|
|
+ line-height: 18px;
|
|
|
+ padding-left: 2px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .box-but-con {
|
|
|
+ margin: 0 43px;
|
|
|
+ .container-cancel {
|
|
|
+ margin-top: 20px;
|
|
|
+ width: 290px;
|
|
|
+ height: 48px;
|
|
|
+ border-radius: 12px;
|
|
|
+ border: 1px solid #159eff;
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: 400;
|
|
|
+ color: #159eff;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 48px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.default {
|
|
|
+ padding: 17px 20px;
|
|
|
+}
|
|
|
+</style>
|