task.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <view class="container clearfix">
  3. <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading="true"
  4. :loadingType="5" />
  5. <template v-else>
  6. <view class="container-list">
  7. <view class="empty-container" v-if="showEmpty">
  8. <image class="empty-container-image"
  9. src="https://static.caimei365.com/app/img//icon/icon-remarks-empty@2x.png"></image>
  10. <text class="error-text">暂无任务~</text>
  11. </view>
  12. <template v-else>
  13. <view v-for="(task, index) in taskList" :key="index" :id="task.id" class="task-list"
  14. @click.stop="handleTaskDetails(task)">
  15. <view class="list-cell-le">
  16. <image class="le-image" :src="task.topPic" mode=""></image>
  17. </view>
  18. <view class="list-cell-ri">
  19. <view class="list-cell-top">
  20. <text>{{ task.title }}</text>
  21. </view>
  22. <view class="list-cell-time">{{ task.startTime }} - {{ task.endTime }}</view>
  23. <view class="list-cell-btn">
  24. <view class="le-tags">
  25. <text>奖金:{{ task.reward }}元</text>
  26. </view>
  27. <button class="button" @click.stop="handleReceive(task)">领取任务</button>
  28. </view>
  29. </view>
  30. </view>
  31. <!--加载loadding-->
  32. <tui-loadmore :visible="loadding" :index="3" type="black" />
  33. <tui-nomore :visible="!pullUpOn" :backgroundColor="'#F7F7F7'" :text="nomoreText" />
  34. <!--加载loadding-->
  35. </template>
  36. </view>
  37. <view class="add-btn" @click.stop="handleUse" :style="{ bottom: isIphoneX ? '68rpx' : '34rpx' }"
  38. >我的任务</view
  39. >
  40. </template>
  41. </view>
  42. </template>
  43. <script>
  44. import { mapState, mapMutations } from 'vuex'
  45. import authorize from '@/common/config/authorize.js'
  46. export default {
  47. data() {
  48. return {
  49. isIphoneX: this.$store.state.isIphoneX,
  50. listQuery: {
  51. taskType:0,
  52. serviceProviderId: 0,
  53. pageNum: 1,
  54. pageSize: 10
  55. },
  56. taskList: [],
  57. skeletonShow: true,
  58. showEmpty: false,
  59. nomoreText: '上拉显示更多',
  60. hasNextPage: false,
  61. loadding: false,
  62. pullUpOn: true,
  63. pullFlag: true
  64. }
  65. },
  66. onLoad() {},
  67. computed: {
  68. ...mapState(['hasLogin', 'userInfo', 'identity', 'isActivity'])
  69. },
  70. methods: {
  71. async initGetStotage() {
  72. // 初始化
  73. const userInfo = await this.$api.getStorage()
  74. this.listQuery.serviceProviderId = userInfo.serviceProviderId ? userInfo.serviceProviderId : 0
  75. this.getTaskList()
  76. },
  77. async getTaskList() {
  78. // 初始化查询任务列表
  79. try {
  80. this.listQuery.pageNum = 1
  81. const res = await this.SellerService.getTaskList(this.listQuery)
  82. const data = res.data
  83. if (data.list && data.list.length > 0) {
  84. this.showEmpty = false
  85. this.hasNextPage = data.hasNextPage
  86. this.taskList = []
  87. this.taskList = data.list
  88. this.pullFlag = false
  89. setTimeout(() => {
  90. this.pullFlag = true
  91. }, 500)
  92. if (this.hasNextPage) {
  93. this.pullUpOn = false
  94. this.nomoreText = '上拉显示更多'
  95. } else {
  96. if (this.taskList.length < 8) {
  97. this.pullUpOn = true
  98. } else {
  99. this.pullUpOn = false
  100. this.loadding = false
  101. this.nomoreText = '已至底部'
  102. }
  103. }
  104. } else {
  105. this.showEmpty = true
  106. }
  107. setTimeout(() => {
  108. this.skeletonShow = false
  109. }, 500)
  110. } catch (e) {
  111. console.log('获取任务列表失败~')
  112. }
  113. },
  114. async getOnReachBottomData() {
  115. // 上滑加载分页
  116. try {
  117. this.listQuery.pageNum += 1
  118. const res = await this.SellerService.getTaskList(this.listQuery)
  119. const data = res.data
  120. if (data.list && data.list.length > 0) {
  121. this.hasNextPage = data.hasNextPage
  122. this.taskList = this.taskList.concat(data.list)
  123. this.pullFlag = false // 防上拉暴滑
  124. setTimeout(() => {
  125. this.pullFlag = true
  126. }, 500)
  127. if (this.hasNextPage) {
  128. this.pullUpOn = false
  129. this.nomoreText = '上拉显示更多'
  130. } else {
  131. this.pullUpOn = false
  132. this.loadding = false
  133. this.nomoreText = '已至底部'
  134. }
  135. }
  136. } catch (error) {
  137. //TODO handle the exception
  138. this.$util.msg(error.msg, 2000)
  139. }
  140. },
  141. async handleReceive(task) {
  142. // 点击领取任务
  143. try {
  144. const param = { serviceProviderId: this.listQuery.serviceProviderId, taskId: task.taskId }
  145. await this.SellerService.receiveTask(param)
  146. this.$util.msg('领取成功', 2000, true, 'success')
  147. setTimeout(()=>{
  148. this.$api.navigateTo('/pages/seller/task/task-use')
  149. },2000)
  150. } catch (error) {
  151. //TODO handle the exception
  152. this.$util.msg(error.msg, 2000)
  153. }
  154. },
  155. // 我的任务
  156. handleUse(){
  157. this.$api.navigateTo('/pages/seller/task/task-use')
  158. },
  159. // 跳转推广任务详情
  160. handleTaskDetails(task) {
  161. const path = `/pages/seller/task/task-details?taskId=${task.taskId}&shareSpid=${this.listQuery.serviceProviderId}`
  162. this.$api.navigateTo(path)
  163. }
  164. },
  165. onPullDownRefresh() {
  166. setTimeout(() => {
  167. this.getTaskList()
  168. uni.stopPullDownRefresh()
  169. }, 200)
  170. },
  171. onReachBottom() {
  172. if (this.hasNextPage) {
  173. this.loadding = true
  174. this.pullUpOn = true
  175. this.getOnReachBottomData()
  176. }
  177. },
  178. onShow() {
  179. this.initGetStotage()
  180. }
  181. }
  182. </script>
  183. <style lang="scss">
  184. page {
  185. background-color: #f7f7f7;
  186. }
  187. .container {
  188. width: 100%;
  189. height: auto;
  190. }
  191. .container-list {
  192. box-sizing: border-box;
  193. padding: 24rpx 20rpx;
  194. .empty-container-image {
  195. width: 260rpx;
  196. height: 260rpx;
  197. margin-top: -300rpx;
  198. }
  199. .toIndexPage {
  200. bottom: 390rpx;
  201. }
  202. .task-list {
  203. width: 100%;
  204. height: 270rpx;
  205. margin-bottom: 24rpx;
  206. box-sizing: border-box;
  207. padding:15rpx 10rpx;
  208. background: #FFFFFF;
  209. border-radius: 16rpx;
  210. display: flex;
  211. flex-direction: row;
  212. overflow: hidden;
  213. .list-cell-le {
  214. width: 240rpx;
  215. height: 240rpx;
  216. position: relative;
  217. box-sizing: border-box;
  218. border: 1px solid #F7F7F7;
  219. border-radius: 16rpx;
  220. overflow: hidden;
  221. .le-image {
  222. width: 238rpx;
  223. height: 238rpx;
  224. display: block;
  225. }
  226. }
  227. .list-cell-ri {
  228. width: 442rpx;
  229. height: 100%;
  230. box-sizing: border-box;
  231. padding: 0 0 0 20rpx;
  232. position: relative;
  233. display: flex;
  234. flex-direction: column;
  235. position: relative;
  236. .ri-icon{
  237. width: 128rpx;
  238. height: 128rpx;
  239. position: absolute;
  240. top: 10rpx;
  241. right: 0;
  242. &.reviewed{
  243. background: url(https://static.caimei365.com/app/img/icon/icon-verify1@2x.png);
  244. background-size: cover;
  245. }
  246. &.failed{
  247. background: url(https://static.caimei365.com/app/img/icon/icon-verify2@2x.png);
  248. background-size: cover;
  249. }
  250. &.approved{
  251. background: url(https://static.caimei365.com/app/img/icon/icon-verify3@2x.png);
  252. background-size: cover;
  253. }
  254. }
  255. .list-cell-top {
  256. width: 100%;
  257. height: 80rpx;
  258. text-overflow: ellipsis;
  259. overflow: hidden;
  260. display: -webkit-box;
  261. -webkit-line-clamp: 2;
  262. line-clamp: 2;
  263. -webkit-box-orient: vertical;
  264. line-height: 40rpx;
  265. color: #333333;
  266. font-size: 24rpx;
  267. }
  268. .list-cell-btn {
  269. width: 100%;
  270. height: 54rpx;
  271. display: flex;
  272. justify-content: space-between;
  273. align-items: center;
  274. margin-top: 35rpx;
  275. .le-tags{
  276. height: 54rpx;
  277. color: #FF5B00;
  278. text-align: center;
  279. font-size: 22rpx;
  280. line-height: 54rpx;
  281. font-weight: bold;
  282. }
  283. .button {
  284. height: 54rpx;
  285. padding: 0 25rpx;
  286. box-sizing: border-box;
  287. line-height: 54rpx;
  288. font-size: $font-size-24;
  289. background: $btn-confirm;
  290. color: #FFFFFF;
  291. text-align: center;
  292. float: right;
  293. position: relative;
  294. border-radius: 30rpx;
  295. margin: 0 0 0 15rpx;
  296. &.share {
  297. background: #07c160;
  298. }
  299. &.add{
  300. background: #999999;
  301. }
  302. }
  303. }
  304. .list-cell-share {
  305. width: 60rpx;
  306. height: 60rpx;
  307. line-height: 60rpx;
  308. text-align: center;
  309. position: absolute;
  310. right: 0;
  311. bottom: 0;
  312. box-sizing: border-box;
  313. display: block;
  314. background: transparent;
  315. border-radius: 0;
  316. border: 0;
  317. margin: 0;
  318. .iconfont {
  319. font-size: 40rpx;
  320. color: #07c160;
  321. }
  322. }
  323. .list-cell-time {
  324. width: 100%;
  325. height: 58rpx;
  326. line-height: 58rpx;
  327. text-align: left;
  328. font-size: $font-size-20;
  329. color: #999999;
  330. }
  331. }
  332. }
  333. }
  334. .add-btn {
  335. position: fixed;
  336. left: 0;
  337. right: 0;
  338. bottom: 34rpx;
  339. z-index: 999;
  340. display: flex;
  341. align-items: center;
  342. justify-content: center;
  343. width: 350rpx;
  344. height: 88rpx;
  345. font-size: $font-size-28;
  346. line-height: 88rpx;
  347. color: #ffffff;
  348. text-align: center;
  349. background: #07c160;
  350. border-radius: 44rpx;
  351. margin: 0 auto;
  352. }
  353. </style>