Przeglądaj źródła

分享,代理,登录的bug

hmp 4 lat temu
rodzic
commit
a6630f079e
3 zmienionych plików z 64 dodań i 14 usunięć
  1. 3 0
      App.vue
  2. 54 12
      components/homeViews/points-view.vue
  3. 7 2
      pages/index/guide.vue

+ 3 - 0
App.vue

@@ -8,6 +8,9 @@
 			// } else {
 			// 	this.externalBrowser(e);
 			// }
+			if (e.query.agenterId) {
+				uni.setStorageSync("agenterId",e.query.agenterId)
+			}
 			if (this.$isWxBrowser() && this.$u.test.isEmpty(e.query.isWxBrowse)) {
 				// uni.reLaunch({
 				// 	url: "/pages/index/guide"

+ 54 - 12
components/homeViews/points-view.vue

@@ -7,21 +7,21 @@
 					mode="aspectFill"></u-image>
 			</swiper-item>
 		</swiper>
-		<goods :goodsList="goodsList" :activityId="activityId"></goods>
-		<view style="height: 50rpx;">
-			
-		</view>
+		<meScroll  :up="up" :down="down" @up="upFn" :fixed="false" @down="downFn" @init="initMeScroll">
+			<goods :goodsList="goodsList" :activityId="activityId"></goods>
+		</meScroll>
 	</view>
 </template>
 
 <script>
+	import meScroll from "../mescroll-body/mescroll-uni.vue"
 	import goods from "@/components/goods/goods.vue"
 	import {
 		wx_launch
 	} from "../../common/utils/wx_launch.js"; // 引入公共js文件
 	export default {
 		components: {
-			goods
+			goods,meScroll
 		},
 		props: {
 			activityId: {
@@ -31,16 +31,40 @@
 		},
 		data() {
 			return {
+				status: 'loadmore',
+				current:1,
+				
 				goodsList: [],
 				adsList: [],
-				appletList: []
+				appletList: [],
+				
+				isInit: false, // 是否初始化
+				goodsList: [], // 列表数据
+				mescroll: null, // mescroll 对象
+				// 上拉配置参数
+				up: {
+					noMoreSize: 3, 
+					auto: true,
+					page: {
+						page: 0,
+						size: 10
+					}
+				},
+				// 下拉配置参数
+				down: {
+					use: false, 
+					auto: false
+				}
 			}
 		},
 		created() {
-			this.fetchGoodsList();
+			// this.fetchGoodsList();
 			this.fetchAds()
 		},
 		methods: {
+			initMeScroll(mescroll) {
+				this.mescroll = mescroll
+			},
 			async fetchAds() {
 				let res = await this.$u.api.pointsGoods.ads({
 					activityId: this.activityId
@@ -48,10 +72,12 @@
 				this.adsList = res.records;
 			},
 			fetchGoodsList() {
-				this.$u.api.pointsGoods.list({
-					activityId: this.activityId
-				}).then(res => {
-					this.goodsList = res.records;
+				let params={
+					activityId: this.activityId,
+					current:this.current
+				}
+				this.$u.api.pointsGoods.list(params).then(res => {
+					this.goodsList =[...this.goodsList,...res.records]
 				})
 			},
 			jump(item) {
@@ -62,7 +88,23 @@
 				uni.navigateTo({
 					url: '/pages/web-view/web-view?url=' + item.path
 				})
-			}
+			},
+			upFn(mescroll) {
+				let params={
+					activityId: this.activityId,
+					current:mescroll.num
+				}
+				try{
+					this.$u.api.pointsGoods.list(params).then(res => {
+						let data=res.records
+						mescroll.endBySize(data.length, res.total);
+						if(mescroll.num == 1) this.goodsList = []; //如果是第一页需手动制空列表
+						this.goodsList=this.goodsList.concat(data); //追加新数据
+					})
+				}catch(e){
+					mescroll.endErr();
+				}
+			},
 		}
 	}
 </script>

+ 7 - 2
pages/index/guide.vue

@@ -62,9 +62,14 @@
 				}
 			},
 			fetchPoster(){
+				// let link = window.location.href;
+				let link = 'https://music.nanyue6688.com/vote-h5/#/pages/index/guide'
+				let userId= uni.getStorageSync("userId")
+				if (!this.$u.test.isEmpty(userId)) {
+					link = link + "?agenterId=" + userId
+				}
 				this.$u.api.activity.getList({enable:1}).then(res=>{
 					this.src=res.records[0].poster;
-					let link = window.location.href;
 					let obj = {
 						link: link,
 						title: res.records[0].shareTitle,
@@ -91,6 +96,7 @@
 					}
 					if (!this.$u.test.isEmpty(agenterId)) {
 						datas.agenterId=agenterId
+						// uni.removeStorageSync("agenterId")
 					}
 					let result = await this.$u.api.user.login(datas);
 					if (result) {
@@ -98,7 +104,6 @@
 						uni.setStorageSync("userId", result.id);
 						let url = window.location.href;
 						url = url + "&userId=" +  this.userId;
-						console.log(url);
 						window.location.href = url;
 						// window.location.href = 'https://music.nanyue6688.comm/vote-h5/index.html#/pages/index/guide?userId=' + this.userId + '&openId=' + res.openid;
 					}