// pages/settlement/settlement.js
wx.cloud.init()
const db = wx.cloud.database()
const _ = db.command
Page({
/**
* 页面的初始数据
*/
data: {
res: null,
address: null,
Allprice: null,
allNum: null
},
// 购买
pay() {
let that = this
if (this.data.address == null) {
wx.showToast({
title: '请点击上方的选择地址',
icon: 'none',
duration: 3000
})
} else if (that.data.address.cityName.trim() !== "" && that.data.address.countyName.trim() !== "" && that.data.address.detailInfo.trim() !== "" && that.data.address.provinceName.trim() !== "" && that.data.address.telNumber.trim() !== "" && that.data.address.userName.trim() !== "") {
let address = that.data.address.provinceName.trim() + that.data.address.cityName.trim() + that.data.address.countyName.trim() + that.data.address.detailInfo.trim()
var myDate = new Date();
// console.log(myDate.getFullYear() + "/" + myDate.getMonth()+ "/" +myDate.getDate() + " " +myDate.getHours() + ":" + myDate.getMinutes()+ ":" +myDate.getSeconds());
let getTime = myDate.getFullYear() + "/" + myDate.getMonth() + "/" + myDate.getDate() + " " + myDate.getHours() + ":" + myDate.getMinutes() + ":" + myDate.getSeconds()
for (let i = 0; i < that.data.res.length; i++) {
db.collection("order").add({
data: {
productSrc: that.data.res[i].productSrc,
productName: that.data.res[i].productName,
productNum: that.data.res[i].productNum,
productPrice: that.data.res[i].productPrice,
productShopCate: that.data.res[i].productShopCate,
productId: that.data.res[i].productId,
fahuoStatus: 0,
shouhuoStatus: 0,
phone: that.data.address.telNumber.trim(),