|
|
@@ -65,7 +65,7 @@
|
|
|
<div
|
|
|
@click="navigateTo('/pages/storedetails')"
|
|
|
class="merchantroCon"
|
|
|
- v-for="(item, index) in merchantorLists"
|
|
|
+ v-for="(item, index) in merchantorListsData"
|
|
|
:key="index"
|
|
|
>
|
|
|
<img :src="item.image" alt="" />
|
|
|
@@ -74,17 +74,17 @@
|
|
|
<div class="text2">月销{{ item.num }} 赞{{ item.fabulous }}</div>
|
|
|
<div class="bottom" @click.stop>
|
|
|
<div class="price">¥{{ item.price }}.00</div>
|
|
|
- <div v-if="count == 0">
|
|
|
- <div class="add" @click="falgs(item.price)">+</div>
|
|
|
+ <div class="addcon">
|
|
|
+ <div v-if="item.currentNum > 0">
|
|
|
+ <div class="add" @click="minus(item)">-</div>
|
|
|
+ </div>
|
|
|
+ <div class="text" v-show="item.currentNum > 0">
|
|
|
+ {{ item.currentNum }}
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <div class="add" @click="add(item)">+</div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- <van-stepper
|
|
|
- v-else
|
|
|
- :min="min"
|
|
|
- disable-input
|
|
|
- @minus="minus(item.price)"
|
|
|
- @plus="add(item.price)"
|
|
|
- @change="onChange"
|
|
|
- />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -204,13 +204,14 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <orderBtn :tal="tal" :count="count" :merchantorLists="merchantorLists"></orderBtn>
|
|
|
+ <orderBtn :totalPrice="totalPrice" :allreadyGoodsList="allreadyGoodsList"></orderBtn>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
import { mapState } from 'vuex';
|
|
|
import NavHeader from '../components/NavHeader.vue';
|
|
|
import orderBtn from '../components/orderBtn.vue';
|
|
|
+import { merchantorLists } from './mock/merchantorList.js';
|
|
|
export default {
|
|
|
components: { NavHeader, orderBtn },
|
|
|
data() {
|
|
|
@@ -218,9 +219,6 @@ export default {
|
|
|
active: '点餐',
|
|
|
active2: '全部',
|
|
|
falg: 0,
|
|
|
- min: 0,
|
|
|
- count: 0,
|
|
|
- tal: 0,
|
|
|
tabs: ['点餐', '评价', '商家'],
|
|
|
tabs2: ['全部', '最新', '有图'],
|
|
|
items: [
|
|
|
@@ -264,22 +262,6 @@ export default {
|
|
|
distribution: '起送20元/约20分钟送达/配送费2元'
|
|
|
}
|
|
|
],
|
|
|
- merchantorLists: [
|
|
|
- {
|
|
|
- name: '寿司',
|
|
|
- image: 'https://ticket-exchange.oss-cn-hangzhou.aliyuncs.com/image/2021-08-13-15-54-36URxMKUXs.jpg',
|
|
|
- num: '226',
|
|
|
- fabulous: '40',
|
|
|
- price: 20.0
|
|
|
- },
|
|
|
- {
|
|
|
- name: '冒菜',
|
|
|
- image: 'https://ticket-exchange.oss-cn-hangzhou.aliyuncs.com/image/2021-08-13-15-56-45UCHrCoTS.gif',
|
|
|
- num: '12',
|
|
|
- fabulous: '6',
|
|
|
- price: 10.0
|
|
|
- }
|
|
|
- ],
|
|
|
merchantorListss: [
|
|
|
{
|
|
|
name: '油条',
|
|
|
@@ -288,11 +270,29 @@ export default {
|
|
|
fabulous: '6',
|
|
|
price: '2'
|
|
|
}
|
|
|
- ]
|
|
|
+ ],
|
|
|
+ merchantorListsData: []
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
- ...mapState(['userInfo'])
|
|
|
+ ...mapState(['userInfo']),
|
|
|
+ totalPrice() {
|
|
|
+ let result = this.merchantorListsData.reduce(function(prev, curr, idx, arr) {
|
|
|
+ return prev + curr.currentCount;
|
|
|
+ }, 0);
|
|
|
+ return result;
|
|
|
+ },
|
|
|
+ allreadyGoodsList() {
|
|
|
+ let resultArr = this.merchantorListsData.filter(item => item.currentNum > 0);
|
|
|
+ return resultArr;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ merchantorLists.forEach(item => {
|
|
|
+ item.currentNum = 0;
|
|
|
+ item.currentCount = 0;
|
|
|
+ this.merchantorListsData.push(item);
|
|
|
+ });
|
|
|
},
|
|
|
methods: {
|
|
|
tab(item) {
|
|
|
@@ -304,24 +304,13 @@ export default {
|
|
|
change(e) {
|
|
|
this.active2 = e;
|
|
|
},
|
|
|
- onChange(e) {
|
|
|
- this.count = e.detail;
|
|
|
- },
|
|
|
-
|
|
|
- falgs(price) {
|
|
|
- this.tal = price * 1;
|
|
|
- this.count = 1;
|
|
|
- this.min = 1;
|
|
|
- },
|
|
|
- add(price) {
|
|
|
- var that = this;
|
|
|
- this.or_amount = 0;
|
|
|
- this.now_amount = 0;
|
|
|
- this.tal = this.tal + price + this.count;
|
|
|
+ add(item) {
|
|
|
+ item.currentNum++;
|
|
|
+ item.currentCount = item.currentNum * item.price;
|
|
|
},
|
|
|
- minus(price) {
|
|
|
- this.min = 0;
|
|
|
- this.tal = price * this.count;
|
|
|
+ minus(item) {
|
|
|
+ item.currentNum--;
|
|
|
+ item.currentCount = item.currentNum * item.price;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
@@ -489,8 +478,19 @@ export default {
|
|
|
.price {
|
|
|
.price();
|
|
|
}
|
|
|
- .add {
|
|
|
- .add();
|
|
|
+ .addcon {
|
|
|
+ .flex();
|
|
|
+ .text {
|
|
|
+ width: 24px;
|
|
|
+ height: 24px;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 24px;
|
|
|
+ background: #f5f7fa;
|
|
|
+ margin: 0 4px;
|
|
|
+ }
|
|
|
+ .add {
|
|
|
+ .add();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|