Skip to content

Commit b6a87f7

Browse files
committed
confrim
1 parent a8df5a4 commit b6a87f7

File tree

22 files changed

+1131
-107
lines changed

22 files changed

+1131
-107
lines changed

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ vue2 + vue-rotuer2 + vuex + webpack + ES6/7 + fetch + sass + flex + svg + http-p
6666
| |-- city // 当前城市页
6767
| |-- food // 食品筛选排序页
6868
| |-- confirmOrder // 确认订单页
69-
| |--children
69+
| |--children
70+
| |--chooseAddress // 选择地址页
71+
| |--children
72+
| |--addAddress // 添加地址页
73+
| |--children
74+
| |--searchAddress // 搜索地址页
75+
| |--invoice // 选择发票页
7076
| |--remark // 订单备注页
7177
| |-- forget // 忘记密码,修改密码页
7278
| |-- home // 首页
@@ -83,9 +89,10 @@ vue2 + vue-rotuer2 + vuex + webpack + ES6/7 + fetch + sass + flex + svg + http-p
8389
| |-- search // 搜索页
8490
|       |-- shop                     // 商铺筛选页
8591
| |-- children
86-
| |-- foodDetail // 单个商铺信息页
87-
| |-- shopDetail // 商铺信息页
88-
| |-- shopSafe // 商铺认证信息页
92+
| |-- foodDetail // 单个商铺信息页
93+
| |-- children
94+
| |-- shopSafe // 商铺认证信息页
95+
| |-- shopDetail // 商铺信息页
8996
| |-- vipcard // vip办理页
9097
|
9198
| |-- plugins // 引用的插件

src/components/common/alertTip.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
mounted(){
2323
2424
},
25-
props: ['showHide','alertText'],
25+
props: ['alertText'],
2626
methods: {
2727
closeTip(){
2828
this.$emit('closeTip')

src/components/header/head.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</template>
2525

2626
<script>
27-
import {mapState, mapMutations} from 'vuex'
27+
import {mapState, mapActions} from 'vuex'
2828
export default {
2929
data(){
3030
return{
@@ -33,10 +33,12 @@
3333
},
3434
created(){
3535
//获取本地存储的用户信息
36-
this.GET_USERINFO();
36+
if (this.signinUp) {
37+
this.getUserInfo();
38+
}
3739
},
3840
mounted(){
39-
41+
4042
},
4143
props: ['signinUp', 'headTitle', 'goBack'],
4244
computed: {
@@ -45,8 +47,8 @@
4547
]),
4648
},
4749
methods: {
48-
...mapMutations([
49-
'GET_USERINFO',
50+
...mapActions([
51+
'getUserInfo'
5052
]),
5153
},
5254

src/config/fetch.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import {baseUrl} from './env'
1+
import {
2+
baseUrl
3+
} from './env'
24

3-
export default async (type = 'GET', url = '', data = {}) => {
5+
export default async(type = 'GET', url = '', data = {}, method = 'fetch') => {
46
type = type.toUpperCase();
57
url = baseUrl + url;
68

@@ -16,16 +18,16 @@ export default async (type = 'GET', url = '', data = {}) => {
1618
}
1719
}
1820

19-
if (window.fetch) {
21+
if (window.fetch && method == 'fetch') {
2022
let requestConfig = {
2123
credentials: 'include',
22-
method: type,
23-
headers: {
24-
'Accept': 'application/json',
25-
'Content-Type': 'application/json'
26-
},
27-
mode: "cors",
28-
cache: "only-if-cached"
24+
method: type,
25+
headers: {
26+
'Accept': 'application/json',
27+
'Content-Type': 'application/json'
28+
},
29+
mode: "cors",
30+
cache: "only-if-cached"
2931
}
3032

3133
if (type == 'POST') {
@@ -37,12 +39,11 @@ export default async (type = 'GET', url = '', data = {}) => {
3739
try {
3840
var response = await fetch(url, requestConfig);
3941
var responseJson = await response.json();
40-
}catch (error){
42+
} catch (error) {
4143
throw new Error(error)
4244
}
43-
4445
return responseJson
45-
}else{
46+
} else {
4647
let requestObj;
4748
if (window.XMLHttpRequest) {
4849
requestObj = new XMLHttpRequest();
@@ -62,12 +63,13 @@ export default async (type = 'GET', url = '', data = {}) => {
6263
requestObj.onreadystatechange = () => {
6364
if (requestObj.readyState == 4) {
6465
if (requestObj.status == 200) {
66+
6567
let obj = requestObj.response
6668
if (typeof obj !== 'object') {
6769
obj = JSON.parse(obj);
6870
}
6971
return obj
70-
}else {
72+
} else {
7173
throw new Error(requestObj)
7274
}
7375
}

src/images/add_address.png

1.1 KB
Loading

src/images/add_phone.png

186 Bytes
Loading

src/images/search.png

1019 Bytes
Loading
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
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

Comments
 (0)