Sfoglia il codice sorgente

feat: 对接接口:我的点赞列表、我的收藏列表

Moss 1 anno fa
parent
commit
3d6b143a73
5 ha cambiato i file con 118 aggiunte e 28 eliminazioni
  1. 3 3
      src/components/Loading.vue
  2. 61 0
      src/filters/index.js
  3. 6 0
      src/main.js
  4. 33 14
      src/pages/mine/myCollection.vue
  5. 15 11
      src/pages/mine/myLike.vue

+ 3 - 3
src/components/Loading.vue

@@ -3,7 +3,7 @@
 		<view v-if="type === 1">
 			<u-empty
 				mode="list"
-				icon="/static/images/common/empty_data.png"
+				icon="/static/common/empty_data.png"
 				:text="loadStatus === 1 ? loadText : showText"
 				v-if="dataList.length < 1">
 			</u-empty>
@@ -15,7 +15,7 @@
 		<view v-if="type === 2">
 			<u-empty
 				mode="list"
-				icon="/static/images/common/empty_data.png"
+				icon="/static/common/empty_data.png"
 				:text="loadStatus === 1 ? loadText : showText"
 				v-if="dataList.length < 1">
 			</u-empty>
@@ -25,7 +25,7 @@
 			<u-loading-page :loading-text="loadText" :loading="loadStatus === 1"></u-loading-page>
 			<u-empty
 				mode="list"
-				icon="/static/images/common/empty_data.png"
+				icon="/static/common/empty_data.png"
 				:text="showText"
 				v-if="loadStatus === 2">
 			</u-empty>

+ 61 - 0
src/filters/index.js

@@ -0,0 +1,61 @@
+
+/**
+ * 数字保留两位小数点
+ * @param {number} num
+ * @return {string}
+ */
+export function numToFixed(num) {
+	if(!num) return '0.00';
+	num = Number(num);
+	return num.toFixed(2);
+}
+
+/**
+ * 日期转 年月日格式 YY-mm-dd
+ * @param {string} date
+ * @return {string}
+ */
+export function dateToYYmmdd(date) {
+	if(!date) return '';
+	return date.slice(0, 10);
+}
+
+/**
+ * 日期转 年月日格式 YY.mm.dd
+ * @param {string} date
+ * @return {string}
+ */
+export function dateToYYmmdd2(date) {
+	if(!date) return '';
+	let newDate = date.slice(0, 10);
+	newDate = newDate.replace(/-/g, '.');
+	return newDate;
+}
+
+/**
+ * 日期转 月日格式
+ * @param {string} date
+ * @return {string}
+ */
+export function dateTommdd(date) {
+	if(!date) return '';
+	return date.slice(5, 10);
+}
+
+/**
+ * 日期转 时分秒格式
+ * @param {string} date
+ * @return {string}
+ */
+export function dateToHHmmss(date) {
+	if(!date) return '';
+	return date.slice(11, 19);
+}
+
+export function priceFilter(val) {
+	if(!val && val != 0) return '-';
+  if(val == 0) return '面议';
+	val = Number(val);
+	return val.toFixed(2);
+}
+

+ 6 - 0
src/main.js

@@ -50,6 +50,12 @@ App.mpType = 'app'
 import api from '@/common/http/'
 Vue.prototype.$api = api
 
+import * as filters from './filters/index.js' // global filters
+// register global utility filters
+Object.keys(filters).forEach(key => {
+  Vue.filter(key, filters[key])
+})
+
 import custom from '@/components/custom.vue';
 import Loading from '@/components/Loading.vue';
 import zjPageLayout from "@/components/zj-container/zj-page-layout.vue"

+ 33 - 14
src/pages/mine/myCollection.vue

@@ -1,4 +1,5 @@
 <template>
+  <!-- #ifdef H5 -->
   <zj-page-layout
   	:hasFooter="false"
   	:isScroll="true"
@@ -6,52 +7,60 @@
   	@refresherrefresh="refresherrefresh"
   	@scrolltolower="scrolltolower">
     <view class="common-goods-list">
-      <view class="item">
+      <view class="item" v-for="(item, index) in dataList" :key="index" @tap="toGoodsDetail(item.id)">
         <view class="top">
           <image src="@/static/common/logo.png"></image>
           <view class="user">
-            <view class="name">张三</view>
-            <view class="time">23小时前发布</view>
+            <view class="name">{{item.userName}}</view>
+            <view class="time">{{item.createTime}}</view>
           </view>
-          <view class="price">¥1888.00</view>
+          <view class="price">{{item.amount | priceFilter}}</view>
         </view>
-        <view class="title">商品名称</view>
-        <view class="des">商品描述</view>
+        <view class="title">{{item.title}}</view>
+        <view class="des">{{item.content}}</view>
         <view class="imgs">
-          <image src="@/static/user/other_speech.png"></image>
-          <image src="@/static/user/other_speech.png"></image>
-          <image src="@/static/user/other_speech.png"></image>
+          <image :src="imgUrl + it.imgUrl" v-for="(it, idx) in item.goodsFiles" :key="idx"></image>
         </view>
         <view class="bottom">
-          <view class="left-location">天河区棠下</view>
+          <view class="left-location"><text class="iconfont icon-dingwei"></text>{{item.address}}</view>
           <view class="right-btn">
-            <u-button text="取消收藏" shape="circle"></u-button>
+            <u-button text="取消点赞" shape="circle"></u-button>
           </view>
         </view>
       </view>
     </view>
+
+    <Loading :loadStatus="loadStatus" :dataList="dataList" />
   </zj-page-layout>
+  <!-- #endif -->
+  <!-- #ifndef H5 -->
+  <web-view :src="webViewHref('/pages/mine/myCollection')"></web-view>
+  <!-- #endif -->
 </template>
 
 <script>
+  // #ifdef H5
   export default {
     data() {
       return {
         imgUrl: this.$imageUrl,
         dataList: [],
-        pageNum: 1,
+        pageNum: 1,
+				loadStatus: 0,
         refresherTriggered: false,
       }
     },
 
     async onLoad() {
-      // await this.getList()
+      await this.getList()
     },
 
     methods: {
       //获取列表数据
       async getList() {
-        this.$api.post('/xxx/xxxlist', {
+        this.$api.get('/likeOrCollect/list', {
+          userId: '',
+          type: 2,
           pageNum: this.pageNum,
           pageSize: 10,
         }).then(res => {
@@ -84,8 +93,18 @@
       	this.getList();
       },
 
+      toGoodsDetail(id) {
+        this.$navToPage({
+          url: `/pages/goods/detail?id=${id}`
+        })
+      },
+
     }
   }
+  // #endif
+  // #ifndef H5
+
+  // #endif
 </script>
 
 <style lang="scss" scoped>

+ 15 - 11
src/pages/mine/myLike.vue

@@ -7,24 +7,22 @@
   	@refresherrefresh="refresherrefresh"
   	@scrolltolower="scrolltolower">
     <view class="common-goods-list">
-      <view class="item">
+      <view class="item" v-for="(item, index) in dataList" :key="index" @tap="toGoodsDetail(item.id)">
         <view class="top">
           <image src="@/static/common/logo.png"></image>
           <view class="user">
-            <view class="name">张三</view>
-            <view class="time">23小时前发布</view>
+            <view class="name">{{item.userName}}</view>
+            <view class="time">{{item.createTime}}</view>
           </view>
-          <view class="price">¥1888.00</view>
+          <view class="price">{{item.amount | priceFilter}}</view>
         </view>
-        <view class="title">商品名称</view>
-        <view class="des">商品描述</view>
+        <view class="title">{{item.title}}</view>
+        <view class="des">{{item.content}}</view>
         <view class="imgs">
-          <image src="@/static/user/other_speech.png"></image>
-          <image src="@/static/user/other_speech.png"></image>
-          <image src="@/static/user/other_speech.png"></image>
+          <image :src="imgUrl + it.imgUrl" v-for="(it, idx) in item.goodsFiles" :key="idx"></image>
         </view>
         <view class="bottom">
-          <view class="left-location">天河区棠下</view>
+          <view class="left-location"><text class="iconfont icon-dingwei"></text>{{item.address}}</view>
           <view class="right-btn">
             <u-button text="取消点赞" shape="circle"></u-button>
           </view>
@@ -60,7 +58,7 @@
     methods: {
       //获取列表数据
       async getList() {
-        this.$api.post('/likeOrCollect/list', {
+        this.$api.get('/likeOrCollect/list', {
           userId: '',
           type: 1,
           pageNum: this.pageNum,
@@ -95,6 +93,12 @@
       	this.getList();
       },
 
+      toGoodsDetail(id) {
+        this.$navToPage({
+          url: `/pages/goods/detail?id=${id}`
+        })
+      },
+
     }
   }
   // #endif