|
| 1 | + <template> |
| 2 | + <div class="address_page"> |
| 3 | + <head-top head-title="添加地址" go-back='true'></head-top> |
| 4 | + <section class="page_text_container"> |
| 5 | + <section class="section_list"> |
| 6 | + <span class="section_left">联系人</span> |
| 7 | + <section class="section_right"> |
| 8 | + <input type="text" name="name" placeholder="你的名字" v-model="name" class="input_style"> |
| 9 | + <div class="choose_sex"> |
| 10 | + <span class="choose_option"> |
| 11 | + <svg class="address_empty_right" @click="chooseSex(1)" :class="{choosed: sex == 1}"> |
| 12 | + <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#select"></use> |
| 13 | + </svg> |
| 14 | + <span>先生</span> |
| 15 | + </span> |
| 16 | + <span class="choose_option"> |
| 17 | + <svg class="address_empty_right" @click="chooseSex(2)" :class="{choosed: sex == 2}"> |
| 18 | + <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#select"></use> |
| 19 | + </svg> |
| 20 | + <span>女士</span> |
| 21 | + </span> |
| 22 | + </div> |
| 23 | + </section> |
| 24 | + </section> |
| 25 | + <section class="section_list"> |
| 26 | + <span class="section_left">联系电话</span> |
| 27 | + <section class="section_right"> |
| 28 | + <div class="phone_add"> |
| 29 | + <input type="text" name="phone" placeholder="你的手机号" v-model="phone" class="input_style"> |
| 30 | + <img src="../../../../images/add_phone.png" height="20" width="20" @click="phone_bk = true"> |
| 31 | + </div> |
| 32 | + <input v-if="phone_bk" type="text" name="anntherPhoneNumber" placeholder="备选电话" v-model="anntherPhoneNumber" class="input_style phone_bk"> |
| 33 | + </section> |
| 34 | + </section> |
| 35 | + <section class="section_list"> |
| 36 | + <span class="section_left">送餐地址</span> |
| 37 | + <section class="section_right"> |
| 38 | + <router-link to="/confirmOrder/chooseAddress/addAddress/searchAddress" tag="div" class="choose_address">{{searchAddress? searchAddress.name : '小区/写字楼/学校等'}}</router-link> |
| 39 | + <input type="text" name="address_detail" placeholder="详细地址(如门牌号等)" v-model="address_detail" class="input_style"> |
| 40 | + |
| 41 | + </section> |
| 42 | + </section> |
| 43 | + <section class="section_list"> |
| 44 | + <span class="section_left">标签</span> |
| 45 | + <section class="section_right"> |
| 46 | + <input type="text" name="tag" placeholder="无/家/学校/公司" v-model="tag" class="input_style"> |
| 47 | + </section> |
| 48 | + </section> |
| 49 | + </section> |
| 50 | + <div class="determine" @click="addAddress">确定</div> |
| 51 | + <alert-tip v-if="showAlert" @closeTip="showAlert = false" :alertText="alertText"></alert-tip> |
| 52 | + <transition name="router-slid"> |
| 53 | + <router-view></router-view> |
| 54 | + </transition> |
| 55 | + </div> |
| 56 | +</template> |
| 57 | + |
| 58 | +<script> |
| 59 | + import headTop from '../../../../components/header/head' |
| 60 | + import {mapState, mapMutations} from 'vuex' |
| 61 | + import {getAddress, getUser, postAddAddress} from '../../../../service/getData' |
| 62 | + import alertTip from '../../../../components/common/alertTip' |
| 63 | +
|
| 64 | + export default { |
| 65 | + data(){ |
| 66 | + return{ |
| 67 | + name: null, |
| 68 | + sex: 1, |
| 69 | + phone: null, |
| 70 | + address_detail: null, |
| 71 | + tag: '', |
| 72 | + tag_type: 1, |
| 73 | + phone_bk: false, |
| 74 | + anntherPhoneNumber: '', |
| 75 | + showAlert: false, |
| 76 | + alertText: null, |
| 77 | + poi_type: 0, |
| 78 | + } |
| 79 | + }, |
| 80 | + created(){ |
| 81 | + |
| 82 | + }, |
| 83 | + components: { |
| 84 | + headTop, |
| 85 | + alertTip, |
| 86 | + }, |
| 87 | + computed: { |
| 88 | + ...mapState([ |
| 89 | + 'searchAddress', 'geohash', 'userInfo', |
| 90 | + ]), |
| 91 | + }, |
| 92 | + methods: { |
| 93 | + ...mapMutations([ |
| 94 | + |
| 95 | + ]), |
| 96 | + chooseSex(sex){ |
| 97 | + this.sex = sex; |
| 98 | + }, |
| 99 | + async addAddress(){ |
| 100 | + if (!(this.userInfo && this.userInfo.user_id)) { |
| 101 | + this.showAlert = true; |
| 102 | + this.alertText = '请登陆' |
| 103 | + }else if(!this.name){ |
| 104 | + this.showAlert = true; |
| 105 | + this.alertText = '请输入姓名' |
| 106 | + }else if(!this.phone){ |
| 107 | + this.showAlert = true; |
| 108 | + this.alertText = '请输入电话号码' |
| 109 | + }else if(!this.searchAddress){ |
| 110 | + this.showAlert = true; |
| 111 | + this.alertText = '请选择地址' |
| 112 | + }else if(!this.address_detail){ |
| 113 | + this.showAlert = true; |
| 114 | + this.alertText = '请输入详细地址' |
| 115 | + } |
| 116 | + if (this.tag == '家') { |
| 117 | + this.tag_type = 2; |
| 118 | + }else if(this.tag == '学校'){ |
| 119 | + this.tag_type = 3; |
| 120 | + }else if(this.tag == '公司'){ |
| 121 | + this.tag_type = 4; |
| 122 | + } |
| 123 | + let res = await postAddAddress(this.userInfo.user_id, this.searchAddress.name, this.address_detail, this.geohash, this.name, this.phone, this.anntherPhoneNumber, 0, this.sex, this.tag, this.tag_type); |
| 124 | + this.$router.go(-1); |
| 125 | + }, |
| 126 | + } |
| 127 | + } |
| 128 | +</script> |
| 129 | + |
| 130 | +<style lang="scss" scoped> |
| 131 | + @import '../../../../style/mixin'; |
| 132 | + |
| 133 | + .address_page{ |
| 134 | + position: fixed; |
| 135 | + top: 0; |
| 136 | + left: 0; |
| 137 | + right: 0; |
| 138 | + bottom: 0; |
| 139 | + background-color: #f5f5f5; |
| 140 | + z-index: 204; |
| 141 | + padding-top: 1.95rem; |
| 142 | + p, span, input{ |
| 143 | + font-family: Helvetica Neue,Tahoma,Arial; |
| 144 | + } |
| 145 | + } |
| 146 | + .page_text_container{ |
| 147 | + background-color: #fff; |
| 148 | + padding: 0 .7rem; |
| 149 | + } |
| 150 | + .section_list{ |
| 151 | + display: flex; |
| 152 | + border-bottom: 0.025rem solid #f5f5f5; |
| 153 | + .section_left{ |
| 154 | + @include sc(.7rem, #333); |
| 155 | + flex: 2; |
| 156 | + line-height: 2.5rem; |
| 157 | + } |
| 158 | + .section_right{ |
| 159 | + flex: 5; |
| 160 | + .input_style{ |
| 161 | + width: 100%; |
| 162 | + height: 2.5rem; |
| 163 | + @include sc(.7rem, #999); |
| 164 | + } |
| 165 | + .phone_bk{ |
| 166 | + border-top: 0.025rem solid #f5f5f5; |
| 167 | + } |
| 168 | + .phone_add{ |
| 169 | + @include fj; |
| 170 | + align-items: center; |
| 171 | + } |
| 172 | + .choose_sex{ |
| 173 | + display: flex; |
| 174 | + line-height: 2.5rem; |
| 175 | + border-top: 0.025rem solid #f5f5f5; |
| 176 | + .choose_option{ |
| 177 | + @include sc(.7rem, #333); |
| 178 | + display: flex; |
| 179 | + align-items: center; |
| 180 | + margin-right: .8rem; |
| 181 | + svg{ |
| 182 | + margin-right: .3rem; |
| 183 | + @include wh(.8rem, .8rem); |
| 184 | + fill: #ccc; |
| 185 | + } |
| 186 | + .choosed{ |
| 187 | + fill: #4cd964; |
| 188 | + } |
| 189 | + } |
| 190 | + } |
| 191 | + .choose_address{ |
| 192 | + @include sc(.7rem, #999); |
| 193 | + line-height: 2.5rem; |
| 194 | + border-bottom: 0.025rem solid #f5f5f5; |
| 195 | + } |
| 196 | + } |
| 197 | + } |
| 198 | + .determine{ |
| 199 | + background-color: #4cd964; |
| 200 | + @include sc(.7rem, #fff); |
| 201 | + text-align: center; |
| 202 | + margin: 0 .7rem; |
| 203 | + line-height: 1.8rem; |
| 204 | + border-radius: 0.2rem; |
| 205 | + margin-top: .6rem; |
| 206 | + } |
| 207 | + .router-slid-enter-active, .router-slid-leave-active { |
| 208 | + transition: all .4s; |
| 209 | + } |
| 210 | + .router-slid-enter, .router-slid-leave-active { |
| 211 | + transform: translateX(100%); |
| 212 | + } |
| 213 | +</style> |
0 commit comments