You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hunjianghu/江可飞/小程序开发/pages/detail/detail.js

99 lines
2.2 KiB

Page({
data: {
isLike: true,
// banner
imgUrls: [
"/pages/index/image/suanfa.jpg"
],
'book': [],
// 商品详情介绍
detailImg: [
"/pages/index/image/suanfa.jpg"
],
},
onLoad: function (options) {
console.log("in detail")
var thats = this
wx.request({
url: "https://hunjianghu.xuanjis.com/web/BookInfo.do?bookid=" + options.id,
header: {
"content-type": "json"
},
success: function(res) {
console.log(res.data)
for (var i = 0; i < res.data.length; i++) {
res.data[i].Count = 1;
}
if (res.statusCode == 200) {
thats.setData({
book: res.data,
})
//wx.hideNavigationBarLoading()
}
}
})
},
//预览图片
previewImage: function(e) {
var current = e.target.dataset.src;
wx.previewImage({
current: current, // 当前显示图片的http链接
urls: this.data.imgUrls // 需要预览的图片http链接列表
})
},
// 跳到购物车
addCar() {
var that = this
wx.request({
url: 'https://hunjianghu.xuanjis.com/web/AddCart.do',//?action=Modify&UserID=1&BookID=' + that.data.book[0].BookID + '&Count=' + that.data.book[0].Count,
data: {
'action':'Modify',
'UserID':1,
'BookID':that.data.book[0].BookID,
'Count':that.data.book[0].Count
},
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
// method: 'POST',
dataType: 'json',
responseType: 'text',
success: function(res) {
console.log("sucess")
},
fail: function(res) {},
complete: function(res) {},
})
wx.switchTab({
url: '/pages/gouwu/gouwu'
})
},
// 立即购买
immeBuy() {
var that = this
wx.showToast({
title: '购买成功',
icon: 'success',
duration: 2000
});
wx.request({
url: 'https://hunjianghu.xuanjis.com/web/Buy.do?UserID=1&BookID=' + that.data.book[0].BookID + '&Count=' + 1 + '&MessageID=' + 1,
header: {
},
success: function (res) {
if (res.statusCode == 200) {
}
}
})
},
})