Commit faaf94b7 authored by Junling Bu's avatar Junling Bu
Browse files

区域地址和收货地址调整,参考了vant框架的Area组件

parent d6efbd65
...@@ -34,26 +34,6 @@ public class AdminAddressController { ...@@ -34,26 +34,6 @@ public class AdminAddressController {
@Autowired @Autowired
private LitemallRegionService regionService; private LitemallRegionService regionService;
private Map<String, Object> toVo(LitemallAddress address) {
Map<String, Object> addressVo = new HashMap<>();
addressVo.put("id", address.getId());
addressVo.put("userId", address.getUserId());
addressVo.put("name", address.getName());
addressVo.put("mobile", address.getMobile());
addressVo.put("isDefault", address.getIsDefault());
addressVo.put("provinceId", address.getProvinceId());
addressVo.put("cityId", address.getCityId());
addressVo.put("areaId", address.getAreaId());
addressVo.put("address", address.getAddress());
String province = regionService.findById(address.getProvinceId()).getName();
String city = regionService.findById(address.getCityId()).getName();
String area = regionService.findById(address.getAreaId()).getName();
addressVo.put("province", province);
addressVo.put("city", city);
addressVo.put("area", area);
return addressVo;
}
@RequiresPermissions("admin:address:list") @RequiresPermissions("admin:address:list")
@RequiresPermissionsDesc(menu={"用户管理" , "收货地址"}, button="查询") @RequiresPermissionsDesc(menu={"用户管理" , "收货地址"}, button="查询")
@GetMapping("/list") @GetMapping("/list")
...@@ -66,15 +46,10 @@ public class AdminAddressController { ...@@ -66,15 +46,10 @@ public class AdminAddressController {
List<LitemallAddress> addressList = addressService.querySelective(userId, name, page, limit, sort, order); List<LitemallAddress> addressList = addressService.querySelective(userId, name, page, limit, sort, order);
long total = PageInfo.of(addressList).getTotal(); long total = PageInfo.of(addressList).getTotal();
List<Map<String, Object>> addressVoList = new ArrayList<>(addressList.size());
for (LitemallAddress address : addressList) {
Map<String, Object> addressVo = toVo(address);
addressVoList.add(addressVo);
}
Map<String, Object> data = new HashMap<>(); Map<String, Object> data = new HashMap<>();
data.put("total", total); data.put("total", total);
data.put("items", addressVoList); data.put("items", addressList);
return ResponseUtil.ok(data); return ResponseUtil.ok(data);
} }
......
...@@ -53,47 +53,65 @@ public class LitemallAddress { ...@@ -53,47 +53,65 @@ public class LitemallAddress {
/** /**
* *
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_address.province_id * This field corresponds to the database column litemall_address.province
* *
* @mbg.generated * @mbg.generated
*/ */
private Integer provinceId; private String province;
/** /**
* *
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_address.city_id * This field corresponds to the database column litemall_address.city
* *
* @mbg.generated * @mbg.generated
*/ */
private Integer cityId; private String city;
/** /**
* *
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_address.area_id * This field corresponds to the database column litemall_address.county
* *
* @mbg.generated * @mbg.generated
*/ */
private Integer areaId; private String county;
/** /**
* *
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_address.address * This field corresponds to the database column litemall_address.address_detail
* *
* @mbg.generated * @mbg.generated
*/ */
private String address; private String addressDetail;
/** /**
* *
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_address.mobile * This field corresponds to the database column litemall_address.area_code
* *
* @mbg.generated * @mbg.generated
*/ */
private String mobile; private String areaCode;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_address.postal_code
*
* @mbg.generated
*/
private String postalCode;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_address.tel
*
* @mbg.generated
*/
private String tel;
/** /**
* *
...@@ -205,122 +223,170 @@ public class LitemallAddress { ...@@ -205,122 +223,170 @@ public class LitemallAddress {
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_address.province_id * This method returns the value of the database column litemall_address.province
*
* @return the value of litemall_address.province
*
* @mbg.generated
*/
public String getProvince() {
return province;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_address.province
*
* @param province the value for litemall_address.province
*
* @mbg.generated
*/
public void setProvince(String province) {
this.province = province;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_address.city
*
* @return the value of litemall_address.city
*
* @mbg.generated
*/
public String getCity() {
return city;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_address.city
*
* @param city the value for litemall_address.city
*
* @mbg.generated
*/
public void setCity(String city) {
this.city = city;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_address.county
* *
* @return the value of litemall_address.province_id * @return the value of litemall_address.county
* *
* @mbg.generated * @mbg.generated
*/ */
public Integer getProvinceId() { public String getCounty() {
return provinceId; return county;
} }
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_address.province_id * This method sets the value of the database column litemall_address.county
* *
* @param provinceId the value for litemall_address.province_id * @param county the value for litemall_address.county
* *
* @mbg.generated * @mbg.generated
*/ */
public void setProvinceId(Integer provinceId) { public void setCounty(String county) {
this.provinceId = provinceId; this.county = county;
} }
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_address.city_id * This method returns the value of the database column litemall_address.address_detail
* *
* @return the value of litemall_address.city_id * @return the value of litemall_address.address_detail
* *
* @mbg.generated * @mbg.generated
*/ */
public Integer getCityId() { public String getAddressDetail() {
return cityId; return addressDetail;
} }
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_address.city_id * This method sets the value of the database column litemall_address.address_detail
* *
* @param cityId the value for litemall_address.city_id * @param addressDetail the value for litemall_address.address_detail
* *
* @mbg.generated * @mbg.generated
*/ */
public void setCityId(Integer cityId) { public void setAddressDetail(String addressDetail) {
this.cityId = cityId; this.addressDetail = addressDetail;
} }
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_address.area_id * This method returns the value of the database column litemall_address.area_code
* *
* @return the value of litemall_address.area_id * @return the value of litemall_address.area_code
* *
* @mbg.generated * @mbg.generated
*/ */
public Integer getAreaId() { public String getAreaCode() {
return areaId; return areaCode;
} }
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_address.area_id * This method sets the value of the database column litemall_address.area_code
* *
* @param areaId the value for litemall_address.area_id * @param areaCode the value for litemall_address.area_code
* *
* @mbg.generated * @mbg.generated
*/ */
public void setAreaId(Integer areaId) { public void setAreaCode(String areaCode) {
this.areaId = areaId; this.areaCode = areaCode;
} }
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_address.address * This method returns the value of the database column litemall_address.postal_code
* *
* @return the value of litemall_address.address * @return the value of litemall_address.postal_code
* *
* @mbg.generated * @mbg.generated
*/ */
public String getAddress() { public String getPostalCode() {
return address; return postalCode;
} }
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_address.address * This method sets the value of the database column litemall_address.postal_code
* *
* @param address the value for litemall_address.address * @param postalCode the value for litemall_address.postal_code
* *
* @mbg.generated * @mbg.generated
*/ */
public void setAddress(String address) { public void setPostalCode(String postalCode) {
this.address = address; this.postalCode = postalCode;
} }
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_address.mobile * This method returns the value of the database column litemall_address.tel
* *
* @return the value of litemall_address.mobile * @return the value of litemall_address.tel
* *
* @mbg.generated * @mbg.generated
*/ */
public String getMobile() { public String getTel() {
return mobile; return tel;
} }
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_address.mobile * This method sets the value of the database column litemall_address.tel
* *
* @param mobile the value for litemall_address.mobile * @param tel the value for litemall_address.tel
* *
* @mbg.generated * @mbg.generated
*/ */
public void setMobile(String mobile) { public void setTel(String tel) {
this.mobile = mobile; this.tel = tel;
} }
/** /**
...@@ -434,11 +500,13 @@ public class LitemallAddress { ...@@ -434,11 +500,13 @@ public class LitemallAddress {
sb.append(", id=").append(id); sb.append(", id=").append(id);
sb.append(", name=").append(name); sb.append(", name=").append(name);
sb.append(", userId=").append(userId); sb.append(", userId=").append(userId);
sb.append(", provinceId=").append(provinceId); sb.append(", province=").append(province);
sb.append(", cityId=").append(cityId); sb.append(", city=").append(city);
sb.append(", areaId=").append(areaId); sb.append(", county=").append(county);
sb.append(", address=").append(address); sb.append(", addressDetail=").append(addressDetail);
sb.append(", mobile=").append(mobile); sb.append(", areaCode=").append(areaCode);
sb.append(", postalCode=").append(postalCode);
sb.append(", tel=").append(tel);
sb.append(", isDefault=").append(isDefault); sb.append(", isDefault=").append(isDefault);
sb.append(", addTime=").append(addTime); sb.append(", addTime=").append(addTime);
sb.append(", updateTime=").append(updateTime); sb.append(", updateTime=").append(updateTime);
...@@ -468,11 +536,13 @@ public class LitemallAddress { ...@@ -468,11 +536,13 @@ public class LitemallAddress {
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName())) && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getProvinceId() == null ? other.getProvinceId() == null : this.getProvinceId().equals(other.getProvinceId())) && (this.getProvince() == null ? other.getProvince() == null : this.getProvince().equals(other.getProvince()))
&& (this.getCityId() == null ? other.getCityId() == null : this.getCityId().equals(other.getCityId())) && (this.getCity() == null ? other.getCity() == null : this.getCity().equals(other.getCity()))
&& (this.getAreaId() == null ? other.getAreaId() == null : this.getAreaId().equals(other.getAreaId())) && (this.getCounty() == null ? other.getCounty() == null : this.getCounty().equals(other.getCounty()))
&& (this.getAddress() == null ? other.getAddress() == null : this.getAddress().equals(other.getAddress())) && (this.getAddressDetail() == null ? other.getAddressDetail() == null : this.getAddressDetail().equals(other.getAddressDetail()))
&& (this.getMobile() == null ? other.getMobile() == null : this.getMobile().equals(other.getMobile())) && (this.getAreaCode() == null ? other.getAreaCode() == null : this.getAreaCode().equals(other.getAreaCode()))
&& (this.getPostalCode() == null ? other.getPostalCode() == null : this.getPostalCode().equals(other.getPostalCode()))
&& (this.getTel() == null ? other.getTel() == null : this.getTel().equals(other.getTel()))
&& (this.getIsDefault() == null ? other.getIsDefault() == null : this.getIsDefault().equals(other.getIsDefault())) && (this.getIsDefault() == null ? other.getIsDefault() == null : this.getIsDefault().equals(other.getIsDefault()))
&& (this.getAddTime() == null ? other.getAddTime() == null : this.getAddTime().equals(other.getAddTime())) && (this.getAddTime() == null ? other.getAddTime() == null : this.getAddTime().equals(other.getAddTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
...@@ -492,11 +562,13 @@ public class LitemallAddress { ...@@ -492,11 +562,13 @@ public class LitemallAddress {
result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getProvinceId() == null) ? 0 : getProvinceId().hashCode()); result = prime * result + ((getProvince() == null) ? 0 : getProvince().hashCode());
result = prime * result + ((getCityId() == null) ? 0 : getCityId().hashCode()); result = prime * result + ((getCity() == null) ? 0 : getCity().hashCode());
result = prime * result + ((getAreaId() == null) ? 0 : getAreaId().hashCode()); result = prime * result + ((getCounty() == null) ? 0 : getCounty().hashCode());
result = prime * result + ((getAddress() == null) ? 0 : getAddress().hashCode()); result = prime * result + ((getAddressDetail() == null) ? 0 : getAddressDetail().hashCode());
result = prime * result + ((getMobile() == null) ? 0 : getMobile().hashCode()); result = prime * result + ((getAreaCode() == null) ? 0 : getAreaCode().hashCode());
result = prime * result + ((getPostalCode() == null) ? 0 : getPostalCode().hashCode());
result = prime * result + ((getTel() == null) ? 0 : getTel().hashCode());
result = prime * result + ((getIsDefault() == null) ? 0 : getIsDefault().hashCode()); result = prime * result + ((getIsDefault() == null) ? 0 : getIsDefault().hashCode());
result = prime * result + ((getAddTime() == null) ? 0 : getAddTime().hashCode()); result = prime * result + ((getAddTime() == null) ? 0 : getAddTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
...@@ -526,11 +598,13 @@ public class LitemallAddress { ...@@ -526,11 +598,13 @@ public class LitemallAddress {
id("id", "id", "INTEGER", false), id("id", "id", "INTEGER", false),
name("name", "name", "VARCHAR", true), name("name", "name", "VARCHAR", true),
userId("user_id", "userId", "INTEGER", false), userId("user_id", "userId", "INTEGER", false),
provinceId("province_id", "provinceId", "INTEGER", false), province("province", "province", "VARCHAR", false),
cityId("city_id", "cityId", "INTEGER", false), city("city", "city", "VARCHAR", false),
areaId("area_id", "areaId", "INTEGER", false), county("county", "county", "VARCHAR", false),
address("address", "address", "VARCHAR", false), addressDetail("address_detail", "addressDetail", "VARCHAR", false),
mobile("mobile", "mobile", "VARCHAR", false), areaCode("area_code", "areaCode", "CHAR", false),
postalCode("postal_code", "postalCode", "CHAR", false),
tel("tel", "tel", "VARCHAR", false),
isDefault("is_default", "isDefault", "BIT", false), isDefault("is_default", "isDefault", "BIT", false),
addTime("add_time", "addTime", "TIMESTAMP", false), addTime("add_time", "addTime", "TIMESTAMP", false),
updateTime("update_time", "updateTime", "TIMESTAMP", false), updateTime("update_time", "updateTime", "TIMESTAMP", false),
......
...@@ -52,10 +52,4 @@ public class LitemallRegionService { ...@@ -52,10 +52,4 @@ public class LitemallRegionService {
return regionMapper.selectByExample(example); return regionMapper.selectByExample(example);
} }
public List<LitemallRegion> queryChildren(Integer id) {
LitemallRegionExample example = new LitemallRegionExample();
example.or().andPidEqualTo(id);
return regionMapper.selectByExample(example);
}
} }
...@@ -9,11 +9,13 @@ ...@@ -9,11 +9,13 @@
<id column="id" jdbcType="INTEGER" property="id" /> <id column="id" jdbcType="INTEGER" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" /> <result column="name" jdbcType="VARCHAR" property="name" />
<result column="user_id" jdbcType="INTEGER" property="userId" /> <result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="province_id" jdbcType="INTEGER" property="provinceId" /> <result column="province" jdbcType="VARCHAR" property="province" />
<result column="city_id" jdbcType="INTEGER" property="cityId" /> <result column="city" jdbcType="VARCHAR" property="city" />
<result column="area_id" jdbcType="INTEGER" property="areaId" /> <result column="county" jdbcType="VARCHAR" property="county" />
<result column="address" jdbcType="VARCHAR" property="address" /> <result column="address_detail" jdbcType="VARCHAR" property="addressDetail" />
<result column="mobile" jdbcType="VARCHAR" property="mobile" /> <result column="area_code" jdbcType="CHAR" property="areaCode" />
<result column="postal_code" jdbcType="CHAR" property="postalCode" />
<result column="tel" jdbcType="VARCHAR" property="tel" />
<result column="is_default" jdbcType="BIT" property="isDefault" /> <result column="is_default" jdbcType="BIT" property="isDefault" />
<result column="add_time" jdbcType="TIMESTAMP" property="addTime" /> <result column="add_time" jdbcType="TIMESTAMP" property="addTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
...@@ -90,8 +92,8 @@ ...@@ -90,8 +92,8 @@
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
--> -->
id, `name`, user_id, province_id, city_id, area_id, address, mobile, is_default, id, `name`, user_id, province, city, county, address_detail, area_code, postal_code,
add_time, update_time, deleted tel, is_default, add_time, update_time, deleted
</sql> </sql>
<select id="selectByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallAddressExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallAddressExample" resultMap="BaseResultMap">
<!-- <!--
...@@ -128,8 +130,8 @@ ...@@ -128,8 +130,8 @@
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, `name`, user_id, province_id, city_id, area_id, address, mobile, is_default, id, `name`, user_id, province, city, county, address_detail, area_code, postal_code,
add_time, update_time, deleted tel, is_default, add_time, update_time, deleted
</otherwise> </otherwise>
</choose> </choose>
from litemall_address from litemall_address
...@@ -188,8 +190,8 @@ ...@@ -188,8 +190,8 @@
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, `name`, user_id, province_id, city_id, area_id, address, mobile, is_default, id, `name`, user_id, province, city, county, address_detail, area_code, postal_code,
add_time, update_time, deleted tel, is_default, add_time, update_time, deleted
</otherwise> </otherwise>
</choose> </choose>
from litemall_address from litemall_address
...@@ -221,14 +223,16 @@ ...@@ -221,14 +223,16 @@
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer"> <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID() SELECT LAST_INSERT_ID()
</selectKey> </selectKey>
insert into litemall_address (`name`, user_id, province_id, insert into litemall_address (`name`, user_id, province,
city_id, area_id, address, city, county, address_detail,
mobile, is_default, add_time, area_code, postal_code, tel,
update_time, deleted) is_default, add_time, update_time,
values (#{name,jdbcType=VARCHAR}, #{userId,jdbcType=INTEGER}, #{provinceId,jdbcType=INTEGER}, deleted)
#{cityId,jdbcType=INTEGER}, #{areaId,jdbcType=INTEGER}, #{address,jdbcType=VARCHAR}, values (#{name,jdbcType=VARCHAR}, #{userId,jdbcType=INTEGER}, #{province,jdbcType=VARCHAR},
#{mobile,jdbcType=VARCHAR}, #{isDefault,jdbcType=BIT}, #{addTime,jdbcType=TIMESTAMP}, #{city,jdbcType=VARCHAR}, #{county,jdbcType=VARCHAR}, #{addressDetail,jdbcType=VARCHAR},
#{updateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT}) #{areaCode,jdbcType=CHAR}, #{postalCode,jdbcType=CHAR}, #{tel,jdbcType=VARCHAR},
#{isDefault,jdbcType=BIT}, #{addTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{deleted,jdbcType=BIT})
</insert> </insert>
<insert id="insertSelective" parameterType="org.linlinjava.litemall.db.domain.LitemallAddress"> <insert id="insertSelective" parameterType="org.linlinjava.litemall.db.domain.LitemallAddress">
<!-- <!--
...@@ -246,20 +250,26 @@ ...@@ -246,20 +250,26 @@
<if test="userId != null"> <if test="userId != null">
user_id, user_id,
</if> </if>
<if test="provinceId != null"> <if test="province != null">
province_id, province,
</if> </if>
<if test="cityId != null"> <if test="city != null">
city_id, city,
</if> </if>
<if test="areaId != null"> <if test="county != null">
area_id, county,
</if> </if>
<if test="address != null"> <if test="addressDetail != null">
address, address_detail,
</if> </if>
<if test="mobile != null"> <if test="areaCode != null">
mobile, area_code,
</if>
<if test="postalCode != null">
postal_code,
</if>
<if test="tel != null">
tel,
</if> </if>
<if test="isDefault != null"> <if test="isDefault != null">
is_default, is_default,
...@@ -281,20 +291,26 @@ ...@@ -281,20 +291,26 @@
<if test="userId != null"> <if test="userId != null">
#{userId,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER},
</if> </if>
<if test="provinceId != null"> <if test="province != null">
#{provinceId,jdbcType=INTEGER}, #{province,jdbcType=VARCHAR},
</if>
<if test="city != null">
#{city,jdbcType=VARCHAR},
</if>
<if test="county != null">
#{county,jdbcType=VARCHAR},
</if> </if>
<if test="cityId != null"> <if test="addressDetail != null">
#{cityId,jdbcType=INTEGER}, #{addressDetail,jdbcType=VARCHAR},
</if> </if>
<if test="areaId != null"> <if test="areaCode != null">
#{areaId,jdbcType=INTEGER}, #{areaCode,jdbcType=CHAR},
</if> </if>
<if test="address != null"> <if test="postalCode != null">
#{address,jdbcType=VARCHAR}, #{postalCode,jdbcType=CHAR},
</if> </if>
<if test="mobile != null"> <if test="tel != null">
#{mobile,jdbcType=VARCHAR}, #{tel,jdbcType=VARCHAR},
</if> </if>
<if test="isDefault != null"> <if test="isDefault != null">
#{isDefault,jdbcType=BIT}, #{isDefault,jdbcType=BIT},
...@@ -336,20 +352,26 @@ ...@@ -336,20 +352,26 @@
<if test="record.userId != null"> <if test="record.userId != null">
user_id = #{record.userId,jdbcType=INTEGER}, user_id = #{record.userId,jdbcType=INTEGER},
</if> </if>
<if test="record.provinceId != null"> <if test="record.province != null">
province_id = #{record.provinceId,jdbcType=INTEGER}, province = #{record.province,jdbcType=VARCHAR},
</if> </if>
<if test="record.cityId != null"> <if test="record.city != null">
city_id = #{record.cityId,jdbcType=INTEGER}, city = #{record.city,jdbcType=VARCHAR},
</if> </if>
<if test="record.areaId != null"> <if test="record.county != null">
area_id = #{record.areaId,jdbcType=INTEGER}, county = #{record.county,jdbcType=VARCHAR},
</if> </if>
<if test="record.address != null"> <if test="record.addressDetail != null">
address = #{record.address,jdbcType=VARCHAR}, address_detail = #{record.addressDetail,jdbcType=VARCHAR},
</if> </if>
<if test="record.mobile != null"> <if test="record.areaCode != null">
mobile = #{record.mobile,jdbcType=VARCHAR}, area_code = #{record.areaCode,jdbcType=CHAR},
</if>
<if test="record.postalCode != null">
postal_code = #{record.postalCode,jdbcType=CHAR},
</if>
<if test="record.tel != null">
tel = #{record.tel,jdbcType=VARCHAR},
</if> </if>
<if test="record.isDefault != null"> <if test="record.isDefault != null">
is_default = #{record.isDefault,jdbcType=BIT}, is_default = #{record.isDefault,jdbcType=BIT},
...@@ -377,11 +399,13 @@ ...@@ -377,11 +399,13 @@
set id = #{record.id,jdbcType=INTEGER}, set id = #{record.id,jdbcType=INTEGER},
`name` = #{record.name,jdbcType=VARCHAR}, `name` = #{record.name,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=INTEGER}, user_id = #{record.userId,jdbcType=INTEGER},
province_id = #{record.provinceId,jdbcType=INTEGER}, province = #{record.province,jdbcType=VARCHAR},
city_id = #{record.cityId,jdbcType=INTEGER}, city = #{record.city,jdbcType=VARCHAR},
area_id = #{record.areaId,jdbcType=INTEGER}, county = #{record.county,jdbcType=VARCHAR},
address = #{record.address,jdbcType=VARCHAR}, address_detail = #{record.addressDetail,jdbcType=VARCHAR},
mobile = #{record.mobile,jdbcType=VARCHAR}, area_code = #{record.areaCode,jdbcType=CHAR},
postal_code = #{record.postalCode,jdbcType=CHAR},
tel = #{record.tel,jdbcType=VARCHAR},
is_default = #{record.isDefault,jdbcType=BIT}, is_default = #{record.isDefault,jdbcType=BIT},
add_time = #{record.addTime,jdbcType=TIMESTAMP}, add_time = #{record.addTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}, update_time = #{record.updateTime,jdbcType=TIMESTAMP},
...@@ -403,20 +427,26 @@ ...@@ -403,20 +427,26 @@
<if test="userId != null"> <if test="userId != null">
user_id = #{userId,jdbcType=INTEGER}, user_id = #{userId,jdbcType=INTEGER},
</if> </if>
<if test="provinceId != null"> <if test="province != null">
province_id = #{provinceId,jdbcType=INTEGER}, province = #{province,jdbcType=VARCHAR},
</if>
<if test="city != null">
city = #{city,jdbcType=VARCHAR},
</if>
<if test="county != null">
county = #{county,jdbcType=VARCHAR},
</if> </if>
<if test="cityId != null"> <if test="addressDetail != null">
city_id = #{cityId,jdbcType=INTEGER}, address_detail = #{addressDetail,jdbcType=VARCHAR},
</if> </if>
<if test="areaId != null"> <if test="areaCode != null">
area_id = #{areaId,jdbcType=INTEGER}, area_code = #{areaCode,jdbcType=CHAR},
</if> </if>
<if test="address != null"> <if test="postalCode != null">
address = #{address,jdbcType=VARCHAR}, postal_code = #{postalCode,jdbcType=CHAR},
</if> </if>
<if test="mobile != null"> <if test="tel != null">
mobile = #{mobile,jdbcType=VARCHAR}, tel = #{tel,jdbcType=VARCHAR},
</if> </if>
<if test="isDefault != null"> <if test="isDefault != null">
is_default = #{isDefault,jdbcType=BIT}, is_default = #{isDefault,jdbcType=BIT},
...@@ -441,11 +471,13 @@ ...@@ -441,11 +471,13 @@
update litemall_address update litemall_address
set `name` = #{name,jdbcType=VARCHAR}, set `name` = #{name,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=INTEGER}, user_id = #{userId,jdbcType=INTEGER},
province_id = #{provinceId,jdbcType=INTEGER}, province = #{province,jdbcType=VARCHAR},
city_id = #{cityId,jdbcType=INTEGER}, city = #{city,jdbcType=VARCHAR},
area_id = #{areaId,jdbcType=INTEGER}, county = #{county,jdbcType=VARCHAR},
address = #{address,jdbcType=VARCHAR}, address_detail = #{addressDetail,jdbcType=VARCHAR},
mobile = #{mobile,jdbcType=VARCHAR}, area_code = #{areaCode,jdbcType=CHAR},
postal_code = #{postalCode,jdbcType=CHAR},
tel = #{tel,jdbcType=VARCHAR},
is_default = #{isDefault,jdbcType=BIT}, is_default = #{isDefault,jdbcType=BIT},
add_time = #{addTime,jdbcType=TIMESTAMP}, add_time = #{addTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP},
...@@ -483,8 +515,8 @@ ...@@ -483,8 +515,8 @@
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, `name`, user_id, province_id, city_id, area_id, address, mobile, is_default, id, `name`, user_id, province, city, county, address_detail, area_code, postal_code,
add_time, update_time, deleted tel, is_default, add_time, update_time, deleted
</otherwise> </otherwise>
</choose> </choose>
from litemall_address from litemall_address
......
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
distinct distinct
</if> </if>
<choose> <choose>
<when test="selective != null and selective.length > 0"> <when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=","> <foreach collection="selective" item="column" separator=",">
${column.escapedColumnName} ${column.escapedColumnName}
</foreach> </foreach>
...@@ -174,7 +174,7 @@ ...@@ -174,7 +174,7 @@
--> -->
select select
<choose> <choose>
<when test="selective != null and selective.length > 0"> <when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=","> <foreach collection="selective" item="column" separator=",">
${column.escapedColumnName} ${column.escapedColumnName}
</foreach> </foreach>
...@@ -380,7 +380,7 @@ ...@@ -380,7 +380,7 @@
--> -->
select select
<choose> <choose>
<when test="selective != null and selective.length > 0"> <when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=","> <foreach collection="selective" item="column" separator=",">
${column.escapedColumnName} ${column.escapedColumnName}
</foreach> </foreach>
......
...@@ -327,7 +327,7 @@ export function couponReceive(data) { ...@@ -327,7 +327,7 @@ export function couponReceive(data) {
} }
const CouponExchange='wx/coupon/exchange'; //优惠券兑换 const CouponExchange='wx/coupon/exchange'; //优惠券兑换
const StorageUpload='wx/torage/upload'; //图片上传, const StorageUpload='wx/storage/upload'; //图片上传,
const UserIndex='wx/user/index'; //个人页面用户相关信息 const UserIndex='wx/user/index'; //个人页面用户相关信息
export function userIndex() { export function userIndex() {
......
...@@ -106,17 +106,6 @@ public class WxOrderService { ...@@ -106,17 +106,6 @@ public class WxOrderService {
@Autowired @Autowired
private CouponVerifyService couponVerifyService; private CouponVerifyService couponVerifyService;
private String detailedAddress(LitemallAddress litemallAddress) {
Integer provinceId = litemallAddress.getProvinceId();
Integer cityId = litemallAddress.getCityId();
Integer areaId = litemallAddress.getAreaId();
String provinceName = regionService.findById(provinceId).getName();
String cityName = regionService.findById(cityId).getName();
String areaName = regionService.findById(areaId).getName();
String fullRegion = provinceName + " " + cityName + " " + areaName;
return fullRegion + " " + litemallAddress.getAddress();
}
/** /**
* 订单列表 * 订单列表
* *
...@@ -165,6 +154,7 @@ public class WxOrderService { ...@@ -165,6 +154,7 @@ public class WxOrderService {
orderGoodsVo.put("goodsName", orderGoods.getGoodsName()); orderGoodsVo.put("goodsName", orderGoods.getGoodsName());
orderGoodsVo.put("number", orderGoods.getNumber()); orderGoodsVo.put("number", orderGoods.getNumber());
orderGoodsVo.put("picUrl", orderGoods.getPicUrl()); orderGoodsVo.put("picUrl", orderGoods.getPicUrl());
orderGoodsVo.put("specifications", orderGoods.getSpecifications());
orderGoodsVoList.add(orderGoodsVo); orderGoodsVoList.add(orderGoodsVo);
} }
orderVo.put("goodsList", orderGoodsVoList); orderVo.put("goodsList", orderGoodsVoList);
...@@ -348,9 +338,9 @@ public class WxOrderService { ...@@ -348,9 +338,9 @@ public class WxOrderService {
order.setOrderSn(orderService.generateOrderSn(userId)); order.setOrderSn(orderService.generateOrderSn(userId));
order.setOrderStatus(OrderUtil.STATUS_CREATE); order.setOrderStatus(OrderUtil.STATUS_CREATE);
order.setConsignee(checkedAddress.getName()); order.setConsignee(checkedAddress.getName());
order.setMobile(checkedAddress.getMobile()); order.setMobile(checkedAddress.getTel());
order.setMessage(message); order.setMessage(message);
String detailedAddress = detailedAddress(checkedAddress); String detailedAddress = checkedAddress.getProvince() + checkedAddress.getCity() + checkedAddress.getCounty() + " " + checkedAddress.getAddressDetail();
order.setAddress(detailedAddress); order.setAddress(detailedAddress);
order.setGoodsPrice(checkedGoodsPrice); order.setGoodsPrice(checkedGoodsPrice);
order.setFreightPrice(freightPrice); order.setFreightPrice(freightPrice);
......
...@@ -5,7 +5,6 @@ import org.apache.commons.logging.LogFactory; ...@@ -5,7 +5,6 @@ import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.core.util.RegexUtil; import org.linlinjava.litemall.core.util.RegexUtil;
import org.linlinjava.litemall.core.util.ResponseUtil; import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.LitemallAddress; import org.linlinjava.litemall.db.domain.LitemallAddress;
import org.linlinjava.litemall.db.domain.LitemallRegion;
import org.linlinjava.litemall.db.service.LitemallAddressService; import org.linlinjava.litemall.db.service.LitemallAddressService;
import org.linlinjava.litemall.db.service.LitemallRegionService; import org.linlinjava.litemall.db.service.LitemallRegionService;
import org.linlinjava.litemall.wx.annotation.LoginUser; import org.linlinjava.litemall.wx.annotation.LoginUser;
...@@ -16,11 +15,7 @@ import org.springframework.validation.annotation.Validated; ...@@ -16,11 +15,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.*;
/** /**
* 用户收货地址服务 * 用户收货地址服务
...@@ -37,11 +32,6 @@ public class WxAddressController extends GetRegionService { ...@@ -37,11 +32,6 @@ public class WxAddressController extends GetRegionService {
@Autowired @Autowired
private LitemallRegionService regionService; private LitemallRegionService regionService;
private final static ArrayBlockingQueue<Runnable> WORK_QUEUE = new ArrayBlockingQueue<>(6);
private final static RejectedExecutionHandler HANDLER = new ThreadPoolExecutor.CallerRunsPolicy();
private static ThreadPoolExecutor executorService = new ThreadPoolExecutor(3, 6, 1000, TimeUnit.MILLISECONDS, WORK_QUEUE, HANDLER);
/** /**
* 用户收货地址列表 * 用户收货地址列表
...@@ -55,39 +45,7 @@ public class WxAddressController extends GetRegionService { ...@@ -55,39 +45,7 @@ public class WxAddressController extends GetRegionService {
return ResponseUtil.unlogin(); return ResponseUtil.unlogin();
} }
List<LitemallAddress> addressList = addressService.queryByUid(userId); List<LitemallAddress> addressList = addressService.queryByUid(userId);
List<Map<String, Object>> addressVoList = new ArrayList<>(addressList.size()); return ResponseUtil.ok(addressList);
List<LitemallRegion> regionList = getLitemallRegions();
for (LitemallAddress address : addressList) {
Map<String, Object> addressVo = new HashMap<>();
addressVo.put("id", address.getId());
addressVo.put("name", address.getName());
addressVo.put("mobile", address.getMobile());
addressVo.put("isDefault", address.getIsDefault());
Callable<String> provinceCallable = () -> regionList.stream().filter(region -> region.getId().equals(address.getProvinceId())).findAny().orElse(null).getName();
Callable<String> cityCallable = () -> regionList.stream().filter(region -> region.getId().equals(address.getCityId())).findAny().orElse(null).getName();
Callable<String> areaCallable = () -> regionList.stream().filter(region -> region.getId().equals(address.getAreaId())).findAny().orElse(null).getName();
FutureTask<String> provinceNameCallableTask = new FutureTask<>(provinceCallable);
FutureTask<String> cityNameCallableTask = new FutureTask<>(cityCallable);
FutureTask<String> areaNameCallableTask = new FutureTask<>(areaCallable);
executorService.submit(provinceNameCallableTask);
executorService.submit(cityNameCallableTask);
executorService.submit(areaNameCallableTask);
String detailedAddress = "";
try {
String province = provinceNameCallableTask.get();
String city = cityNameCallableTask.get();
String area = areaNameCallableTask.get();
String addr = address.getAddress();
detailedAddress = province + city + area + " " + addr;
}
catch (Exception e) {
e.printStackTrace();
}
addressVo.put("detailedAddress", detailedAddress);
addressVoList.add(addressVo);
}
return ResponseUtil.ok(addressVoList);
} }
/** /**
...@@ -107,23 +65,7 @@ public class WxAddressController extends GetRegionService { ...@@ -107,23 +65,7 @@ public class WxAddressController extends GetRegionService {
if (address == null) { if (address == null) {
return ResponseUtil.badArgumentValue(); return ResponseUtil.badArgumentValue();
} }
return ResponseUtil.ok(address);
Map<Object, Object> data = new HashMap<Object, Object>();
data.put("id", address.getId());
data.put("name", address.getName());
data.put("provinceId", address.getProvinceId());
data.put("cityId", address.getCityId());
data.put("areaId", address.getAreaId());
data.put("mobile", address.getMobile());
data.put("address", address.getAddress());
data.put("isDefault", address.getIsDefault());
String pname = regionService.findById(address.getProvinceId()).getName();
data.put("provinceName", pname);
String cname = regionService.findById(address.getCityId()).getName();
data.put("cityName", cname);
String dname = regionService.findById(address.getAreaId()).getName();
data.put("areaName", dname);
return ResponseUtil.ok(data);
} }
private Object validate(LitemallAddress address) { private Object validate(LitemallAddress address) {
...@@ -133,7 +75,7 @@ public class WxAddressController extends GetRegionService { ...@@ -133,7 +75,7 @@ public class WxAddressController extends GetRegionService {
} }
// 测试收货手机号码是否正确 // 测试收货手机号码是否正确
String mobile = address.getMobile(); String mobile = address.getTel();
if (StringUtils.isEmpty(mobile)) { if (StringUtils.isEmpty(mobile)) {
return ResponseUtil.badArgument(); return ResponseUtil.badArgument();
} }
...@@ -141,31 +83,28 @@ public class WxAddressController extends GetRegionService { ...@@ -141,31 +83,28 @@ public class WxAddressController extends GetRegionService {
return ResponseUtil.badArgument(); return ResponseUtil.badArgument();
} }
Integer pid = address.getProvinceId(); String province = address.getProvince();
if (pid == null) { if (StringUtils.isEmpty(province)) {
return ResponseUtil.badArgument(); return ResponseUtil.badArgument();
} }
if (regionService.findById(pid) == null) {
return ResponseUtil.badArgumentValue();
}
Integer cid = address.getCityId(); String city = address.getCity();
if (cid == null) { if (StringUtils.isEmpty(city)) {
return ResponseUtil.badArgument(); return ResponseUtil.badArgument();
} }
if (regionService.findById(cid) == null) {
return ResponseUtil.badArgumentValue();
}
Integer aid = address.getAreaId(); String county = address.getCounty();
if (aid == null) { if (StringUtils.isEmpty(county)) {
return ResponseUtil.badArgument(); return ResponseUtil.badArgument();
} }
if (regionService.findById(aid) == null) {
return ResponseUtil.badArgumentValue();
String areaCode = address.getAreaCode();
if (StringUtils.isEmpty(areaCode)) {
return ResponseUtil.badArgument();
} }
String detailedAddress = address.getAddress(); String detailedAddress = address.getAddressDetail();
if (StringUtils.isEmpty(detailedAddress)) { if (StringUtils.isEmpty(detailedAddress)) {
return ResponseUtil.badArgument(); return ResponseUtil.badArgument();
} }
......
...@@ -491,10 +491,11 @@ public class WxCartController { ...@@ -491,10 +491,11 @@ public class WxCartController {
Map<String, Object> data = new HashMap<>(); Map<String, Object> data = new HashMap<>();
data.put("addressId", addressId); data.put("addressId", addressId);
data.put("couponId", couponId);
data.put("cartId", cartId);
data.put("grouponRulesId", grouponRulesId); data.put("grouponRulesId", grouponRulesId);
data.put("grouponPrice", grouponPrice); data.put("grouponPrice", grouponPrice);
data.put("checkedAddress", checkedAddress); data.put("checkedAddress", checkedAddress);
data.put("couponId", couponId);
data.put("availableCouponLength", availableCouponLength); data.put("availableCouponLength", availableCouponLength);
data.put("goodsTotalPrice", checkedGoodsPrice); data.put("goodsTotalPrice", checkedGoodsPrice);
data.put("freightPrice", freightPrice); data.put("freightPrice", freightPrice);
......
package org.linlinjava.litemall.wx.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.LitemallRegion;
import org.linlinjava.litemall.db.service.LitemallRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 区域服务
*/
@RestController
@RequestMapping("/wx/region")
@Validated
public class WxRegionController {
private final Log logger = LogFactory.getLog(WxRegionController.class);
@Autowired
private LitemallRegionService regionService;
/**
* 区域数据
* <p>
* 根据父区域ID,返回子区域数据。
* 如果父区域ID是0,则返回省级区域数据;
*
* @param pid 父区域ID
* @return 区域数据
*/
@GetMapping("list")
public Object list(@NotNull Integer pid) {
List<LitemallRegion> regionList = regionService.queryByPid(pid);
return ResponseUtil.ok(regionList);
}
}
\ No newline at end of file
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<view class="default" wx:if="{{item.isDefault}}">默认</view> <view class="default" wx:if="{{item.isDefault}}">默认</view>
</view> </view>
<view class="c"> <view class="c">
<view class="mobile">{{item.mobile}}</view> <view class="mobile">{{item.tel}}</view>
<view class="address">{{item.detailedAddress}}</view> <view class="address">{{item.addressDetail}}</view>
</view> </view>
<view class="r"> <view class="r">
<image catchtap="deleteAddress" data-address-id="{{item.id}}" class="del" src="/static/images/del-address.png"></image> <image catchtap="deleteAddress" data-address-id="{{item.id}}" class="del" src="/static/images/del-address.png"></image>
......
var util = require('../../../utils/util.js'); var util = require('../../../utils/util.js');
var api = require('../../../config/api.js'); var api = require('../../../config/api.js');
var check = require('../../../utils/check.js'); var check = require('../../../utils/check.js');
var area = require('../../../utils/area.js');
var app = getApp(); var app = getApp();
Page({ Page({
data: { data: {
address: { address: {
id: 0, id: 0,
provinceId: 0, areaCode: 0,
cityId: 0,
areaId: 0,
address: '', address: '',
name: '', name: '',
mobile: '', tel: '',
isDefault: 0, isDefault: 0,
provinceName: '', province: '',
cityName: '', city: '',
areaName: '' county: ''
}, },
addressId: 0, addressId: 0,
openSelectRegion: false, openSelectRegion: false,
selectRegionList: [{ selectRegionList: [{
id: 0, code: 0,
name: '省份', name: '省份'
pid: 1,
type: 1
}, },
{ {
id: 0, code: 0,
name: '城市', name: '城市'
pid: 1,
type: 2
}, },
{ {
id: 0, code: 0,
name: '区县', name: '区县'
pid: 1,
type: 3
} }
], ],
regionType: 1, regionType: 1,
...@@ -45,7 +38,7 @@ Page({ ...@@ -45,7 +38,7 @@ Page({
}, },
bindinputMobile(event) { bindinputMobile(event) {
let address = this.data.address; let address = this.data.address;
address.mobile = event.detail.value; address.tel = event.detail.value;
this.setData({ this.setData({
address: address address: address
}); });
...@@ -59,7 +52,7 @@ Page({ ...@@ -59,7 +52,7 @@ Page({
}, },
bindinputAddress(event) { bindinputAddress(event) {
let address = this.data.address; let address = this.data.address;
address.address = event.detail.value; address.addressDetail = event.detail.value;
this.setData({ this.setData({
address: address address: address
}); });
...@@ -88,7 +81,7 @@ Page({ ...@@ -88,7 +81,7 @@ Page({
setRegionDoneStatus() { setRegionDoneStatus() {
let that = this; let that = this;
let doneStatus = that.data.selectRegionList.every(item => { let doneStatus = that.data.selectRegionList.every(item => {
return item.id != 0; return item.code != 0;
}); });
that.setData({ that.setData({
...@@ -104,50 +97,54 @@ Page({ ...@@ -104,50 +97,54 @@ Page({
//设置区域选择数据 //设置区域选择数据
let address = this.data.address; let address = this.data.address;
if (address.provinceId > 0 && address.cityId > 0 && address.areaId > 0) { if (address.areaCode > 0) {
let selectRegionList = this.data.selectRegionList; let selectRegionList = this.data.selectRegionList;
selectRegionList[0].id = address.provinceId; selectRegionList[0].code = address.areaCode.slice(0, 2) + '0000';
selectRegionList[0].name = address.provinceName; selectRegionList[0].name = address.province;
selectRegionList[0].pid = 0;
selectRegionList[1].id = address.cityId; selectRegionList[1].code = address.areaCode.slice(0, 4) + '00';
selectRegionList[1].name = address.cityName; selectRegionList[1].name = address.city;
selectRegionList[1].pid = address.provinceId;
selectRegionList[2].id = address.areaId; selectRegionList[2].code = address.areaCode;
selectRegionList[2].name = address.areaName; selectRegionList[2].name = address.county;
selectRegionList[2].pid = address.cityId;
let regionList = area.getList('county', address.areaCode.slice(0, 4));
regionList = regionList.map(item => {
//标记已选择的
if (address.areaCode === item.code) {
item.selected = true;
} else {
item.selected = false;
}
return item;
})
this.setData({ this.setData({
selectRegionList: selectRegionList, selectRegionList: selectRegionList,
regionType: 3 regionType: 3,
regionList: regionList
}); });
this.getRegionList(address.cityId);
} else { } else {
this.setData({ let selectRegionList = [{
selectRegionList: [{ code: 0,
id: 0,
name: '省份', name: '省份',
pid: 0,
type: 1
}, },
{ {
id: 0, code: 0,
name: '城市', name: '城市',
pid: 0,
type: 2
}, },
{ {
id: 0, code: 0,
name: '区县', name: '区县',
pid: 0,
type: 3
} }
], ];
regionType: 1
}) this.setData({
this.getRegionList(0); selectRegionList: selectRegionList,
regionType: 1,
regionList: area.getList('province')
});
} }
this.setRegionDoneStatus(); this.setRegionDoneStatus();
...@@ -172,73 +169,104 @@ Page({ ...@@ -172,73 +169,104 @@ Page({
let selectRegionList = that.data.selectRegionList; let selectRegionList = that.data.selectRegionList;
//判断是否可点击 //判断是否可点击
if (regionTypeIndex + 1 == this.data.regionType || (regionTypeIndex - 1 >= 0 && selectRegionList[regionTypeIndex - 1].id <= 0)) { if (regionTypeIndex + 1 == this.data.regionType || (regionTypeIndex - 1 >= 0 && selectRegionList[regionTypeIndex - 1].code <= 0)) {
return false; return false;
} }
let selectRegionItem = selectRegionList[regionTypeIndex];
let code = selectRegionItem.code;
let regionList;
if (regionTypeIndex === 0) {
// 点击省级,取省级
regionList = area.getList('province');
}
else if (regionTypeIndex === 1) {
// 点击市级,取市级
regionList = area.getList('city', code.slice(0, 2));
}
else{
// 点击县级,取县级
regionList = area.getList('county', code.slice(0, 4));
}
regionList = regionList.map(item => {
//标记已选择的
if (that.data.selectRegionList[regionTypeIndex].code == item.code) {
item.selected = true;
} else {
item.selected = false;
}
return item;
})
this.setData({ this.setData({
regionList: regionList,
regionType: regionTypeIndex + 1 regionType: regionTypeIndex + 1
}) })
let selectRegionItem = selectRegionList[regionTypeIndex];
this.getRegionList(selectRegionItem.pid);
this.setRegionDoneStatus(); this.setRegionDoneStatus();
}, },
selectRegion(event) { selectRegion(event) {
let that = this; let that = this;
let regionIndex = event.target.dataset.regionIndex; let regionIndex = event.target.dataset.regionIndex;
let regionItem = this.data.regionList[regionIndex]; let regionItem = this.data.regionList[regionIndex];
let regionType = regionItem.type; let regionType = this.data.regionType;
let selectRegionList = this.data.selectRegionList; let selectRegionList = this.data.selectRegionList;
selectRegionList[regionType - 1] = regionItem; selectRegionList[regionType - 1] = regionItem;
if (regionType == 3) {
if (regionType != 3) {
this.setData({ this.setData({
selectRegionList: selectRegionList, selectRegionList: selectRegionList
regionType: regionType + 1
}) })
this.getRegionList(regionItem.id);
} else { let regionList = that.data.regionList.map(item => {
//标记已选择的
if (that.data.selectRegionList[that.data.regionType - 1].code == item.code) {
item.selected = true;
} else {
item.selected = false;
}
return item;
})
this.setData({ this.setData({
selectRegionList: selectRegionList regionList: regionList
}) })
this.setRegionDoneStatus();
return
} }
//重置下级区域为空 //重置下级区域为空
selectRegionList.map((item, index) => { selectRegionList.map((item, index) => {
if (index > regionType - 1) { if (index > regionType - 1) {
item.id = 0; item.code = 0;
item.name = index == 1 ? '城市' : '区县'; item.name = index == 1 ? '城市' : '区县';
item.pid = 0;
} }
return item; return item;
}); });
this.setData({ this.setData({
selectRegionList: selectRegionList selectRegionList: selectRegionList,
regionType: regionType + 1
}) })
let code = regionItem.code;
let regionList = [];
if (regionType === 1) {
// 点击省级,取市级
regionList= area.getList('city', code.slice(0, 2))
}
else {
// 点击市级,取县级
regionList= area.getList('county', code.slice(0, 4))
}
this.setData({
that.setData({ regionList: regionList
regionList: that.data.regionList.map(item => { })
//标记已选择的
if (that.data.regionType == item.type && that.data.selectRegionList[that.data.regionType - 1].id == item.id) {
item.selected = true;
} else {
item.selected = false;
}
return item;
})
});
this.setRegionDoneStatus(); this.setRegionDoneStatus();
}, },
doneSelectRegion() { doneSelectRegion() {
if (this.data.selectRegionDone === false) { if (this.data.selectRegionDone === false) {
...@@ -247,12 +275,10 @@ Page({ ...@@ -247,12 +275,10 @@ Page({
let address = this.data.address; let address = this.data.address;
let selectRegionList = this.data.selectRegionList; let selectRegionList = this.data.selectRegionList;
address.provinceId = selectRegionList[0].id; address.province = selectRegionList[0].name;
address.cityId = selectRegionList[1].id; address.city = selectRegionList[1].name;
address.areaId = selectRegionList[2].id; address.county = selectRegionList[2].name;
address.provinceName = selectRegionList[0].name; address.areaCode = selectRegionList[2].code;
address.cityName = selectRegionList[1].name;
address.areaName = selectRegionList[2].name;
this.setData({ this.setData({
address: address, address: address,
...@@ -267,29 +293,6 @@ Page({ ...@@ -267,29 +293,6 @@ Page({
}); });
}, },
getRegionList(regionId) {
let that = this;
let regionType = that.data.regionType;
util.request(api.RegionList, {
pid: regionId
}).then(function(res) {
if (res.errno === 0) {
that.setData({
regionList: res.data.map(item => {
//标记已选择的
if (regionType == item.type && that.data.selectRegionList[regionType - 1].id == item.id) {
item.selected = true;
} else {
item.selected = false;
}
return item;
})
});
}
});
},
cancelAddress() { cancelAddress() {
wx.navigateBack(); wx.navigateBack();
}, },
...@@ -303,23 +306,23 @@ Page({ ...@@ -303,23 +306,23 @@ Page({
return false; return false;
} }
if (address.mobile == '') { if (address.tel == '') {
util.showErrorToast('请输入手机号码'); util.showErrorToast('请输入手机号码');
return false; return false;
} }
if (address.areaId == 0) { if (address.areaCode == 0) {
util.showErrorToast('请输入省市区'); util.showErrorToast('请输入省市区');
return false; return false;
} }
if (address.address == '') { if (address.addressDetail == '') {
util.showErrorToast('请输入详细地址'); util.showErrorToast('请输入详细地址');
return false; return false;
} }
if (!check.isValidPhone(address.mobile)) { if (!check.isValidPhone(address.tel)) {
util.showErrorToast('手机号不正确'); util.showErrorToast('手机号不正确');
return false; return false;
} }
...@@ -328,11 +331,12 @@ Page({ ...@@ -328,11 +331,12 @@ Page({
util.request(api.AddressSave, { util.request(api.AddressSave, {
id: address.id, id: address.id,
name: address.name, name: address.name,
mobile: address.mobile, tel: address.tel,
provinceId: address.provinceId, province: address.province,
cityId: address.cityId, city: address.city,
areaId: address.areaId, county: address.county,
address: address.address, areaCode: address.areaCode,
addressDetail: address.addressDetail,
isDefault: address.isDefault isDefault: address.isDefault
}, 'POST').then(function(res) { }, 'POST').then(function(res) {
if (res.errno === 0) { if (res.errno === 0) {
...@@ -359,7 +363,6 @@ Page({ ...@@ -359,7 +363,6 @@ Page({
}, },
onShow: function() { onShow: function() {
// 页面显示 // 页面显示
}, },
onHide: function() { onHide: function() {
// 页面隐藏 // 页面隐藏
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
<input class="input" bindinput="bindinputName" placeholder="姓名" value="{{address.name}}" auto-focus/> <input class="input" bindinput="bindinputName" placeholder="姓名" value="{{address.name}}" auto-focus/>
</view> </view>
<view class="form-item"> <view class="form-item">
<input class="input" bindinput="bindinputMobile" value="{{address.mobile}}" placeholder="手机号码" /> <input class="input" bindinput="bindinputMobile" value="{{address.tel}}" placeholder="手机号码" />
</view> </view>
<view class="form-item"> <view class="form-item">
<input class="input" value="{{address.provinceName + address.cityName + address.areaName}}" disabled="true" bindtap="chooseRegion" placeholder="省份、城市、区县" /> <input class="input" value="{{address.province + address.city + address.county}}" disabled="true" bindtap="chooseRegion" placeholder="省份、城市、区县" />
</view> </view>
<view class="form-item"> <view class="form-item">
<input class="input" bindinput="bindinputAddress" value="{{address.address}}" placeholder="详细地址, 如街道、楼盘号等" /> <input class="input" bindinput="bindinputAddress" value="{{address.addressDetail}}" placeholder="详细地址, 如街道、楼盘号等" />
</view> </view>
<view class="form-default"> <view class="form-default">
<text bindtap="bindIsDefault" class="default-input {{address.isDefault == 1 ? 'selected' : ''}}">设为默认地址</text> <text bindtap="bindIsDefault" class="default-input {{address.isDefault == 1 ? 'selected' : ''}}">设为默认地址</text>
...@@ -25,13 +25,13 @@ ...@@ -25,13 +25,13 @@
<view class="region-select" wx:if="{{openSelectRegion}}"> <view class="region-select" wx:if="{{openSelectRegion}}">
<view class="hd"> <view class="hd">
<view class="region-selected"> <view class="region-selected">
<view class="item {{item.id == 0 ? 'disabled' : ''}} {{(regionType -1) === index ? 'selected' : ''}}" bindtap="selectRegionType" data-region-type-index="{{index}}" wx:for="{{selectRegionList}}" wx:key="id">{{item.name}}</view> <view class="item {{item.code == 0 ? 'disabled' : ''}} {{(regionType -1) === index ? 'selected' : ''}}" bindtap="selectRegionType" data-region-type-index="{{index}}" wx:for="{{selectRegionList}}" wx:key="code">{{item.name}}</view>
</view> </view>
<view class="done {{selectRegionDone ? '' : 'disabled'}}" bindtap="doneSelectRegion">确定</view> <view class="done {{selectRegionDone ? '' : 'disabled'}}" bindtap="doneSelectRegion">确定</view>
</view> </view>
<view class="bd"> <view class="bd">
<scroll-view scroll-y class="region-list"> <scroll-view scroll-y class="region-list">
<view class="item {{item.selected ? 'selected' : ''}}" bindtap="selectRegion" data-region-index="{{index}}" wx:for="{{regionList}}" wx:key="id">{{item.name}}</view> <view class="item {{item.selected ? 'selected' : ''}}" bindtap="selectRegion" data-region-index="{{index}}" wx:for="{{regionList}}" wx:key="code">{{item.name}}</view>
</scroll-view> </scroll-view>
</view> </view>
</view> </view>
......
This diff is collapsed.
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<view class="default" wx:if="{{item.isDefault}}">默认</view> <view class="default" wx:if="{{item.isDefault}}">默认</view>
</view> </view>
<view class="c"> <view class="c">
<view class="mobile">{{item.mobile}}</view> <view class="mobile">{{item.tel}}</view>
<view class="address">{{item.detailedAddress}}</view> <view class="address">{{item.addressDetail}}</view>
</view> </view>
<view class="r"> <view class="r">
<image catchtap="deleteAddress" data-address-id="{{item.id}}" class="del" src="/static/images/del-address.png"></image> <image catchtap="deleteAddress" data-address-id="{{item.id}}" class="del" src="/static/images/del-address.png"></image>
......
var util = require('../../../utils/util.js'); var util = require('../../../utils/util.js');
var api = require('../../../config/api.js'); var api = require('../../../config/api.js');
var check = require('../../../utils/check.js'); var check = require('../../../utils/check.js');
var area = require('../../../utils/area.js');
var app = getApp(); var app = getApp();
Page({ Page({
data: { data: {
address: { address: {
id: 0, id: 0,
provinceId: 0, areaCode: 0,
cityId: 0,
areaId: 0,
address: '', address: '',
name: '', name: '',
mobile: '', tel: '',
isDefault: 0, isDefault: 0,
provinceName: '', province: '',
cityName: '', city: '',
areaName: '' county: ''
}, },
addressId: 0, addressId: 0,
openSelectRegion: false, openSelectRegion: false,
selectRegionList: [{ selectRegionList: [{
id: 0, code: 0,
name: '省份', name: '省份'
pid: 1, },
type: 1 {
}, code: 0,
{ name: '城市'
id: 0, },
name: '城市', {
pid: 1, code: 0,
type: 2 name: '区县'
}, }
{
id: 0,
name: '区县',
pid: 1,
type: 3
}
], ],
regionType: 1, regionType: 1,
regionList: [], regionList: [],
...@@ -45,7 +38,7 @@ Page({ ...@@ -45,7 +38,7 @@ Page({
}, },
bindinputMobile(event) { bindinputMobile(event) {
let address = this.data.address; let address = this.data.address;
address.mobile = event.detail.value; address.tel = event.detail.value;
this.setData({ this.setData({
address: address address: address
}); });
...@@ -59,7 +52,7 @@ Page({ ...@@ -59,7 +52,7 @@ Page({
}, },
bindinputAddress(event) { bindinputAddress(event) {
let address = this.data.address; let address = this.data.address;
address.address = event.detail.value; address.addressDetail = event.detail.value;
this.setData({ this.setData({
address: address address: address
}); });
...@@ -75,7 +68,7 @@ Page({ ...@@ -75,7 +68,7 @@ Page({
let that = this; let that = this;
util.request(api.AddressDetail, { util.request(api.AddressDetail, {
id: that.data.addressId id: that.data.addressId
}).then(function(res) { }).then(function (res) {
if (res.errno === 0) { if (res.errno === 0) {
if (res.data) { if (res.data) {
that.setData({ that.setData({
...@@ -88,7 +81,7 @@ Page({ ...@@ -88,7 +81,7 @@ Page({
setRegionDoneStatus() { setRegionDoneStatus() {
let that = this; let that = this;
let doneStatus = that.data.selectRegionList.every(item => { let doneStatus = that.data.selectRegionList.every(item => {
return item.id != 0; return item.code != 0;
}); });
that.setData({ that.setData({
...@@ -104,56 +97,60 @@ Page({ ...@@ -104,56 +97,60 @@ Page({
//设置区域选择数据 //设置区域选择数据
let address = this.data.address; let address = this.data.address;
if (address.provinceId > 0 && address.cityId > 0 && address.areaId > 0) { if (address.areaCode > 0) {
let selectRegionList = this.data.selectRegionList; let selectRegionList = this.data.selectRegionList;
selectRegionList[0].id = address.provinceId; selectRegionList[0].code = address.areaCode.slice(0, 2) + '0000';
selectRegionList[0].name = address.provinceName; selectRegionList[0].name = address.province;
selectRegionList[0].pid = 0;
selectRegionList[1].id = address.cityId; selectRegionList[1].code = address.areaCode.slice(0, 4) + '00';
selectRegionList[1].name = address.cityName; selectRegionList[1].name = address.city;
selectRegionList[1].pid = address.provinceId;
selectRegionList[2].id = address.areaId; selectRegionList[2].code = address.areaCode;
selectRegionList[2].name = address.areaName; selectRegionList[2].name = address.county;
selectRegionList[2].pid = address.cityId;
let regionList = area.getList('county', address.areaCode.slice(0, 4));
regionList = regionList.map(item => {
//标记已选择的
if (address.areaCode === item.code) {
item.selected = true;
} else {
item.selected = false;
}
return item;
})
this.setData({ this.setData({
selectRegionList: selectRegionList, selectRegionList: selectRegionList,
regionType: 3 regionType: 3,
regionList: regionList
}); });
this.getRegionList(address.cityId);
} else { } else {
let selectRegionList = [{
code: 0,
name: '省份',
},
{
code: 0,
name: '城市',
},
{
code: 0,
name: '区县',
}
];
this.setData({ this.setData({
selectRegionList: [{ selectRegionList: selectRegionList,
id: 0, regionType: 1,
name: '省份', regionList: area.getList('province')
pid: 0, });
type: 1
},
{
id: 0,
name: '城市',
pid: 0,
type: 2
},
{
id: 0,
name: '区县',
pid: 0,
type: 3
}
],
regionType: 1
})
this.getRegionList(0);
} }
this.setRegionDoneStatus(); this.setRegionDoneStatus();
}, },
onLoad: function(options) { onLoad: function (options) {
// 页面初始化 options为页面跳转所带来的参数 // 页面初始化 options为页面跳转所带来的参数
console.log(options) console.log(options)
if (options.id && options.id != 0) { if (options.id && options.id != 0) {
...@@ -163,7 +160,7 @@ Page({ ...@@ -163,7 +160,7 @@ Page({
this.getAddressDetail(); this.getAddressDetail();
} }
}, },
onReady: function() { onReady: function () {
}, },
selectRegionType(event) { selectRegionType(event) {
...@@ -172,73 +169,104 @@ Page({ ...@@ -172,73 +169,104 @@ Page({
let selectRegionList = that.data.selectRegionList; let selectRegionList = that.data.selectRegionList;
//判断是否可点击 //判断是否可点击
if (regionTypeIndex + 1 == this.data.regionType || (regionTypeIndex - 1 >= 0 && selectRegionList[regionTypeIndex - 1].id <= 0)) { if (regionTypeIndex + 1 == this.data.regionType || (regionTypeIndex - 1 >= 0 && selectRegionList[regionTypeIndex - 1].code <= 0)) {
return false; return false;
} }
let selectRegionItem = selectRegionList[regionTypeIndex];
let code = selectRegionItem.code;
let regionList;
if (regionTypeIndex === 0) {
// 点击省级,取省级
regionList = area.getList('province');
}
else if (regionTypeIndex === 1) {
// 点击市级,取市级
regionList = area.getList('city', code.slice(0, 2));
}
else {
// 点击县级,取县级
regionList = area.getList('county', code.slice(0, 4));
}
regionList = regionList.map(item => {
//标记已选择的
if (that.data.selectRegionList[regionTypeIndex].code == item.code) {
item.selected = true;
} else {
item.selected = false;
}
return item;
})
this.setData({ this.setData({
regionList: regionList,
regionType: regionTypeIndex + 1 regionType: regionTypeIndex + 1
}) })
let selectRegionItem = selectRegionList[regionTypeIndex];
this.getRegionList(selectRegionItem.pid);
this.setRegionDoneStatus(); this.setRegionDoneStatus();
}, },
selectRegion(event) { selectRegion(event) {
let that = this; let that = this;
let regionIndex = event.target.dataset.regionIndex; let regionIndex = event.target.dataset.regionIndex;
let regionItem = this.data.regionList[regionIndex]; let regionItem = this.data.regionList[regionIndex];
let regionType = regionItem.type; let regionType = this.data.regionType;
let selectRegionList = this.data.selectRegionList; let selectRegionList = this.data.selectRegionList;
selectRegionList[regionType - 1] = regionItem; selectRegionList[regionType - 1] = regionItem;
if (regionType == 3) {
if (regionType != 3) {
this.setData({ this.setData({
selectRegionList: selectRegionList, selectRegionList: selectRegionList
regionType: regionType + 1
}) })
this.getRegionList(regionItem.id);
} else { let regionList = that.data.regionList.map(item => {
//标记已选择的
if (that.data.selectRegionList[that.data.regionType - 1].code == item.code) {
item.selected = true;
} else {
item.selected = false;
}
return item;
})
this.setData({ this.setData({
selectRegionList: selectRegionList regionList: regionList
}) })
this.setRegionDoneStatus();
return
} }
//重置下级区域为空 //重置下级区域为空
selectRegionList.map((item, index) => { selectRegionList.map((item, index) => {
if (index > regionType - 1) { if (index > regionType - 1) {
item.id = 0; item.code = 0;
item.name = index == 1 ? '城市' : '区县'; item.name = index == 1 ? '城市' : '区县';
item.pid = 0;
} }
return item; return item;
}); });
this.setData({ this.setData({
selectRegionList: selectRegionList selectRegionList: selectRegionList,
regionType: regionType + 1
}) })
let code = regionItem.code;
let regionList = [];
if (regionType === 1) {
// 点击省级,取市级
regionList = area.getList('city', code.slice(0, 2))
}
else {
// 点击市级,取县级
regionList = area.getList('county', code.slice(0, 4))
}
that.setData({ this.setData({
regionList: that.data.regionList.map(item => { regionList: regionList
})
//标记已选择的
if (that.data.regionType == item.type && that.data.selectRegionList[that.data.regionType - 1].id == item.id) {
item.selected = true;
} else {
item.selected = false;
}
return item;
})
});
this.setRegionDoneStatus(); this.setRegionDoneStatus();
}, },
doneSelectRegion() { doneSelectRegion() {
if (this.data.selectRegionDone === false) { if (this.data.selectRegionDone === false) {
...@@ -247,12 +275,10 @@ Page({ ...@@ -247,12 +275,10 @@ Page({
let address = this.data.address; let address = this.data.address;
let selectRegionList = this.data.selectRegionList; let selectRegionList = this.data.selectRegionList;
address.provinceId = selectRegionList[0].id; address.province = selectRegionList[0].name;
address.cityId = selectRegionList[1].id; address.city = selectRegionList[1].name;
address.areaId = selectRegionList[2].id; address.county = selectRegionList[2].name;
address.provinceName = selectRegionList[0].name; address.areaCode = selectRegionList[2].code;
address.cityName = selectRegionList[1].name;
address.areaName = selectRegionList[2].name;
this.setData({ this.setData({
address: address, address: address,
...@@ -267,29 +293,6 @@ Page({ ...@@ -267,29 +293,6 @@ Page({
}); });
}, },
getRegionList(regionId) {
let that = this;
let regionType = that.data.regionType;
util.request(api.RegionList, {
pid: regionId
}).then(function(res) {
if (res.errno === 0) {
that.setData({
regionList: res.data.map(item => {
//标记已选择的
if (regionType == item.type && that.data.selectRegionList[regionType - 1].id == item.id) {
item.selected = true;
} else {
item.selected = false;
}
return item;
})
});
}
});
},
cancelAddress() { cancelAddress() {
wx.navigateBack(); wx.navigateBack();
}, },
...@@ -303,23 +306,23 @@ Page({ ...@@ -303,23 +306,23 @@ Page({
return false; return false;
} }
if (address.mobile == '') { if (address.tel == '') {
util.showErrorToast('请输入手机号码'); util.showErrorToast('请输入手机号码');
return false; return false;
} }
if (address.areaId == 0) { if (address.areaCode == 0) {
util.showErrorToast('请输入省市区'); util.showErrorToast('请输入省市区');
return false; return false;
} }
if (address.address == '') { if (address.addressDetail == '') {
util.showErrorToast('请输入详细地址'); util.showErrorToast('请输入详细地址');
return false; return false;
} }
if (!check.isValidPhone(address.mobile)) { if (!check.isValidPhone(address.tel)) {
util.showErrorToast('手机号不正确'); util.showErrorToast('手机号不正确');
return false; return false;
} }
...@@ -328,13 +331,14 @@ Page({ ...@@ -328,13 +331,14 @@ Page({
util.request(api.AddressSave, { util.request(api.AddressSave, {
id: address.id, id: address.id,
name: address.name, name: address.name,
mobile: address.mobile, tel: address.tel,
provinceId: address.provinceId, province: address.province,
cityId: address.cityId, city: address.city,
areaId: address.areaId, county: address.county,
address: address.address, areaCode: address.areaCode,
addressDetail: address.addressDetail,
isDefault: address.isDefault isDefault: address.isDefault
}, 'POST').then(function(res) { }, 'POST').then(function (res) {
if (res.errno === 0) { if (res.errno === 0) {
//返回之前,先取出上一页对象,并设置addressId //返回之前,先取出上一页对象,并设置addressId
var pages = getCurrentPages(); var pages = getCurrentPages();
...@@ -357,15 +361,14 @@ Page({ ...@@ -357,15 +361,14 @@ Page({
}); });
}, },
onShow: function() { onShow: function () {
// 页面显示 // 页面显示
}, },
onHide: function() { onHide: function () {
// 页面隐藏 // 页面隐藏
}, },
onUnload: function() { onUnload: function () {
// 页面关闭 // 页面关闭
} }
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
<input class="input" bindinput="bindinputName" placeholder="姓名" value="{{address.name}}" auto-focus/> <input class="input" bindinput="bindinputName" placeholder="姓名" value="{{address.name}}" auto-focus/>
</view> </view>
<view class="form-item"> <view class="form-item">
<input class="input" bindinput="bindinputMobile" value="{{address.mobile}}" placeholder="手机号码" /> <input class="input" bindinput="bindinputMobile" value="{{address.tel}}" placeholder="手机号码" />
</view> </view>
<view class="form-item"> <view class="form-item">
<input class="input" value="{{address.provinceName + address.cityName + address.areaName}}" disabled="true" bindtap="chooseRegion" placeholder="省份、城市、区县" /> <input class="input" value="{{address.province + address.city + address.county}}" disabled="true" bindtap="chooseRegion" placeholder="省份、城市、区县" />
</view> </view>
<view class="form-item"> <view class="form-item">
<input class="input" bindinput="bindinputAddress" value="{{address.address}}" placeholder="详细地址, 如街道、楼盘号等" /> <input class="input" bindinput="bindinputAddress" value="{{address.addressDetail}}" placeholder="详细地址, 如街道、楼盘号等" />
</view> </view>
<view class="form-default"> <view class="form-default">
<text bindtap="bindIsDefault" class="default-input {{address.isDefault == 1 ? 'selected' : ''}}">设为默认地址</text> <text bindtap="bindIsDefault" class="default-input {{address.isDefault == 1 ? 'selected' : ''}}">设为默认地址</text>
...@@ -25,13 +25,13 @@ ...@@ -25,13 +25,13 @@
<view class="region-select" wx:if="{{openSelectRegion}}"> <view class="region-select" wx:if="{{openSelectRegion}}">
<view class="hd"> <view class="hd">
<view class="region-selected"> <view class="region-selected">
<view class="item {{item.id == 0 ? 'disabled' : ''}} {{(regionType -1) === index ? 'selected' : ''}}" bindtap="selectRegionType" data-region-type-index="{{index}}" wx:for="{{selectRegionList}}" wx:key="id">{{item.name}}</view> <view class="item {{item.code == 0 ? 'disabled' : ''}} {{(regionType -1) === index ? 'selected' : ''}}" bindtap="selectRegionType" data-region-type-index="{{index}}" wx:for="{{selectRegionList}}" wx:key="code">{{item.name}}</view>
</view> </view>
<view class="done {{selectRegionDone ? '' : 'disabled'}}" bindtap="doneSelectRegion">确定</view> <view class="done {{selectRegionDone ? '' : 'disabled'}}" bindtap="doneSelectRegion">确定</view>
</view> </view>
<view class="bd"> <view class="bd">
<scroll-view scroll-y class="region-list"> <scroll-view scroll-y class="region-list">
<view class="item {{item.selected ? 'selected' : ''}}" bindtap="selectRegion" data-region-index="{{index}}" wx:for="{{regionList}}" wx:key="id">{{item.name}}</view> <view class="item {{item.selected ? 'selected' : ''}}" bindtap="selectRegion" data-region-index="{{index}}" wx:for="{{regionList}}" wx:key="code">{{item.name}}</view>
</scroll-view> </scroll-view>
</view> </view>
</view> </view>
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment