个人中心

zhc4dev
wangjiadong 2 years ago
parent b291587a44
commit 5a213bff3a
  1. 73
      ant-design-vue-jeecg/src/views/shopping/components/addrView.vue
  2. 13
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/customerreceivingaddress/mapper/CustomerReceivingAddressMapper.java
  3. 12
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/customerreceivingaddress/service/ICustomerReceivingAddressService.java
  4. 27
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/customerreceivingaddress/service/impl/CustomerReceivingAddressServiceImpl.java
  5. 69
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/ApeopersionController.java

@ -1,16 +1,16 @@
<template>
<div class="addrView">
<div class="weizhuce d-flex" v-if="addrList.length == 0">
<div class="weizhuce d-flex" v-if="addrList1.length == 0">
<p class="c_1B f_30"> 您还未注册地址</p>
</div>
<div class="d-flex btnDiv">
<div type="primary" class="dialogButton primary f_12" @click="addAddr">创建新地址</div>
</div>
<div class="addrList" v-if="addrList.length != 0">
<div class="item" v-for="(item,index) in addrList" :key="index">
<p class="default" v-if="item.flag"><span class="f_12">默认地址</span></p>
<div class="addrList" v-if="addrList1.length != 0">
<div class="item" v-for="(item,index) in addrList1" :key="index">
<p class="default" v-if="item.sort==0"><span class="f_12">默认地址</span></p>
<div class="d-flex">
<div><span>{{item.name}}</span><span v-if="item.sex == 1">女士</span><span v-if="item.sex == 2">先生</span></div>
<div><span>{{item.usernamme}}</span><span v-if="item.sysOrgCode == 2">女士</span><span v-if="item.sysOrgCode == 1">先生</span></div>
<div class="btnDiv">
<span class="btn" @click="handleEdit(item)">编辑</span>
<a-popconfirm
@ -26,15 +26,15 @@
cancel-text="No"
@confirm="confirm2(item.id)"
@cancel="cancel"
v-if="!item.flag"
v-if="!item.sort==0"
><span class="btn">将其设置为默认地址</span></a-popconfirm>
<!-- <span class="btn" v-if="!item.flag" @click="handleDefault(item.id)">将其设置为默认地址</span>-->
</div>
</div>
<p>
{{item.detailed}}
{{item.address}}
</p>
<p><j-area-linkage disabled type="cascader" v-model="item.addr" placeholder="请选择省市区"/></p>
<p><j-area-linkage disabled type="cascader" v-model="item.cityId" placeholder="请选择省市区"/></p>
</div>
</div>
<a-modal
@ -105,6 +105,10 @@
</div>
</template>
<script>
import { httpAction, getAction } from '@/api/manage'
import { deleteAction } from '@/api/manage'
export default {
name: "addrView",
components: { },
@ -115,6 +119,7 @@
copyItem:{},//
labelCol: { span: 4 },
wrapperCol: { span: 20 },
addrList1:[],
addrList:[
{
id:1,
@ -144,6 +149,7 @@
flag:false,//
},//
],//
addrList1:[],
addr1:'210521',
//
form: {
@ -167,9 +173,40 @@
phone: [{ required: true, message: '请输入手机号码', trigger: 'blur' },
],
},
url: {
getaddress: "/getuserpersion/getaddress",
deleteadd: "/getuserpersion/deleteadd",
sdqx: "/getuserpersion/sdqx"
},
};
},
created() {
this.getaddress();
},
methods: {
reload() {
this.isReload = false
this.$nextTick(() => {
this.isReload = true
})
},
getaddress(){
getAction(this.url.getaddress).then((res) => {
if(res.success) {
this.addrList1= res.result;
console.log("===================")
console.log(res.result)
} else {
}
});
},
addAddr(){
this.visible = true
this.flag = 'add'
@ -244,13 +281,23 @@
this.form = item
},
confirm1(id) {
let itemIndex = this.addrList.findIndex(item =>item.id == id)
this.addrList.splice(itemIndex,1)
/*这个是删除功能*/
console.log(id)
deleteAction(this.url.deleteadd,{id,id}).then((res) => {
if(res.success) {
this.loadData(1);
} else {
}
});
},
confirm2(id) {
this.changeDefault()
let itemIndex2 = this.addrList.findIndex(item =>item.id == id)
this.addrList[itemIndex2].flag = true
console.log(id)
getAction(this.url.sdqx,{id,id}).then((res) => {
if(res.success) {
this.$router.go(0)
} else {
}
});
},
cancel(e) {
this.$message.warning('已取消');

@ -31,5 +31,18 @@ public interface CustomerReceivingAddressMapper extends BaseMapper<CustomerRecei
@Select("select sort from customer_receiving_address where id=#{id} ")
int findSort(String id);
@Select("select * from customer_receiving_address where user_id =#{userid}")
List<CustomerReceivingAddress> getcra(String userid);
@Select("select * from customer_receiving_address where user_id =#{userid} and sort ='0'")
CustomerReceivingAddress getneed(String userid);
@Update("update customer_receiving_address set sort ='0' where id = #{id} ")
void updatesetneed(String id);
@Update("update customer_receiving_address set sort =#{sort} where id = #{id} ")
void updatec(String id, Integer sort);
@Update("update customer_receiving_address set sort ='0' where id = #{id} ")
void updates(String id);
}

@ -3,6 +3,8 @@ package org.jeecg.modules.demo.customerreceivingaddress.service;
import org.jeecg.modules.demo.customerreceivingaddress.entity.CustomerReceivingAddress;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* @Description: 顾客地址表
* @Author: jeecg-boot
@ -16,4 +18,14 @@ public interface ICustomerReceivingAddressService extends IService<CustomerRecei
int findSort(String id);
void down(String id);
List<CustomerReceivingAddress> getcra(String userid);
CustomerReceivingAddress getneed(String userid);
void updatesetneed(String id);
void updatec(String id, Integer sort);
void updates(String id);
}

@ -8,6 +8,8 @@ import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
/**
* @Description: 顾客地址表
* @Author: jeecg-boot
@ -51,4 +53,29 @@ public class CustomerReceivingAddressServiceImpl extends ServiceImpl<CustomerRec
}
}
}
@Override
public List<CustomerReceivingAddress> getcra(String userid) {
return customerReceivingAddressMapper.getcra(userid);
}
@Override
public CustomerReceivingAddress getneed(String userid) {
return customerReceivingAddressMapper.getneed(userid);
}
@Override
public void updatesetneed(String id) {
customerReceivingAddressMapper.updatesetneed(id);
}
@Override
public void updatec(String id, Integer sort) {
customerReceivingAddressMapper.updatec(id,sort);
}
@Override
public void updates(String id) {
customerReceivingAddressMapper.updates(id);
}
}

@ -4,16 +4,20 @@ package org.jeecg.modules.system.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Joiner;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.aspectj.apache.bcel.generic.RET;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.base.service.BaseCommonService;
import org.jeecg.modules.demo.customercollectgoods.entity.Customercollectgoods;
import org.jeecg.modules.demo.customercollectgoods.service.ICustomercollectgoodsService;
import org.jeecg.modules.demo.customerreceivingaddress.entity.CustomerReceivingAddress;
import org.jeecg.modules.demo.customerreceivingaddress.service.ICustomerReceivingAddressService;
import org.jeecg.modules.demo.customershoppingcart.entity.CustomerShoppingCart;
import org.jeecg.modules.demo.customershoppingcart.service.ICustomerShoppingCartService;
import org.jeecg.modules.demo.zygoods.entity.ZyGoods;
@ -52,6 +56,9 @@ public class ApeopersionController {
@Autowired
private ICustomerShoppingCartService customerShoppingCartService;
@Autowired
private ICustomerReceivingAddressService customerReceivingAddressService;
/*
个人中心我的账户的数据获取
@ -160,4 +167,66 @@ public class ApeopersionController {
return Result.ok("添加完成");
}
//个人中心的收货地址的首页需要的数据
@RequestMapping(value = "/getaddress", method = RequestMethod.GET)
public Result<?> getaddress() {
//这里方便获取当前登陆信息
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//这里获取当前登陆的id
String userid = loginUser.getId();
Integer usersex = loginUser.getSex();
//这个是根据用户id查收货地址
List<CustomerReceivingAddress> cra =customerReceivingAddressService.getcra(userid);
for (int i=0;i<cra.size();i++) {
cra.get(i).setSysOrgCode(usersex.toString());
}
return Result.ok(cra);
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "顾客地址表-通过id删除")
@ApiOperation(value="顾客地址表-通过id删除", notes="顾客地址表-通过id删除")
@DeleteMapping(value = "/deleteadd")
public Result<?> deleteadd(@RequestParam(name="id",required=true) String id) {
customerReceivingAddressService.removeById(id);
return Result.OK("删除成功!");
}
@RequestMapping(value = "/getaddressbyid", method = RequestMethod.GET)
public Result<?> getaddressbyid(@RequestParam(name="id",required=true) String id) {
System.out.println(id);
/*return Result.ok("");*/
return null;
}
@RequestMapping(value = "/sdqx", method = RequestMethod.GET)
public Result<?> sdqx(@RequestParam(name="id",required=true) String id) {
//根据id查询需要设置成默认收货地址的收货地址
CustomerReceivingAddress cus = customerReceivingAddressService.getById(id);
String userid = cus.getUserId();
Integer sort = cus.getSort();
//开始寻找之前的默认地址
CustomerReceivingAddress cusm = customerReceivingAddressService.getneed(userid);
//如果没有默认地址
if (cusm==null){
customerReceivingAddressService.updatesetneed(id);
}else{
//这个是更新默认地址
customerReceivingAddressService.updatec(cusm.getId(),sort);
customerReceivingAddressService.updates(id);
}
return Result.OK("成功!");
}
}

Loading…
Cancel
Save