USER-20230908AJ\Administrator 1 tahun lalu
induk
melakukan
6797f0beb3

+ 27 - 2
common/task/task-item.vue

@@ -28,7 +28,7 @@
 							</image>
 							<button class="button-background en_button sys-weight-500 text-color-fff size-28 r-100"
 								style="width: 200rpx;height: 70rpx;line-height: 70rpx;" type="default"
-								hover-class="is-hover" v-else-if="type === 2">领取任务</button>
+								hover-class="is-hover" v-else-if="type === 2" @click.stop="takeTask(index)">领取任务</button>
 							<button class="button-background en_button sys-weight-500 text-color-fff size-28 r-100"
 								style="width: 200rpx;height: 70rpx;line-height: 70rpx;" type="default"
 								hover-class="is-hover" v-else-if="type === 4">去处理</button>
@@ -46,14 +46,19 @@
 			</view>
 			<view class="placeholder sys-list-background-color" v-if="is_bottom"></view>
 		</view>
+    <en-blank v-if="taskList.length<=0"></en-blank>
 	</view>
 </template>
 
 <script>
 	import EnButton from "@/components/en-utils/en-button/en-button.vue";
+  import {takeTask} from "@/api/task";
+  import tools from "@/service/tools";
+  import EnBlank from "@/components/en-utils/en-blank/en-blank.vue";
 
 	export default {
 		components: {
+      EnBlank,
 			EnButton
 		},
 		props: {
@@ -85,15 +90,35 @@
 				type: Boolean,
 				default: false
 			},
+
 		},
 		data() {
 			return {
 				leftImg: ['task-house', 'task-business', 'task-repayment'],
 				iconList: ['task-audit', 'task-do', 'task-stay'],
-				lineColor: ['#DE5847', '#EF8F27', '#0FB160']
+				lineColor: ['#DE5847', '#EF8F27', '#0FB160'],
+        isAjax:false
 			}
 		},
 		methods: {
+      takeTask(index) {
+        if (this.isAjax) {
+          return;
+        }
+        this.isAjax = true;
+        takeTask({
+          'id': this.taskList[index].id
+        }).then((res) => {
+          this.isAjax = false
+          if (res.code === 1) {
+            tools.success(res.msg)
+            // this.taskList.splice(index, 1)
+            this.$emit('takeTask',index)
+          } else {
+            tools.error(res.msg)
+          }
+        })
+      },
 			getIconStatus() {
 				return `/static/img/task/${this.iconList[this.iconStatus]}.png`
 			},

+ 43 - 4
page_task/gain_task/gain_task.vue

@@ -2,11 +2,11 @@
 	<view class="total-page page-box">
 		<Nav :title="'领取任务'" :genre="1" :fixedHeight="110"></Nav>
 		<view class="task-tabs m-t30">
-			<TaskImgTab></TaskImgTab>
+			<TaskImgTab @setProductId="setProductId"></TaskImgTab>
 		</view>
 		<!-- <EnButton is_both></EnButton> -->
 		<EnScroll ref="scroll" :navHeight="110" class="main" @onRefresh="onRefresh" @onScrollBottom="onScrollBottom">
-			<TaskItem :type="2" is_bottom></TaskItem>
+			<TaskItem :type="2" :task-list="taskList" is_bottom @takeTask="setTakeTask"></TaskItem>
 		</EnScroll>
 	</view>
 </template>
@@ -14,6 +14,8 @@
 <script>
 	import TaskItem from "@/common/task/task-item.vue"
 	import TaskImgTab from "@/page_task/module/task_ima_tab.vue"
+  import {getTaskReceiving, takeTask} from "@/api/task";
+  import tools from "@/service/tools";
 
 	export default {
 		components: {
@@ -22,11 +24,46 @@
 		},
 		data() {
 			return {
-
+        taskList: [],
+        page: 1,
+        totalNum: 9999,
+        isAjax: false,
+        productId:0
 			}
 		},
-		methods: {
+    mounted() {
+      this.getTaskReceiving()
+    },
+    methods: {
+      setProductId(productId){
+        console.log('productId:'+productId)
+        this.productId=productId
+        this.startList()
+      },
 			// 下拉刷新
+      startList() {
+        this.taskList = [];
+        this.page = 1
+        this.totalNum = 99999
+        this.getTaskReceiving()
+      },
+      async getTaskReceiving() {
+        if (this.totalNum <= this.taskList.length) {
+          return;
+        }
+        const res = await getTaskReceiving({'page':this.page,'productId':this.productId})
+        if (res.code === 1) {
+          this.totalNum=res.data.totalNum
+          this.taskList.push(...res.data.items)
+          ++this.page
+        }
+      },
+      setTakeTask(index){
+        console.log('index:'+index)
+        this.taskList.splice(index, 1)
+        uni.$emit('updateMemberInfo')
+      },
+
 			onRefresh() {
 				uni.showLoading({
 					title: '数据加载中'
@@ -37,6 +74,7 @@
 						icon: 'none'
 					})
 					this.$refs.scroll.onEndPulling()
+          this.startList()
 				}, 1000)
 				console.log("下拉刷新");
 			},
@@ -45,6 +83,7 @@
 				uni.showLoading({
 					title: '数据加载中'
 				})
+        this.getTaskReceiving()
 				setTimeout(() => {
 					uni.showToast({
 						title: '加载完成',

+ 3 - 2
page_task/module/task_ima_tab.vue

@@ -9,7 +9,7 @@
 					</image>
 					<view class="m-t16 sys-size-24 text-center sys-weight-600"
 						:class="{'default-text':index===current}">
-						{{item.product_name}}
+						{{item.briefness_name}}
 					</view>
 					<!-- <view class="half-circle m-t20" :class="{'half-circle1':current==1}" v-if="current==index"></view> -->
 				</view>
@@ -29,7 +29,7 @@
         navList: [
           {
             id:0,
-            product_name: '全部',
+            briefness_name: '全部',
             product_icon: '/static/img/task/task-all.png'
           }
         ]
@@ -60,6 +60,7 @@
 				// })
 				if (current !== this.current) {
 					this.current = current
+          this.$emit('setProductId',this.navList[current].id)
 				}
 			},
 		}