作者 王旭宇

食品包

... ... @@ -36,7 +36,8 @@ Page({
goods1: {},
origin: 0,
skuid_arr: [],
is_vip: 0
is_vip: 0,
countn: null
},
fetchVip() {
let url = '/wxapp/user/index'
... ... @@ -140,7 +141,7 @@ Page({
console.log(is_vip + 'shibushis')
app.post(url, params).then(r => {
// console.log(r);
r.data.list.forEach(function (ele, indexxx) {
r.data.list.forEach(function(ele, indexxx) {
if (is_vip == 1) {
ele.ggprice = ele.vip_price
} else {
... ... @@ -150,10 +151,10 @@ Page({
showList.push(ele)
}
ele.t = false
if(indexxx<r.data.info.num){
ele.t=true
if (indexxx < r.data.info.num) {
ele.t = true
}
ele.attr.attr_sku.forEach(function (eles, indexxxx) {
ele.attr.attr_sku.forEach(function(eles, indexxxx) {
for (let i = 0; i < eles.item.length; i++) {
eles.item[i].t = false
eles.item[0].t = true;
... ... @@ -190,6 +191,7 @@ Page({
var minutes = ''
var seconds = ''
var percent = 0
function time() {
var cut_time = r.data.groupType.count_down_time
days = Math.floor((cut_time) / (60 * 60 * 24));
... ... @@ -211,7 +213,8 @@ Page({
collocation: r.data.collocation,
comment: r.data.comment,
// star_arr: star_arr,
is_group: r.data.info.group_min_number
is_group: r.data.info.group_min_number,
countn: r.data.info.num
});
} else {
that.setData({
... ... @@ -219,7 +222,8 @@ Page({
gPrice: r.data.info.price,
// comment: r.data.comment,
packageList: r.data.list,
showList: showList
showList: showList,
countn: r.data.info.num
});
}
});
... ... @@ -246,7 +250,7 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
onLoad: function(options) {
console.log(options)
this.fetchVip();
var query = wx.createSelectorQuery();
... ... @@ -268,15 +272,15 @@ Page({
let num = goods.info.num
let showList = []
let n = 0
goods.list.forEach(function (ele, index) {
goods.list.forEach(function(ele, index) {
if (ele.t) {
showList.push(ele)
n++;
}
})
if ((n < goods.info.num && n > 0) || n > goods.info.num) {
if ((n < goods.info.num && n >= 0) || n > goods.info.num) {
wx.showToast({
title: '您最多只能选择' + num + '种商品',
title: '您最多能选择' + num + '种商品',
icon: 'none'
})
return;
... ... @@ -323,7 +327,7 @@ Page({
let iindex = e.currentTarget.dataset.origin
//父级索引
let parent = e.currentTarget.dataset.parent
goods.forEach(function (ele, index) {
goods.forEach(function(ele, index) {
if (iindex == index) {
let new_arr = ele.arr
let listAll = ele.attr.attr_sku;
... ... @@ -341,7 +345,7 @@ Page({
if (foo > -1) {
new_arr.splice(foo, 1)
} else {
ele.attr.attr_sku.forEach(function (eles, indexxxx) {
ele.attr.attr_sku.forEach(function(eles, indexxxx) {
if (indexxxx == parent) {
for (let i = 0; i < eles.item.length; i++) {
let havId = ele.attr.attr_sku[indexxxx].item[i].id
... ... @@ -357,7 +361,7 @@ Page({
let tempArry = JSON.parse(JSON.stringify(ele.attr.attr_sku[parent]));
!tempArry.chooseIndex ? tempArry.chooseIndex = [] : '';
// 是否多选
if (is_checkMore) { } else {
if (is_checkMore) {} else {
tempArry.chooseIndex.pop();
tempArry.chooseIndex.push(nowId);
for (let obj of tempArry.item) {
... ... @@ -372,7 +376,7 @@ Page({
goods1: goods[iindex]
})
// let goods = t.data.goodsList;
goods.forEach(function (ele, indexaa) {
goods.forEach(function(ele, indexaa) {
if (iindex == indexaa) {
let new_arr = ele.arr
let sys_attrprice = goods[indexaa].sys_attrprice;
... ... @@ -382,7 +386,7 @@ Page({
let skuid_price = 0
let old_skuid_price = 0
let vip_skuid_price = 0
ele.attr.attr_sku.forEach(function (eles, indexx) {
ele.attr.attr_sku.forEach(function(eles, indexx) {
if (indexx == parent) {
new_arr = new_arr.concat(eles.chooseIndex);
}
... ... @@ -429,7 +433,7 @@ Page({
// skuid_arr.push(skuid1)
}
var goods = this.data.showList
goods.forEach(function (ele, index) {
goods.forEach(function(ele, index) {
if (index == indexs) {
for (let i = 0; i < ele.attr.attr_sku.length; i++) {
if (ele.arr.length == 1) {
... ... @@ -452,7 +456,7 @@ Page({
var goodsList = that.data.showList
var skuid_arr = []
var total_price = 0
goodsList.forEach(function (ele, index) {
goodsList.forEach(function(ele, index) {
var skuid = ele.ggid
if (ele.ggprice) {
ele.ggprice = ele.ggprice.substring(0, ele.ggprice.length - 3)
... ... @@ -490,23 +494,30 @@ Page({
let indexs = e.currentTarget.dataset.index
let that = this
let list = that.data.packageList
let n=0
list.forEach(function (ele, index) {
let n = that.data.countn
list.forEach(function(ele, index) {
if (indexs == index) {
ele.t = !ele.t
}
if(ele.t){
n--
ele.t=false
}else{
n++
}
if(n>that.data.goods.info.num){
wx.showToast({
title: '您最多可选择'+that.data.goods.info.num+'种商品',
title: '您最多选择'+that.data.goods.info.num+'种商品',
icon:'none'
})
ele.t = false
n--
}else{
ele.t=true
}
}
}
})
that.setData({
packageList: list
packageList: list,
countn: n
})
},
// 跳转图文食谱
... ... @@ -579,49 +590,49 @@ Page({
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
onShareAppMessage: function() {
var shareObj = {
// title: options.target.dataset.title, // 默认是小程序的名称(可以写slogan等)
path: '/pages/start/start',
... ...
... ... @@ -52,9 +52,9 @@
<text class='money '>{{goods.info.price}}</text>
<text class='original_price '>¥{{goods.info.old_price}}</text>
</view>
<view class='display_box '>
<view class='money_icon2 '>¥</view>
<view class='money2 '>{{goods.info.vip_price}}</view>
<view class=' '>
<text class='money_icon2ds'>¥</text>
<text class='money2d '>{{goods.info.vip_price}}</text>
<view class='vip '>
<image class='vipvip ' src='{{imgUrl}}vipvip.png '></image>
</view>
... ...
... ... @@ -119,6 +119,11 @@ text{
font-size: 22rpx;
color: #222;
}
.money_icon2ds {
font-size: 22rpx;
color: red;
margin-left: 8rpx!important
}
.money {
font-size: 38rpx;
... ... @@ -135,7 +140,7 @@ text{
height: 30rpx;
margin-left: 40rpx;
display: flex;
align-items: center;
/* align-items: center; */
flex-wrap: nowrap;
white-space: nowrap;
line-height: 30rpx;
... ... @@ -145,6 +150,14 @@ text{
font-size: 22rpx;
color: #f44;
}
.money_icon2d{
height: 20rpx;
line-height: 20rpx;
font-size: 22rpx;
background: purple;
margin-top: 10rpx;
color: #f44;
}
.money2 {
height: 30rpx;
... ... @@ -153,11 +166,20 @@ text{
font-weight: bold;
color: #f44;
}
.money2d {
height: 30rpx;
line-height: 30rpx;
font-size: 38rpx;
font-weight: bold;
color: #f44;
}
.vip {
width: 80rpx;
height: 25rpx;
margin-left: 5rpx;
margin-top: 5rpx;
display: inline-block
}
.vip image{
... ...
... ... @@ -262,6 +262,7 @@ Page({
}
let addid = null
app.post(url, params).then(r => {
console.log(this.data.amount + "到底是及")
console.log(r)
var list = r.data.list;
r.data.vips.forEach(function(ele, index) {
... ... @@ -287,7 +288,11 @@ Page({
}
ele.arr = new_arr
})
var amount = that.data.amount + r.data.priceData.shipment_price
var amount = that.data.amount * 1
console.log(that.data.amount+'前')
r.data.priceData.shipment_price = r.data.priceData.shipment_price*1
console.log(r.data.priceData.shipment_price)
amount =amount + r.data.priceData.shipment_price
that.setData({
vip: r.data,
goodsList: r.data.list,
... ... @@ -467,6 +472,7 @@ Page({
amount: that.data.amount,
last_total_price: that.data.amount,
});
console.log(that.data.amount+'最后一次')
},
//渲染商品详情
fetchGoods() {
... ... @@ -513,12 +519,23 @@ Page({
}
ele.arr = new_arr
})
r.data.list.forEach(function(ele, index) {
ele.price.substring(0, ele.price.length - 3)
ele.price = ele.price * 1
price += ele.price
console.log(price)
})
// r.data.list.forEach(function(ele, index) {
// ele.price.substring(0, ele.price.length - 3)
// ele.price = ele.price * 1
// price += ele.price
// console.log(price)
// })
console.log(that.data.is_vip+"是不是会员")
r.data.info.vip_price.substring(0, r.data.info.vip_price.length - 3)
r.data.info.price.substring(0, r.data.info.price.length - 3)
var prices = null
if(that.data.is_vip==1){
price = r.data.info.vip_price*1+r.data.priceData.shipment_price*1
prices = r.data.info.vip_price
}else{
prices = r.data.info.price
price = r.data.info.price * 1 + r.data.priceData.shipment_price*1
}
that.setData({
vip: r.data,
goodsList: r.data.list,
... ... @@ -530,7 +547,7 @@ Page({
deliverList: r.data.timeDataArray,
ship_ment_price: r.data.priceData.shipment_price,
amount: price,
goodsTotalPrice: price,
goodsTotalPrice: prices,
last_total_price: price,
addd: addid
});
... ... @@ -1285,29 +1302,29 @@ Page({
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
let that = this
let optionsgid = that.data.optionsgid //直接购买
let optionsis_group = that.data.optionsis_group //团购 不等于undefined&&0
let optionsproId = that.data.optionsproId //促销 数字
let optionspackId = that.data.optionspackId //食品包 数字
let optionscart = that.data.optionscart //购物车 字符串
if (optionsgid != '') {
that.fetchQuick();
}
if (optionsis_group != '') {
that.fetchGroupPay();
}
if (optionsproId != '') {
this.fetchSalePay();
}
if (optionspackId != '') {
this.fetchPackage();
}
if (optionscart != '') {
this.fetchAccount();
}
},
// onShow: function() {
// let that = this
// let optionsgid = that.data.optionsgid //直接购买
// let optionsis_group = that.data.optionsis_group //团购 不等于undefined&&0
// let optionsproId = that.data.optionsproId //促销 数字
// let optionspackId = that.data.optionspackId //食品包 数字
// let optionscart = that.data.optionscart //购物车 字符串
// if (optionsgid != '') {
// that.fetchQuick();
// }
// if (optionsis_group != '') {
// that.fetchGroupPay();
// }
// if (optionsproId != '') {
// this.fetchSalePay();
// }
// if (optionspackId != '') {
// this.fetchPackage();
// }
// if (optionscart != '') {
// this.fetchAccount();
// }
// },
/**
* 生命周期函数--监听页面初次渲染完成
*/
... ...