Selaa lähdekoodia

归藏代码更新

wangfumin 1 kuukausi sitten
vanhempi
commit
28a05c7b99

+ 84 - 58
pages/guicang/index.js

@@ -1,4 +1,6 @@
 // index.js
+const { request, cosBaseUrl } = require('../../utils/newServices');
+
 Page({
   data: {
     // 轮播图配置
@@ -9,36 +11,7 @@ Page({
     circular: true,
     
     // 轮播图数据
-    swiperList: [
-      {
-        id: 1,
-        imageUrl: '../../imgs/guicang/haiwaiwenwu.png',
-        title: '唐代三彩骆驼骑俑',
-        date: '2023-06-30',
-        source: '珍藏馆'
-      },
-      {
-        id: 2,
-        imageUrl: '../../imgs/guicang/haiwaiwenwu.png',
-        title: '明代青花瓷器',
-        date: '2023-06-29',
-        source: '国家博物馆'
-      },
-      {
-        id: 3,
-        imageUrl: '../../imgs/guicang/haiwaiwenwu.png',
-        title: '清代玉器',
-        date: '2023-06-28',
-        source: '故宫博物院'
-      },
-      {
-        id: 4,
-        imageUrl: '../../imgs/guicang/haiwaiwenwu.png',
-        title: '宋代瓷器',
-        date: '2023-06-27',
-        source: '上海博物馆'
-      }
-    ],
+    swiperList: [],
     
     // 最新上传数据
     latestUploads: [],
@@ -51,43 +24,96 @@ Page({
   },
   
   onLoad: function(options) {
+    // 加载轮播图数据
+    this.loadSwiperData();
     // 初始化最新上传数据
     this.loadLatestUploads();
   },
+
+  // 加载轮播图数据
+  loadSwiperData: function() {
+    const params = {
+      orderBy: 'pv',
+      sortBy: 'DESC',
+      pageNo: 1,
+      pageSize: 1
+    };
+
+    request.getAntiqueList(
+      params,
+      'GET',
+      (res) => {
+        console.log('轮播图数据加载成功:', res.data.data.pageData);
+        if (res.data && res.data.data && res.data.data.pageData) {
+          const swiperData = res.data.data.pageData.map(item => ({
+            id: item.id,
+            imageUrl: cosBaseUrl + item.coverImgUrl,
+            title: item.name,
+            date: item.createTime ? item.createTime.split(' ')[0] : '',
+            source: item.source || '归藏'
+          }));
+          this.setData({
+            swiperList: swiperData
+          });
+        }
+      },
+      (err) => {
+        console.error('轮播图数据加载失败:', err);
+        // 加载失败时使用默认数据
+        this.setData({
+          swiperList: []
+        });
+      }
+    );
+  },
   
   // 加载最新上传数据
   loadLatestUploads: function() {
-    if (!this.data.hasMoreData) return;
+    if (!this.data.hasMoreData || this.data.loading) return;
     
     this.setData({ loading: true });
     
-    // 模拟数据加载
-    setTimeout(() => {
-      const newItems = this.getMockData(this.data.currentPage, this.data.pageSize);
-      const hasMore = this.data.currentPage < 3; // 模拟只有3页数据
-      
-      this.setData({
-        latestUploads: [...this.data.latestUploads, ...newItems],
-        currentPage: this.data.currentPage + 1,
-        hasMoreData: hasMore,
-        loading: false
-      });
-    }, 1000);
-  },
-  
-  // 生成模拟数据
-  getMockData: function(page, pageSize) {
-    const result = [];
-    const startIndex = (page - 1) * pageSize;
-    
-    for (let i = 0; i < pageSize; i++) {
-      result.push({
-        id: startIndex + i + 1,
-        imageUrl: '../../imgs/guicang/haiwaiwenwu.png'
-      });
-    }
-    
-    return result;
+    const params = {
+      pageNo: this.data.currentPage,
+      pageSize: 20
+    };
+
+    request.getAntiqueList(
+      params,
+      'GET',
+      (res) => {
+        console.log('最新上传数据加载成功:', res);
+        if (res.data && res.data.data && res.data.data.pageData) {
+          const newItems = res.data.data.pageData.map(item => ({
+            id: item.id,
+            imageUrl: cosBaseUrl + item.coverImgUrl,
+            title: item.name,
+            date: item.createTime ? item.createTime.split(' ')[0] : '',
+            source: item.source || '归藏'
+          }));
+          
+          const hasMore = res.data.data.pageData.length === 20; // 如果返回数据等于pageSize,说明可能还有更多数据
+          
+          this.setData({
+            latestUploads: [...this.data.latestUploads, ...newItems],
+            currentPage: this.data.currentPage + 1,
+            hasMoreData: hasMore,
+            loading: false
+          });
+        } else {
+          this.setData({
+            hasMoreData: false,
+            loading: false
+          });
+        }
+      },
+      (err) => {
+        console.error('最新上传数据加载失败:', err);
+        this.setData({
+          loading: false
+        });
+      }
+    );
   },
   
   // 跳转到详情页

+ 1 - 1
pages/guicang/index.wxml

@@ -6,7 +6,7 @@
       <swiper-item wx:for="{{swiperList}}" wx:key="index">
         <view class="swiper-item">
           <image src="{{item.imageUrl}}" mode="aspectFill" class="slide-image" bindtap="goToDetail" data-id="{{item.id}}"></image>
-          <view class="swiper-info" style="background: url('../../imgs/guicang/heritage_bg.png')">
+          <view class="swiper-info">
             <view class="swiper-title">{{item.title}}</view>
             <view class="swiper-date">{{item.date}} · {{item.source}}</view>
           </view>

+ 6 - 2
pages/guicang/index.wxss

@@ -27,6 +27,7 @@
 .swiper-item {
   width: 100%;
   height: 100%;
+  background: linear-gradient(to bottom, #000 0%, #040404 25%, #262626 50%, #343434 75%, #3D3D3D 100%);
   position: relative;
   border-bottom-left-radius: 20rpx;
   border-bottom-right-radius: 20rpx;
@@ -35,12 +36,13 @@
 
 .slide-image {
   width: 100%;
-  height: 100%;
+  height: 74%;
   border-bottom-left-radius: 20rpx;
   border-bottom-right-radius: 20rpx;
 }
 
 .swiper-info {
+  background: url('https://swkz-1332577016.cos.ap-guangzhou.myqcloud.com/swkzGuicang/heritage_bg.png') no-repeat;
   position: absolute;
   bottom: 0;
   left: 0;
@@ -79,7 +81,8 @@
 .upload-grid {
   display: flex;
   flex-wrap: wrap;
-  justify-content: space-between;
+  justify-content: flex-start;
+  gap: 20rpx;
 }
 
 .upload-item {
@@ -88,6 +91,7 @@
   margin-bottom: 20rpx;
   border-radius: 10rpx;
   overflow: hidden;
+  background: linear-gradient(to bottom, #000 0%, #040404 25%, #262626 50%, #343434 75%, #3D3D3D 100%);
 }
 
 .upload-image {

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 42 - 16
pages/guicangDetails/index.js


+ 1 - 1
pages/guicangDetails/index.wxml

@@ -26,7 +26,7 @@
   </view>
   
   <!-- 可上拉的信息区域 -->
-  <view class="info-box {{isFullScreen ? 'full-screen' : ''}}" style="top: {{ boxTop }}px;" 
+  <view class="info-box {{isFullScreen ? 'full-screen' : ''}}" style="top: {{boxTop}}px;" 
         bindtouchstart="touchStart" bindtouchmove="touchMove" bindtouchend="touchEnd">
     <!-- 上拉指示器 -->
     <view class="drag-indicator"></view>

+ 8 - 3
pages/guicangDetails/index.wxss

@@ -1,7 +1,8 @@
 /* pages/guicangDetails/index.wxss */
 .container {
   padding: 0;
-  background-color: #000;
+  background: url('https://swkz-1332577016.cos.ap-guangzhou.myqcloud.com/swkzGuicang/bg.png') no-repeat 100% 180%;
+  background-size: cover;
   color: #fff;
   min-height: 100vh;
   position: relative;
@@ -84,8 +85,11 @@
 /* 图片区域 */
 .image-container {
   width: 100%;
-  height: 100vh;
-  position: relative;
+  height: 50%;
+  position: absolute;
+  top: 45%;
+  transform: translateY(-50%);
+  background-size: cover;
 }
 
 .main-image {
@@ -327,6 +331,7 @@
 .top-image{
   width: 100%;
   height: 378rpx;
+  background: linear-gradient(to bottom, #000 0%, #040404 25%, #262626 50%, #343434 75%, #3D3D3D 100%);
 }
 .wenwubg{
   width: 100%;

+ 5 - 4
pages/guicangDetails/shareJson.js

@@ -1,7 +1,7 @@
 const getwxml = ( qrcodeUrl, name = '这是一件文物', wenwuUrl ) => {
   const wxml = `<view class="container">
       <view class="top-image">
-        <image class="wenwubg" src="https://swkz-1332577016.cos.ap-guangzhou.myqcloud.com/swkzGuicang/test.png"></image>
+        <image class="wenwubg" src="${wenwuUrl}"></image>
       </view>
       <view class="item-box">
         <image class="btmbg" src="https://swkz-1332577016.cos.ap-guangzhou.myqcloud.com/swkzGuicang/img_share_bg.png"></image>
@@ -23,15 +23,16 @@ const style = {
     width: 360,
     height: 256,
     flexDirection: 'column',
-    backgroundColor: '#ccc',
+    backgroundColor: '#262626',
     alignItems: 'center',
+    justifyContent: 'center',
   },
   topImage: {
-    width: 360,
+    width: 280,
     height: 190,
   },
   wenwubg: {
-    width: 360,
+    width: 280,
     height: 190,
   },
   itemBox: {

+ 218 - 0
utils/newServices.js

@@ -0,0 +1,218 @@
+const {
+  Toast
+} = require('./util');
+
+// 新的API服务域名
+const serverName = 'https://test.4dmuseum.cn/api';
+const fileBaseURL = 'https://test.4dmuseum.cn/swkzModel/index.html';
+const cosBaseUrl = 'https://swkz-1332577016.cos.ap-guangzhou.myqcloud.com/'
+
+const urls = {
+  // 归藏轮播图接口
+  getAntiqueList: '/wx/antique/page',
+  // 归藏详情接口
+  getAntiqueDetail: '/wx/antique'
+};
+
+const requestFns = {};
+
+Object.keys(urls).forEach(function(key) {
+  requestFns[key] = function(
+    data = {},
+    method = "GET",
+    success = () => {},
+    fail = () => {},
+    complete = () => {}
+  ) {
+    console.log(`request ${urls[key]}`);
+    let commonData = {
+      loginSessionKey: wx.getStorageSync('token') || ""
+    };
+
+    const url = `${serverName}${urls[key]}`;
+    return wx.request({
+      method: method || 'GET',
+      url,
+      data: {
+        ...data,
+        ...commonData
+      },
+      header: {
+        'content-type': 'application/x-www-form-urlencoded'
+      },
+      success: function(res) {
+        if (res.data.code == 0) {
+          console.log(`request ${urls[key]}, success:`, res);
+          success(res);
+        } else if (res.data.code == 102) {
+          // 未登录
+          wx.showModal({
+            title: '提示',
+            content: '登录才能进行以上操作,确定登录吗?',
+            confirmColor: '#e83828',
+            success: function (res) {
+              if (res.confirm) {
+                wx.navigateTo({
+                  url: '/pages/login_page/index',
+                  success: function (res) { },
+                  fail: function (res) { },
+                  complete: function (res) { },
+                })
+              } else if (res.cancel) {
+                console.log('用户点击取消')
+              }
+            }
+          })
+          fail(res);
+        } else if (res.data.code == 11) {
+          Toast.showToast('warn', '提交信息不完整');
+          fail(res);
+        } else if (res.data.code == 101) {
+          Toast.showToast('warn', '网络超时,请重新登录');
+          fail(res);
+        } else if (res.data.code == -1) {
+          Toast.showToast('warn', '请求发送失败');
+          fail(res);
+        } else {
+          Toast.showToast('warn', res.data.msg || '网络超时,请检查网络');
+          fail(res);
+        }
+      },
+      fail: function(res) {
+        fail(res);
+      },
+      complete: function() {
+        complete()
+      }
+    });
+  };
+});
+
+const request = {
+  getAntiqueList: function(data, method, success, fail) {
+    wx.request({
+      url: serverName + urls.getAntiqueList,
+      data: data,
+      method: method,
+      header: {
+        'content-type': 'application/json'
+      },
+      success: function(res) {
+        if (res.statusCode === 200) {
+          if (res.data.code === 0) {
+            success(res);
+          } else if (res.data.code === 401) {
+            // 未登录
+            wx.showToast({
+              title: '请先登录',
+              icon: 'none'
+            });
+            fail(res);
+          } else if (res.data.code === 400) {
+            // 提交信息不完整
+            wx.showToast({
+              title: res.data.msg || '提交信息不完整',
+              icon: 'none'
+            });
+            fail(res);
+          } else {
+            // 其他错误
+            wx.showToast({
+              title: res.data.msg || '请求失败',
+              icon: 'none'
+            });
+            fail(res);
+          }
+        } else {
+          // 网络错误
+          wx.showToast({
+            title: '网络错误',
+            icon: 'none'
+          });
+          fail(res);
+        }
+      },
+      fail: function(err) {
+        // 请求失败
+        wx.showToast({
+          title: '请求失败',
+          icon: 'none'
+        });
+        fail(err);
+      }
+    });
+  },
+  
+  getAntiqueDetail: function(data, method, success, fail) {
+    // 从页面参数中获取id
+    const pages = getCurrentPages();
+    const currentPage = pages[pages.length - 1];
+    const id = currentPage.data.id;
+    
+    if (!id) {
+      wx.showToast({
+        title: '缺少文物ID',
+        icon: 'none'
+      });
+      fail({ msg: '缺少文物ID' });
+      return;
+    }
+    
+    wx.request({
+      url: serverName + urls.getAntiqueDetail + '/' + id,
+      data: data,
+      method: method,
+      header: {
+        'content-type': 'application/json'
+      },
+      success: function(res) {
+        if (res.statusCode === 200) {
+          if (res.data.code === 0) {
+            success(res);
+          } else if (res.data.code === 401) {
+            // 未登录
+            wx.showToast({
+              title: '请先登录',
+              icon: 'none'
+            });
+            fail(res);
+          } else if (res.data.code === 400) {
+            // 提交信息不完整
+            wx.showToast({
+              title: res.data.msg || '提交信息不完整',
+              icon: 'none'
+            });
+            fail(res);
+          } else {
+            // 其他错误
+            wx.showToast({
+              title: res.data.msg || '请求失败',
+              icon: 'none'
+            });
+            fail(res);
+          }
+        } else {
+          // 网络错误
+          wx.showToast({
+            title: '网络错误',
+            icon: 'none'
+          });
+          fail(res);
+        }
+      },
+      fail: function(err) {
+        // 请求失败
+        wx.showToast({
+          title: '请求失败',
+          icon: 'none'
+        });
+        fail(err);
+      }
+    });
+  }
+};
+
+module.exports.request = request;
+module.exports.serverName = serverName;
+module.exports.cosBaseUrl = cosBaseUrl;
+module.exports.fileBaseURL = fileBaseURL;

+ 4 - 1
utils/services.js

@@ -70,7 +70,10 @@ const urls = {
   recommend: '/wx/api/exhibition/recommend',
 
   //线下展讯热门推荐
-  offlineRecommend: '/wx/api/exhibition/offlineRecommend'
+  offlineRecommend: '/wx/api/exhibition/offlineRecommend',
+
+  // 归藏的接口
+  getGuicangBanner: 'api/wechat/antique/page',
 };
 // 上传路径
 const uploadUrls = {};