Explorar o código

fix: 增加切换

lxf hai 3 días
pai
achega
6531d05209

+ 10 - 3
src/components/popup/priceSheetPopup.vue

@@ -125,6 +125,8 @@
 import { Popup } from "vant";
 import { ref, computed } from "vue";
 import { useRouter } from "vue-router";
+import wx from "weixin-js-sdk";
+
 const router = useRouter();
 const showPopup = ref(false);
 
@@ -207,9 +209,14 @@ const handleShare = () => {
 
 const handleWechat = () => {
     console.log("handleWechat");
-    router.push({
-        path: "/completed_work",
-        query: { id: quotationData.value.id, farmWorkOrderId: quotationData.value.orderId, isAssign: true },
+    // router.push({
+    //     path: "/completed_work",
+    //     query: { id: quotationData.value.id, farmWorkOrderId: quotationData.value.orderId, isAssign: true },
+    // });
+    const query = { id: quotationData.value.id, farmWorkOrderId: quotationData.value.orderId, isAssign: true }
+
+    wx.miniProgram.navigateTo({
+        url: `/pages/subPages/share_page/index?pageParams=${JSON.stringify(query)}&type=priceSheet`,
     });
 };
 

+ 2 - 2
src/store/modules/app/index.js

@@ -69,8 +69,8 @@ export default {
             localStorage.setItem("isExampleGarden", isExampleGarden);
         },
         [SET_USER_ROLES](state, roles) {
-            state.roles = roles
-            localStorage.setItem(SET_USER_ROLES, roles);
+            state.roles = JSON.stringify(roles)
+            localStorage.setItem(SET_USER_ROLES, state.roles);
         },
         [SET_USER_CUR_ROLE](state, role) {
             state.curRole = role

+ 1 - 1
src/views/old_mini/farm_manage/components/demandHall.vue

@@ -140,7 +140,7 @@ function getSimpleList() {
 function toDetail(item) {
     router.push({
         path: "/completed_work",
-        query: { id: item.id }
+        query: { json: JSON.stringify({ id: item.id }) }
     });
 }
 

+ 38 - 6
src/views/old_mini/mine/index.vue

@@ -14,12 +14,11 @@
                     </div>
                     <div class="user-day">这是您使用飞鸟有味的第15天</div>
                 </div>
-                
             </div>
             <div class="code-icon" v-if="curRole === 1">
                 <img src="@/assets/img/mine/code-icon.png" alt="" />
             </div>
-            <div class="switch-role-btn" v-if="curRole === 2">
+            <div class="switch-role-btn" v-if="roles && roles.length > 1" @click="changeToggle">
                 <span>切换身份</span>
                 <el-icon><Switch /></el-icon>
             </div>
@@ -47,20 +46,49 @@
                 </div>
             </div>
         </div>
+        <!-- 角色切换 -->
+        <action-sheet :style="{ bottom: 50 + 'px' }" v-model:show="show" :actions="actions" @select="onSelect" />
     </div>
 </template>
 <script setup>
-import { onActivated, ref, computed } from "vue";
+import { onActivated, ref, computed, onMounted } from "vue";
 import { useRouter } from "vue-router";
+import { useStore } from "vuex";
+import { ActionSheet } from "vant";
+import { SET_USER_CUR_ROLE } from "@/store/modules/app/type";
 
+const store = useStore();
 const router = useRouter();
 
 // 0: 农户, 1: 专家, 2:农资农服
 const curRole = ref(Number(localStorage.getItem("SET_USER_CUR_ROLE")));
+const roles = ref(JSON.parse(store.state.app.roles));
+// const roles = ref([0,1,2,3])
+const actions = ref([]);
+const userObj = ref({})
+const list = ref([]);
 
 // 网格项数据
 const gridItems = ref([]);
 
+const objects = [
+    { name: "农户", id: 0, text: "NH" },
+    { name: "农资", id: 2, text: "NZ" },
+];
+
+onMounted(() => {
+    // 仅保留 objects 中存在的角色
+    actions.value = objects.filter(obj => roles.value && roles.value.includes(obj.id));
+});
+
+const show = ref(false);
+const onSelect = (item) => {
+    show.value = false;
+    store.dispatch(`app/${SET_USER_CUR_ROLE}`, item.id);
+    localStorage.setItem('SET_USER_CUR_ROLE',item.id)
+    window.location.reload()
+};
+
 onActivated(() => {
     if (curRole.value === 0) {
         gridItems.value = [
@@ -188,6 +216,10 @@ const handleCellClick = (item) => {
         }
     }
 };
+
+const changeToggle = () => {
+    show.value = true;
+};
 </script>
 <style lang="scss" scoped>
 .mine-index {
@@ -203,7 +235,7 @@ const handleCellClick = (item) => {
         justify-content: space-between;
         .user-info-box {
             display: flex;
-            align-items: center;     
+            align-items: center;
             .avatar {
                 border: 1px solid #fff;
                 margin-right: 12px;
@@ -235,14 +267,14 @@ const handleCellClick = (item) => {
                 height: 100%;
             }
         }
-        .switch-role-btn{
+        .switch-role-btn {
             margin-right: -16px;
             display: flex;
             align-items: center;
             justify-content: center;
             padding: 5px 10px 6px 12px;
             color: #fff;
-            background: #2199F8;
+            background: #2199f8;
             border-radius: 25px 0 0 25px;
             gap: 5px;
             font-size: 13px;

+ 9 - 2
src/views/old_mini/modify_work/completedWork.vue

@@ -279,7 +279,7 @@
                 class="fixed-btn-wrap"
                 v-if="curRole == 2 && currentStep == 1"
             >
-                <div class="fixed-btn second">转发给客户</div>
+                <div class="fixed-btn second" @click="handleForward">转发给客户</div>
                 <div class="fixed-btn" @click="showPriceSheetPopup">生成报价单</div>
             </div>
             <!-- 农资,步骤:农资已执行,请求确认 -->
@@ -331,7 +331,7 @@ import { base_img_url2 } from "@/api/config";
 
 const router = useRouter();
 const store = useStore();
-const query = useRoute().query;
+const query = useRoute().query?.json ? JSON.parse(useRoute().query?.json) : {};
 // 角色
 // const curRole = store.state.app.curRole
 const currentStep = ref(0);
@@ -429,6 +429,13 @@ const handleConfirmComplete = () => {
     })
 };
 
+const handleForward = () => {
+    onlyShare.value = true;
+    setTimeout(() => {
+        uploadExecuteRef.value.showPopup(query.id,'share-sheet');
+    }, 10);
+}
+
 const onlyShare = ref(false);
 const handleShare = () => {
     onlyShare.value = true;

+ 1 - 1
src/views/old_mini/modify_work/index.vue

@@ -501,7 +501,7 @@ function handlePopupBtn() {
         router.push({
             path: "/completed_work",
             query: {
-                id: route.query.id,
+                json: JSON.stringify({ id: route.query.id }),
             },
         });
     }

+ 1 - 1
src/views/old_mini/monitor/subPages/plan.vue

@@ -208,7 +208,7 @@ const handleRowClick = (item) => {
         router.push({
             path: "/completed_work",
             query: {
-                id: item.farmWorkRecordId,
+                json: JSON.stringify({ id: item.farmWorkRecordId }),
             },
         });
     }

+ 0 - 1
src/views/old_mini/task_condition/components/calendar.vue

@@ -136,7 +136,6 @@ function setSolarTerm(taskList) {
 const expiredCounts = ref(0);
 const completedCounts = ref(0);
 function setCounts(index, counts) {
-    console.log('sssset', index, counts);
     if (index === 2) {
         completedCounts.value = counts;
     } else if (index === 3) {

+ 19 - 8
src/views/old_mini/task_condition/components/task.vue

@@ -56,7 +56,7 @@
                                     查看详情
                                 </div>
                                 <div class="footer-r">
-                                    <div class="btn second">
+                                    <div class="btn second" @click="handleForward(item)">
                                         转发给客户
                                     </div>
                                     <div class="btn primary" @click="showPriceSheetPopup(item)">
@@ -113,6 +113,8 @@ import calendar from "./calendar.vue"
 import { useRouter } from "vue-router";
 import uploadExecute from "./uploadExecute.vue";
 import priceSheetPopup from "@/components/popup/priceSheetPopup.vue";
+import wx from "weixin-js-sdk";
+
 const store = useStore();
 const router = useRouter();
 const indexMap = new IndexMap();
@@ -222,19 +224,20 @@ function getSimpleList() {
         loading.value = false;
         // 假设返回的数据结构是 { list: [], total: 0 } 或者直接是数组
         if (Array.isArray(data) && data.length > 0) {
-            console.log('ssssget', data);
             taskList.value = data;
             // 更新当前状态的数量
             taskCounts.value[activeIndex.value] = data.length;
-            if (activeIndex.value === 1) {
+            if (activeIndex.value === 2) {
                 calendarRef.value && calendarRef.value.setSolarTerm(taskList.value)
                 indexMap.initData(taskList.value)
             }
         } else {
             taskList.value = [];
-            taskCounts.value[activeIndex.value] = 0;
-            indexMap.initData(taskList.value)
-            calendarRef.value && calendarRef.value.setSolarTerm(taskList.value)
+            if (activeIndex.value === 2) {
+                taskCounts.value[activeIndex.value] = 0;
+                indexMap.initData(taskList.value)
+                calendarRef.value && calendarRef.value.setSolarTerm(taskList.value)
+            }
             noData.value = true;
         }
     }).catch((error) => {
@@ -280,12 +283,12 @@ function toDetail(item) {
     if (activeIndex.value === 0) {
         router.push({
             path: "/modify_work",
-            query: { id: item.id }
+            query: { json: JSON.stringify({ id: item.id }) }
         });
     } else {
         router.push({
             path: "/completed_work",
-            query: { id: item.id }
+            query: { json: JSON.stringify({ id: item.id }) }
         });
     }
 }
@@ -322,6 +325,14 @@ function handlePopupBtn() {
         getTaskCount('1,2,3', 1)
     }
 }
+
+function handleForward(item) {
+    onlyShare.value = true;
+    setTimeout(() => {
+        uploadExecuteRef.value.showPopup(item.id,'share-sheet');
+    }, 10);
+}
+
 </script>
 
 <style lang="scss" scoped>