qinyan 1 year ago
parent
commit
c8810f323f

+ 6 - 26
src/pages.json

@@ -21,20 +21,6 @@
         "navigationBarTitleText": "详情"
       }
     },
-    {
-      "path": "pages/tag/tag",
-      "style": {
-        "navigationBarTitleText": "分类",
-        "enablePullDownRefresh": false
-      }
-    },
-    {
-      "path": "pages/list/list",
-      "style": {
-        "navigationBarTitleText": "专题",
-        "enablePullDownRefresh": true
-      }
-    },
     {
       "path": "pages/center/center",
       "style": {
@@ -77,18 +63,12 @@
         "selectedIconPath": "static/index-1.png",
         "text": "推广"
       },
-      // {
-      //   "pagePath": "pages/hot/hot",
-      //   "iconPath": "static/hot-0.png",
-      //   "selectedIconPath": "static/hot-1.png",
-      //   "text": "发现"
-      // },
-      // {
-      //   "pagePath": "pages/tag/tag",
-      //   "iconPath": "static/tag-0.png",
-      //   "selectedIconPath": "static/tag-1.png",
-      //   "text": "分类"
-      // },
+      {
+        "pagePath": "pages/hot/hot",
+        "iconPath": "static/hot-0.png",
+        "selectedIconPath": "static/hot-1.png",
+        "text": "发现"
+      },
       {
         "pagePath": "pages/center/center",
         "iconPath": "static/center-0.png",

+ 1 - 5
src/pages/about/about.vue

@@ -16,13 +16,9 @@ export default {
 </script>
 
 <style>
-page,
-view {
-  display: block;
-  text-align: center;
-}
 page {
   min-height: 100%;
+  text-align: center;
   background-color: #ffffff;
 }
 .about {

+ 19 - 3
src/pages/detail/detail.vue

@@ -1,28 +1,39 @@
 <template>
   <view class="index">
-    <web-view :src="url"></web-view>
+    <web-view :src="url" class="main"></web-view>
   </view>
 </template>
 
 <script>
+import { getDesignDetail } from "../../services/https/promotion";
+
 export default {
   data() {
     return {
+      id: "",
       url: "",
     };
   },
   onLoad(e) {
+    this.id = e.id;
     this.url = `https://show.3dqueen.cloud/share.html?id=${e.id}`;
+    // this.url = `https://www.baidu.com`;
+    this.getData();
   },
   onShareAppMessage() {
     return {
-      title: "欢迎使用uni-app看图模板",
+      title: "",
       path: "/pages/detail/detail?data=" + this.detailDec,
       imageUrl: this.data[this.index],
     };
   },
 
-  methods: {},
+  methods: {
+    async getData() {
+      const res = await getDesignDetail(this.id);
+      console.log("data: ", res);
+    },
+  },
 };
 </script>
 
@@ -31,4 +42,9 @@ page {
   background-color: #fff;
   height: 100%;
 }
+.main {
+  height: 100%;
+  width: 750rpx;
+  overflow: hidden;
+}
 </style>

+ 18 - 161
src/pages/hot/hot.vue

@@ -1,169 +1,26 @@
 <template>
-	<view class="index">
-		<view class="grid">
-			<view class="grid-c-06" v-for="item in lists" :key="item.guid">
-				<view class="panel" @click="goDetail(item)">
-					<image class="card-img card-list2-img" :src="item.img_src"></image>
-					<text class="card-num-view card-list2-num-view">{{item.img_num}}P</text>
-					<view class="card-bottm row">
-						<view class="car-title-view row">
-							<text class="card-title card-list2-title">{{item.title}}</text>
-						</view>
-						<view @click.stop="share(item)" class="card-share-view"></view>
-					</view>
-				</view>
-			</view>
-		</view>
-		<text class="loadMore">加载中...</text>
-	</view>
+  <view class="index">
+    <view class="main">
+      <text class="loadMore">开发中...</text>
+    </view>
+  </view>
 </template>
 
 <script>
-	export default {
-		data() {
-			return {
-				refreshing: false,
-				lists: [],
-				fetchPageNum: 1
-			}
-		},
-		onLoad() {
-			this.getData();
-			uni.getProvider({
-				service: 'share',
-				success: (e) => {
-					let data = [];
-					for (let i = 0; i < e.provider.length; i++) {
-						switch (e.provider[i]) {
-							case 'weixin':
-								data.push({
-									name: '分享到微信好友',
-									id: 'weixin'
-								});
-								data.push({
-									name: '分享到微信朋友圈',
-									id: 'weixin',
-									type: 'WXSenceTimeline'
-								});
-								break;
-							case 'qq':
-								data.push({
-									name: '分享到QQ',
-									id: 'qq'
-								});
-								break;
-							default:
-								break;
-						}
-					}
-					this.providerList = data;
-				},
-				fail: (e) => {
-					console.log('获取登录通道失败', e);
-				}
-			});
-		},
-		onPullDownRefresh() {
-			console.log('下拉刷新');
-			this.refreshing = true;
-			this.getData();
-		},
-		onReachBottom() {
-			this.getData();
-		},
-		methods: {
-			getData() {
-				uni.request({
-					url: this.$serverUrl + '/api/picture/posts.php?page=' + (this.refreshing ? 1 : this.fetchPageNum) +
-						'&per_page=10',
-					success: (ret) => {
-						console.log(ret)
-						if (ret.statusCode !== 200) {
-							console.log('请求失败:', ret)
-						} else {
-							if (this.refreshing && ret.data[0].id === this.lists[0].id) {
-								uni.showToast({
-									title: '已经最新',
-									icon: 'none',
-								});
-								this.refreshing = false;
-								uni.stopPullDownRefresh();
-								return;
-							}
-							let list = [],
-								data = ret.data;
-							for (let i = 0, length = data.length; i < length; i++) {
-								var item = data[i];
-								item.guid = this.newGuid() + item.id
-								list.push(item);
-							}
-							console.log('得到list', list);
-							if (this.refreshing) {
-								this.refreshing = false;
-								uni.stopPullDownRefresh()
-								this.lists = list;
-								this.fetchPageNum = 2;
-							} else {
-								this.lists = this.lists.concat(list);
-								this.fetchPageNum += 1;
-							}
-						}
-					}
-				});
-			},
-			newGuid() {
-				let s4 = function() {
-					return (65536 * (1 + Math.random()) | 0).toString(16).substring(1);
-				}
-				return (s4() + s4() + "-" + s4() + "-4" + s4().substr(0, 3) + "-" + s4() + "-" + s4() + s4() + s4()).toUpperCase();
-			},
-			goDetail(e) {
-				uni.navigateTo({
-					url: '../detail/detail?data=' + encodeURIComponent(JSON.stringify(e))
-				})
-			},
-			share(e) {
-				if (this.providerList.length === 0) {
-					uni.showModal({
-						title: '当前环境无分享渠道!',
-						showCancel: false
-					})
-					return;
-				}
-				let itemList = this.providerList.map(function(value) {
-					return value.name
-				})
-				uni.showActionSheet({
-					itemList: itemList,
-					success: (res) => {
-						uni.share({
-							provider: this.providerList[res.tapIndex].id,
-							scene: this.providerList[res.tapIndex].type && this.providerList[res.tapIndex].type === 'WXSenceTimeline' ?
-								'WXSenceTimeline' : 'WXSceneSession',
-							type: 0,
-							title: 'uni-app模版',
-							summary: e.title,
-							imageUrl: e.img_src,
-							href: 'https://uniapp.dcloud.io',
-							success: (res) => {
-								console.log('success:' + JSON.stringify(res));
-							},
-							fail: (e) => {
-								uni.showModal({
-									content: e.errMsg,
-									showCancel: false
-								})
-							}
-						});
-					}
-				})
-			}
-		}
-	}
+export default {
+  data() {
+    return {};
+  },
+  onLoad() {},
+  onPullDownRefresh() {},
+  onReachBottom() {},
+  methods: {},
+};
 </script>
 
 <style>
-	.grid{
-		padding-top: 10px;
-	}
+.main {
+  margin-top: 50rpx;
+  text-align: center;
+}
 </style>

+ 66 - 38
src/pages/index/index.vue

@@ -1,69 +1,85 @@
 <template>
   <view class="index">
-    <block v-for="item in list" :key="item._id">
-      <view class="card" @click="goDetail(item)">
-        <image class="card-img" :src="item.thumbnail" mode="aspectFill"></image>
-        <text class="card-num-view">{{ item.views }} 次浏览</text>
-        <view class="card-bottm row">
-          <view class="car-title-view row">
-            <text class="card-title">{{ item.title }}</text>
+    <view v-if="login">
+      <block v-for="item in list" :key="item._id">
+        <view class="card" @click="goDetail(item)">
+          <image
+            class="card-img"
+            :src="item.thumbnail"
+            mode="aspectFill"
+          ></image>
+          <text class="card-num-view">{{ item.views }} 次浏览</text>
+          <view class="card-bottm row">
+            <view class="car-title-view row">
+              <text class="card-title">{{ item.title }}</text>
+            </view>
           </view>
         </view>
+      </block>
+      <view class="loadMore">
+        <text>{{ hasMore ? "加载中..." : "没有更多了" }}</text>
       </view>
-    </block>
-    <view class="loadMore">
-      <text>加载中...</text>
+    </view>
+    <view v-else class="auth_card">
+      <text>还未登录, </text>
+      <navigator class="text" url="/pages/login/index">去登录</navigator>
     </view>
   </view>
 </template>
 
 <script>
+import { getDesignList } from "../../services/https/promotion";
 export default {
   data() {
     return {
+      login: false,
+      hasMore: true,
       refreshing: false,
       list: [],
       fetchPageNum: 1,
     };
   },
   onLoad() {
-    this.getData();
+    const token = uni.getStorageSync("access-token");
+    if (token) {
+      this.login = true;
+      this.getData();
+    }
   },
   onReachBottom() {
-    console.log("滑动到页面底部");
+    // console.log("滑动到页面底部");
+    if (!this.hasMore) return;
     this.getData();
   },
   onPullDownRefresh() {
-    console.log("下拉刷新");
+    // console.log("下拉刷新");
     this.refreshing = true;
+    this.fetchPageNum = 1;
     this.getData();
   },
   methods: {
-    getData() {
-      uni.request({
-        url:
-          this.$serverUrl + "/h5/list?page=" + this.fetchPageNum + "&size=10",
-        header: {
-          Authorization: "Bearer " + uni.getStorageSync("access-token"),
-        },
-        success: (ret) => {
-          //   console.log("data", ret.data);
-          if (ret.statusCode !== 200 || ret.data.errorNo !== 200) {
-            console.log("失败!");
-          } else {
-            const list = ret.data.result.list;
-            if (this.refreshing) {
-              this.refreshing = false;
-              uni.stopPullDownRefresh();
-              this.list = list;
-              this.fetchPageNum = 2;
-            } else {
-              this.list = this.list.concat(list);
-              this.fetchPageNum += 1;
-            }
-          }
-        },
+    async getData() {
+      const data = await getDesignList({
+        page: this.fetchPageNum,
+        size: 5,
       });
+
+      if (data.errorNo === 401) {
+        uni.clearStorageSync("access-token");
+        this.login = false;
+        return;
+      }
+      const result = data.result;
+      this.hasMore = result.total > result.size * result.page;
+      if (this.refreshing) {
+        this.refreshing = false;
+        uni.stopPullDownRefresh();
+        this.list = result.list;
+        this.fetchPageNum = 2;
+      } else {
+        this.list = this.list.concat(result.list);
+        this.fetchPageNum += 1;
+      }
     },
     goDetail(data) {
       uni.navigateTo({
@@ -140,7 +156,7 @@ export default {
   text-align: left;
   color: #555555;
   text-overflow: ellipsis;
-  lines: 2;
+  /* lines: 2; */
   display: -webkit-box;
   white-space: normal;
   display: -webkit-box;
@@ -148,4 +164,16 @@ export default {
   -webkit-line-clamp: 2;
   overflow: hidden;
 }
+.auth_card {
+  height: 100vh;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  font-size: 30rpx;
+  color: #666;
+}
+.text {
+  color: #41969c;
+  text-decoration: underline;
+}
 </style>

+ 0 - 189
src/pages/list/list.vue

@@ -1,189 +0,0 @@
-<template>
-	<view class="grid">
-		<view class="grid-c-06" v-for="item in dataList" :key="item.guid">
-			<view class="panel" @click="goDetail(item)">
-				<image class="card-img card-list2-img" :src="item.img_src"></image>
-				<text class="card-num-view card-list2-num-view">{{item.img_num}}P</text>
-				<view class="card-bottm row">
-					<view class="car-title-view row">
-						<text class="card-title card-list2-title">{{item.title}}</text>
-					</view>
-					<view @click.stop="share(item)" class="card-share-view"></view>
-				</view>
-			</view>
-		</view>
-		<view class="grid-c-12">
-			<text class="loadMore">{{loadMoreText}}</text>
-		</view>
-	</view>
-</template>
-
-<script>
-	export default {
-		data() {
-			return {
-				refreshing: false,
-				loadMoreText: '加载中...',
-				dataList: [],
-				id: 0,
-				fetchPageNum: 0
-			}
-		},
-		onLoad(e) {
-			uni.setNavigationBarTitle({
-				title: '专题:' + e.type
-			});
-			this.id = e.id;
-			// 防止app里由于渲染导致转场动画卡顿
-			setTimeout(() => {
-				this.getData();
-			}, 300);
-			uni.getProvider({
-				service: 'share',
-				success: (e) => {
-					let data = [];
-					for (let i = 0; i < e.provider.length; i++) {
-						switch (e.provider[i]) {
-							case 'weixin':
-								data.push({
-									name: '分享到微信好友',
-									id: 'weixin'
-								});
-								data.push({
-									name: '分享到微信朋友圈',
-									id: 'weixin',
-									type: 'WXSenceTimeline'
-								});
-								break;
-							case 'qq':
-								data.push({
-									name: '分享到QQ',
-									id: 'qq'
-								});
-								break;
-							default:
-								break;
-						}
-					}
-					this.providerList = data;
-				},
-				fail: (e) => {
-					console.log('获取分享通道失败', e);
-				}
-			});
-		},
-		onPullDownRefresh() {
-			console.log('下拉刷新');
-			this.refreshing = true;
-			this.getData();
-		},
-		onReachBottom() {
-			console.log('上拉加载刷新');
-			if (this.fetchPageNum > 4) {
-				this.loadMoreText = '没有更多了'
-				return;
-			}
-			this.getData();
-		},
-		methods: {
-			getData(e) {
-				uni.request({
-					url: this.$serverUrl + '/api/picture/list.php?type=' + this.id,
-					success: (ret) => {
-						if (ret.statusCode !== 200) {
-							console.log('请求失败', ret)
-							return;
-						}
-
-						const data = ret.data.data;
-
-						if (this.refreshing && data[0].id === this.dataList[0].id) {
-							uni.showToast({
-								title: '已经最新',
-								icon: 'none',
-							});
-							this.refreshing = false;
-							uni.stopPullDownRefresh();
-							return;
-						}
-
-						let list = [];
-						for (var i = 0; i < data.length; i++) {
-							var item = data[i];
-							item.guid = this.newGuid() + item.id
-							list.push(item);
-						}
-
-						if (this.refreshing) {
-							this.refreshing = false;
-							uni.stopPullDownRefresh();
-							this.dataList = list;
-							this.fetchPageNum = 2;
-						} else {
-							this.dataList = this.dataList.concat(list);
-							this.fetchPageNum += 1;
-						}
-						this.fetchPageNum += 1;
-					}
-				});
-			},
-			newGuid() {
-				let s4 = function() {
-					return (65536 * (1 + Math.random()) | 0).toString(16).substring(1);
-				}
-				return (s4() + s4() + "-" + s4() + "-4" + s4().substr(0, 3) + "-" + s4() + "-" + s4() + s4() + s4()).toUpperCase();
-			},
-			goDetail(e) {
-				uni.navigateTo({
-					url: '/pages/detail/detail?data=' + encodeURIComponent(JSON.stringify(e))
-				});
-			},
-			share(e) {
-				if (this.providerList.length === 0) {
-					uni.showModal({
-						title: '当前环境无分享渠道!',
-						showCancel: false
-					});
-					return;
-				}
-				let itemList = this.providerList.map(function(value) {
-					return value.name;
-				});
-				uni.showActionSheet({
-					itemList: itemList,
-					success: (res) => {
-						uni.share({
-							provider: this.providerList[res.tapIndex].id,
-							scene: this.providerList[res.tapIndex].type && this.providerList[res.tapIndex].type === 'WXSenceTimeline' ?
-								'WXSenceTimeline' : 'WXSceneSession',
-							type: 0,
-							title: 'uni-app模版',
-							summary: e.title,
-							imageUrl: e.img_src,
-							href: 'https://uniapp.dcloud.io',
-							success: (res) => {
-								console.log('success:' + JSON.stringify(res));
-							},
-							fail: (e) => {
-								uni.showModal({
-									content: e.errMsg,
-									showCancel: false
-								});
-							}
-						});
-					}
-				});
-			}
-		}
-	}
-</script>
-
-<style scoped>
-	.grid {
-		padding-top: 10px;
-	}
-
-	.grid-c-12 {
-		justify-content: center;
-	}
-</style>

+ 0 - 81
src/pages/tag/tag.vue

@@ -1,81 +0,0 @@
-<template>
-	<view class="index">
-		<view class="tags">
-			<block v-for="value in data" :key="value.key">
-				<view class="tag" @tap="goList(value)">
-					<image class="tag-img" :src="value.icon"></image>
-					<text class="tag-text">{{value.type}}</text>
-				</view>
-			</block>
-		</view>
-	</view>
-</template>
-
-<script>
-	export default {
-		data() {
-			return {
-				data: [{
-						type: '动物',
-						id: 1,
-						key: 1,
-						icon: 'http://placehold.it/150x150'
-					},
-					{
-						type: '风景',
-						id: 2,
-						key: 2,
-						icon: 'http://placehold.it/150x150'
-					},
-					{
-						type: '建筑',
-						id: 3,
-						key: 3,
-						icon: 'http://placehold.it/150x150'
-					},
-					{
-						type: '美女',
-						id: 4,
-						key: 4,
-						icon: 'http://placehold.it/150x150'
-					},
-					{
-						type: '汽车',
-						id: 5,
-						key: 5,
-						icon: 'http://placehold.it/150x150'
-					},
-					{
-						type: '运动',
-						id: 6,
-						key: 6,
-						icon: 'http://placehold.it/150x150'
-					},
-					{
-						type: '动物',
-						id: 1,
-						key: 7,
-						icon: 'http://placehold.it/150x150'
-					},
-					{
-						type: '风景',
-						id: 2,
-						key: 8,
-						icon: 'http://placehold.it/150x150'
-					}
-				]
-			}
-		},
-		methods: {
-			goList(value) {
-				uni.navigateTo({
-					url: '../list/list?type=' + value.type + '&id=' + value.id
-				})
-			}
-		}
-	}
-</script>
-
-<style>
-
-</style>

+ 12 - 3
src/services/https/promotion.js

@@ -1,8 +1,17 @@
+import { Dict_Apis } from "../../dict/apis";
 import request from "../request";
 
-export function login(data) {
-  return request("/wechat/mini/login", {
-    method: "POST",
+export function getDesignList(data) {
+  return request("/h5/list", {
+    baseURL: Dict_Apis.promotion,
+    method: "GET",
     data,
   });
 }
+
+export function getDesignDetail(id) {
+  return request("/h5/detail/" + id, {
+    baseURL: Dict_Apis.promotion,
+    method: "GET",
+  });
+}

+ 4 - 0
src/services/request.js

@@ -7,6 +7,7 @@ export default function (url, options = {}) {
     if (options.method && options.method !== "GET")
       uni.showLoading({ title: "加载中" });
 
+    console.log("options: ", options);
     uni.request({
       ...options,
       url: (options.baseURL ? options.baseURL : baseURL) + url,
@@ -17,6 +18,9 @@ export default function (url, options = {}) {
         uni.hideLoading();
         if (res.statusCode === 200) {
           let data = res.data;
+          if (data.errorNo === 401) {
+            uni.clearStorageSync("access-token");
+          }
           resolve(data);
         } else {
           resolve({

BIN
src/static/center-0.png


BIN
src/static/center-1.png


BIN
src/static/hot-0.png


BIN
src/static/hot-1.png


BIN
src/static/index-0.png


BIN
src/static/index-1.png


BIN
src/static/tag-0.png


BIN
src/static/tag-1.png