index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <template>
  2. <view class="container">
  3. <!-- #ifdef H5 -->
  4. <!-- <view style="color: #fff;">
  5. <tn-nav-bar :isBack="false" backgroundColor="#26B3A0" :bottomShadow="false" @rightClick="jumpScoreRed">任务大厅
  6. </tn-nav-bar>
  7. <view :style="{ height: tobheight + 'px' }"></view>
  8. </view> -->
  9. <!-- #endif -->
  10. <view class="content">
  11. <view class="top">
  12. <!-- 方案一 -->
  13. <swiper class="banner" circular :autoplay="true">
  14. <swiper-item v-for="i in bannerList">
  15. <image :src="i.picture
  16. " mode="" @click="handleBannerJump(i.url)"></image>
  17. </swiper-item>
  18. </swiper>
  19. <!-- 方案二 -->
  20. <!-- <u-swiper height="250" radius="15" imgMode="scaleToFill" :list="list3" circular></u-swiper> -->
  21. <view class="searchBox">
  22. <view class="search">
  23. <icon type="search" size="18"></icon>
  24. <icon v-if="searchValue" @click="clearInputValue" class="clear" type="clear" size="16" />
  25. </view>
  26. <uni-easyinput placeholderStyle="fontSize:28rpx" :clearable="false" :inputBorder="false"
  27. v-model="searchValue" placeholder="搜索任务">
  28. </uni-easyinput>
  29. </view>
  30. <view class="line">
  31. </view>
  32. </view>
  33. <view class="keyWordBox" v-if="searchValue">
  34. <view class="taskList">
  35. <view class="ul">
  36. <view class="li" v-for="(item,index) in tuskList2" @click="goDetail(item.id)">
  37. <image :src="item.cover_image?item.cover_image:'../../static/posImg.png'" mode=""></image>
  38. <view class="right">
  39. <view class="title mb30">
  40. <!-- Chat GPT应用场景 -->
  41. {{item.name }}
  42. </view>
  43. <view class="des2 mb30">
  44. <!-- 主要完成应用场景的填写,查找,上传,学习后将收获对open ai的了解更加多元。 -->
  45. {{item.intro }}
  46. </view>
  47. <view class="bottom">
  48. <view class="money">
  49. <text class="yongjin">佣金:</text>¥{{item.task_commission}}
  50. </view>
  51. <view class="btn" @click="goDetail(item.id)">
  52. 立即报名
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <!-- 未搜索关键词时-------- -->
  61. <view class="catBox" v-if="!searchValue && tuskTabList.length!=0">
  62. <view class="taskGrid">
  63. <view class="title">
  64. 任务分类
  65. </view>
  66. <ul>
  67. <li v-for="(item,index) in tuskTabList" @click="jumpPage(item)">
  68. <image :src="item.icon==''?'../../static/posImg.png':item.icon" mode=""></image>
  69. <view class="des" style="font-size: 32rpx;">
  70. {{item.name}}
  71. </view>
  72. </li>
  73. </ul>
  74. </view>
  75. <!-- tab部分 -->
  76. <view class="ct_tab">
  77. <view :class="{ 'ct_active': index == tabCur }" v-for="(item, index) in tabList" :key="index"
  78. class="ct_item" @click="clickCtTab(index)">
  79. <text v-text="item.title"></text>
  80. </view>
  81. </view>
  82. <view v-if="tabCur===0" class="taskList">
  83. <view class="ul">
  84. <view class="li" v-for="(item,index) in tuskList" @click="goDetail(item.id)">
  85. <image :src="item.cover_image?item.cover_image:'../../static/posImg.png'" mode=""></image>
  86. <view class="right">
  87. <view class="title mb30">
  88. <!-- Chat GPT应用场景 -->
  89. {{item.name }}
  90. </view>
  91. <view class="des2 mb30">
  92. <!-- 主要完成应用场景的填写,查找,上传,学习后将收获对open ai的了解更加多元。 -->
  93. {{item.intro }}
  94. </view>
  95. <view class="bottom">
  96. <view class="money">
  97. <text class="yongjin">佣金:</text>¥{{item.task_commission}}
  98. </view>
  99. <view class="btn" @click="goDetail(item.id)">
  100. 立即报名
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. </view>
  106. </view>
  107. <view v-if="tabCur===1" class="taskList">
  108. <view class="ul">
  109. <view class="li" v-for="(item,index) in tuskList" @click="goDetail(item.id)">
  110. <image :src="item.cover_image?item.cover_image:'../../static/posImg.png'" mode=""></image>
  111. <view class="right">
  112. <view class="title mb30">
  113. <!-- Chat GPT应用场景 -->
  114. {{item.name }}
  115. </view>
  116. <view class="des2 mb30">
  117. <!-- 主要完成应用场景的填写,查找,上传,学习后将收获对open ai的了解更加多元。 -->
  118. {{item.intro }}
  119. </view>
  120. <view class="bottom">
  121. <view class="money">
  122. <text class="yongjin">佣金:</text>¥{{item.task_commission}}
  123. </view>
  124. <view class="btn" @click="goDetail(item.id)">
  125. 立即报名
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. </view>
  131. </view>
  132. <view v-if="tabCur===2" class="taskList">
  133. <view class="ul">
  134. <view class="li" v-for="(item,index) in tuskList" @click="goDetail(item.id)">
  135. <image :src="item.cover_image?item.cover_image:'../../static/posImg.png'" mode=""></image>
  136. <view class="right">
  137. <view class="title mb30">
  138. <!-- Chat GPT应用场景 -->
  139. {{item.name }}
  140. </view>
  141. <view class="des2 mb30">
  142. <!-- 主要完成应用场景的填写,查找,上传,学习后将收获对open ai的了解更加多元。 -->
  143. {{item.intro }}
  144. </view>
  145. <view class="bottom">
  146. <view class="money">
  147. <text class="yongjin">佣金:</text>¥{{item.task_commission}}
  148. </view>
  149. <view class="btn" @click="goDetail(item.id)">
  150. 立即报名
  151. </view>
  152. </view>
  153. </view>
  154. </view>
  155. </view>
  156. </view>
  157. </view>
  158. </view>
  159. <empty v-if="tuskList.length==0"></empty>
  160. <u-loadmore v-if="tuskList.length!=0" :status="status" />
  161. <wike-tabbar onTabbar="" isShowAnimate=""></wike-tabbar>
  162. </view>
  163. </template>
  164. <script>
  165. import {
  166. catTab,
  167. taskList
  168. } from '@/api/tusk/index.js'
  169. import {
  170. banner
  171. } from '@/api/index/index.js'
  172. import empty from '@/components/empty/empty.vue'
  173. export default {
  174. components: {
  175. empty
  176. },
  177. data() {
  178. return {
  179. list3: [
  180. 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
  181. 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
  182. 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
  183. ],
  184. tuskTabList: ['直播任务', '填写任务', '观察任务', '学习任务'],
  185. tobheight: 45,
  186. searchValue: '',
  187. tabCur: 0,
  188. tabList: [{
  189. title: '所有任务',
  190. }, {
  191. title: '今日任务',
  192. }, {
  193. title: '热门任务',
  194. }],
  195. bannerList: [],
  196. tuskList: [],
  197. tuskList2: [],
  198. timer: null,
  199. page: 1,
  200. pagesize: 10,
  201. totalElements: '',
  202. // loadstatus: "noMore"
  203. status: 'nomore',
  204. };
  205. },
  206. computed: {
  207. },
  208. watch: {
  209. searchValue(n, o) {
  210. if (this.tabCur) {
  211. this.tabCur = 0
  212. }
  213. this.handleSearch(n.trim())
  214. }
  215. },
  216. async onLoad() {
  217. if (!uni.getStorageSync('token')) {
  218. uni.redirectTo({
  219. url: '/pages/user/signin'
  220. })
  221. }
  222. let res1 = await banner()
  223. console.log('任务大厅轮播图返回值', res1);
  224. if (res1.code == 0) {
  225. this.bannerList = res1.data
  226. }
  227. let res = await catTab({
  228. // task_id: 1
  229. })
  230. if (res.code == 0) {
  231. this.tuskTabList = res.data
  232. this.totalElements = res.total
  233. }
  234. console.log('任务分类导航返回值', res);
  235. },
  236. async onReachBottom() {
  237. let allTotal = this.page * this.pagesize
  238. if (allTotal < this.totalElements) {
  239. console.log('onReachBottom()------------------');
  240. this.page++;
  241. this.status = "loading"
  242. let parms = {
  243. page: this.page,
  244. per_page: this.pagesize,
  245. name: '',
  246. type: ''
  247. }
  248. if (this.searchValue) {
  249. parms.name = this.searchValue
  250. } else if (this.tabCur == 0) {
  251. // parms.name=this.searchValue
  252. } else if (this.tabCur == 1) {
  253. parms.type = 'day'
  254. } else if (this.tabCur == 2) {
  255. parms.type = 'hot'
  256. }
  257. console.log('每次传递的参数', parms);
  258. let res = await taskList(parms)
  259. if (res.code == 0) {
  260. if (this.searchValue) {
  261. this.tuskList2 = [...this.tuskList2, ...res.data.data]
  262. } else {
  263. this.tuskList = [...this.tuskList, ...res.data.data]
  264. }
  265. this.status = "nomore"
  266. }
  267. } else {
  268. this.status = "nomore"
  269. }
  270. },
  271. onReady() {
  272. },
  273. onShow() {
  274. if (uni.getStorageSync('clickStudyBtn')) {
  275. uni.removeStorageSync('clickStudyBtn')
  276. }
  277. if (uni.getStorageSync('myScoreId')) {
  278. uni.removeStorageSync('myScoreId')
  279. }
  280. this.fetchTuskList()
  281. },
  282. onUnload() {
  283. },
  284. methods: {
  285. handleBannerJump(url) {
  286. // url = url.replace(/https/, 'http')
  287. console.log('url.............', url);
  288. if (url) {
  289. window.open(url)
  290. }
  291. },
  292. handleSearch(searchWord) {
  293. // if (this.timer) {
  294. // this.timer = null
  295. // return
  296. // }
  297. clearTimeout(this.timer)
  298. this.timer = setTimeout(() => {
  299. console.log('搜索传递的关键词参数', {
  300. name: searchWord
  301. });
  302. this.fetchTuskList(searchWord)
  303. }, 1500)
  304. console.log('this.timer', this.timer)
  305. },
  306. async fetchTuskList(name = '', type = '', page = 1, per_page = 10) {
  307. this.page = 1
  308. let ress = await taskList({
  309. name,
  310. type,
  311. page,
  312. per_page
  313. })
  314. if (ress.code == 0) {
  315. this.totalElements = ress.data.total
  316. if (this.searchValue) {
  317. // this.page = 1
  318. this.tuskList2 = ress.data.data
  319. } else {
  320. this.tuskList = ress.data.data
  321. }
  322. }
  323. console.log('任务列表返回值', ress);
  324. },
  325. clearInputValue() {
  326. this.searchValue = ''
  327. },
  328. jumpPage(item) {
  329. console.log('任务分类导航跳转地址', item);
  330. if (item.url !== '') {
  331. uni.navigateTo({
  332. url: item.url + '&catName=' + item.name
  333. })
  334. }
  335. // uni.navigateTo({
  336. // url: 'pages/tusk/tuskCat/index?catId=' + item.name
  337. // })
  338. },
  339. goDetail(id) {
  340. uni.navigateTo({
  341. url: '/pages/tusk/tuskDetail/index?id=' + id
  342. })
  343. },
  344. clickCtTab(ctCur) {
  345. this.tabCur = ctCur
  346. if (ctCur == 0) {
  347. this.fetchTuskList('', '')
  348. } else if (ctCur == 2) {
  349. this.fetchTuskList('', 'hot')
  350. } else {
  351. this.fetchTuskList('', 'day')
  352. }
  353. console.log('点击了--->' + this.tabCur)
  354. },
  355. goScoreDetail() {
  356. uni.navigateTo({
  357. url: '/pages/index/scoreDetail/index'
  358. })
  359. }
  360. }
  361. };
  362. </script>
  363. <style lang="scss" scoped>
  364. @import './index.scss';
  365. </style>