Browse Source

feat: 对接我发布的列表、我买到的列表

Moss 1 year ago
parent
commit
bd62eebfe5

+ 3 - 5
src/common/utils/util.js

@@ -4,9 +4,7 @@ import store from '@/store/index.js'
 // 获取用户信息
 export const getUserInfo = () => {
   return new Promise((resolve, reject) => {
-    api.post('/account/getaccountinfo', {
-        accountCode: store.getters.usercode
-      }).then((response) => {
+    api.get('/wechat/user/info').then((response) => {
         const {
           data
         } = response;
@@ -109,7 +107,7 @@ export const getArea = function(str) {
 	} else {
 	  area.Province = str.substring(0, index1 + 1)
 	}
-				 
+
 	let index2 = str.indexOf("市")
 	if (index11 == -1) {
 	  area.City = str.substring(index11 + 1, index2 + 1)
@@ -120,7 +118,7 @@ export const getArea = function(str) {
 	    area.City = str.substring(index11 + 3, index2 + 1)
 	  }
 	}
-				 
+
 	let index3 = str.lastIndexOf("区")
 	if (index3 == -1) {
 	  index3 = str.indexOf("县")

+ 28 - 32
src/components/zj-dialog/zj-dialog-deliver.vue

@@ -19,7 +19,7 @@
         </view>
         <view class="row" v-show="type === 2">
           <view class="label">物流公司</view>
-          <view class="value" @tap="isShowCompanyDialog = true">{{company ? company : '请选择'}}</view>
+          <view class="value" @tap="isShowCompanyDialog = true">{{company ? company.name : '请选择'}}</view>
         </view>
         <view class="row" v-show="type === 2">
           <view class="label">物流单号</view>
@@ -39,8 +39,7 @@
     	:styleType="2"
     	:title="'物流公司'"
     	:list="companyList"
-    	:keyName="'label'"
-    	:isSearch="true"
+    	:keyName="'name'"
     	@search="searchCompanyDialog"
     	@cancel="isShowCompanyDialog = false"
     	@confirm="confirmCompanyDialog">
@@ -62,29 +61,30 @@
 				type: Boolean,
 				default: false
 			},
-			orderId: {
-				type: String,
-				default: ''
-			},
 		},
 
 		data() {
 			return {
+        goodsId: null,
         type: 1, // 发货方式
-        company: '', // 物流公司
+        company: null, // 物流公司
         orderNo: '', // 物流单号
 
-        companyList: [
-          {label: '顺丰快递', value: 1},
-          {label: '申通快递', value: 1},
-        ],
+        companyList: [],
         isShowCompanyDialog: false,
 			}
 		},
 
 		methods: {
       setValue(id) {
+        this.goodsId = id;
+        this.getCompanyList();
+      },
 
+      getCompanyList() {
+        this.$api.post('/orderPay/expressCompany').then(res => {
+          this.companyList = res.data || [];
+        })
       },
 
       searchCompanyDialog() {
@@ -92,7 +92,7 @@
       },
 
       confirmCompanyDialog(e) {
-        this.company = this.companyList[e[0]].label;
+        this.company = this.companyList[e[0]];
         this.isShowCompanyDialog = false;
       },
 
@@ -103,26 +103,22 @@
 			confirmDialog() {
         if(this.type === 2 && !this.company) return this.$toast('请选择物流公司');
         if(this.type === 2 && !this.orderNo) return this.$toast('请填写物流单号');
-
-				let url = '';
-				if(this.detail.dispatchStatus == 'SQGP') {
-					url = '/order/dispatch/ack';
-				}else {
-					url = '/order/rece/ack';
-				}
-				this.$axios({
-					url,
-					method: 'POST',
-					params: {
-						id: this.orderId,
-					},
-					isLoading: 1
-				}).then(res => {
-					uni.$emit('refreshHome');
-					uni.$emit('refreshOrderDetail');
-					this.$successToast('接收成功');
+        
+        let params = {};
+        if(this.type === 2) {
+          params.logisticsName = this.company.name;
+          params.logisticsCode = this.company.code;
+          params.logisticsNum = this.orderNoe;
+        }
+
+				this.$api.post('/orderPay/logisticsAdd', {
+          goodsId: this.goodsId,
+          logisticsType: this.type === 1 ? 'SELF' : 'DELIVERY',
+          ...params
+        }).then(res => {
+					uni.$emit('refreshMyIssueList');
+					this.$successToast('发货成功');
 					this.cancelDialog();
-					this.$navPage(`/packageOrder/pages/orderDetail?id=${this.orderId}`);
 				})
 			}
 		}

+ 1 - 1
src/filters/index.js

@@ -53,8 +53,8 @@ export function dateToHHmmss(date) {
 }
 
 export function priceFilter2(val) {
-	if(!val && val != 0) return '-';
   if(val == 0) return '面议';
+	if(!val) return '-';
 	val = Number(val);
 	return val.toFixed(2);
 }

+ 12 - 12
src/pages/mine/index.vue

@@ -16,8 +16,8 @@
           <view class="user">
             <image src="@/static/common/logo.png" mode="aspectFill"></image>
             <view class="main" v-if="isLogin">
-              <view class="name">张三</view>
-              <view class="real">实名认证</view>
+              <view class="name">微信用户</view>
+              <!-- <view class="real">实名认证</view> -->
             </view>
             <view class="main" v-else @tap="navToPage('/pages/login/indexs')">
               <view class="name">请先登录</view>
@@ -34,10 +34,10 @@
         <view class="stats-container card">
           <view class="top">
             <view class="left">我发布的</view>
-            <view class="right" @tap="$navPage(`/pages/mine/myIssue/list`)">全部<text class="iconfont icon-jinru"></text></view>
+            <view class="right" @tap="navToPage(`/pages/mine/myIssue/list?tab=`)">全部<text class="iconfont icon-jinru"></text></view>
           </view>
           <view class="stats">
-            <view class="item" v-for="(item, index) in issueStats" :key="index" @tap="$navPage(`/pages/mine/myIssue/list`)">
+            <view class="item" v-for="(item, index) in issueStats" :key="index" @tap="navToPage(`/pages/mine/myIssue/list?tab=${item.tab}`)">
               <view class="icon">
                 <text class="iconfont" :class="item.icon"></text>
                 <u-badge max="99" :value="item.num" :absolute="true" :offset="[-4, -4]"></u-badge>
@@ -50,10 +50,10 @@
         <view class="stats-container card">
           <view class="top">
             <view class="left">我买到的</view>
-            <view class="right" @tap="$navPage(`/pages/mine/myBuy/list`)">全部<text class="iconfont icon-jinru"></text></view>
+            <view class="right" @tap="navToPage(`/pages/mine/myBuy/list`)">全部<text class="iconfont icon-jinru"></text></view>
           </view>
           <view class="stats">
-            <view class="item" v-for="(item, index) in buyStats" :key="index" @tap="$navPage(`/pages/mine/myBuy/list`)">
+            <view class="item" v-for="(item, index) in buyStats" :key="index" @tap="navToPage(`/pages/mine/myBuy/list`)">
               <view class="icon">
                 <text class="iconfont" :class="item.icon"></text>
                 <u-badge max="99" :value="item.num" :absolute="true" :offset="[-4, -4]"></u-badge>
@@ -93,9 +93,9 @@ export default {
         { name: '我的收益', num: 0, url: '/pages/mine/myEarnings/list' },
       ],
       issueStats: [
-        { name: '我的发布', icon: 'icon-xiangji', num: 0 },
-        { name: '已卖出', icon: 'icon-xiangji', num: 0 },
-        { name: '已下架', icon: 'icon-xiangji', num: 0 },
+        { name: '我的发布', tab: 0, icon: 'icon-xiangji', num: 0 },
+        { name: '已卖出', tab: 1, icon: 'icon-xiangji', num: 0 },
+        { name: '已下架', tab: 2, icon: 'icon-xiangji', num: 0 },
       ],
       buyStats: [
         { name: '待付款', icon: 'icon-xiangji', num: 0 },
@@ -149,9 +149,9 @@ export default {
           userId: this.$store.state.user.userId,
         }).then(res => {
           if(!res.data) return false;
-          this.userStats[0].num = res.data.dz;
-          this.userStats[1].num = res.data.sc;
-          this.userStats[2].num = res.data.sy;
+          this.userStats[0].num = res.data.dz || 0;
+          this.userStats[1].num = res.data.sc || 0;
+          this.userStats[2].num = res.data.sy || 0;
         }).finally(res => {
           resolve(1);
         })

+ 53 - 17
src/pages/mine/myBuy/list.vue

@@ -1,4 +1,5 @@
 <template>
+  <!-- #ifdef H5 -->
   <zj-page-layout
   	:hasFooter="false"
   	:isScroll="true"
@@ -25,38 +26,57 @@
     </template>
 
     <view class="common-order-list">
-      <view class="item" @tap="$navPage(`/pages/mine/myBuy/detail`)">
+      <view class="item" v-for="(item, index) in dataList" :key="index" @tap="toDetail(item.orderId)">
         <view class="top">
           <image src="@/static/common/logo.png"></image>
           <view class="user">
-            <view class="name">李海</view>
-            <view class="time">21小时前发布</view>
+            <view class="name">{{item.userName}}</view>
+            <view class="time">{{item.goodsCreateTime}}</view>
           </view>
-          <view class="status">待付款</view>
+          <view class="status">{{item.status | statusFilter}}</view>
         </view>
         <view class="goods">
-          <image src="@/static/user/other_book.png"></image>
+          <image :src="imageUrl + item.goodsPicUrl"></image>
           <view class="main">
-            <view class="name">商品名称</view>
-            <view class="des">商品描述</view>
-            <view class="price"><text>¥18.00</text>x2</view>
+            <view class="name">{{item.goodsTitle}}</view>
+            <view class="des">{{item.content}}</view>
+            <view class="price"><text>{{item.goodsAmount | priceFilter2}}</text>数量:{{item.num}}</view>
           </view>
         </view>
-        <view class="total">订单总金额<text>¥1200.00</text></view>
+        <view class="total">订单总金额<text>{{item.price | priceFilter2}}</text></view>
         <view class="bottom">
-          <view class="left-location"><text class="iconfont icon-dingwei"></text>天河区棠下</view>
-          <view class="right-btn">
+          <view class="left-location"><text class="iconfont icon-dingwei"></text>{{item.address}}</view>
+          <view class="right-btn" @tap.stop>
             <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/myBuy/list')"></web-view>
+  <!-- #endif -->
 </template>
 
 <script>
+  // #ifdef H5
   export default {
+    filters: {
+      statusFilter(val) {
+        const MAP = {
+          WAIT: '待支付',
+          WAIT_SEND: '待发货',
+          SEND: '已发货',
+          COMPLETE: '已完成',
+        }
+        return MAP[val];
+      }
+    },
+
     data() {
       return {
         imgUrl: this.$imageUrl,
@@ -71,20 +91,26 @@
         curTab: 0,
         dataList: [],
         pageNum: 1,
+        loadStatus: 0,
         refresherTriggered: false,
       }
     },
 
     async onLoad() {
-      // await this.getList()
+      await this.getList();
     },
 
     methods: {
       //获取列表数据
       async getList() {
-        this.$api.post('/xxx/xxxlist', {
+        this.$api.post('/goodsAdmin/list', {
           pageNum: this.pageNum,
           pageSize: 10,
+          params: [{
+            param: 'a.user_id',
+            compare: '=',
+            value: this.$store.state.user.userId
+          }]
         }).then(res => {
           this.loadStatus = 0;
           let list = res.data.records;
@@ -93,10 +119,10 @@
           }
           this.dataList = this.dataList.concat(list);
         }).catch(() => {
-					this.loadStatus = 2;
-				}).finally(res => {
-					this.refresherTriggered = false;
-				})
+      		this.loadStatus = 2;
+      	}).finally(res => {
+      		this.refresherTriggered = false;
+      	})
       },
 
       // 滚动到底部
@@ -114,9 +140,19 @@
       	this.pageNum = 1;
       	this.getList();
       },
+      
+      toDetail(id) {
+        this.$navToPage({
+          url: `/pages/mine/myBuy/detail?id=${id}`
+        })
+      },
 
     }
   }
+  // #endif
+  // #ifndef H5
+
+  // #endif
 </script>
 
 <style lang="scss" scoped>

+ 89 - 26
src/pages/mine/myIssue/list.vue

@@ -1,4 +1,5 @@
 <template>
+  <!-- #ifdef H5 -->
   <view>
     <zj-page-layout
       :hasFooter="false"
@@ -11,8 +12,8 @@
           <u-tabs
             :scrollable="false"
             :list="tabList"
-            :current="curTab"
-            @click="changeTab"
+            :current="tabCurrent"
+            @click="clickTab"
             lineColor="#01C30B"
             :activeStyle="{
               color: '#01C30B'
@@ -26,32 +27,34 @@
       </template>
 
       <view class="common-order-list">
-        <view class="item" @tap="$navPage(`/pages/mine/myBuy/detail`)">
+        <view class="item" v-for="(item, index) in dataList" :key="index" @tap="toDetail(item.id)">
           <view class="top">
             <image src="@/static/common/logo.png"></image>
             <view class="user">
-              <view class="name">李海</view>
-              <view class="time">21小时前发布</view>
+              <view class="name">{{item.userName}}</view>
+              <view class="time">{{item.goodsCreateTime}}</view>
             </view>
-            <view class="status">待付款</view>
+            <view class="status">{{item.status | statusFilter}}</view>
           </view>
           <view class="goods">
-            <image src="@/static/user/other_book.png"></image>
+            <image :src="imageUrl + item.goodsPicUrl"></image>
             <view class="main">
-              <view class="name">商品名称</view>
-              <view class="des">商品描述</view>
-              <view class="price"><text>¥18.00</text>x2</view>
+              <view class="name">{{item.title}}</view>
+              <view class="des">{{item.content}}</view>
+              <view class="price"><text>{{item.amount | priceFilter2}}</text></view>
             </view>
           </view>
           <view class="bottom">
-            <view class="left-location"><text class="iconfont icon-dingwei"></text>天河区棠下</view>
+            <view class="left-location"><text class="iconfont icon-dingwei"></text>{{item.address}}</view>
             <view class="right-btn" @tap.stop>
-              <u-button text="确认发货" shape="circle" @click="openDeliver()"></u-button>
+              <u-button text="确认发货" shape="circle" @click="openDeliver(item.id)"></u-button>
             </view>
           </view>
         </view>
       </view>
 
+      <Loading :loadStatus="loadStatus" :dataList="dataList" />
+
     </zj-page-layout>
 
     <zj-dialog-deliver
@@ -60,9 +63,14 @@
       @close="isShowDeliverDialog = false">
     </zj-dialog-deliver>
   </view>
+  <!-- #endif -->
+  <!-- #ifndef H5 -->
+  <web-view :src="webViewHref('/pages/mine/myIssue/list')"></web-view>
+  <!-- #endif -->
 </template>
 
-<script>
+<script>
+  // #ifdef H5
 	import zjDialogDeliver from '@/components/zj-dialog/zj-dialog-deliver.vue';
 
   export default {
@@ -70,33 +78,63 @@
       zjDialogDeliver
     },
 
+    filters: {
+      statusFilter(val) {
+        const MAP = {
+          1: '上架中',
+          2: '已转让',
+          0: '已下架',
+          3: '已冻结',
+          4: '已卖出',
+        }
+        return MAP[val];
+      }
+    },
+
     data() {
       return {
-        imgUrl: this.$imageUrl,
+        imageUrl: this.$imageUrl,
         tabList: [
-          {name: '我发布的', value: 1},
-          {name: '已卖出', value: 2},
-          {name: '已下架', value: 3},
+          {name: '我发布的', value: 0},
+          {name: '已卖出', value: 1},
+          {name: '已下架', value: 2},
         ],
-        curTab: 0,
+        tabCurrent: 0,
         dataList: [],
         pageNum: 1,
+        loadStatus: 0,
         refresherTriggered: false,
 
         isShowDeliverDialog: false,
       }
     },
 
-    async onLoad() {
-      // await this.getList()
+    async onLoad({tab}) {
+      this.tabCurrent = tab ? Number(tab) : 0;
+      await this.getList();
+
+      uni.$on('refreshMyIssueList', () => {
+        this.refreshLish();
+      })
+    },
+
+    onUnload() {
+      uni.$off('refreshMyIssueList');
     },
 
     methods: {
       //获取列表数据
       async getList() {
-        this.$api.post('/xxx/xxxlist', {
+        const statusMap = {
+          0: 1,
+          1: 4,
+          2: 0
+        }
+        this.$api.get('/goods/list', {
           pageNum: this.pageNum,
           pageSize: 10,
+          status: statusMap[this.tabCurrent],
+          userId: this.$store.state.user.userId
         }).then(res => {
           this.loadStatus = 0;
           let list = res.data.records;
@@ -122,18 +160,43 @@
       // 触发下拉刷新
       refresherrefresh(e) {
       	this.refresherTriggered = true;
-      	this.dataList = [];
-      	this.pageNum = 1;
-      	this.getList();
+      	this.refreshLish();
       },
 
-      openDeliver() {
-        this.$refs.deliverDialog.setValue();
+      refreshLish() {
+        this.dataList = [];
+        this.pageNum = 1;
+        this.getList();
+      },
+
+      clickTab(item) {
+        this.tabCurrent = item.value;
+        this.refreshLish();
+      },
+
+      toDetail(id) {
+        this.$navToPage({
+          url: `/pages/goods/detail?id=${id}`
+        })
+      },
+
+      openDeliver(id) {
+        this.$refs.deliverDialog.setValue(id);
         this.isShowDeliverDialog = true;
       }
 
     }
   }
+  // #endif
+  // #ifndef H5
+  import zjDialogDeliver from '@/components/zj-dialog/zj-dialog-deliver.vue';
+
+  export default {
+    components: {
+      zjDialogDeliver
+    },
+  }
+  // #endif
 </script>
 
 <style lang="scss" scoped>