Browse Source

线上版本

文杰 1 week ago
parent
commit
5602d9ff8f
8 changed files with 106 additions and 88 deletions
  1. 8 3
      app.js
  2. 18 2
      pages/category/category.js
  3. 26 72
      pages/category1/category.js
  4. 46 7
      pages/index/index.js
  5. 5 2
      pages/login/login.js
  6. 1 0
      pages/prod/prod.wxss
  7. 1 1
      pages/user/user.js
  8. 1 1
      utils/config.js

+ 8 - 3
app.js

@@ -6,9 +6,14 @@ App({
     http.getToken();
     //自定义导航栏 获取设备顶部窗口的高度(不同设备窗口高度不一样,根据这个来设置自定义导航栏的高度)
     const windowInfo = wx.getWindowInfo()
-        let custom = wx.getMenuButtonBoundingClientRect()
-        this.globalData.statusBarHeight = windowInfo.statusBarHeight
-        this.globalData.navBarHeight = custom.height + (custom.top - windowInfo.statusBarHeight) * 2
+    let custom = wx.getMenuButtonBoundingClientRect()
+    this.globalData.statusBarHeight = windowInfo.statusBarHeight
+    this.globalData.navBarHeight = custom.height + (custom.top - windowInfo.statusBarHeight) * 2
+
+    // 默认店铺
+    if(!wx.getStorageSync('shopInfo')){
+      wx.setStorageSync('shopInfo',{shopName:'瑞果商链-“星闪豹”',shopId:1})
+    }
   },
   globalData: {
     // 定义全局请求队列

+ 18 - 2
pages/category/category.js

@@ -56,7 +56,13 @@ Page({
   onLoad: function (options) {
     console.log('onload');
     this.getRecommended()
-    this.get_neighborShop()
+    // this.get_neighborShop()
+    this.setData({
+      shopId:wx.getStorageSync('shopInfo').shopId
+    })
+    this.resetData()
+    this.get_categoryInfo(wx.getStorageSync('shopInfo').shopId)
+    this.getCarData(wx.getStorageSync('shopInfo').shopId)
     // this.get_categoryInfo()
   },
   scroll(){
@@ -123,6 +129,7 @@ Page({
   },
   resetData(){
     this.setData({
+      productList:[],
       subIndex:0,
       thridIndex:-1,
       subCategoryId:0,
@@ -325,11 +332,20 @@ Page({
    */
   onShow: function () {
     console.log('show');
+
+    
+    
+    
     // 每次重新加载
     if(this.data.shopId != wx.getStorageSync('shopInfo').shopId){
       console.log('店铺切换了 刷新');
+      this.setData({
+        shopId:wx.getStorageSync('shopInfo').shopId
+      })
       this.resetData()
-      this.get_neighborShop()
+      this.get_categoryInfo(wx.getStorageSync('shopInfo').shopId)
+      this.getCarData(wx.getStorageSync('shopInfo').shopId)
+      // this.get_neighborShop()
     }else if(this.data.shopId){
       this.getCarData(this.data.shopId)
     }

+ 26 - 72
pages/category1/category.js

@@ -54,9 +54,15 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    
+    console.log('onload');
     this.getRecommended()
-    this.get_neighborShop()
+    // this.get_neighborShop()
+    this.setData({
+      shopId:wx.getStorageSync('shopInfo').shopId
+    })
+    this.resetData()
+    this.get_categoryInfo(wx.getStorageSync('shopInfo').shopId)
+    this.getCarData(wx.getStorageSync('shopInfo').shopId)
     // this.get_categoryInfo()
   },
   scroll(){
@@ -123,6 +129,7 @@ Page({
   },
   resetData(){
     this.setData({
+      productList:[],
       subIndex:0,
       thridIndex:-1,
       subCategoryId:0,
@@ -185,58 +192,7 @@ Page({
     })
   },
 
-  // 获取点击位置和购物车位置
-  getNodePositions(index) {
-    const query = wx.createSelectorQuery().in(this);
-
-    // 1. 获取"加入购物车"按钮的位置(动画起始点)
-    query.select(`.product-item:nth-child(${index + 1}) .info .price-box .test`).boundingClientRect(btnRect => {
-      if (!btnRect) return; // 容错:防止节点未找到
-      const startX = btnRect.left + btnRect.width / 2 - 20; // 20 = 40rpx/2(图标宽高)
-      const startY = btnRect.top + btnRect.height / 2 - 20;
-
-      // 2. 获取购物车位置(动画结束点)
-      query.select('.bottom-box .left .icon').boundingClientRect(cartRect => {
-        if (!cartRect) return;
-        const endX = cartRect.left + cartRect.width / 2 - 20;
-        const endY = cartRect.top + cartRect.height / 2 - 20;
-
-        // 3. 计算抛物线中间点(控制弧度)
-        const midX = (startX + endX) / 2;
-        const midY = startY - 80; // 向上凸起80px,可调整弧度
-
-        // 4. 创建动画图标
-        this.createAnimationIcon(startX, startY, midX, midY, endX, endY);
-      }).exec();
-    }).exec();
-  },
-
-  // 创建抛物线动画(数据驱动,无DOM操作)
-  createAnimationIcon(startX, startY, midX, midY, endX, endY) {
-    // 生成唯一ID,避免key冲突
-    const iconId = Date.now() + Math.floor(Math.random() * 1000);
-    const newIcon = {
-      id: iconId,
-      startX,
-      startY,
-      midX,
-      midY,
-      endX,
-      endY
-    };
-
-    // 添加动画图标到数组(自动渲染)
-    this.setData({
-      animationIcons: [...this.data.animationIcons, newIcon]
-    });
-
-    // 动画结束后移除图标+更新购物车
-    setTimeout(() => {
-      this.setData({
-        animationIcons: this.data.animationIcons.filter(icon => icon.id !== iconId),
-      });
-    }, 700); // 与动画时长保持一致(0.7s)
-  },
+  
   
   handleAll(){
     this.setData({
@@ -289,7 +245,7 @@ Page({
     let that = this
     //加载分类列表
     var params = {
-     // url: "/category/categoryInfo",
+      // url: "/category/categoryInfo",
       // url: "/category/listCategoryForUser/"+(this.data.testShopId||shopid),
       url: "/category/listCategoryForUser",
       method: "GET",
@@ -376,24 +332,23 @@ Page({
    */
   onShow: function () {
     console.log('show');
-    if(this.data.shopId){
+
+    
+    
+    
+    // 每次重新加载
+    if(this.data.shopId != wx.getStorageSync('shopInfo').shopId){
+      console.log('店铺切换了 刷新');
+      this.setData({
+        shopId:wx.getStorageSync('shopInfo').shopId
+      })
+      this.resetData()
+      this.get_categoryInfo(wx.getStorageSync('shopInfo').shopId)
+      this.getCarData(wx.getStorageSync('shopInfo').shopId)
+      // this.get_neighborShop()
+    }else if(this.data.shopId){
       this.getCarData(this.data.shopId)
     }
-    // if (getApp().globalData.categoryId) {
-    //   let categoryId = getApp().globalData.categoryId
-    //   let index = getApp().globalData.index
-    //   let pic = getApp().globalData.pic
-
-    //   this.setData({
-    //     categoryImg: pic,
-    //     selIndex: index
-    //   });
-    // }else{
-    // this.get_neighborShop()
-    // }
-    // 之前逻辑 每次重新加载
-    // this.resetData()
-    // this.get_neighborShop()
 
   },
 
@@ -737,7 +692,6 @@ Page({
   toProdPage: function (e) {
     var prodid = e.currentTarget.dataset.prodid;
     var shopid = e.currentTarget.dataset.shopid;
-    console.log(22222222,e);
     if (prodid) {
       wx.navigateTo({
         url: `/pages/prod/prod?prodid=${prodid}&shopid=${shopid}`,

+ 46 - 7
pages/index/index.js

@@ -79,9 +79,19 @@ Page({
     this.setData({
       select_address: wx.getStorageSync('ADDRESS')
     })
-    setTimeout(() => {
-      this.getAllData();
-    }, 1000)
+    // 默认店铺
+    if(!wx.getStorageSync('shopInfo')){
+      wx.setStorageSync('shopInfo',{shopName:'瑞果商链-“星闪豹”',shopId:1})
+    }
+    if(wx.getStorageSync('loginResult').userId){
+      this.getUserInfo().then(()=>{
+        this.getAllData();
+      })
+    }else{
+      setTimeout(() => {
+        this.getAllData();
+      }, 1000)
+    }
   },
 
   handleTab(e){
@@ -395,6 +405,25 @@ Page({
     return result;
   },
 
+   /**
+   * 获取用户信息
+   */
+   getUserInfo: function() {
+    return new Promise((resolve,reject)=>{
+      var that = this;
+      var param = {
+        url: '/p/user/userInfo',
+        method: 'GET',
+        data: {},
+        callBack: (res) => {
+          res.channelId&&wx.setStorageSync('channelId',res.channelId)
+          resolve()
+        }
+      }
+      http.request(param)
+    })
+  },
+
   /**
    * 宫格分类
    */
@@ -405,7 +434,7 @@ Page({
       url: "/category/listCategoryForUser",
       method: "GET",
       data: {
-        shopId: shopId,
+        shopId: wx.getStorageSync('shopInfo').shopId,
         channelId:wx.getStorageSync('channelId')||3
       },
       callBack: function (res) {
@@ -785,6 +814,7 @@ Page({
   },
 
   onShow: function () {
+    
     // this.get_test()
     this.setData({
       select_address: wx.getStorageSync('ADDRESS')
@@ -813,7 +843,13 @@ Page({
    * 选择定位后更新列表
    */
   go_update() {
-    this.get_neighborShop()
+    // this.get_neighborShop()
+    this.setData({
+      current:1,
+      shop_id: wx.getStorageSync("shopInfo").shopId,
+      shopName:wx.getStorageSync("shopInfo").shopName
+    })
+    
     setTimeout(() => {
       this.getNewList();
       this.getSnapUpList();
@@ -822,11 +858,14 @@ Page({
   },
   getAllData() {
     this.setData({
-      current:1
+      current:1,
+      shop_id: wx.getStorageSync("shopInfo").shopId,
+      shopName:wx.getStorageSync("shopInfo").shopName
     })
     http.getCartCount(); //重新计算购物车总数量
     this.getIndexImgs();
-    this.get_neighborShop()
+    this.getClassInfo(this.data.shopId);
+    // this.get_neighborShop()
     // this.getNoticeList();
     this.getAbulk();
     this.getRecommended()

+ 5 - 2
pages/login/login.js

@@ -53,7 +53,7 @@ Page({
         },
         callBack: res => {
           http.loginSuccess(res,that.getUserInfo)
-          wx.switchTab({
+          wx.reLaunch({
             url: '/pages/index/index'
           })
         }
@@ -91,7 +91,10 @@ Page({
   },
 
   goback(){
-    wx.navigateBack()
+    wx.reLaunch({
+      url: '/pages/index/index',
+    })
+    // wx.navigateBack()
   },
   /**
    * 生命周期函数--监听页面加载

+ 1 - 0
pages/prod/prod.wxss

@@ -2123,6 +2123,7 @@ button.btn-type::after {
   font-weight: 800;
   font-size: 28rpx;
   color: #222222;
+  text-emphasis: emphasis;
 }
 .intro-box .more{
   position: absolute;

+ 1 - 1
pages/user/user.js

@@ -497,7 +497,7 @@ Page({
     wx.removeTabBarBadge({
       index: 1
     });
-    wx.navigateTo({
+    wx.reLaunch({
       url: "/pages/login/login"
     })
   }

+ 1 - 1
utils/config.js

@@ -4,7 +4,7 @@
 
 var domain = "https://shop.api.zswlgz.com"; //统一接口域名,测试环境 
 var wsDomain = "wss://shop-h5.dev.zswllife.cn/api"; //统一接口域名,测试环境 
-var domain = "http://47.109.84.152:8112"; //统一接口域名,正式环境 
+// var domain = "http://47.109.84.152:8112"; //统一接口域名,正式环境 
 // var domain = "https://5d2f568f.r36.cpolar.top"; //统一接口域名,正式环境 
 // var wsDomain = "wss://shop.haimamart.com/api"; //统一接口域名,正式环境