ç®å½
1.ç¨æ·éæ±
2.æ°æ®åºè®¾è®¡
3.Javaåå°å®ç°
- 3.1Mybatis对åºçé ç½®æ件GoodsCollectDao.xml
- 3.2 GoodsCollectDaoå®ç°
- 3.3 Serviceæ¥å£åå®ç°
4.微信å°ç¨åºå®ç°
- 4.1index.wxml
- 4.2 index.wxss
5.æçæ¶èææ
1.ç¨æ·éæ±
æçæ¶èéæ±å¦ä¸ï¼
1).å¨å°ç¨åºçåºé¨èåä¸ï¼æ°å¢âæçæ¶èâï¼æ¾ç¤ºæ¶èååå表ãç¹æ¶èæ个åååï¼è·³è½¬å°åå详æ
2).åå详æ 页é¢ï¼å¯ä»¥æ¶èååæ¶æ¶èã
3).ååä¸æ¶åï¼èªå¨å é¤ç¨æ·æ¶èçååã
2.æ°æ®åºè®¾è®¡
æ°æ®åºè¡¨ç»æï¼æ¯è¾ç®åï¼æç¨æ·idåååidä¿åå³å¯ï¼å¦ä¸ï¼
CREATE TABLE `goods_collect` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主é®',
`gmt_create` datetime NOT NULL COMMENT 'å建æ¶é´',
`goods_id` int(11) NOT NULL COMMENT 'ååid',
`member_id` int(11) DEFAULT NULL COMMENT 'ç¨æ·id',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 comment="æ¶èåå";
3.Javaåå°å®ç°
3.1Mybatis对åºçé ç½®æ件GoodsCollectDao.xml
å 容å¦ä¸ï¼
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ddc.dao.goods.GoodsCollectDao">
<resultMap id="BaseResultMap" type="com.ddc.model.goods.GoodsCollect">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate"/>
<result column="goods_id" jdbcType="INTEGER" property="goodsId"/>
<result column="member_id" jdbcType="INTEGER" property="memberId"/>
</resultMap>
<sql id="Base_Column_List">
id, gmt_create, goods_id, member_id
</sql>
<select id="queryApilistPage" resultType="map" parameterType="object">
select c.id AS catId,g.main_img as imgUrl, g.goods_name as goodsName, g.id as goodsId, g.goods_price as price,
wholesale_price as wholePrice,
DATE_FORMAT(g.gmt_create,'%Y-%m-%d') as createTime,g.goods_sales AS goodsSales,c.cat_name AS catName
,g.goods_status AS goodStatus
FROM goods_info g
LEFT JOIN goods_cat c ON g.cat_id = c.id
LEFT JOIN goods_collect d ON d.goods_id=g.id
where d.member_id=${pd.memberId}
<if test="pd.goodsName != null and pd.goodsName != ''">
and g.goods_name like CONCAT('%',#{pd.goodsName},'%')
</if>
<if test="pd.orderBy != null and pd.orderBy != ''">
${pd.orderBy}
</if>
</select>
<select id="queryByGoodIdAndMemberId" resultMap="BaseResultMap" parameterType="com.ddc.model.goods.GoodsCollect">
select id, gmt_create, goods_id, member_id from goods_collect
where goods_id = #{goodsId} and member_id=#{memberId}
</select>
<delete id="delete" parameterType="com.ddc.model.goods.GoodsCollect">
delete from goods_collect where goods_id = #{goodsId} and member_id=#{memberId}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ddc.model.goods.GoodsCollect" useGeneratedKeys="true">
insert into goods_collect (gmt_create, goods_id, member_id) values (now(), #{goodsId}, #{memberId})
</insert>
</mapper>
3.2 GoodsCollectDaoå®ç°
代ç å¦ä¸ï¼
public interface GoodsCollectDao {
//æçæ¶èååå表
List<Map<String, Object>> queryApilistPage(Page pages);
//æ¶è
int insert(GoodsCollect goodsCollect);
//åæ¶æ¶è
int delete(GoodsCollect goodsCollect);
//æ¥è¯¢ååæ¯å¦è¢«ç¨æ·æ¶è
GoodsCollect queryByGoodIdAndMemberId(GoodsCollect goodsCollect);
}
3.3 Serviceæ¥å£åå®ç°
æ¥å£ä»£ç å¦ä¸ï¼
public interface GoodsCollectService {
//æçæ¶èååå表
List<Map<String, Object>> queryApilistPage(Page pages);
//æ¶è
void insert(GoodsCollect goodsCollect);
//åæ¶æ¶è
void delete(GoodsCollect goodsCollect);
//æ¥è¯¢ååæ¯å¦è¢«ç¨æ·æ¶è
GoodsCollect queryByGoodIdAndMemberId(GoodsCollect goodsCollect);
}
å®ç°ä»£ç å¦ä¸ï¼
@Service
public class GoodsCollectServiceImpl implements GoodsCollectService {
@Resource
private GoodsCollectDao goodsCollectDao;
//æçæ¶èååå表
public List<Map<String, Object>> queryApilistPage(Page pages){
return goodsCollectDao.queryApilistPage(pages);
}
//æ¶è
public void insert(GoodsCollect goodsCollect){
goodsCollectDao.insert(goodsCollect);
}
//åæ¶æ¶è
public void delete(GoodsCollect goodsCollect){
goodsCollectDao.delete(goodsCollect);
}
//æ¥è¯¢ååæ¯å¦è¢«ç¨æ·æ¶è
public GoodsCollect queryByGoodIdAndMemberId(GoodsCollect goodsCollect){
return goodsCollectDao.queryByGoodIdAndMemberId(goodsCollect);
}
}
4.微信å°ç¨åºå®ç°
4.1index.wxml
<view class='ddc-search-box'>
<view class='inp'>
<input value='{{searchKey}}' type='text' bindinput="searchInput" placeholder='æç´¢' />
</view>
<view class='search-btn' bindtap='searchBtn'>æç´¢</view>
</view>
<scroll-view scroll-y='true' style="height:{{scrollViewHeight}}px" bindscrolltolower='getGoodList'>
<view class='ddc-category-box'>
<block wx:if='{{goodsList.length!=0}}'>
<view class='active-wrap' wx:for='{{goodsList}}' wx:key='index'>
<view class='pic'>
<image src='{{item.imgUrl}}' src="{{item.imgUrl}}" bindtap="enlarge" />
</view>
<view class='txt' data-goodsid='{{item.goodsId}}' data-goodstatus='{{item.goodStatus}}' bindtap='viewDetail'>
<view class='title'>{{item.goodsName}}</view>
<view class='ddc-info'>
<view>ï¿¥{{item.price}}</view>
<view>å·²å®{{item.goodsSales==null?'0':item.goodsSales}}</view>
<view>
<text>äºè§£è¯¦æ
</text>
</view>
</view>
</view>
</view>
</block>
<view class='no-data' wx:if='{{goodsList.length==0}}'>ææ æ°æ®</view>
</view>
</scroll-view>
4.2 index.wxss
page{background: #fff;}
.ddc-category-box{ margin-top: 10px}
.active-wrap{margin: 5px 15px; background: #f5f5f5; padding: 8px 5px 5px 5px}
.active-wrap.recom-area { margin-bottom: 30px;}
.active-wrap{display: flex;border-radius: 5px;}
.active-wrap .pic{flex:1;}
.active-wrap .pic image{ width:100px;height: 60px}
.active-wrap .txt{flex:4; padding-left: 10px}
.active-wrap .txt .title{font-size: 14px}
.active-wrap .ddc-info{display: flex; font-size: 14px; padding-top: 10px}
.active-wrap .ddc-info view{ flex: 1}
.active-wrap .ddc-info view:nth-of-type(1){ color: #fc6737}
.active-wrap .ddc-info view:nth-of-type(3) text{ background: #07c160; font-size: 12px; color: #ffffff; border-radius: 5px; padding: 2px 0px}
#tab-title .icon-sort image{ width: 8px; height: 6px; }
.ddc-search-box{margin-top: 10px; display: flex; padding: 0px 20px}
/* .ddc-search-box view{ flex: 1} */
.ddc-search-box .inp{ width: 100%; height: 32px; border: 1px solid #e5e5e5; font-size: 14px; padding-left: 10px; border-radius: 5px;vertical-align:middle;}
.search-btn{ width: 80px;font-size: 14px; background:#07c160;border-radius: 5px; color: #ffffff; text-align: center; line-height: 32px; margin-left: 10px}
.no-data{ font-size: 14px; text-align: center;}
.titlenotshow{display:none}
.titleshow{display:block}
.backHome{ height: 30px;background:#07c160; color: #ffffff;font-size: 14px;
display: flex;flex-direction:center;justify-content: center;align-items: center; }
.backHome .backtext{width: 33%;}
.backHome .gwtitle{text-align:center;font-size: 16px; }