浏览代码

Merge branch 'developer' of http://git.caimei365.com/zhengjinyi/caimei-applets-mcare into developer

zhengjinyi 2 年之前
父节点
当前提交
f6588ca980

+ 1 - 1
pages/goods/components/procurement-btn.vue

@@ -7,7 +7,7 @@
         fontSize,
         borderRadius: border ? borderRadius : '',
         lineHeight: height
-    }">
+    }" @click="$emit('click')">
         <span><slot></slot></span>
     </button>
 </template>

+ 4 - 4
pages/goods/components/procurement_card.vue

@@ -1,12 +1,12 @@
 <template>
-    <view class="card" :style="{ padding: (procurementStatus('isAllTab') || procurementStatus('isDelFlag')) ? '32rpx 32rpx 0 32rpx' : '32rpx' }">
+    <view class="card">
         <view class="card_title">
             <view class="card_user_icon">发起者</view>
             <view class="card_user">{{ procuretInfo.clubName }}</view>
         </view>
         <view class="card_time">{{ procuretInfo.saveTime }}</view>
         <view class="card_content">
-            <image class="card_content_img" src="" mode="aspectFill"></image>
+            <image class="card_content_img" :src="procuretInfo.productImage" mode="aspectFill"></image>
             <view class="card_content_title">{{ procuretInfo.productName }}</view>
         </view>
         <view class="card_form">
@@ -36,7 +36,7 @@
                 <view class="foot_exit" @click="procurementExit">退出</view>
             </view>
         </view>
-        <view class="card_foot_2" @click="procurementAdd">
+        <view class="card_foot_2" @click="procurementAdd" v-if="procurementStatus('isInvolved')">
             <view class="foot_title">我要参与</view>
         </view>
         <view class="card_foot_2" v-if="procurementStatus('isAllTab') && procurementStatus('isInvolved')"><view class="foot_title_2">您已参与</view></view>
@@ -121,7 +121,7 @@ export default {
     border-radius: 8rpx;
     width: 100%;
     background: #fff;
-    padding: 32rpx 32rpx 0 32rpx;
+    padding: 32rpx;
     box-sizing: border-box;
     position: relative;
 }

+ 69 - 10
pages/goods/components/upload.vue

@@ -1,21 +1,55 @@
 <template>
-    <view class="upload" @click="handlerUpload">
-        <input type="file" ref='upload_inp' class="upload_inp">
+    <view>
+        <view class="upload" @click="handlerUpload" v-if="imageUrl==null || imageUrl == ''">
+            <text class="iconfont icon-shangchuantupian"></text>
+            <text>选择图片</text>
+        </view>
+        <view class="upload_image" v-else>
+            <image :src="imageUrl" style="width: 100%;height: 100%;" mode="aspectFill"></image>
+            <view class="upload-del" @click="handleDelete">
+            	<text class="iconfont icon-shanchu"></text>
+            </view>
+        </view>
     </view>
 </template>
 
 <script>
+    import { uploadFileImage } from '@/services/public.js'
     export default {
+        props: {
+            imageData: {
+                type: String,
+                default: () => ''
+            }
+        },
         data() {
-            return {}
+            return {
+                imageUrl: '',
+            }
         },
-        methods: {
-            handlerUpload() {
-                const upload = this.$refs.upload_inp
-                upload.onclick = function (e) {
-                    console.log(e)
+        watch: {
+            imageData(val) {
+                if (val) {
+                    console.log(val)
+                    this.imageUrl = val
                 }
             }
+        },
+        methods: {
+            async handlerUpload() {
+                try{
+                    const {data} = await uploadFileImage()
+                    this.imageUrl = JSON.parse(data).data
+                    this.$emit('uploadImg', JSON.parse(data).data)
+                    console.log(this.imageUrl)
+                }catch(error){
+                    console.log(error)
+                }
+            },
+            handleDelete() {
+                this.imageUrl = ''
+                this.$emit('uploadDel', '')
+            },
         }
     }
 </script>
@@ -26,8 +60,33 @@
         height: 210rpx;
         border-radius: 6rpx 6rpx 6rpx 6rpx;
         border: 1rpx dotted #B2B2B2;
+        display: flex;
+        align-items: center;
+        flex-direction: column;
+        font-size: 24rpx;
+        color: #B2B2B2;
+        justify-content: space-around;
+        padding: 40rpx 56rpx;
+        box-sizing: border-box;
+        white-space: nowrap;
     }
-    .upload_inp {
-        display: none;
+    .upload_image {
+        width: 210rpx;
+        height: 210rpx;
+        border: 1rpx dotted #B2B2B2;
+        position: relative;
+        .upload-del {
+        	width: 40rpx;
+        	height: 40rpx;
+        	position: absolute;
+        	top: -20rpx;
+        	right: -20rpx;
+        	line-height: 40rpx;
+        	text-align: center;
+        	.iconfont {
+        		font-size: $font-size-40;
+        		color: #F85050;
+        	}
+        }
     }
 </style>

+ 1 - 1
pages/goods/good-activity.vue

@@ -15,7 +15,7 @@
         ></tui-skeleton>
         <view v-else>
             <view class="img_big" v-if="active.activeType == '2'" @click="activeProducts">
-                <image style="width: 100%;height: 100%;" :src="active.activeImageVos[0]" mode="aspectFill"></image>
+                <image style="width: 100%;height: 100%;" :src="active.activeImageVos[0].image" mode="aspectFill"></image>
             </view>
             <view class="special_all" v-if="active.activeType == '3'">
                 <SpecialItem v-for="(item, index) in active.activeImageVos" :key="index" :activeImage="item" />

+ 60 - 35
pages/goods/procurement.vue

@@ -75,10 +75,12 @@
                 </form>
             </view>
         </tui-bottom-popup>
-        <!--加载loadding-->
-        <tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
-        <!-- <tui-nomore :visible="!pullUpOn" :backgroundColor="'#F7F7F7'" :text="nomoreText"></tui-nomore> -->
-        <!--加载loadding-->
+        <view :style="{marginTop: procurementList.length > 0 ? '0' : '88rpx'}">
+            <!--加载loadding-->
+            <tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
+            <tui-nomore :visible="!pullUpOn" :backgroundColor="'#F7F7F7'" :text="nomoreText"></tui-nomore>
+            <!--加载loadding-->
+        </view>
     </view>
 </template>
 
@@ -128,37 +130,37 @@ export default {
             // 组件传递集采需求
             proDataInfo: {},
             popupShow: false, // 底部上移栏
-            loadding: false, // 下拉刷新
-            pullUpOn: false, // 下拉刷新
+            loadding: true, // 下拉刷新
+            pullUpOn: true, // 下拉刷新
             // 分页参数
             pageInfo: {
                 pageNo: 1,
                 pageSize: 10
             },
+            // 我参与的数据请求
+            participate: {
+                userId: '',
+                procurementType: 0,
+            },
             // 所有数据
-            procurementList: [
-                {
-                    id: 1,
-                    userId: 2,
-                    productImage: '',
-                    productName: '测试',
-                    price: 1000,
-                    number: 1000,
-                    saveTime: '2023-1-2',
-                    createUserId: 33,
-                    isAchieve: 0,
-                    delFlag: 0,
-                    clubName: '测试机构',
-                    isInvolved: 0
-                }
-            ], 
+            procurementList: [], 
             // 下拉刷新
-            nomoreText: '已经被掏空了~'
+            nomoreText: '已经被掏空了~',
+            userInfo: {},
+            isLastPage: false, // 是否是最后一页
         }
     },
     watch: {
         currentTab(val) {
-            if (val) {
+            this.loadding = true
+            this.pullUpOn = true
+            if (val>0) {
+                this.participate.procurementType = --val
+                this.procurementTabChange()
+            } else {
+                this.isLastPage = false
+                this.pageInfo.pageNo = 1
+                this.procurementAllList()
             }
         }
     },
@@ -167,13 +169,18 @@ export default {
         ...mapState(['hasLogin'])
     },
     onShow() {
+        // if (this.hasLogin) {
+            this.userInfo = uni.getStorageSync('userInfo')
+            this.pageInfo.userId = this.userInfo.userId
+            this.participate.userId = this.userInfo.userId
+            this.procurementAllList()
+        // } else {
+        //     this.$api.redirectTo('/pages/login/login')
+        // }
+    },
+    onReachBottom() {
+        this.pageInfo.pageNo+=1
         this.procurementAllList()
-        if (this.hasLogin) {
-            this.skeletonShow = false
-        } else {
-            // this.$api.redirectTo('/pages/login/login')
-            this.skeletonShow = false
-        }
     },
     methods: {
         // tab 切换
@@ -218,13 +225,31 @@ export default {
          */
         // 全部集采
         async procurementAllList() {
-            try {
-                const data = await this.ProcurementService.procurementAllList(this.pageInfo)
-                this.procurementList = data.list
-            } catch (error) {
+            if (!this.isLastPage) {
+                try {
+                    const {data} = await this.ProcurementService.procurementAllList(this.pageInfo)
+                    this.procurementList = [...this.procurementList, ...data.list]
+                    this.isLastPage = data.isLastPage
+                    this.loadding = !data.isLastPage
+                    this.pullUpOn = !data.isLastPage
+                    this.skeletonShow = false
+                } catch (error) {
+                    console.log(error)
+                }
+            }
+        },
+        // 我参与的 | 我发起的
+        async procurementTabChange() {
+            try{
+                const {data} = await this.ProcurementService.procurementTabChange(this.participate)
+                this.procurementList = data
+                this.loadding = false
+                this.pullUpOn = false
+                this.skeletonShow = false
+            }catch(error){
                 console.log(error)
             }
-        }
+        },
     }
 }
 </script>

+ 81 - 18
pages/goods/procurementAdd.vue

@@ -1,36 +1,35 @@
 <template>
     <view class="release">
-        <uni-forms>
-            <uni-forms-item label="申请人" name="Name">
-                <uni-easyinput v-model="form.Name" placeholder="请输入申请人" />
-            </uni-forms-item>
-            <!-- <view class="uni-form-item uni-column">
+        <form>
+            <view class="uni-form-item uni-column">
                 <view class="title">商品图片</view>
                 <view class="uploadComp">
-                    <proUpload />
+                    <proUpload @uploadDel='uploadDel' @uploadImg='uploadImg'/>
                 </view>
             </view>
             <view class="uni-form-item uni-column">
                 <view class="title"><span>*</span>商品名称</view>
                 <view>
-                    <input class="uni-input" focus placeholder="自动获得焦点" v-model='formData.productName' />
+                    <input class="uni-input" focus placeholder="请输入想要采购的商品名称" v-model='formData.productName' />
+                    <!-- <small>请输入商品名称</small> -->
                 </view>
             </view>
             <view class="uni-form-item uni-column">
                 <view class="title"><span>*</span>期望单价</view>
                 <view>
-                    <input class="uni-input" focus placeholder="自动获得焦点" v-model="formData.price" />
+                    <input class="uni-input" focus placeholder="请输入您对商品的期望单价" v-model="formData.price" />
                 </view>
             </view>
             <view class="uni-form-item uni-column">
                 <view class="title"><span>*</span>采购数量</view>
                 <view>
-                    <input class="uni-input" focus placeholder="自动获得焦点" v-model="formData.number" />
+                    <input class="uni-input" focus placeholder="请输入您的采购数量" v-model="formData.number" />
                 </view>
-            </view> -->
-        </uni-forms>
+            </view>
+        </form>
         <view class="release_btn">
-            <proBtn width="600rpx" height="90rpx" background='#E2E2E2' color='#999999' fontSize='32rpx' @click="handlerSave">发布</proBtn>
+            <proBtn width="600rpx" v-if='isActive' @click="handlerSave" height="90rpx" background='#F3B574' color='#FFFFFF' fontSize='32rpx'>发布</proBtn>
+            <proBtn width="600rpx" height="90rpx" v-else background='#E2E2E2' color='#999999' fontSize='32rpx'>发布</proBtn>
         </view>
     </view>
 </template>
@@ -38,6 +37,7 @@
 <script>
     import proBtn from './components/procurement-btn.vue'
     import proUpload from './components/upload.vue'
+    import {mapState} from 'vuex'
     export default {
         components: {
             proUpload,
@@ -47,20 +47,83 @@
             return {
                 // 发布需求
                 formData: {
-                    userId: 1,
+                    userId: 0,
                     productImage: '',
                     productName: '',
                     price: '',
-                    number: ''
-                }
+                    number: '',
+                    userName: ''
+                },
+                userInfo: {}, // 用户详情
+                isActive: false
+            }
+        },
+        watch: {
+            'formData.productName': {
+                handler() {
+                    this.activeBtn()
+                },
+                deep: true
+            },
+            'formData.price': {
+                handler() {
+                    this.activeBtn()
+                },
+                deep: true
+            },
+            'formData.number': {
+                handler() {
+                    this.activeBtn()
+                },
+                deep: true
+            }
+        },
+        onLoad(options) {
+            if (options.id) {
+                
             }
         },
-        onLoad(e) {},
-        onShow() {},
+        mounted() {
+            this.userInfo = uni.getStorageSync('userInfo')
+            this.formData.userId = this.userInfo.userId
+            this.formData.userName = this.userInfo.name
+        },
         methods: {
+            // 发布按钮
+            activeBtn() {
+                if (this.formData.productName === '' || this.formData.price === ''|| this.formData.number === '') {
+                    this.isActive = false
+                } else {
+                    this.isActive = true
+                }
+            },
+            // 图片上传
+            uploadImg(url) {
+                if (url !== '' || url !== null) {
+                    this.formData.productImage = url
+                }
+            },
+            // 图片删除
+            uploadDel(e) {
+                this.formData.productImage = e
+            },
             // submit 发布
-            handlerSave() {
+            async handlerSave() {
                 console.log(this.formData)
+                try{
+                    const data = await this.ProcurementService.procurementSave(this.formData)
+                    console.log(data)
+                }catch(error){
+                    console.log(error)
+                }
+            },
+            // 集采详情
+            async handlerDetail(id) {
+                try{
+                    const data = await this.ProcurementService.procurementSave()
+                }catch(e){
+                    //TODO handle the exception
+                }
             },
         },
     }

+ 1 - 1
services/procurement.service.js

@@ -36,7 +36,7 @@ export default class ProcurementService {
      */
     procurementTabChange(data={}) {
         return this.AjaxService.get({
-            url: '/commodity/procurement/detail',
+            url: '/commodity/procurement/procurement',
             data,
             isLoading: false,
         })