ext.liuqiwen3 пре 1 дан
родитељ
комит
3e46fd15f4

+ 2 - 2
config/app.js

@@ -1,6 +1,6 @@
 // let domain = "https://www.shuibeibyg.com/front-api"; // 正式环境IP
-// let domain = "https://test.shuibeibyg.com/front-api"; // 测试环境IP
-let domain = 'http://192.168.100.199:8081' // 晋守桦IP
+let domain = "https://test.shuibeibyg.com/front-api"; // 测试环境IP
+// let domain = 'http://192.168.100.199:8081' // 晋守桦IP
 // let domain = 'http://192.168.100.246:8081' // 韩朝龙IP
 let share = "https://www.shuibeibyg.com";
 

+ 7 - 7
pages/goods/goods_search/index.vue

@@ -9,12 +9,12 @@
         </view>
         <view class='bnt' @tap='searchBut'>搜索</view>
       </view>
-      <view class='title'>热门搜索</view>
-      <view class='list acea-row'>
-        <block v-for="(item, index) in hotSearchList" :key="index">
-          <view class='item' @tap='setHotSearchValue(item.title)'>{{ item.title }}</view>
-        </block>
-      </view>
+<!--      <view class='title'>热门搜索</view>-->
+<!--      <view class='list acea-row'>-->
+<!--        <block v-for="(item, index) in hotSearchList" :key="index">-->
+<!--          <view class='item' @tap='setHotSearchValue(item.title)'>{{ item.title }}</view>-->
+<!--        </block>-->
+<!--      </view>-->
       <view class='line'></view>
       <goodList :bastList="bastList" v-if="bastList.length > 0"></goodList>
       <view class='loadingicon acea-row row-center-wrapper' v-if="bastList.length > 0">
@@ -25,7 +25,7 @@
       <view class='pictrue' v-if="bastList.length == 0 && isbastList">
         <image :src="HTTP_REQUEST_URL_IMG+'noSearch.png'"></image>
       </view>
-      <recommend :hostProduct='hostProduct' v-if="bastList.length == 0"></recommend>
+<!--      <recommend :hostProduct='hostProduct' v-if="bastList.length == 0"></recommend>-->
     </view>
   </view>
 </template>

+ 2 - 0
pages/goods_cate/goods_cate.vue

@@ -122,6 +122,8 @@ const infoScroll = () => {
         let top = res[0].top;
         hightArrTemp.push(top);
         hightArr.value = hightArrTemp;
+        console.log('hightArr.value')
+        console.log(hightArr.value)
       }
     });
   }

+ 44 - 19
pages/index/index.vue

@@ -259,7 +259,22 @@ const calculatedProducts = computed(() => {
 });
 onLoad(async (options) => {
   const params = await getSceneInfo(options,'index');
+  // 2. 设置商户ID
+  const isLogin = appStore.isLogin;
+  if (appStore.merchantId && appStore.merchantId !== '') {
+    merchantId.value = appStore.merchantId;
+    if (!isLogin) {
+      toLogin();
+      return; // 登录后页面会刷新,避免继续执行
+    }
+  } else if (appStore?.userInfo?.merchant?.id) {
+    merchantId.value = appStore.userInfo.merchant.id;
+  } else {
+    merchantId.value = '';
+  }
 
+  // 3. 根据商户ID获取不同数据
+  await initPageData();
 });
 onShow(() => {
   const isLogin = appStore.isLogin;
@@ -270,27 +285,37 @@ onShow(() => {
 
   uni.setNavigationBarTitle({ title: site_name.value });
 
-  if(appStore.merchantId && appStore.merchantId!=''){
-    merchantId.value = appStore.merchantId;
-    if(!isLogin){
-      toLogin();
+});
+const initPageData = async () => {
+  try {
+    loading.value = true;
+
+    // 并行执行不依赖的数据获取
+    const promises = [];
+
+    if (merchantId.value && merchantId.value !== '') {
+      promises.push(getSbmerchantInfoFn());
+      promises.push(getMerchantBannerListFn());
+    } else {
+      promises.push(getIndexConfig());
     }
-  }else if(appStore?.userInfo?.merchant && appStore?.userInfo?.merchant.id){
-    merchantId.value = appStore.userInfo.merchant.id
-  }else{
-    merchantId.value = '';
-  }
-  if(merchantId.value && merchantId.value!=''){
-    console.log('++++++++++++++++')
-    getSbmerchantInfoFn();
-    getMerchantBannerListFn()
-  }else{
-    console.log('+++++===============')
-    getIndexConfig();
+
+    promises.push(getGroomList());
+    promises.push(getAllCategory());
+
+    // 等待所有数据获取完成
+    await Promise.all(promises);
+
+  } catch (error) {
+    console.error('初始化页面数据失败:', error);
+    uni.showToast({
+      title: '数据加载失败',
+      icon: 'none'
+    });
+  } finally {
+    loading.value = false;
   }
-  getGroomList();
-  getAllCategory();
-});
+};
 const getMerchantBannerListFn = async () => {
   try {
     let obj = {

+ 25 - 7
pages/merchantCenters/components/merchant_cate.vue

@@ -93,6 +93,7 @@ const getAllCategory = async () => {
 
 // 计算滚动相关数据
 const infoScroll = () => {
+  console.log('infoScroll++++++++')
   let len = productList.value.length;
   let child = productList.value[len - 1] && productList.value[len - 1].child
       ? productList.value[len - 1].child
@@ -119,6 +120,8 @@ const infoScroll = () => {
         let top = res[0].top;
         hightArrTemp.push(top);
         hightArr.value = hightArrTemp;
+        console.log('hightArr.value======')
+        console.log(hightArr.value)
       }
     });
   }
@@ -135,17 +138,32 @@ const scroll = (e) => {
   let scrollTop = e.detail.scrollTop;
   let scrollArr = hightArr.value;
 
-  if (!scrollArr || scrollArr.length === 0) return;
+  console.log('scrollTop:', scrollTop, 'scrollArr:', scrollArr);
 
+  if (!scrollArr || scrollArr.length === 0 || scrollArr.length < 2) return;
+
+  // 修正逻辑:减去第一个元素的高度作为偏移量
+  const baseOffset = scrollArr[0] || 0;
+  const adjustedScrollTop = scrollTop + baseOffset;
+
+  // 找到当前应该激活的索引
+  let currentIndex = 0;
   for (let i = 0; i < scrollArr.length; i++) {
-    if (scrollTop >= 0 && scrollTop < scrollArr[1] - scrollArr[0]) {
-      navActive.value = 0;
-    } else if (scrollTop >= scrollArr[i] - scrollArr[0] && scrollTop < scrollArr[i + 1] - scrollArr[0]) {
-      navActive.value = i;
-    } else if (scrollTop >= scrollArr[scrollArr.length - 1] - scrollArr[0]) {
-      navActive.value = scrollArr.length - 1;
+    if (i === 0 && adjustedScrollTop < scrollArr[0]) {
+      currentIndex = 0;
+      break;
+    } else if (i === scrollArr.length - 1 && adjustedScrollTop >= scrollArr[i]) {
+      currentIndex = i;
+      break;
+    } else if (adjustedScrollTop >= scrollArr[i] && adjustedScrollTop < scrollArr[i + 1]) {
+      currentIndex = i;
+      break;
     }
   }
+
+  if (navActive.value !== currentIndex) {
+    navActive.value = currentIndex;
+  }
 };
 // 监听 merchantId 变化
 watch(() => props.merchantId, (newVal) => {

+ 72 - 30
pages/user/index.vue

@@ -152,7 +152,7 @@
 </template>
 
 <script setup>
-import { ref, reactive, watch } from 'vue'
+import { ref, reactive, watch,computed } from 'vue'
 import { onLoad, onShow, onPageScroll } from "@dcloudio/uni-app";
 import UniIcons from "../../uni_modules/uni-icons/components/uni-icons/uni-icons.vue";
 import { HTTP_REQUEST_URL_IMG } from "@/config/app";
@@ -197,27 +197,49 @@ const orderStatus = ref([
   { src: `${HTTP_REQUEST_URL_IMG}setting/tuikuan.png`, name: '退款/换货' ,id:5},
   { src: `${HTTP_REQUEST_URL_IMG}setting/yiwancheng.png`, name: '已完成',id:4 },
 ])
-
+const merchantZYShow = ref(false)
+const lxsjShow = ref(false);
+const logoutShow = ref(false);
 // 常用功能
-const commonFunctions = ref([
-  { src: `${HTTP_REQUEST_URL_IMG}setting/zuji.png`, name: '浏览足迹',pageUrl:'/pages/users/browsing_history/index',show:true },
-  { src: `${HTTP_REQUEST_URL_IMG}setting/shoucang.png`, name: '我的收藏',pageUrl:'/pages/users/user_goods_collection/index' ,show:true},
-  { src: `${HTTP_REQUEST_URL_IMG}setting/dingwei.png`, name: '收货地址',pageUrl:'/pages/users/user_address_list/index' ,show:true},
-  { src: `${HTTP_REQUEST_URL_IMG}setting/dianpu.png`, name: '联系商家',pageUrl: '/pages/users/my_merchant/index' ,show:!!(appStore.merchantId || appStore.userInfo?.merchant?.id)},
-  { src: `${HTTP_REQUEST_URL_IMG}setting/dianpu.png`, name: '门店主页',pageUrl: '/pages/merchantCenter/index' ,show:!!appStore.userInfo?.merchant?.id},
-  // { src: `${HTTP_REQUEST_URL_IMG}setting/yijianjianyi.png`, name: '意见建议' ,show:true},
-  { src: `${HTTP_REQUEST_URL_IMG}setting/xiazaiapp.png`, name: '下载APP',pageUrl: 'download',show:true },
-  { src: `${HTTP_REQUEST_URL_IMG}setting/lianxikefu.png`, name: '平台客服' ,show:true},
-  // { src: \`${HTTP_REQUEST_URL_IMG}setting/lianxikefu.png', name: '资产明细' ,pageUrl:'/pages/users/user_asset/asset_info/asset_info',show:true}
-])
+const commonFunctions = computed(() => {
+  const baseFunctions = [
+    { src: `${HTTP_REQUEST_URL_IMG}setting/zuji.png`, name: '浏览足迹', pageUrl: '/pages/users/browsing_history/index', show: true },
+    { src: `${HTTP_REQUEST_URL_IMG}setting/shoucang.png`, name: '我的收藏', pageUrl: '/pages/users/user_goods_collection/index', show: true },
+    { src: `${HTTP_REQUEST_URL_IMG}setting/dingwei.png`, name: '收货地址', pageUrl: '/pages/users/user_address_list/index', show: true },
+    { src: `${HTTP_REQUEST_URL_IMG}setting/dianpu.png`, name: '联系商家', pageUrl: '/pages/users/my_merchant/index', show: lxsjShow.value },
+    { src: `${HTTP_REQUEST_URL_IMG}setting/dianpu.png`, name: '门店主页', pageUrl: '/pages/merchantCenter/index', show: merchantZYShow.value },
+    { src: `${HTTP_REQUEST_URL_IMG}setting/xiazaiapp.png`, name: '下载APP', pageUrl: 'download', show: true },
+    { src: `${HTTP_REQUEST_URL_IMG}setting/lianxikefu.png`, name: '平台客服', show: true },
+    { src: `${HTTP_REQUEST_URL_IMG}setting/logout.png`, name: '退出登录', pageUrl: 'logout', show: logoutShow.value }
+  ];
+
+  // 根据 show 值过滤
+  return baseFunctions.filter(func => func.show);
+});
 const params = ref({
   page: 1,
   limit: 10,
 });
 
 // 页面加载
-onShow(() => {
-  console.log(appStore.userInfo)
+onShow(async () => {
+  if(appStore.isLogin){
+    await appStore.USERINFO();
+    logoutShow.value = true;
+    if(appStore.userInfo?.merchant?.id){
+      merchantZYShow.value = true;
+    }else{
+      merchantZYShow.value = false;
+    }
+    if(appStore.merchantId || appStore.userInfo?.merchant?.id){
+      lxsjShow.value = true;
+    }else{
+      lxsjShow.value = false;
+    }
+  }else{
+    logoutShow.value = false;
+  }
+
   fetchMetalBalance()
   getHistoryList()
 })
@@ -322,23 +344,27 @@ const goDetail = (url) => {
 	});
 }
 
+function handleLogOut() {
+  uni.showModal({
+    title: "提示",
+    content: "确认退出登录吗?",
+    success: function (res) {
+      if (res.confirm) {
+        // 清除全局定时器
+        if (getApp().globalData?.messageTimer) {
+          clearInterval(getApp().globalData.messageTimer);
+          getApp().globalData.messageTimer = null;
+        }
+        appStore.LOGOUT();
+        uni.reLaunch({ url: "/pages/users/login/index" });
+      }
+    },
+  });
+}
 // 功能点击
 const handleFunctionClick = (url) => {
   console.log(url)
-  if(url === "download"){
-	  uni.setClipboardData({
-	  	data: 'https://a.app.qq.com/o/simple.jsp?pkgname=uni.app.UNI9DE338F',
-		showToast: false,
-	  	success: function () {
-			uni.showToast({
-				title: "下载链接复制成功,请打开内置手机浏览器访问下载。",
-				icon: 'none'
-			})
-	  		console.log('success');
-	  	}
-	  });
-	return
-  }
+
   if (!url) return;
   // 买料、卖料、消费需要通过webview跳转
   if (
@@ -361,8 +387,24 @@ const handleFunctionClick = (url) => {
       },
     });
     return; // 阻止继续执行后续跳转逻辑
+  }else if(url === "download"){
+    uni.setClipboardData({
+      data: 'https://a.app.qq.com/o/simple.jsp?pkgname=uni.app.UNI9DE338F',
+      showToast: false,
+      success: function () {
+        uni.showToast({
+          title: "下载链接复制成功,请打开内置手机浏览器访问下载。",
+          icon: 'none'
+        })
+        console.log('success');
+      }
+    });
+    return
+  }else if(url === "logout"){
+    handleLogOut();
+  }else{
+    uni.navigateTo({ url });
   }
-  uni.navigateTo({ url });
 }
 
 // 查看商家