task-use.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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="ri-icon" :class="{
  20. reviewed: task.auditStatus == 1,
  21. approved: task.auditStatus == 2,
  22. failed: task.auditStatus == 3
  23. }">
  24. </view>
  25. <view class="list-cell-top">
  26. <text>{{ task.title }}</text>
  27. </view>
  28. <view class="list-cell-time">{{ task.startTime }} - {{ task.endTime }}</view>
  29. <view class="list-cell-btn">
  30. <view class="le-tags">
  31. <text>奖金:{{ task.reward }}元</text>
  32. </view>
  33. <button class="button add" @click.stop="handleAdd(task)"
  34. v-if="task.auditStatus === 0 || task.auditStatus === 3">
  35. {{ task.auditStatus === 3 ? '重新上传' : '上传截图' }}
  36. </button>
  37. <button open-type="share" @tap.native.stop="handleShare($event)" class="button share"
  38. :data-task="task" v-if="task.receiveFlag === 1">
  39. 分享
  40. </button>
  41. </view>
  42. </view>
  43. </view>
  44. <!--加载loadding-->
  45. <tui-loadmore :visible="loadding" :index="3" type="black" />
  46. <tui-nomore :visible="!pullUpOn" :backgroundColor="'#F7F7F7'" :text="nomoreText" />
  47. <!--加载loadding-->
  48. </template>
  49. </view>
  50. </template>
  51. <!-- 弹窗提示 -->
  52. <tui-modal :show="modal" @click="handleClick" @cancel="hideMobel" :content="contentModalText"
  53. :button="modalButton" color="#333" :size="32" shape="circle" :maskClosable="false">
  54. </tui-modal>
  55. </view>
  56. </template>
  57. <script>
  58. import { mapState, mapMutations } from 'vuex'
  59. import authorize from '@/common/config/authorize.js'
  60. export default {
  61. data() {
  62. return {
  63. listQuery: {
  64. taskType: 1,
  65. serviceProviderId: 0,
  66. pageNum: 1,
  67. pageSize: 10
  68. },
  69. taskList: [],
  70. skeletonShow: true,
  71. showEmpty: false,
  72. nomoreText: '上拉显示更多',
  73. hasNextPage: false,
  74. loadding: false,
  75. pullUpOn: true,
  76. pullFlag: true,
  77. isReceiveLoading: false, //领券操作状态
  78. contentModalText: '', //操作文字提示语句
  79. modal: false,
  80. modalButton: [{
  81. text: '取消',
  82. type: 'gray',
  83. plain: true //是否空心
  84. },
  85. {
  86. text: '去升级',
  87. customStyle: {
  88. color: '#fff',
  89. bgColor: 'linear-gradient(90deg, #F28F31 0%, #FF5B00 100%)'
  90. },
  91. plain: false
  92. }
  93. ],
  94. }
  95. },
  96. onLoad() {},
  97. computed: {
  98. ...mapState(['hasLogin', 'userInfo', 'identity', 'isActivity'])
  99. },
  100. methods: {
  101. async initGetStotage() {
  102. // 初始化
  103. const userInfo = await this.$api.getStorage()
  104. this.listQuery.serviceProviderId = userInfo.serviceProviderId ? userInfo.serviceProviderId : 0
  105. this.getTaskList()
  106. },
  107. async getTaskList() {
  108. // 初始化查询任务列表
  109. try {
  110. this.listQuery.pageNum = 1
  111. const res = await this.SellerService.getTaskList(this.listQuery)
  112. const data = res.data
  113. if (data.list && data.list.length > 0) {
  114. this.showEmpty = false
  115. this.hasNextPage = data.hasNextPage
  116. this.taskList = []
  117. this.taskList = data.list
  118. this.pullFlag = false
  119. setTimeout(() => {
  120. this.pullFlag = true
  121. }, 500)
  122. if (this.hasNextPage) {
  123. this.pullUpOn = false
  124. this.nomoreText = '上拉显示更多'
  125. } else {
  126. if (this.taskList.length < 8) {
  127. this.pullUpOn = true
  128. } else {
  129. this.pullUpOn = false
  130. this.loadding = false
  131. this.nomoreText = '已至底部'
  132. }
  133. }
  134. } else {
  135. this.showEmpty = true
  136. }
  137. setTimeout(() => {
  138. this.skeletonShow = false
  139. }, 500)
  140. } catch (e) {
  141. console.log('获取任务列表失败~')
  142. }
  143. },
  144. async getOnReachBottomData() {
  145. // 上滑加载分页
  146. try {
  147. this.listQuery.pageNum += 1
  148. const res = await this.SellerService.getTaskList(this.listQuery)
  149. const data = res.data
  150. if (data.list && data.list.length > 0) {
  151. this.hasNextPage = data.hasNextPage
  152. this.taskList = this.taskList.concat(data.list)
  153. this.pullFlag = false // 防上拉暴滑
  154. setTimeout(() => {
  155. this.pullFlag = true
  156. }, 500)
  157. if (this.hasNextPage) {
  158. this.pullUpOn = false
  159. this.nomoreText = '上拉显示更多'
  160. } else {
  161. this.pullUpOn = false
  162. this.loadding = false
  163. this.nomoreText = '已至底部'
  164. }
  165. }
  166. } catch (error) {
  167. //TODO handle the exception
  168. this.$util.msg(error.msg, 2000)
  169. }
  170. },
  171. // 跳转上传推广截图
  172. handleAdd(task) {
  173. let type = 'add'
  174. if (task.auditStatus === 3) {
  175. type = 'edit'
  176. }
  177. this.$api.navigateTo(
  178. `/pages/seller/task/task-add?type=${type}&taskId=${task.taskId}&serviceProviderId=${this.listQuery.serviceProviderId}`
  179. )
  180. },
  181. // 跳转推广任务详情
  182. handleTaskDetails(task) {
  183. const path =
  184. `/pages/seller/task/task-details?taskId=${task.taskId}&shareSpid=${this.listQuery.serviceProviderId}`
  185. this.$api.navigateTo(path)
  186. },
  187. hideMobel() {
  188. this.modal = false
  189. },
  190. handleClick(e) {
  191. //个人机构跳转升级页面
  192. if (e.index == 1) {
  193. this.$api.navigateTo('/pages/login/apply')
  194. }
  195. this.modal = false
  196. },
  197. handleShare(res) {
  198. //分享
  199. console.log('handleShare')
  200. }
  201. },
  202. onShareAppMessage(res) {
  203. //分享
  204. if (res.from === 'button') {
  205. const task = res.target.dataset.task
  206. const path =
  207. `/pages/seller/task/task-details?taskId=${task.taskId}&shareSpid=${this.listQuery.serviceProviderId}`
  208. return {
  209. title: task.title,
  210. path: path,
  211. imageUrl: task.topPic ? `${task.topPic}` : ''
  212. }
  213. }
  214. },
  215. onPullDownRefresh() {
  216. setTimeout(() => {
  217. this.getTaskList()
  218. uni.stopPullDownRefresh()
  219. }, 200)
  220. },
  221. onReachBottom() {
  222. if (this.hasNextPage) {
  223. this.loadding = true
  224. this.pullUpOn = true
  225. this.getOnReachBottomData()
  226. }
  227. },
  228. onShow() {
  229. // 隐藏右上角分享菜单
  230. uni.hideShareMenu()
  231. this.initGetStotage()
  232. }
  233. }
  234. </script>
  235. <style lang="scss">
  236. page {
  237. background-color: #f7f7f7;
  238. }
  239. .container {
  240. width: 100%;
  241. height: auto;
  242. }
  243. .container-list {
  244. box-sizing: border-box;
  245. padding: 24rpx;
  246. .empty-container-image {
  247. width: 260rpx;
  248. height: 260rpx;
  249. margin-top: -300rpx;
  250. }
  251. .toIndexPage {
  252. bottom: 390rpx;
  253. }
  254. .task-list {
  255. width: 100%;
  256. height: 270rpx;
  257. margin-bottom: 24rpx;
  258. box-sizing: border-box;
  259. padding: 15rpx 10rpx;
  260. background: #FFFFFF;
  261. border-radius: 16rpx;
  262. display: flex;
  263. flex-direction: row;
  264. overflow: hidden;
  265. .list-cell-le {
  266. width: 240rpx;
  267. height: 240rpx;
  268. position: relative;
  269. box-sizing: border-box;
  270. border: 1px solid #F7F7F7;
  271. border-radius: 16rpx;
  272. overflow: hidden;
  273. .le-image {
  274. width: 238rpx;
  275. height: 238rpx;
  276. display: block;
  277. }
  278. }
  279. .list-cell-ri {
  280. width: 442rpx;
  281. height: 100%;
  282. box-sizing: border-box;
  283. padding: 0 0 0 20rpx;
  284. position: relative;
  285. display: flex;
  286. flex-direction: column;
  287. position: relative;
  288. .ri-icon {
  289. width: 128rpx;
  290. height: 128rpx;
  291. position: absolute;
  292. bottom: 5rpx;
  293. left: 0;
  294. &.reviewed {
  295. background: url(https://static.caimei365.com/app/img/icon/icon-verify1@2x.png);
  296. background-size: cover;
  297. }
  298. &.failed {
  299. background: url(https://static.caimei365.com/app/img/icon/icon-verify2@2x.png);
  300. background-size: cover;
  301. }
  302. &.approved {
  303. background: url(https://static.caimei365.com/app/img/icon/icon-verify3@2x.png);
  304. background-size: cover;
  305. }
  306. }
  307. .list-cell-top {
  308. width: 100%;
  309. height: 80rpx;
  310. text-overflow: ellipsis;
  311. overflow: hidden;
  312. display: -webkit-box;
  313. -webkit-line-clamp: 2;
  314. line-clamp: 2;
  315. -webkit-box-orient: vertical;
  316. line-height: 40rpx;
  317. color: #333333;
  318. font-size: 24rpx;
  319. }
  320. .list-cell-btn {
  321. width: 100%;
  322. height: 54rpx;
  323. display: flex;
  324. justify-content: space-between;
  325. align-items: center;
  326. margin-top: 35rpx;
  327. .le-tags {
  328. height: 54rpx;
  329. color: #FF5B00;
  330. text-align: center;
  331. font-size: 22rpx;
  332. line-height: 54rpx;
  333. font-weight: bold;
  334. }
  335. .button {
  336. height: 54rpx;
  337. padding: 0 25rpx;
  338. box-sizing: border-box;
  339. line-height: 54rpx;
  340. font-size: $font-size-24;
  341. background: $btn-confirm;
  342. color: #FFFFFF;
  343. text-align: center;
  344. float: right;
  345. position: relative;
  346. border-radius: 30rpx;
  347. margin: 0 0 0 15rpx;
  348. &.share {
  349. background: #07c160;
  350. }
  351. &.add {
  352. background: #999999;
  353. }
  354. }
  355. }
  356. .list-cell-share {
  357. width: 60rpx;
  358. height: 60rpx;
  359. line-height: 60rpx;
  360. text-align: center;
  361. position: absolute;
  362. right: 0;
  363. bottom: 0;
  364. box-sizing: border-box;
  365. display: block;
  366. background: transparent;
  367. border-radius: 0;
  368. border: 0;
  369. margin: 0;
  370. .iconfont {
  371. font-size: 40rpx;
  372. color: #07c160;
  373. }
  374. }
  375. .list-cell-time {
  376. width: 100%;
  377. height: 58rpx;
  378. line-height: 58rpx;
  379. text-align: left;
  380. font-size: $font-size-20;
  381. color: #999999;
  382. }
  383. }
  384. }
  385. }
  386. </style>