Procházet zdrojové kódy

Merge branch 'master' of ssh://gogs.zfire.top:2222/zfire-front/recycle-mobile

linwenxin před 1 rokem
rodič
revize
0b2bdf10d9
5 změnil soubory, kde provedl 367 přidání a 151 odebrání
  1. 83 90
      package-lock.json
  2. 79 2
      src/common/utils/common.js
  3. 5 1
      src/main.js
  4. 114 42
      src/pages/goods/list.vue
  5. 86 16
      src/pages/index/index.vue

+ 83 - 90
package-lock.json

@@ -3054,6 +3054,44 @@
           "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
           "dev": true
         },
+        "ansi-styles": {
+          "version": "4.3.0",
+          "resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz",
+          "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "color-convert": "^2.0.1"
+          }
+        },
+        "chalk": {
+          "version": "4.1.2",
+          "resolved": "https://registry.npmmirror.com/chalk/-/chalk-4.1.2.tgz",
+          "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "ansi-styles": "^4.1.0",
+            "supports-color": "^7.1.0"
+          }
+        },
+        "color-convert": {
+          "version": "2.0.1",
+          "resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz",
+          "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "color-name": "~1.1.4"
+          }
+        },
+        "color-name": {
+          "version": "1.1.4",
+          "resolved": "https://registry.npmmirror.com/color-name/-/color-name-1.1.4.tgz",
+          "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
+          "dev": true,
+          "optional": true
+        },
         "css-loader": {
           "version": "3.6.0",
           "resolved": "https://registry.npmmirror.com/css-loader/-/css-loader-3.6.0.tgz",
@@ -3111,6 +3149,13 @@
             "pump": "^3.0.0"
           }
         },
+        "has-flag": {
+          "version": "4.0.0",
+          "resolved": "https://registry.npmmirror.com/has-flag/-/has-flag-4.0.0.tgz",
+          "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
+          "dev": true,
+          "optional": true
+        },
         "hash-sum": {
           "version": "2.0.0",
           "resolved": "https://registry.npmmirror.com/hash-sum/-/hash-sum-2.0.0.tgz",
@@ -3213,6 +3258,42 @@
           "requires": {
             "minipass": "^3.1.1"
           }
+        },
+        "supports-color": {
+          "version": "7.2.0",
+          "resolved": "https://registry.npmmirror.com/supports-color/-/supports-color-7.2.0.tgz",
+          "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "has-flag": "^4.0.0"
+          }
+        },
+        "vue-loader-v16": {
+          "version": "npm:vue-loader@16.8.3",
+          "resolved": "https://registry.npmmirror.com/vue-loader/-/vue-loader-16.8.3.tgz",
+          "integrity": "sha512-7vKN45IxsKxe5GcVCbc2qFU5aWzyiLrYJyUuMz4BQLKctCj/fmCa0w6fGiiQ2cLFetNcek1ppGJQDCup0c1hpA==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "chalk": "^4.1.0",
+            "hash-sum": "^2.0.0",
+            "loader-utils": "^2.0.0"
+          },
+          "dependencies": {
+            "loader-utils": {
+              "version": "2.0.4",
+              "resolved": "https://registry.npmmirror.com/loader-utils/-/loader-utils-2.0.4.tgz",
+              "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==",
+              "dev": true,
+              "optional": true,
+              "requires": {
+                "big.js": "^5.2.2",
+                "emojis-list": "^3.0.0",
+                "json5": "^2.1.2"
+              }
+            }
+          }
         }
       }
     },
@@ -10435,7 +10516,7 @@
     },
     "js-perform-lock": {
       "version": "1.0.5",
-      "resolved": "http://121.41.110.30:4873/js-perform-lock/-/js-perform-lock-1.0.5.tgz",
+      "resolved": "https://registry.npmmirror.com/js-perform-lock/-/js-perform-lock-1.0.5.tgz",
       "integrity": "sha512-aDp38fxLnur2YMsJhw1Ab23PdwceXMU5Pkcb4R5MSaRfySiDwbDR2L/ysnB4X7/1XERkLC56r32qwtNlitBSGg=="
     },
     "js-tokens": {
@@ -16159,94 +16240,6 @@
         "vue-style-loader": "^4.1.0"
       }
     },
-    "vue-loader-v16": {
-      "version": "npm:vue-loader@16.8.3",
-      "resolved": "http://121.41.110.30:4873/vue-loader/-/vue-loader-16.8.3.tgz",
-      "integrity": "sha512-7vKN45IxsKxe5GcVCbc2qFU5aWzyiLrYJyUuMz4BQLKctCj/fmCa0w6fGiiQ2cLFetNcek1ppGJQDCup0c1hpA==",
-      "dev": true,
-      "optional": true,
-      "requires": {
-        "chalk": "^4.1.0",
-        "hash-sum": "^2.0.0",
-        "loader-utils": "^2.0.0"
-      },
-      "dependencies": {
-        "ansi-styles": {
-          "version": "4.3.0",
-          "resolved": "http://121.41.110.30:4873/ansi-styles/-/ansi-styles-4.3.0.tgz",
-          "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
-          "dev": true,
-          "optional": true,
-          "requires": {
-            "color-convert": "^2.0.1"
-          }
-        },
-        "chalk": {
-          "version": "4.1.2",
-          "resolved": "http://121.41.110.30:4873/chalk/-/chalk-4.1.2.tgz",
-          "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
-          "dev": true,
-          "optional": true,
-          "requires": {
-            "ansi-styles": "^4.1.0",
-            "supports-color": "^7.1.0"
-          }
-        },
-        "color-convert": {
-          "version": "2.0.1",
-          "resolved": "http://121.41.110.30:4873/color-convert/-/color-convert-2.0.1.tgz",
-          "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
-          "dev": true,
-          "optional": true,
-          "requires": {
-            "color-name": "~1.1.4"
-          }
-        },
-        "color-name": {
-          "version": "1.1.4",
-          "resolved": "http://121.41.110.30:4873/color-name/-/color-name-1.1.4.tgz",
-          "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
-          "dev": true,
-          "optional": true
-        },
-        "has-flag": {
-          "version": "4.0.0",
-          "resolved": "http://121.41.110.30:4873/has-flag/-/has-flag-4.0.0.tgz",
-          "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
-          "dev": true,
-          "optional": true
-        },
-        "hash-sum": {
-          "version": "2.0.0",
-          "resolved": "http://121.41.110.30:4873/hash-sum/-/hash-sum-2.0.0.tgz",
-          "integrity": "sha512-WdZTbAByD+pHfl/g9QSsBIIwy8IT+EsPiKDs0KNX+zSHhdDLFKdZu0BQHljvO+0QI/BasbMSUa8wYNCZTvhslg==",
-          "dev": true,
-          "optional": true
-        },
-        "loader-utils": {
-          "version": "2.0.4",
-          "resolved": "http://121.41.110.30:4873/loader-utils/-/loader-utils-2.0.4.tgz",
-          "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==",
-          "dev": true,
-          "optional": true,
-          "requires": {
-            "big.js": "^5.2.2",
-            "emojis-list": "^3.0.0",
-            "json5": "^2.1.2"
-          }
-        },
-        "supports-color": {
-          "version": "7.2.0",
-          "resolved": "http://121.41.110.30:4873/supports-color/-/supports-color-7.2.0.tgz",
-          "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
-          "dev": true,
-          "optional": true,
-          "requires": {
-            "has-flag": "^4.0.0"
-          }
-        }
-      }
-    },
     "vue-pdf": {
       "version": "4.3.0",
       "resolved": "https://registry.npmmirror.com/vue-pdf/-/vue-pdf-4.3.0.tgz",
@@ -16951,7 +16944,7 @@
     },
     "weixin-js-sdk": {
       "version": "1.6.3",
-      "resolved": "http://121.41.110.30:4873/weixin-js-sdk/-/weixin-js-sdk-1.6.3.tgz",
+      "resolved": "https://registry.npmmirror.com/weixin-js-sdk/-/weixin-js-sdk-1.6.3.tgz",
       "integrity": "sha512-5jYNtVcxWmgHNqCLSPoX6vXab9G4RPDZx0klX8IsVwGjDTwx/UDmgfF7fkRMGguRpuFv0O7tk1jb+Oay2QiV1w=="
     },
     "whatwg-encoding": {

+ 79 - 2
src/common/utils/common.js

@@ -205,6 +205,82 @@ export const copy = (val) => {
       successToast('复制成功');
     },
   });
+};
+
+// 获取当前定位
+export const getLocation = async function() {
+	return new Promise((resolve, reject) => {
+		uni.getLocation({
+			type: 'gcj02',
+			geocode: true,
+			success: (res) => {
+				resolve(res);
+			},
+			fail: (err) => {
+				console.log('获取当前定位失败', err);
+				uni.authorize({
+					scope: 'scope.userLocation',
+					success: () => {
+						// 允许授权
+						uni.getLocation({
+							type: 'gcj02',
+							geocode: true,
+							success: (res) => {
+								resolve(res);
+							},
+							fail: (err) => {
+								modal({
+									title: '提示',
+									content: '定位失败,请重试',
+									showCancel: false,
+								}).then(() => {});
+							},
+						});
+					},
+					fail: () => {
+						// 拒绝授权
+						modal({
+							title: '提示',
+							content: '定位失败,请重试',
+							showCancel: false,
+							// confirmText: '重新定位',
+						}).then(() => {
+							// getLocation();
+						});
+					},
+				});
+			},
+		});
+	});
+};
+
+// 获取地址
+export const getAddress = async function() {
+	const location = await getLocation();
+	return new Promise((resolve, reject) => {
+		uni.request({
+			url: 'https://restapi.amap.com/v3/geocode/regeo',
+			method: 'GET',
+			data: {
+				location: location.longitude + ',' + location.latitude,
+				key: 'b772f8b0ace6bc96c04ae8e48f241e36',
+			},
+			success: (res) => {
+				resolve({
+					longitude: location.longitude,
+					latitude: location.latitude,
+					address: res.data.regeocode.formatted_address,
+					province: res.data.regeocode.addressComponent.province,
+					city: res.data.regeocode.addressComponent.city,
+					area: res.data.regeocode.addressComponent.district,
+					street: res.data.regeocode.addressComponent.township,
+				});
+			},
+			fail: function(err) {
+				console.log('地址解析失败' + err);
+			},
+		});
+	});
 };
 
 // 判断微信环境
@@ -239,7 +315,6 @@ export function getQueryVariable(variable) {
   return undefined;
 }
 
-
 export default {
   toast,
   successToast,
@@ -251,5 +326,7 @@ export default {
   redPage,
   backPage,
   callPhone,
-  copy
+  copy,
+	getLocation,
+	getAddress,
 };

+ 5 - 1
src/main.js

@@ -23,6 +23,8 @@ import {
   backPage,
   callPhone,
   copy,
+  getLocation,
+  getAddress,
 } from "common/utils/common"
 import {
   navToPage
@@ -40,6 +42,8 @@ Vue.prototype.$redPage = redPage;
 Vue.prototype.$backPage = backPage;
 Vue.prototype.$callPhone = callPhone;
 Vue.prototype.$copy = copy;
+Vue.prototype.$getLocation = getLocation;
+Vue.prototype.$getAddress = getAddress;
 
 // 注入全局
 import pages from 'mixins';
@@ -80,7 +84,7 @@ Vue.component('my-link', Mylink)
 // #endif
 
 // 渲染图片文件
-Vue.prototype.$imageUrl = process.env.VUE_APP_BASE_URL + process.env.VUE_APP_BASE_API + '/file/img/get?key=';
+Vue.prototype.$imageUrl = process.env.VUE_APP_BASE_URL + process.env.VUE_APP_BASE_API + '/img/get?key=';
 
 const app = new Vue({
   ...App,

+ 114 - 42
src/pages/goods/list.vue

@@ -1,4 +1,5 @@
 <template>
+  <!-- #ifdef H5 -->
   <zj-page-layout
   	:hasFooter="false"
   	:isScroll="true"
@@ -9,19 +10,24 @@
       <view class="header-container">
         <u-tabs
           :list="categoryList"
-          @click="click"
-          :scrollable="false"
+          :current="categoryCurrent"
+          @click="clickCategory"
+          keyName="categoryName"
+          :scrollable="categoryList.length === 4 ? false : true"
           lineColor="#01C30B">
         </u-tabs>
         <u-search
           placeholder="输入商品名称搜索"
           :showAction="false"
           clearabled
-          v-model="keyword">
+          v-model="keyword"
+          @search="refreshList"
+          @clear="refreshList">
         </u-search>
         <u-tabs
           :list="tabList"
-          @click="click"
+          :current="tabCurrent"
+          @click="clickTab"
           :scrollable="false"
           lineColor="#01C30B">
         </u-tabs>
@@ -29,24 +35,22 @@
     </template>
 
     <view class="common-goods-list">
-      <view class="item" @tap="$navPage(`/pages/goods/detail`)">
+      <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 | priceFilter2}}</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-stats">
             <view class="it">
               <text class="iconfont icon-dianzan"></text>
@@ -64,75 +68,143 @@
         </view>
       </view>
     </view>
+
+    <Loading :loadStatus="loadStatus" :dataList="dataList" />
   </zj-page-layout>
+  <!-- #endif -->
+  <!-- #ifndef H5 -->
+  <web-view :src="webViewHref('/pages/goods/list')"></web-view>
+  <!-- #endif -->
 </template>
 
 <script>
+  // #ifdef H5
   export default {
     data() {
       return {
         imgUrl: this.$imageUrl,
-        categoryList: [
-          {name: '家用空调', value: 1},
-          {name: '商用空调', value: 2},
-          {name: '冷冻空调', value: 3},
-          {name: '特种空调', value: 4},
-        ],
+        categoryList: [],
+        categoryId: '',
         tabList: [
-          {name: '默认顺序', value: 1},
-          {name: '在售商品', value: 2},
-          {name: '离我最近', value: 3},
-          {name: '人气最高', value: 4},
+          {name: '默认顺序', value: 0},
+          {name: '在售商品', value: 1},
+          {name: '离我最近', value: 2},
+          {name: '人气最高', value: 3},
         ],
+        tabCurrent: 0,
         keyword: '',
         dataList: [],
         pageNum: 1,
+        loadStatus: 0,
         refresherTriggered: false,
       }
     },
 
-    async onLoad() {
-      // await this.getList()
+    computed:{
+    	categoryCurrent() {
+        if(this.categoryId) {
+          return this.categoryList.map(item => item.categoryId).indexOf(this.categoryId)
+        }else {
+          return 0
+        }
+    	}
+    },
+
+    async onLoad({categoryId, keyword}) {
+      console.log(categoryId);
+      console.log(keyword);
+      this.categoryId = categoryId;
+      this.keyword = keyword;
+      await this.getCategory();
+      await this.getList();
     },
 
     methods: {
+      async getCategory() {
+        return new Promise((resolve, reject) => {
+          this.$api.get('/goods/category/list')
+          .then(res => {
+            this.categoryList = res.data || [];
+          }).finally(res => {
+            resolve(1);
+          })
+        })
+      },
+
       //获取列表数据
       async getList() {
-        this.$api.post('/xxx/xxxlist', {
+        let params = {};
+        if(this.tabCurrent === 1) {
+          params.status = '1';
+        }else if(this.tabCurrent === 2) {
+          params.lng = this.lng;
+          params.lat = this.lat;
+        }else if(this.tabCurrent === 3) {
+          params.visitOrderBy = 'YES';
+        }
+
+        this.$api.get('/goods/list', {
           pageNum: this.pageNum,
           pageSize: 10,
+          categoryId: this.categoryId,
+          title: this.keyword,
+          ...params
         }).then(res => {
           this.loadStatus = 0;
           let list = res.data.records;
-          if(list.length < 10){
-          	this.loadStatus = 2;
+          if (list.length < 10) {
+            this.loadStatus = 2;
           }
           this.dataList = this.dataList.concat(list);
         }).catch(() => {
-					this.loadStatus = 2;
-				}).finally(res => {
-					this.refresherTriggered = false;
-				})
+          this.loadStatus = 2;
+        })
+      },
+
+      clickCategory(item) {
+        this.categoryId = item.categoryId;
+        this.refreshList();
+      },
+
+      clickTab(item) {
+        this.tabCurrent = item.value;
+        this.refreshList();
       },
 
       // 滚动到底部
       scrolltolower(e) {
-      	if (this.loadStatus === 0) {
-      		this.pageNum++;
-      		this.getList();
-      	}
+        if (this.loadStatus === 0) {
+          this.pageNum++;
+          this.getList();
+        }
       },
 
       // 触发下拉刷新
-      refresherrefresh(e) {
-      	this.refresherTriggered = true;
-      	this.dataList = [];
-      	this.pageNum = 1;
-      	this.getList();
+      async refresherrefresh(e) {
+        this.refresherTriggered = true;
+        // await this.getCategory();
+        this.refreshList();
+        this.refresherTriggered = false;
+      },
+
+      refreshList() {
+        this.dataList = [];
+        this.pageNum = 1;
+        this.getList();
+      },
+
+      toGoodsDetail(id) {
+        this.$navToPage({
+          url: `/pages/goods/detail?${id}`
+        })
       },
 
     }
   }
+  // #endif
+  // #ifndef H5
+
+  // #endif
 </script>
 
 <style lang="scss" scoped>

+ 86 - 16
src/pages/index/index.vue

@@ -10,7 +10,7 @@
 
       <view class="all-container">
         <view class="search-container">
-          <u-search placeholder="输入商品名称搜索" :showAction="false" clearabled v-model="keyword">
+          <u-search placeholder="输入商品名称搜索" :showAction="false" clearabled v-model="keyword" @search="handleSearch">
           </u-search>
         </view>
 
@@ -19,19 +19,19 @@
         </view>
 
         <view class="category-container card mt30">
-          <view class="item" v-for="(item, index) in categoryList" :key="index" @tap="$navPage(`/pages/goods/list?${item.categoryId}`)">
+          <view class="item" v-for="(item, index) in categoryList" :key="index" @tap="toGoodsList(item.categoryId)">
             <image :src="imageUrl + item.imgUrl"></image>
             <view class="name">{{item.categoryName}}</view>
           </view>
         </view>
 
         <view class="tab-container mt30">
-          <u-tabs :list="tabList" @click="click" :scrollable="false" lineColor="#01C30B">
+          <u-tabs :list="tabList" @click="clickTab" :current="tabCurrent" :scrollable="false" lineColor="#01C30B">
           </u-tabs>
         </view>
 
         <view class="common-goods-list">
-          <view class="item card" v-for="(item, index) in dataList" :key="index" @tap="$navPage(`/pages/goods/detail`)">
+          <view class="item card" 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">
@@ -64,7 +64,7 @@
             </view>
           </view>
         </view>
-        
+
         <Loading :loadStatus="loadStatus" :dataList="dataList" />
 
       </view>
@@ -87,29 +87,29 @@
         loadStatus: 0,
         refresherTriggered: false,
         keyword: '',
-        bannerList: [
-          'https://cdn.uviewui.com/uview/swiper/swiper3.png',
-          'https://cdn.uviewui.com/uview/swiper/swiper2.png',
-          'https://cdn.uviewui.com/uview/swiper/swiper1.png',
-        ],
+        bannerList: [],
         categoryList: [],
         tabList: [{
             name: '默认顺序',
-            value: 1
+            value: 0
           },
           {
             name: '在售商品',
-            value: 2
+            value: 1
           },
           {
             name: '离我最近',
-            value: 3
+            value: 2
           },
           {
             name: '人气最高',
-            value: 4
+            value: 3
           },
         ],
+        tabCurrent: 0,
+
+        lat: '',
+        lng: '',
       }
     },
 
@@ -120,11 +120,41 @@
     },
 
     async onLoad() {
+      await this.getBanner();
       await this.getCategory();
       await this.getList();
+      let lo = await this.$getLocation();
+      this.lat = lo.latitude;
+      this.lng = lo.longitude;
     },
 
     methods: {
+      async getBanner() {
+        // let res = await this.$api.get('/carouselMap/list/page', {
+        //   pageNum: 1,
+        //   pageSize: -1,
+        //   state: true
+        // })
+        // this.bannerList = res.data.records;
+        // return res.data.records
+
+        return new Promise((resolve, reject) => {
+          this.$api.get('/carouselMap/list/page', {
+            pageNum: 1,
+            pageSize: -1,
+            state: true
+          }).then(res => {
+            if(res.data && res.data.records) {
+              this.bannerList = res.data.records.map(item => {
+                return this.imageUrl + item.imgSrc;
+              });
+            }
+          }).finally(res => {
+            resolve(1);
+          })
+        })
+      },
+
       async getCategory() {
         return new Promise((resolve, reject) => {
           this.$api.get('/goods/category/list')
@@ -138,9 +168,20 @@
 
       //获取列表数据
       async getList() {
+        let params = {};
+        if(this.tabCurrent === 1) {
+          params.status = '1';
+        }else if(this.tabCurrent === 2) {
+          params.lng = this.lng;
+          params.lat = this.lat;
+        }else if(this.tabCurrent === 3) {
+          params.visitOrderBy = 'YES';
+        }
+
         this.$api.get('/goods/list', {
           pageNum: this.pageNum,
           pageSize: 10,
+          ...params
         }).then(res => {
           this.loadStatus = 0;
           let list = res.data.records;
@@ -153,6 +194,11 @@
         })
       },
 
+      clickTab(item) {
+        this.tabCurrent = item.value;
+        this.refreshList();
+      },
+
       // 滚动到底部
       scrolltolower(e) {
         if (this.loadStatus === 0) {
@@ -164,11 +210,35 @@
       // 触发下拉刷新
       async refresherrefresh(e) {
         this.refresherTriggered = true;
+        await this.getBanner();
+        await this.getCategory();
+        this.refreshList();
+        this.refresherTriggered = false;
+      },
+
+      refreshList() {
         this.dataList = [];
         this.pageNum = 1;
         this.getList();
-        await this.getCategory();
-        this.refresherTriggered = false;
+      },
+      
+      handleSearch() {
+        this.$navToPage({
+          url: `/pages/goods/list?keyword=${this.keyword}`
+        })
+        this.keyword = '';
+      },
+
+      toGoodsList(categoryId) {
+        this.$navToPage({
+          url: `/pages/goods/list?categoryId=${categoryId}`
+        })
+      },
+
+      toGoodsDetail(id) {
+        this.$navToPage({
+          url: `/pages/goods/detail?id=${id}`
+        })
       },
 
     }