hookehuyr

待申领物资-购物车操作逻辑完善

This diff is collapsed. Click to expand it.
1 <!-- 1 <!--
2 * @Date: 2024-07-23 12:53:15 2 * @Date: 2024-07-23 12:53:15
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-07-24 14:44:31 4 + * @LastEditTime: 2024-07-24 15:15:38
5 * @FilePath: /temple_material_request/src/views/material_request.vue 5 * @FilePath: /temple_material_request/src/views/material_request.vue
6 * @Description: 申领物资页面 6 * @Description: 申领物资页面
7 --> 7 -->
8 <template> 8 <template>
9 <div class="material-request-page"> 9 <div class="material-request-page">
10 -
11 <van-tabs v-model:active="active" @change="onChange" sticky :color="styleColor.baseColor"> 10 <van-tabs v-model:active="active" @change="onChange" sticky :color="styleColor.baseColor">
12 <van-tab v-for="index in 8" :title="'标签 ' + index"> 11 <van-tab v-for="index in 8" :title="'标签 ' + index">
13 <div class="list-wrapper"> 12 <div class="list-wrapper">
...@@ -81,7 +80,7 @@ ...@@ -81,7 +80,7 @@
81 <script setup> 80 <script setup>
82 import { ref } from 'vue' 81 import { ref } from 'vue'
83 import { useRoute, useRouter } from 'vue-router' 82 import { useRoute, useRouter } from 'vue-router'
84 - 83 +import { showToast } from 'vant';
85 import { Cookies, $, _, axios, storeToRefs, mainStore, Toast, useTitle } from '@/utils/generatePackage.js' 84 import { Cookies, $, _, axios, storeToRefs, mainStore, Toast, useTitle } from '@/utils/generatePackage.js'
86 //import { } from '@/utils/generateModules.js' 85 //import { } from '@/utils/generateModules.js'
87 //import { } from '@/utils/generateIcons.js' 86 //import { } from '@/utils/generateIcons.js'
...@@ -192,6 +191,11 @@ const addShoppingCart = () => { // 加入购物车 ...@@ -192,6 +191,11 @@ const addShoppingCart = () => { // 加入购物车
192 .forEach(item => { 191 .forEach(item => {
193 shop_cart_list.value = shop_cart_list.value.concat(item); 192 shop_cart_list.value = shop_cart_list.value.concat(item);
194 }); 193 });
194 + // 购物车为空提示
195 + if (!shop_cart_list.value.length) {
196 + showToast('请选择物资');
197 + return;
198 + }
195 // 校验购物车值 199 // 校验购物车值
196 let error_list = shop_cart_list.value.filter((item) => { if (item.num === null || item.num === '') { return item;} }) 200 let error_list = shop_cart_list.value.filter((item) => { if (item.num === null || item.num === '') { return item;} })
197 if (error_list.length) { 201 if (error_list.length) {
...@@ -213,7 +217,7 @@ const goShoppingCart = () => { // 跳转购物车 ...@@ -213,7 +217,7 @@ const goShoppingCart = () => { // 跳转购物车
213 } 217 }
214 218
215 const show_choose_material = ref(false); 219 const show_choose_material = ref(false);
216 -const onCloseChoose = () => { 220 +const onCloseChoose = () => { // 关闭选择物资弹窗回调
217 show_choose_material.value = false; 221 show_choose_material.value = false;
218 } 222 }
219 223
......