作者 王旭宇

食品包

@@ -36,7 +36,8 @@ Page({ @@ -36,7 +36,8 @@ Page({
36 goods1: {}, 36 goods1: {},
37 origin: 0, 37 origin: 0,
38 skuid_arr: [], 38 skuid_arr: [],
39 - is_vip: 0 39 + is_vip: 0,
  40 + countn: null
40 }, 41 },
41 fetchVip() { 42 fetchVip() {
42 let url = '/wxapp/user/index' 43 let url = '/wxapp/user/index'
@@ -140,7 +141,7 @@ Page({ @@ -140,7 +141,7 @@ Page({
140 console.log(is_vip + 'shibushis') 141 console.log(is_vip + 'shibushis')
141 app.post(url, params).then(r => { 142 app.post(url, params).then(r => {
142 // console.log(r); 143 // console.log(r);
143 - r.data.list.forEach(function (ele, indexxx) { 144 + r.data.list.forEach(function(ele, indexxx) {
144 if (is_vip == 1) { 145 if (is_vip == 1) {
145 ele.ggprice = ele.vip_price 146 ele.ggprice = ele.vip_price
146 } else { 147 } else {
@@ -150,10 +151,10 @@ Page({ @@ -150,10 +151,10 @@ Page({
150 showList.push(ele) 151 showList.push(ele)
151 } 152 }
152 ele.t = false 153 ele.t = false
153 - if(indexxx<r.data.info.num){  
154 - ele.t=true 154 + if (indexxx < r.data.info.num) {
  155 + ele.t = true
155 } 156 }
156 - ele.attr.attr_sku.forEach(function (eles, indexxxx) { 157 + ele.attr.attr_sku.forEach(function(eles, indexxxx) {
157 for (let i = 0; i < eles.item.length; i++) { 158 for (let i = 0; i < eles.item.length; i++) {
158 eles.item[i].t = false 159 eles.item[i].t = false
159 eles.item[0].t = true; 160 eles.item[0].t = true;
@@ -190,6 +191,7 @@ Page({ @@ -190,6 +191,7 @@ Page({
190 var minutes = '' 191 var minutes = ''
191 var seconds = '' 192 var seconds = ''
192 var percent = 0 193 var percent = 0
  194 +
193 function time() { 195 function time() {
194 var cut_time = r.data.groupType.count_down_time 196 var cut_time = r.data.groupType.count_down_time
195 days = Math.floor((cut_time) / (60 * 60 * 24)); 197 days = Math.floor((cut_time) / (60 * 60 * 24));
@@ -211,7 +213,8 @@ Page({ @@ -211,7 +213,8 @@ Page({
211 collocation: r.data.collocation, 213 collocation: r.data.collocation,
212 comment: r.data.comment, 214 comment: r.data.comment,
213 // star_arr: star_arr, 215 // star_arr: star_arr,
214 - is_group: r.data.info.group_min_number 216 + is_group: r.data.info.group_min_number,
  217 + countn: r.data.info.num
215 }); 218 });
216 } else { 219 } else {
217 that.setData({ 220 that.setData({
@@ -219,7 +222,8 @@ Page({ @@ -219,7 +222,8 @@ Page({
219 gPrice: r.data.info.price, 222 gPrice: r.data.info.price,
220 // comment: r.data.comment, 223 // comment: r.data.comment,
221 packageList: r.data.list, 224 packageList: r.data.list,
222 - showList: showList 225 + showList: showList,
  226 + countn: r.data.info.num
223 }); 227 });
224 } 228 }
225 }); 229 });
@@ -246,7 +250,7 @@ Page({ @@ -246,7 +250,7 @@ Page({
246 /** 250 /**
247 * 生命周期函数--监听页面加载 251 * 生命周期函数--监听页面加载
248 */ 252 */
249 - onLoad: function (options) { 253 + onLoad: function(options) {
250 console.log(options) 254 console.log(options)
251 this.fetchVip(); 255 this.fetchVip();
252 var query = wx.createSelectorQuery(); 256 var query = wx.createSelectorQuery();
@@ -268,15 +272,15 @@ Page({ @@ -268,15 +272,15 @@ Page({
268 let num = goods.info.num 272 let num = goods.info.num
269 let showList = [] 273 let showList = []
270 let n = 0 274 let n = 0
271 - goods.list.forEach(function (ele, index) { 275 + goods.list.forEach(function(ele, index) {
272 if (ele.t) { 276 if (ele.t) {
273 showList.push(ele) 277 showList.push(ele)
274 n++; 278 n++;
275 } 279 }
276 }) 280 })
277 - if ((n < goods.info.num && n > 0) || n > goods.info.num) { 281 + if ((n < goods.info.num && n >= 0) || n > goods.info.num) {
278 wx.showToast({ 282 wx.showToast({
279 - title: '您最多只能选择' + num + '种商品', 283 + title: '您最多能选择' + num + '种商品',
280 icon: 'none' 284 icon: 'none'
281 }) 285 })
282 return; 286 return;
@@ -323,7 +327,7 @@ Page({ @@ -323,7 +327,7 @@ Page({
323 let iindex = e.currentTarget.dataset.origin 327 let iindex = e.currentTarget.dataset.origin
324 //父级索引 328 //父级索引
325 let parent = e.currentTarget.dataset.parent 329 let parent = e.currentTarget.dataset.parent
326 - goods.forEach(function (ele, index) { 330 + goods.forEach(function(ele, index) {
327 if (iindex == index) { 331 if (iindex == index) {
328 let new_arr = ele.arr 332 let new_arr = ele.arr
329 let listAll = ele.attr.attr_sku; 333 let listAll = ele.attr.attr_sku;
@@ -341,7 +345,7 @@ Page({ @@ -341,7 +345,7 @@ Page({
341 if (foo > -1) { 345 if (foo > -1) {
342 new_arr.splice(foo, 1) 346 new_arr.splice(foo, 1)
343 } else { 347 } else {
344 - ele.attr.attr_sku.forEach(function (eles, indexxxx) { 348 + ele.attr.attr_sku.forEach(function(eles, indexxxx) {
345 if (indexxxx == parent) { 349 if (indexxxx == parent) {
346 for (let i = 0; i < eles.item.length; i++) { 350 for (let i = 0; i < eles.item.length; i++) {
347 let havId = ele.attr.attr_sku[indexxxx].item[i].id 351 let havId = ele.attr.attr_sku[indexxxx].item[i].id
@@ -357,7 +361,7 @@ Page({ @@ -357,7 +361,7 @@ Page({
357 let tempArry = JSON.parse(JSON.stringify(ele.attr.attr_sku[parent])); 361 let tempArry = JSON.parse(JSON.stringify(ele.attr.attr_sku[parent]));
358 !tempArry.chooseIndex ? tempArry.chooseIndex = [] : ''; 362 !tempArry.chooseIndex ? tempArry.chooseIndex = [] : '';
359 // 是否多选 363 // 是否多选
360 - if (is_checkMore) { } else { 364 + if (is_checkMore) {} else {
361 tempArry.chooseIndex.pop(); 365 tempArry.chooseIndex.pop();
362 tempArry.chooseIndex.push(nowId); 366 tempArry.chooseIndex.push(nowId);
363 for (let obj of tempArry.item) { 367 for (let obj of tempArry.item) {
@@ -372,7 +376,7 @@ Page({ @@ -372,7 +376,7 @@ Page({
372 goods1: goods[iindex] 376 goods1: goods[iindex]
373 }) 377 })
374 // let goods = t.data.goodsList; 378 // let goods = t.data.goodsList;
375 - goods.forEach(function (ele, indexaa) { 379 + goods.forEach(function(ele, indexaa) {
376 if (iindex == indexaa) { 380 if (iindex == indexaa) {
377 let new_arr = ele.arr 381 let new_arr = ele.arr
378 let sys_attrprice = goods[indexaa].sys_attrprice; 382 let sys_attrprice = goods[indexaa].sys_attrprice;
@@ -382,7 +386,7 @@ Page({ @@ -382,7 +386,7 @@ Page({
382 let skuid_price = 0 386 let skuid_price = 0
383 let old_skuid_price = 0 387 let old_skuid_price = 0
384 let vip_skuid_price = 0 388 let vip_skuid_price = 0
385 - ele.attr.attr_sku.forEach(function (eles, indexx) { 389 + ele.attr.attr_sku.forEach(function(eles, indexx) {
386 if (indexx == parent) { 390 if (indexx == parent) {
387 new_arr = new_arr.concat(eles.chooseIndex); 391 new_arr = new_arr.concat(eles.chooseIndex);
388 } 392 }
@@ -429,7 +433,7 @@ Page({ @@ -429,7 +433,7 @@ Page({
429 // skuid_arr.push(skuid1) 433 // skuid_arr.push(skuid1)
430 } 434 }
431 var goods = this.data.showList 435 var goods = this.data.showList
432 - goods.forEach(function (ele, index) { 436 + goods.forEach(function(ele, index) {
433 if (index == indexs) { 437 if (index == indexs) {
434 for (let i = 0; i < ele.attr.attr_sku.length; i++) { 438 for (let i = 0; i < ele.attr.attr_sku.length; i++) {
435 if (ele.arr.length == 1) { 439 if (ele.arr.length == 1) {
@@ -452,7 +456,7 @@ Page({ @@ -452,7 +456,7 @@ Page({
452 var goodsList = that.data.showList 456 var goodsList = that.data.showList
453 var skuid_arr = [] 457 var skuid_arr = []
454 var total_price = 0 458 var total_price = 0
455 - goodsList.forEach(function (ele, index) { 459 + goodsList.forEach(function(ele, index) {
456 var skuid = ele.ggid 460 var skuid = ele.ggid
457 if (ele.ggprice) { 461 if (ele.ggprice) {
458 ele.ggprice = ele.ggprice.substring(0, ele.ggprice.length - 3) 462 ele.ggprice = ele.ggprice.substring(0, ele.ggprice.length - 3)
@@ -490,23 +494,30 @@ Page({ @@ -490,23 +494,30 @@ Page({
490 let indexs = e.currentTarget.dataset.index 494 let indexs = e.currentTarget.dataset.index
491 let that = this 495 let that = this
492 let list = that.data.packageList 496 let list = that.data.packageList
493 - let n=0  
494 - list.forEach(function (ele, index) { 497 + let n = that.data.countn
  498 + list.forEach(function(ele, index) {
495 if (indexs == index) { 499 if (indexs == index) {
496 - ele.t = !ele.t  
497 - }  
498 if(ele.t){ 500 if(ele.t){
  501 + n--
  502 + ele.t=false
  503 + }else{
499 n++ 504 n++
500 - }  
501 if(n>that.data.goods.info.num){ 505 if(n>that.data.goods.info.num){
502 wx.showToast({ 506 wx.showToast({
503 - title: '您最多可选择'+that.data.goods.info.num+'种商品', 507 + title: '您最多选择'+that.data.goods.info.num+'种商品',
504 icon:'none' 508 icon:'none'
505 }) 509 })
  510 + ele.t = false
  511 + n--
  512 + }else{
  513 + ele.t=true
  514 + }
  515 + }
506 } 516 }
507 }) 517 })
508 that.setData({ 518 that.setData({
509 - packageList: list 519 + packageList: list,
  520 + countn: n
510 }) 521 })
511 }, 522 },
512 // 跳转图文食谱 523 // 跳转图文食谱
@@ -579,49 +590,49 @@ Page({ @@ -579,49 +590,49 @@ Page({
579 /** 590 /**
580 * 生命周期函数--监听页面初次渲染完成 591 * 生命周期函数--监听页面初次渲染完成
581 */ 592 */
582 - onReady: function () { 593 + onReady: function() {
583 594
584 }, 595 },
585 596
586 /** 597 /**
587 * 生命周期函数--监听页面显示 598 * 生命周期函数--监听页面显示
588 */ 599 */
589 - onShow: function () { 600 + onShow: function() {
590 601
591 }, 602 },
592 603
593 /** 604 /**
594 * 生命周期函数--监听页面隐藏 605 * 生命周期函数--监听页面隐藏
595 */ 606 */
596 - onHide: function () { 607 + onHide: function() {
597 608
598 }, 609 },
599 610
600 /** 611 /**
601 * 生命周期函数--监听页面卸载 612 * 生命周期函数--监听页面卸载
602 */ 613 */
603 - onUnload: function () { 614 + onUnload: function() {
604 615
605 }, 616 },
606 617
607 /** 618 /**
608 * 页面相关事件处理函数--监听用户下拉动作 619 * 页面相关事件处理函数--监听用户下拉动作
609 */ 620 */
610 - onPullDownRefresh: function () { 621 + onPullDownRefresh: function() {
611 622
612 }, 623 },
613 624
614 /** 625 /**
615 * 页面上拉触底事件的处理函数 626 * 页面上拉触底事件的处理函数
616 */ 627 */
617 - onReachBottom: function () { 628 + onReachBottom: function() {
618 629
619 }, 630 },
620 631
621 /** 632 /**
622 * 用户点击右上角分享 633 * 用户点击右上角分享
623 */ 634 */
624 - onShareAppMessage: function () { 635 + onShareAppMessage: function() {
625 var shareObj = { 636 var shareObj = {
626 // title: options.target.dataset.title, // 默认是小程序的名称(可以写slogan等) 637 // title: options.target.dataset.title, // 默认是小程序的名称(可以写slogan等)
627 path: '/pages/start/start', 638 path: '/pages/start/start',
@@ -52,9 +52,9 @@ @@ -52,9 +52,9 @@
52 <text class='money '>{{goods.info.price}}</text> 52 <text class='money '>{{goods.info.price}}</text>
53 <text class='original_price '>¥{{goods.info.old_price}}</text> 53 <text class='original_price '>¥{{goods.info.old_price}}</text>
54 </view> 54 </view>
55 - <view class='display_box '>  
56 - <view class='money_icon2 '>¥</view>  
57 - <view class='money2 '>{{goods.info.vip_price}}</view> 55 + <view class=' '>
  56 + <text class='money_icon2ds'>¥</text>
  57 + <text class='money2d '>{{goods.info.vip_price}}</text>
58 <view class='vip '> 58 <view class='vip '>
59 <image class='vipvip ' src='{{imgUrl}}vipvip.png '></image> 59 <image class='vipvip ' src='{{imgUrl}}vipvip.png '></image>
60 </view> 60 </view>
@@ -119,6 +119,11 @@ text{ @@ -119,6 +119,11 @@ text{
119 font-size: 22rpx; 119 font-size: 22rpx;
120 color: #222; 120 color: #222;
121 } 121 }
  122 +.money_icon2ds {
  123 + font-size: 22rpx;
  124 + color: red;
  125 + margin-left: 8rpx!important
  126 +}
122 127
123 .money { 128 .money {
124 font-size: 38rpx; 129 font-size: 38rpx;
@@ -135,7 +140,7 @@ text{ @@ -135,7 +140,7 @@ text{
135 height: 30rpx; 140 height: 30rpx;
136 margin-left: 40rpx; 141 margin-left: 40rpx;
137 display: flex; 142 display: flex;
138 - align-items: center; 143 + /* align-items: center; */
139 flex-wrap: nowrap; 144 flex-wrap: nowrap;
140 white-space: nowrap; 145 white-space: nowrap;
141 line-height: 30rpx; 146 line-height: 30rpx;
@@ -145,6 +150,14 @@ text{ @@ -145,6 +150,14 @@ text{
145 font-size: 22rpx; 150 font-size: 22rpx;
146 color: #f44; 151 color: #f44;
147 } 152 }
  153 +.money_icon2d{
  154 + height: 20rpx;
  155 + line-height: 20rpx;
  156 + font-size: 22rpx;
  157 + background: purple;
  158 + margin-top: 10rpx;
  159 + color: #f44;
  160 +}
148 161
149 .money2 { 162 .money2 {
150 height: 30rpx; 163 height: 30rpx;
@@ -153,11 +166,20 @@ text{ @@ -153,11 +166,20 @@ text{
153 font-weight: bold; 166 font-weight: bold;
154 color: #f44; 167 color: #f44;
155 } 168 }
  169 +.money2d {
  170 + height: 30rpx;
  171 + line-height: 30rpx;
  172 + font-size: 38rpx;
  173 + font-weight: bold;
  174 + color: #f44;
  175 +}
156 176
157 .vip { 177 .vip {
158 width: 80rpx; 178 width: 80rpx;
159 height: 25rpx; 179 height: 25rpx;
160 margin-left: 5rpx; 180 margin-left: 5rpx;
  181 + margin-top: 5rpx;
  182 + display: inline-block
161 } 183 }
162 184
163 .vip image{ 185 .vip image{
@@ -262,6 +262,7 @@ Page({ @@ -262,6 +262,7 @@ Page({
262 } 262 }
263 let addid = null 263 let addid = null
264 app.post(url, params).then(r => { 264 app.post(url, params).then(r => {
  265 + console.log(this.data.amount + "到底是及")
265 console.log(r) 266 console.log(r)
266 var list = r.data.list; 267 var list = r.data.list;
267 r.data.vips.forEach(function(ele, index) { 268 r.data.vips.forEach(function(ele, index) {
@@ -287,7 +288,11 @@ Page({ @@ -287,7 +288,11 @@ Page({
287 } 288 }
288 ele.arr = new_arr 289 ele.arr = new_arr
289 }) 290 })
290 - var amount = that.data.amount + r.data.priceData.shipment_price 291 + var amount = that.data.amount * 1
  292 + console.log(that.data.amount+'前')
  293 + r.data.priceData.shipment_price = r.data.priceData.shipment_price*1
  294 + console.log(r.data.priceData.shipment_price)
  295 + amount =amount + r.data.priceData.shipment_price
291 that.setData({ 296 that.setData({
292 vip: r.data, 297 vip: r.data,
293 goodsList: r.data.list, 298 goodsList: r.data.list,
@@ -467,6 +472,7 @@ Page({ @@ -467,6 +472,7 @@ Page({
467 amount: that.data.amount, 472 amount: that.data.amount,
468 last_total_price: that.data.amount, 473 last_total_price: that.data.amount,
469 }); 474 });
  475 + console.log(that.data.amount+'最后一次')
470 }, 476 },
471 //渲染商品详情 477 //渲染商品详情
472 fetchGoods() { 478 fetchGoods() {
@@ -513,12 +519,23 @@ Page({ @@ -513,12 +519,23 @@ Page({
513 } 519 }
514 ele.arr = new_arr 520 ele.arr = new_arr
515 }) 521 })
516 - r.data.list.forEach(function(ele, index) {  
517 - ele.price.substring(0, ele.price.length - 3)  
518 - ele.price = ele.price * 1  
519 - price += ele.price  
520 - console.log(price)  
521 - }) 522 + // r.data.list.forEach(function(ele, index) {
  523 + // ele.price.substring(0, ele.price.length - 3)
  524 + // ele.price = ele.price * 1
  525 + // price += ele.price
  526 + // console.log(price)
  527 + // })
  528 + console.log(that.data.is_vip+"是不是会员")
  529 + r.data.info.vip_price.substring(0, r.data.info.vip_price.length - 3)
  530 + r.data.info.price.substring(0, r.data.info.price.length - 3)
  531 + var prices = null
  532 + if(that.data.is_vip==1){
  533 + price = r.data.info.vip_price*1+r.data.priceData.shipment_price*1
  534 + prices = r.data.info.vip_price
  535 + }else{
  536 + prices = r.data.info.price
  537 + price = r.data.info.price * 1 + r.data.priceData.shipment_price*1
  538 + }
522 that.setData({ 539 that.setData({
523 vip: r.data, 540 vip: r.data,
524 goodsList: r.data.list, 541 goodsList: r.data.list,
@@ -530,7 +547,7 @@ Page({ @@ -530,7 +547,7 @@ Page({
530 deliverList: r.data.timeDataArray, 547 deliverList: r.data.timeDataArray,
531 ship_ment_price: r.data.priceData.shipment_price, 548 ship_ment_price: r.data.priceData.shipment_price,
532 amount: price, 549 amount: price,
533 - goodsTotalPrice: price, 550 + goodsTotalPrice: prices,
534 last_total_price: price, 551 last_total_price: price,
535 addd: addid 552 addd: addid
536 }); 553 });
@@ -1285,29 +1302,29 @@ Page({ @@ -1285,29 +1302,29 @@ Page({
1285 /** 1302 /**
1286 * 生命周期函数--监听页面显示 1303 * 生命周期函数--监听页面显示
1287 */ 1304 */
1288 - onShow: function() {  
1289 - let that = this  
1290 - let optionsgid = that.data.optionsgid //直接购买  
1291 - let optionsis_group = that.data.optionsis_group //团购 不等于undefined&&0  
1292 - let optionsproId = that.data.optionsproId //促销 数字  
1293 - let optionspackId = that.data.optionspackId //食品包 数字  
1294 - let optionscart = that.data.optionscart //购物车 字符串  
1295 - if (optionsgid != '') {  
1296 - that.fetchQuick();  
1297 - }  
1298 - if (optionsis_group != '') {  
1299 - that.fetchGroupPay();  
1300 - }  
1301 - if (optionsproId != '') {  
1302 - this.fetchSalePay();  
1303 - }  
1304 - if (optionspackId != '') {  
1305 - this.fetchPackage();  
1306 - }  
1307 - if (optionscart != '') {  
1308 - this.fetchAccount();  
1309 - }  
1310 - }, 1305 + // onShow: function() {
  1306 + // let that = this
  1307 + // let optionsgid = that.data.optionsgid //直接购买
  1308 + // let optionsis_group = that.data.optionsis_group //团购 不等于undefined&&0
  1309 + // let optionsproId = that.data.optionsproId //促销 数字
  1310 + // let optionspackId = that.data.optionspackId //食品包 数字
  1311 + // let optionscart = that.data.optionscart //购物车 字符串
  1312 + // if (optionsgid != '') {
  1313 + // that.fetchQuick();
  1314 + // }
  1315 + // if (optionsis_group != '') {
  1316 + // that.fetchGroupPay();
  1317 + // }
  1318 + // if (optionsproId != '') {
  1319 + // this.fetchSalePay();
  1320 + // }
  1321 + // if (optionspackId != '') {
  1322 + // this.fetchPackage();
  1323 + // }
  1324 + // if (optionscart != '') {
  1325 + // this.fetchAccount();
  1326 + // }
  1327 + // },
1311 /** 1328 /**
1312 * 生命周期函数--监听页面初次渲染完成 1329 * 生命周期函数--监听页面初次渲染完成
1313 */ 1330 */