123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365 |
- <template>
- <view class="container clearfix">
- <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading="true"
- :loadingType="5" />
- <template v-else>
- <view class="container-list">
- <view class="empty-container" v-if="showEmpty">
- <image class="empty-container-image"
- src="https://static.caimei365.com/app/img//icon/icon-remarks-empty@2x.png"></image>
- <text class="error-text">暂无任务~</text>
- </view>
- <template v-else>
- <view v-for="(task, index) in taskList" :key="index" :id="task.id" class="task-list"
- @click.stop="handleTaskDetails(task)">
- <view class="list-cell-le">
- <image class="le-image" :src="task.topPic" mode=""></image>
- </view>
- <view class="list-cell-ri">
- <view class="list-cell-top">
- <text>{{ task.title }}</text>
- </view>
- <view class="list-cell-time">{{ task.startTime }} - {{ task.endTime }}</view>
- <view class="list-cell-btn">
- <view class="le-tags">
- <text>奖金:{{ task.reward }}元</text>
- </view>
- <button class="button" @click.stop="handleReceive(task)">领取任务</button>
- </view>
- </view>
- </view>
- <!--加载loadding-->
- <tui-loadmore :visible="loadding" :index="3" type="black" />
- <tui-nomore :visible="!pullUpOn" :backgroundColor="'#F7F7F7'" :text="nomoreText" />
- <!--加载loadding-->
- </template>
- </view>
- <view class="add-btn" @click.stop="handleUse" :style="{ bottom: isIphoneX ? '68rpx' : '34rpx' }"
- >我的任务</view
- >
- </template>
- </view>
- </template>
- <script>
- import { mapState, mapMutations } from 'vuex'
- import authorize from '@/common/config/authorize.js'
- export default {
- data() {
- return {
- isIphoneX: this.$store.state.isIphoneX,
- listQuery: {
- taskType:0,
- serviceProviderId: 0,
- pageNum: 1,
- pageSize: 10
- },
- taskList: [],
- skeletonShow: true,
- showEmpty: false,
- nomoreText: '上拉显示更多',
- hasNextPage: false,
- loadding: false,
- pullUpOn: true,
- pullFlag: true
- }
- },
- onLoad() {},
- computed: {
- ...mapState(['hasLogin', 'userInfo', 'identity', 'isActivity'])
- },
- methods: {
- async initGetStotage() {
- // 初始化
- const userInfo = await this.$api.getStorage()
- this.listQuery.serviceProviderId = userInfo.serviceProviderId ? userInfo.serviceProviderId : 0
- this.getTaskList()
- },
- async getTaskList() {
- // 初始化查询任务列表
- try {
- this.listQuery.pageNum = 1
- const res = await this.SellerService.getTaskList(this.listQuery)
- const data = res.data
- if (data.list && data.list.length > 0) {
- this.showEmpty = false
- this.hasNextPage = data.hasNextPage
- this.taskList = []
- this.taskList = data.list
- this.pullFlag = false
- setTimeout(() => {
- this.pullFlag = true
- }, 500)
- if (this.hasNextPage) {
- this.pullUpOn = false
- this.nomoreText = '上拉显示更多'
- } else {
- if (this.taskList.length < 8) {
- this.pullUpOn = true
- } else {
- this.pullUpOn = false
- this.loadding = false
- this.nomoreText = '已至底部'
- }
- }
- } else {
- this.showEmpty = true
- }
- setTimeout(() => {
- this.skeletonShow = false
- }, 500)
- } catch (e) {
- console.log('获取任务列表失败~')
- }
- },
- async getOnReachBottomData() {
- // 上滑加载分页
- try {
- this.listQuery.pageNum += 1
- const res = await this.SellerService.getTaskList(this.listQuery)
- const data = res.data
- if (data.list && data.list.length > 0) {
- this.hasNextPage = data.hasNextPage
- this.taskList = this.taskList.concat(data.list)
- this.pullFlag = false // 防上拉暴滑
- setTimeout(() => {
- this.pullFlag = true
- }, 500)
- if (this.hasNextPage) {
- this.pullUpOn = false
- this.nomoreText = '上拉显示更多'
- } else {
- this.pullUpOn = false
- this.loadding = false
- this.nomoreText = '已至底部'
- }
- }
- } catch (error) {
- //TODO handle the exception
- this.$util.msg(error.msg, 2000)
- }
- },
- async handleReceive(task) {
- // 点击领取任务
- try {
- const param = { serviceProviderId: this.listQuery.serviceProviderId, taskId: task.taskId }
- await this.SellerService.receiveTask(param)
- this.$util.msg('领取成功', 2000, true, 'success')
- setTimeout(()=>{
- this.$api.navigateTo('/pages/seller/task/task-use')
- },2000)
- } catch (error) {
- //TODO handle the exception
- this.$util.msg(error.msg, 2000)
- }
- },
- // 我的任务
- handleUse(){
- this.$api.navigateTo('/pages/seller/task/task-use')
- },
- // 跳转推广任务详情
- handleTaskDetails(task) {
- const path = `/pages/seller/task/task-details?taskId=${task.taskId}&shareSpid=${this.listQuery.serviceProviderId}`
- this.$api.navigateTo(path)
- }
- },
- onPullDownRefresh() {
- setTimeout(() => {
- this.getTaskList()
- uni.stopPullDownRefresh()
- }, 200)
- },
- onReachBottom() {
- if (this.hasNextPage) {
- this.loadding = true
- this.pullUpOn = true
- this.getOnReachBottomData()
- }
- },
- onShow() {
- this.initGetStotage()
- }
- }
- </script>
- <style lang="scss">
- page {
- background-color: #f7f7f7;
- }
- .container {
- width: 100%;
- height: auto;
- }
- .container-list {
- box-sizing: border-box;
- padding: 24rpx 20rpx;
- .empty-container-image {
- width: 260rpx;
- height: 260rpx;
- margin-top: -300rpx;
- }
- .toIndexPage {
- bottom: 390rpx;
- }
- .task-list {
- width: 100%;
- height: 270rpx;
- margin-bottom: 24rpx;
- box-sizing: border-box;
- padding:15rpx 10rpx;
- background: #FFFFFF;
- border-radius: 16rpx;
- display: flex;
- flex-direction: row;
- overflow: hidden;
- .list-cell-le {
- width: 240rpx;
- height: 240rpx;
- position: relative;
- box-sizing: border-box;
- border: 1px solid #F7F7F7;
- border-radius: 16rpx;
- overflow: hidden;
- .le-image {
- width: 238rpx;
- height: 238rpx;
- display: block;
- }
- }
- .list-cell-ri {
- width: 442rpx;
- height: 100%;
- box-sizing: border-box;
- padding: 0 0 0 20rpx;
- position: relative;
- display: flex;
- flex-direction: column;
- position: relative;
- .ri-icon{
- width: 128rpx;
- height: 128rpx;
- position: absolute;
- top: 10rpx;
- right: 0;
- &.reviewed{
- background: url(https://static.caimei365.com/app/img/icon/icon-verify1@2x.png);
- background-size: cover;
- }
- &.failed{
- background: url(https://static.caimei365.com/app/img/icon/icon-verify2@2x.png);
- background-size: cover;
- }
- &.approved{
- background: url(https://static.caimei365.com/app/img/icon/icon-verify3@2x.png);
- background-size: cover;
- }
- }
- .list-cell-top {
- width: 100%;
- height: 80rpx;
- text-overflow: ellipsis;
- overflow: hidden;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- line-clamp: 2;
- -webkit-box-orient: vertical;
- line-height: 40rpx;
- color: #333333;
- font-size: 24rpx;
- }
- .list-cell-btn {
- width: 100%;
- height: 54rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 35rpx;
- .le-tags{
- height: 54rpx;
- color: #FF5B00;
- text-align: center;
- font-size: 22rpx;
- line-height: 54rpx;
- font-weight: bold;
- }
- .button {
- height: 54rpx;
- padding: 0 25rpx;
- box-sizing: border-box;
- line-height: 54rpx;
- font-size: $font-size-24;
- background: $btn-confirm;
- color: #FFFFFF;
- text-align: center;
- float: right;
- position: relative;
- border-radius: 30rpx;
- margin: 0 0 0 15rpx;
-
- &.share {
- background: #07c160;
- }
-
- &.add{
- background: #999999;
- }
- }
- }
- .list-cell-share {
- width: 60rpx;
- height: 60rpx;
- line-height: 60rpx;
- text-align: center;
- position: absolute;
- right: 0;
- bottom: 0;
- box-sizing: border-box;
- display: block;
- background: transparent;
- border-radius: 0;
- border: 0;
- margin: 0;
- .iconfont {
- font-size: 40rpx;
- color: #07c160;
- }
- }
- .list-cell-time {
- width: 100%;
- height: 58rpx;
- line-height: 58rpx;
- text-align: left;
- font-size: $font-size-20;
- color: #999999;
- }
- }
- }
- }
- .add-btn {
- position: fixed;
- left: 0;
- right: 0;
- bottom: 34rpx;
- z-index: 999;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 350rpx;
- height: 88rpx;
- font-size: $font-size-28;
- line-height: 88rpx;
- color: #ffffff;
- text-align: center;
- background: #07c160;
- border-radius: 44rpx;
- margin: 0 auto;
- }
- </style>
|