由于學習微信小程序開發(fā)。基于微信小程序云開發(fā)做了一款校園二手商城小程序,源碼可加QQ:631389104? 備注:微信小程序,否則不通過
核心代碼如下:
//購買事件
goumai_btn:function(){
letthat =this
? ? wx.request({
url:'http://localhost:8080/Ajax-Servlet-Test1/StoreMsg',
data: {
xx:'insertGM',
//用戶ID
yy: userId,
//商品ID
zz: that.data.GoodId,
//店家ID
ss: that.data.DjId
? ? ? ? },
header: {
'Content-Type':'application/json'
? ? ? ? },
success:function(res){
console.log("購買成功")
? ? ? ? })
? ? }
4.1.8 商品購物車功能
購物車里展示的是用戶已收藏的商品信息展箱,用戶可以刪除相應已收藏的商品信息,也可以點擊進入相應收藏商品的詳細信息界面瀏覽商品信息蹬昌。
核心代碼如下:
//連接數(shù)據(jù)庫獲取用戶收藏信息
wx.request({
url:'http://localhost:8080/Ajax-Servlet-Test1/StoreMsg',
data: {
xx:'showSC',
yy: userId,//用戶ID
? ? },
header: {
'Content-Type':'application/json'
? ? },
success: function (res) {
console.log("查詢收藏信息成功析藕!")
? ? ? ? that.setData({
//將查詢到的收藏信息保存在listContent數(shù)組
listContent: res.data
? ? ? ? })
? ? }
})
//連接數(shù)據(jù)庫刪除用戶收藏信息
wx.request({
url:'http://localhost:8080/Ajax-Servlet-Test1/StoreMsg',
data: {
xx:'delSCGood',
//用戶ID
yy: userId,
//商品ID
zz: msgGId,
//店家ID
ss: msgUId
? ? },
header: {
'Content-Type':'application/json'
? ? },
success: function (res) {
console.log("刪除收藏信息成功!")
? ? ? ? that.switchType(type)
}