Browse Source

完善收货地址逻辑,完善退出登录逻辑

master
邓平艺 4 years ago
parent
commit
b675761621
  1. 15
      pages/address/add/add.vue
  2. 77
      pages/address/list/list.vue
  3. 14
      pages/index/index/index.vue
  4. 12
      pages/user/my/center.vue
  5. 21
      pages/user/my/setting.vue

15
pages/address/add/add.vue

@ -8,7 +8,7 @@
<view class="info-item">
<label for="name">姓名:</label>
<view class="form-control">
<input type="text" id="name" data-type="accept_name" :value="detail.accept_name" @input="input" />
<input type="text" id="name" placeholder="请输入收货人姓名" data-type="accept_name" :value="detail.accept_name" @input="input" />
</view>
</view>
<view class="info-item">
@ -30,7 +30,7 @@
<view class="info-item">
<label for="phone">联系电话:</label>
<view class="form-control">
<input type="number" maxlength="11" id="phone" data-type="mobile" :value="detail.mobile" @input="input" />
<input type="number" maxlength="11" placeholder="请输入联系电话" id="phone" data-type="mobile" :value="detail.mobile" @input="input" />
</view>
</view>
@ -70,14 +70,14 @@
<view class="info-item">
<label for="address">详细地址:</label>
<view class="form-control">
<input type="text" id="address" data-type="address" :value="detail.address" @input="input" />
<input type="text" id="address" data-type="address" placeholder="请输入详细地址" :value="detail.address" @input="input" />
</view>
</view>
<!-- TODO -->
<view class="info-item">
<label for="name">门牌号:</label>
<view class="form-control">
<input type="text" id="name" data-type="house_num" :value="house_num" @input="input" />
<input type="text" id="name" placeholder="请输入门牌号(选填)" data-type="house_num" :value="house_num" @input="input" />
</view>
</view>
<view class="info-item">
@ -425,6 +425,7 @@ export default {
area: data.area,
address_name: data.address_name.join(" "),
address: data.address,
house_num: data.house_num,
sex: data.sex,
is_default: data.is_default ? 1 : 0
};
@ -496,6 +497,7 @@ export default {
address_name: data.address_name.join(" "),
address: data.address,
house_num: data.house_num,
sex: data.sex,
is_default: data.is_default ? 1 : 0
};
var token = this.$cookieStorage.get('user_token');
@ -625,9 +627,12 @@ export default {
watch: {}
};
</script>
<style rel="stylesheet/less" lang="less" scoped>
<style lang="less" scoped>
@import "add";
.identify-address>textarea{
border-color: #e5e5e5 !important;
}
/deep/.input-placeholder{
font-weight: initial;
}
</style>

77
pages/address/list/list.vue

@ -31,21 +31,22 @@
</view>
<view class="lf-row-between">
<view @tap="setInfo(item)">
<text class="lf-iconfont icon--1"></text>
<text class="lf-iconfont icon-bianji"></text>
<text class="lf-m-l-10">编辑</text>
</view>
<view class="lf-m-l-50" @click="deleteAddress(item)">
<text class="lf-iconfont icon--1"></text>
<view class="lf-m-l-50 lf-color-red" @click="deleteAddress(item, index)">
<text class="lf-iconfont icon-shanchu"></text>
<text class="lf-m-l-10">删除</text>
</view>
</view>
</view>
</view>
<lf-nocontent src="/static/images/empty.png" text="您还未添加地址" v-if="list.length <= 0 && !is_load"></lf-nocontent>
</view>
<view style="height: 230rpx;"></view>
<view class="add-address" @tap="add">
<view class="small-btn">
<text class="lf-iconfont icon--2"></text>
<text class="lf-iconfont icon-jia"></text>
<text class="lf-m-l-10">新增收货地址</text>
</view>
</view>
@ -61,7 +62,8 @@ export default {
list: [],
order_no: '',
url: '',
id:''
id:'',
is_load: true
};
},
@ -89,29 +91,62 @@ export default {
props: {},
methods: {
//
deleteAddress(item){
deleteAddress(item, index){
console.log("item", item)
var token = this.$cookieStorage.get('user_token');
this.$http.ajax({
api: '/api/address/'+ item.id,
method: 'DELETE',
header: {
Authorization: token
}
}).then(res => {
console.log("删除地址", res);
uni.showModal({
title: '温馨提示',
content: '您确定删除该收货地址吗?',
success: result => {
if(result.confirm){
var token = this.$cookieStorage.get('user_token');
this.$http.ajax({
api: '/api/address/'+ item.id,
method: 'DELETE',
header: {
Authorization: token
}
}).then(res => {
console.log("删除地址", res);
this.$msg('删除成功', {icon: 'success'});
this.list.splice(index, 1);
}).catch(err => {
this.$msg('删除失败', {icon: 'error'});
})
}
}
})
},
//
radioChange(e){
let current = e.target.value;
let id = null;
this.list.forEach((item, index) => {
if(current == index){
item.is_default = 1;
id = item.id;
}else{
item.is_default = 0;
}
})
this.switchDefaultAddress(id);
},
switchDefaultAddress(id){
var token = this.$cookieStorage.get('user_token');
this.$http.ajax({
api: 'api/address/'+ id,
method: 'PUT',
header: {
Authorization: token
},
data: {
is_default: 1
}
}).then(res => {
this.$msg('操作成功', {icon: 'success'});
}).catch(err => {
this.$msg('切换默认地址失败');
})
},
setInfo(e) {
// var from = e.currentTarget.dataset.info;
@ -150,6 +185,7 @@ export default {
//
queryAddressList() {
this.is_load = true;
var token = this.$cookieStorage.get('user_token');
this.$http.get({
api: 'api/address',
@ -159,7 +195,7 @@ export default {
}).then(res => {
if (res.statusCode == 200) {
res = res.data;
if (res.status) {
this.setData({
list: res.data
@ -176,7 +212,10 @@ export default {
image: '../../../static/error.png'
});
}
});
this.is_load = false;
}).catch(err => {
this.is_load = false;
})
},
setData: function (obj) {
@ -213,7 +252,9 @@ export default {
</style>
<style rel="stylesheet/less" lang="less">
@import "list";
.lf-color-red{
color: red;
}
.user-item, .menu-item{
height: 50rpx;
width: 100%;

14
pages/index/index/index.vue

@ -91,16 +91,16 @@
<text class="fuwu-tips-desc2">(部分品牌满额包邮)</text> -->
</view>
</view>
<!-- 活动页入口 TODO -->
<view class="lf-activity" v-if="item.name == 'micro_page_componet_nav' && item.value && item.value.length" @click="$url('/pages/index/activity/goods')">
<image src="https://picsum.photos/200" mode="aspectFill"></image>
<!-- 活动页入口 TODO 根据旧版魔方修改,一张图 -->
<view class="lf-activity" v-if="item.name == 'micro_page_componet_cube' && item.value && item.value.length && item.type == '1_1'" @click="$url(item.value[0].link)">
<image :src="item.value[0].image" mode="aspectFill"></image>
</view>
<!-- TODO 新做秒杀模块,根据旧版秒杀修改 -->
<view v-if="item.name == 'micro_page_componet_seckill' && item.value && item.value.length">
<lf-seckill :list="item.value" :title="item.title"></lf-seckill>
</view>
<!-- TODO 广告活动模块根据旧版魔方修改 -->
<view v-if="item.name == 'micro_page_componet_cube' && item.value && item.value.length">
<!-- TODO 广告活动模块根据旧版魔方修改,三张图 -->
<view v-if="item.name == 'micro_page_componet_cube' && item.value && item.value.length && item.type == '3_2'">
<lf-multi-column-ad :cube-data="item.value"></lf-multi-column-ad>
</view>
<!-- TODO 首页发现推荐模块根据大咖推荐文章修改 -->
@ -108,7 +108,7 @@
<lf-index-find :list="item.value"></lf-index-find>
</view>
<!-- TODO 大牌不停推模块 - 店铺矩阵 -->
<view v-if="item.name == 'micro_page_componet_nav' && item.value && item.value.length">
<view v-if="item.name == 'micro_page_componet_category' && item.value && item.value.length">
<lf-index-shop-matrix></lf-index-shop-matrix>
</view>
<!-- TODO 店铺商品展示模块 可根据micro_page_componet_category修改 -->
@ -129,7 +129,7 @@
<indexGrouping :grouping-data="item.value" :meta="item.meta"></indexGrouping>
</view> -->
<!-- TODO 为你推荐模块 -->
<view v-if="item.name == 'micro_page_componet_nav' && item.value && item.value.length">
<view v-if="item.name == 'micro_page_componet_category' && item.value && item.value.length">
<view class="lf-module-title">为你推荐</view>
<view style="padding: 0 11px;">
<lf-waterfall :list="recommend_list"></lf-waterfall>

12
pages/user/my/center.vue

@ -153,7 +153,8 @@
userInfo: {mobile_replace: '正在获取'}, //
token: '', // token
code: '',
centerInfo: {}
centerInfo: {},
show_count: 0
}
},
onLoad(){
@ -177,6 +178,15 @@
this.getMeInfo();
this.getUcenter();
},
onShow(){
this.show_count++;
if(this.show_count > 1){
var token = this.$cookieStorage.get('user_token');
this.token = token || '';
this.getMeInfo();
this.getUcenter();
}
},
//
onPageScroll(event){
if(event.scrollTop >= 50){

21
pages/user/my/setting.vue

@ -79,7 +79,7 @@
</view>
</view>
<view class="lf-p-l-32 lf-p-r-32 lf-bg-white">
<view class="set-tag" @click="$msg('敬请期待')">
<view class="set-tag" @click="makePhoneCall">
<view class="lf-font-28 lf-color-black">
客服电话
</view>
@ -158,8 +158,25 @@
}
});
},
//
makePhoneCall(){
uni.makePhoneCall({
phoneNumber: String('13132794740')
})
},
signOut(){
this.$msg('敬请期待')
uni.showModal({
title: '温馨提示',
content: '您确定退出登录吗?',
success: result => {
if(result.confirm){
this.$cookieStorage.clear('user_token');
this.$msg('操作成功', {icon: 'success'}).then(() => {
this.$toBack();
});
}
}
})
}
}
}

Loading…
Cancel
Save