|
@@ -11,8 +11,8 @@ Page({
|
|
|
foodsName: '麻烫',
|
|
|
foodsDesc: '包含香菜、菠菜、面、豆芽、海带',
|
|
|
initPrice: 28.80,
|
|
|
- nowPrice: 10.98
|
|
|
-
|
|
|
+ nowPrice: 10.98,
|
|
|
+ num : 0
|
|
|
},
|
|
|
{
|
|
|
id: 1,
|
|
@@ -20,7 +20,8 @@ Page({
|
|
|
foodsName: '麻辣',
|
|
|
foodsDesc: '包含香菜、菠菜、面、豆芽、海带',
|
|
|
initPrice: 28.80,
|
|
|
- nowPrice: 10.98
|
|
|
+ nowPrice: 10.98,
|
|
|
+ num : 10
|
|
|
},
|
|
|
{
|
|
|
id: 2,
|
|
@@ -28,8 +29,8 @@ Page({
|
|
|
foodsName: '麻辣烫',
|
|
|
foodsDesc: '包含香菜、菠菜、面、豆芽、海带',
|
|
|
initPrice: 28.80,
|
|
|
- nowPrice: 10.98
|
|
|
-
|
|
|
+ nowPrice: 10.98,
|
|
|
+ num : 0
|
|
|
},
|
|
|
{
|
|
|
id: 3,
|
|
@@ -37,8 +38,8 @@ Page({
|
|
|
foodsName: '麻辣烫',
|
|
|
foodsDesc: '包含香菜、菠菜、面、豆芽、海带',
|
|
|
initPrice: 28.80,
|
|
|
- nowPrice: 10.98
|
|
|
-
|
|
|
+ nowPrice: 10.98,
|
|
|
+ num : 0
|
|
|
},
|
|
|
{
|
|
|
id: 4,
|
|
@@ -46,8 +47,8 @@ Page({
|
|
|
foodsName: '麻辣烫',
|
|
|
foodsDesc: '包含香菜、菠菜、面、豆芽、海带',
|
|
|
initPrice: 28.80,
|
|
|
- nowPrice: 10.98
|
|
|
-
|
|
|
+ nowPrice: 10.98,
|
|
|
+ num : 0
|
|
|
},
|
|
|
{
|
|
|
id: 5,
|
|
@@ -55,8 +56,8 @@ Page({
|
|
|
foodsName: '麻辣烫',
|
|
|
foodsDesc: '包含香菜、菠菜、面、豆芽、海带',
|
|
|
initPrice: 28.80,
|
|
|
- nowPrice: 10.98
|
|
|
-
|
|
|
+ nowPrice: 10.98,
|
|
|
+ num : 0
|
|
|
},
|
|
|
{
|
|
|
id: 6,
|
|
@@ -64,8 +65,8 @@ Page({
|
|
|
foodsName: '麻辣烫',
|
|
|
foodsDesc: '包含香菜、菠菜、面、豆芽、海带',
|
|
|
initPrice: 28.80,
|
|
|
- nowPrice: 10.98
|
|
|
-
|
|
|
+ nowPrice: 10.98,
|
|
|
+ num : 0
|
|
|
},
|
|
|
{
|
|
|
id: 7,
|
|
@@ -73,13 +74,14 @@ Page({
|
|
|
foodsName: '麻辣烫',
|
|
|
foodsDesc: '包含香菜、菠菜、面、豆芽、海带',
|
|
|
initPrice: 28.80,
|
|
|
- nowPrice: 10.98
|
|
|
-
|
|
|
+ nowPrice: 10.98,
|
|
|
+ num : 0
|
|
|
}
|
|
|
],
|
|
|
show: false,
|
|
|
totalPrice: 0,
|
|
|
- info: ''
|
|
|
+ info: '',
|
|
|
+ showList: []
|
|
|
},
|
|
|
onInput(e) {
|
|
|
this.setData({
|
|
@@ -88,28 +90,55 @@ Page({
|
|
|
},
|
|
|
onChange(e) {
|
|
|
let id = e.currentTarget.dataset.id;
|
|
|
- let count = e.detail;
|
|
|
- let foodsPrice = this.data.foods[id].nowPrice;
|
|
|
- // console.log(id,foodsPrice);
|
|
|
+ let num = e.detail;
|
|
|
+ // console.log(num);
|
|
|
+ let ans = this.data.foods[0].num
|
|
|
+ console.log(ans);
|
|
|
+ this.setData({
|
|
|
+ [ans ]:'num'
|
|
|
+ })
|
|
|
+ // for( let i = 0 ; i < showList.length ;i ++ ) {
|
|
|
+ // showList[i].num
|
|
|
+ // }
|
|
|
+ // for( let i = 0 ; i < showList.length ;i ++ ) {
|
|
|
+ // showList[i].
|
|
|
+ // }
|
|
|
+ // totalPrice
|
|
|
},
|
|
|
onSearch() {
|
|
|
let list = this.data.foods;
|
|
|
- let arr=[];
|
|
|
- list.forEach(res=>{
|
|
|
- if(this.data.info===res.foodsName)
|
|
|
- {
|
|
|
- arr.push(res)
|
|
|
- }
|
|
|
- })
|
|
|
- console.log(arr);
|
|
|
+ // 给你一个数组 里面包含a这个字的元素 将这些元素抛入新数组
|
|
|
+ let inputData = this.data.info
|
|
|
+ let showList = [];
|
|
|
+ for (let i = 0; i < list.length; i++) {
|
|
|
+ let name = list[i].foodsName
|
|
|
+ if (name.indexOf(inputData) >= 0) {
|
|
|
+ showList.push(list[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log(showList);
|
|
|
+
|
|
|
+ // showList
|
|
|
+ if (showList.length != 0) {
|
|
|
+ this.setData({
|
|
|
+ show: false,
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ show: true,
|
|
|
+ })
|
|
|
+ }
|
|
|
this.setData({
|
|
|
- show: !this.data.show,
|
|
|
+ showList,
|
|
|
})
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad(options) {
|
|
|
+ this.setData({
|
|
|
+ showList: this.data.foods
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
/**
|