Преглед на файлове

update 滚动调整与 git忽略

wangxy преди 11 месеца
родител
ревизия
94ab13b524
променени са 2 файла, в които са добавени 62 реда и са изтрити 48 реда
  1. 7 0
      .gitignore
  2. 55 48
      components/mta-scroll-list/mta-scroll-list.vue

+ 7 - 0
.gitignore

@@ -0,0 +1,7 @@
+node_modules/
+.project
+unpackage/
+.DS_Store
+wxcomponents/**/*.vue
+wxcomponents/**/*.css
+.hbuilderx/

+ 55 - 48
components/mta-scroll-list/mta-scroll-list.vue

@@ -40,59 +40,66 @@
 	/**
 	 * @summary 将请求转换为promise
 	 */
-	function transformUniRequestToPromise(config) => new Promise((resolve, reject) => uni.request(...config, success(
-			data) {
-				resolve(data)
-			}, fail(err) {
-				reject(err)
-			})
-
-			/**
-			 * @summary 更新数据
-			 * @param {String} action  'pull-down-refresh' | 'reach-buttom'
-			 */
-			async function getData(action) {
-				try {
-					// 刷新页码重置
-					action === 'pull-down-refresh' && (page.value = 1);
-					// 触底页码 加1
-					action === 'reach-buttom' && (page.value++);
-
-					const opt = {
-						url: props.refreshUrl,
-						method: "POST",
-						data: {
-							page: page.value,
-							size: props.size,
-							...props.options
-						}
-					}
-
-					const data = await transformUniRequestToPromise(opt)
-
-					action === 'pull-down-refresh' && (uni.stopPullDownRefresh());
-
-					Emit(action, data)
-				} catch (err) {
-					console.log('错误', err)
-					uni.stopPullDownRefresh()
+	const transformUniRequestToPromise = (config) =>
+		new Promise((resolve, reject) => {
+			uni.request({
+				...config,
+				success(data) {
+					resolve(data);
+				},
+				fail(err) {
+					reject(err);
+				},
+			});
+		});
+
+
+	/**
+	 * @summary 更新数据
+	 * @param {String} action  'pull-down-refresh' | 'reach-buttom'
+	 */
+	async function getData(action) {
+		try {
+			// 刷新页码重置
+			action === 'pull-down-refresh' && (page.value = 1);
+			// 触底页码 加1
+			action === 'reach-buttom' && (page.value++);
+
+			const opt = {
+				url: props.refreshUrl,
+				method: "POST",
+				data: {
+					page: page.value,
+					size: props.size,
+					...props.options
 				}
 			}
 
-			/**
-			 * @summary 下拉刷新
-			 */
-			onPullDownRefresh(() => getData('pull-down-refresh'));
+			const data = await transformUniRequestToPromise(opt)
+
+			action === 'pull-down-refresh' && (uni.stopPullDownRefresh());
+
+			Emit(action, data)
+		} catch (err) {
+			console.log('错误', err)
+			uni.stopPullDownRefresh()
+		}
+	}
+
+	/**
+	 * @summary 下拉刷新
+	 */
+	onPullDownRefresh(() => getData('pull-down-refresh'));
 
-			/**
-			 * @summary 加载完成 首次进行下拉刷新
-			 */
-			onLoad(() => uni.startPullDownRefresh());
+	/**
+	 * @summary 加载完成 首次进行下拉刷新
+	 */
+	onLoad(() => uni.startPullDownRefresh());
 
-			/**
-			 * @summary 触底更新
-			 */
-			onReachBottom(() => getData('reach-buttom'));
+	/**
+	 * @summary 触底更新
+	 */
+	onReachBottom(() => getData('reach-buttom'));
 </script>
 
 <style lang="scss">