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/order/order.js

173 lines
4.0 KiB

//index.js
//获取应用实例
const app = getApp()
Page({
data: {
currentTap: 0,
'iscart': false,
'goodsDate': '2018-11-11',
'totalCount': 0,
'totalPrice': 0,
'address': '湖南师范大学理学院',
'consignee': "杨盼成",
'phone': '12345678912',
'unpaidList': [], //待付款
'dueinList': [], //待收货
'deliverList': [], //待发货
'checkList':[],
'unpaidLists': [ //待付款
{
'cover': '../index/image/suanfa.jpg',
'isbn': '9787535482051',
'desc': '计算机算法设计',
'price': 20,
'count': 2
},
{
'cover': '../index/image/jichu.jpg',
'isbn': '9787540455958',
'desc': '计算机基础',
'price': 30,
'count': 1
},
{
'cover': '../index/image/rjgcdl.jpg',
'isbn': '9787539982830',
'desc': '软件工程导论',
'price': 25,
'count': 5
}
],
'deliverLists': [ //待发货
{
'cover': '../index/image/suanfa.jpg',
'isbn': '9787535482051',
'desc': '计算机算法设计',
'count': 2
},
{
'cover': '../index/image/jichu.jpg',
'isbn': '9787540455958',
'desc': '计算机基础',
'count': 1
},
{
'cover': '../index/image/rjgcdl.jpg',
'isbn': '9787539982830',
'desc': '软件工程导论',
'count': 5
}
],
'dueinLists': [ //待收货
{
'cover': '../index/image/suanfa.jpg',
'isbn': '9787535482051',
'desc': '计算机算法设计',
'count': 2
},
{
'cover': '../index/image/jichu.jpg',
'isbn': '9787540455958',
'desc': '计算机基础',
'count': 1
},
{
'cover': '../index/image/rjgcdl.jpg',
'isbn': '9787539982830',
'desc': '软件工程导论',
'count': 5
}
],
},
onLoad: function(options) {
var that = this
if (options.checkLists != null) {
that.data.ccheckList = JSON.parse(options.checkLists);
//console.log(checkList[0].BookName)
} else {
wx.request({
url: "http://45.76.158.31:8080/web/GetFrontInfo.do",
header: {
"content-type": "json"
},
success: function(res) {
if (res.statusCode == 200) {
console.log(res.data)
that.setData({
checkList :res.data
})
//wx.hideNavigationBarLoading()
}
}
})
}
wx.request({
url: "http://45.76.158.31:8080/web/GetFrontInfo.do",
header: {
"content-type": "json"
},
success: function(res) {
if (res.statusCode == 200) {
console.log(res.data)
that.setData({
dueinList: res.data
})
//wx.hideNavigationBarLoading()
}
}
})
wx.request({
url: "http://45.76.158.31:8080/web/GetFrontInfo.do",
header: {
"content-type": "json"
},
success: function (res) {
if (res.statusCode == 200) {
console.log(res.data)
that.setData({
deliverList: res.data
})
//wx.hideNavigationBarLoading()
}
}
})
that.setData({
currentTap: options.typeId,
unpaidList: that.data.checkList
})
var unpaidList = that.data.unpaidList;
var totalCount = 0;
var totalPrice = 0;
for (var i = 0; i < that.data.unpaidList.l; i++) {
var book = that.data.unpaidList[i];
totalCount += book.Count;
totalPrice += book.Count * book.Price;
}
totalPrice = totalPrice.toFixed(2);
that.setData({
'totalCount': totalCount,
'totalPrice': totalPrice
})
},
deleteList: function(e) {
this.setData({
'unpaidList': null
});
},
order_status: function(e) {
var current = e.currentTarget.dataset.current
this.setData({
currentTap: current
})
},
})