task-list.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <view class="task-list-container">
  3. <view class="task-list-header">
  4. <text class="task-list-title">做任务赚积分</text>
  5. </view>
  6. <!-- 加载状态 -->
  7. <view v-if="loading" class="task-list-loading">
  8. <u-loading-icon text="加载中..." mode="circle"></u-loading-icon>
  9. </view>
  10. <!-- 任务数据 -->
  11. <view v-else-if="taskData && taskData.length > 0">
  12. <view class="task-list">
  13. <view
  14. v-for="(task,index) in taskData"
  15. :key="index"
  16. class="task-item">
  17. <view class="task-item-left">
  18. <view class="task-icon">
  19. <ImageItem :src="getTaskIcon(task.taskName)" />
  20. </view>
  21. <view class="task-info">
  22. <view class="task-name">{{ task.taskName }}</view>
  23. <view class="task-reward">
  24. <ImageItem src="/static/points/point.png"/>
  25. <text>+{{ task.rewardPoints }}</text>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="task-item-right">
  30. <text class="progress-text">{{ task.completedCount }}/{{ task.triggerValue }}</text>
  31. <button
  32. :class="Number(task.completedCount) >= Number(task.triggerValue) ? 'task-btn' : 'no-task-btn'"
  33. @click.stop="handleTask(task)"
  34. :disabled="Number(task.completedCount) >= Number(task.triggerValue)">
  35. {{Number(task.completedCount) >= Number(task.triggerValue) ? '已完成' : '去完成' }}
  36. </button>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="more-tasks" @click="handleMoreTasks">赚更多积分 ></view>
  41. </view>
  42. <!-- 空状态 -->
  43. <view v-else class="task-list-empty">暂无任务活动</view>
  44. </view>
  45. </template>
  46. <script>
  47. import ImageItem from "@/components/swiper/components/image.vue";
  48. import { handleServiceShare } from '@/utils/share'
  49. export default {
  50. components: { ImageItem },
  51. props: {
  52. taskData: {
  53. type: Array,
  54. default: () => []
  55. },
  56. loading: {
  57. type: Boolean,
  58. default: false
  59. }
  60. },
  61. data() {
  62. return {
  63. // 任务类型配置
  64. taskConfig: {
  65. order: {
  66. icon: '/static/points/task_order.png',
  67. action: this.handleOrderTask
  68. },
  69. merchant: {
  70. icon: '/static/points/task_shop.png',
  71. action: this.handleMerchantTask
  72. },
  73. dynamic: {
  74. icon: '/static/points/task_trend.png',
  75. action: this.handleDynamicTask
  76. },
  77. service: {
  78. icon: '/static/points/task_wx.png',
  79. action: this.handleServiceTask
  80. },
  81. recharge: {
  82. icon: '/static/points/task_account.png',
  83. action: this.handleRechargeTask
  84. }
  85. }
  86. }
  87. },
  88. methods: {
  89. // 获取任务图标
  90. getTaskIcon(taskName) {
  91. if (taskName.includes('订单')) return this.taskConfig.order.icon;
  92. if (taskName.includes('商户')) return this.taskConfig.merchant.icon;
  93. if (taskName.includes('动态')) return this.taskConfig.dynamic.icon;
  94. if (taskName.includes('服务号')) return this.taskConfig.service.icon;
  95. if (taskName.includes('充值')) return this.taskConfig.recharge.icon;
  96. return '';
  97. },
  98. // 处理任务点击
  99. handleTask(task) {
  100. if (task.completedStatus === 1) return;
  101. if (task.taskName.includes('订单')) {
  102. this.taskConfig.order.action();
  103. } else if (task.taskName.includes('商户')) {
  104. this.taskConfig.merchant.action();
  105. } else if (task.taskName.includes('动态')) {
  106. this.taskConfig.dynamic.action();
  107. } else if (task.taskName.includes('服务号')) {
  108. this.taskConfig.service.action();
  109. } else if (task.taskName.includes('充值')) {
  110. this.taskConfig.recharge.action();
  111. }
  112. },
  113. // 处理订单任务
  114. handleOrderTask() {
  115. uni.switchTab({
  116. url: '/pages/index/index'
  117. });
  118. },
  119. // 处理商户任务
  120. handleMerchantTask() {
  121. uni.switchTab({
  122. url: '/pages/identify/identify'
  123. });
  124. },
  125. // 处理动态任务
  126. handleDynamicTask() {
  127. uni.switchTab({
  128. url: '/pages/discover/discover'
  129. });
  130. },
  131. // 处理服务号任务
  132. handleServiceTask() {
  133. // 调用微信服务号分享功能
  134. handleServiceShare({
  135. title: '广誉远 - 关注服务号123123',
  136. desc: '关注广誉远服务号,获取更多积分和优惠123123123',
  137. link: window.location.href,
  138. imgUrl: '/static/points/task_wx.png'
  139. });
  140. },
  141. // 处理账号充值任务
  142. handleRechargeTask() {
  143. uni.navigateTo({
  144. url: '/pages/my/pay'
  145. });
  146. },
  147. // 处理查看更多任务
  148. handleMoreTasks() {
  149. uni.navigateTo({
  150. url: '/points/pointInfo/taskList'
  151. });
  152. }
  153. }
  154. }
  155. </script>
  156. <style lang="scss" scoped>
  157. .task-list-container {
  158. background-color: #fff;
  159. border-radius: 20rpx;
  160. padding: 24rpx;
  161. height: 360rpx;
  162. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
  163. .task-list-header {
  164. margin-bottom: 26rpx;
  165. .task-list-title {
  166. font-size: 32rpx;
  167. font-weight: 600;
  168. color: #333;
  169. }
  170. }
  171. .task-list-loading {
  172. display: flex;
  173. justify-content: center;
  174. align-items: center;
  175. min-height: 230rpx;
  176. }
  177. .task-list {
  178. .task-item {
  179. display: flex;
  180. justify-content: space-between;
  181. align-items: center;
  182. margin-bottom: 20rpx;
  183. .task-item-left {
  184. display: flex;
  185. align-items: center;
  186. .task-icon {
  187. width: 72rpx;
  188. height: 72rpx;
  189. margin-right: 18rpx;
  190. image {
  191. width: 72rpx;
  192. height: 72rpx;
  193. }
  194. }
  195. .task-info {
  196. .task-name {
  197. font-family: PingFang SC, PingFang SC;
  198. font-weight: 400;
  199. font-size: 28rpx;
  200. color: #333333;
  201. line-height: 28rpx;
  202. margin-bottom: 12rpx;
  203. }
  204. .task-reward {
  205. display: inline-flex;
  206. height: 32rpx;
  207. background: #FBF2E1;
  208. border-radius: 22rpx;
  209. padding-right: 12rpx;
  210. image {
  211. width: 32rpx;
  212. height: 32rpx;
  213. margin-right: 4rpx;
  214. }
  215. text {
  216. font-family: PingFang SC, PingFang SC;
  217. font-weight: 500;
  218. font-size: 24rpx;
  219. color: #FF9F00;
  220. line-height: 32rpx;
  221. }
  222. }
  223. }
  224. }
  225. .task-item-right {
  226. display: flex;
  227. flex-direction: row;
  228. .progress-text{
  229. font-family: PingFang SC, PingFang SC;
  230. font-weight: 500;
  231. font-size: 28rpx;
  232. color: #999999;
  233. line-height: 28rpx;
  234. margin-right: 8rpx;
  235. margin-top: 10rpx;
  236. }
  237. .task-btn {
  238. height: 48rpx;
  239. background: #EEEEEE;
  240. border-radius: 98rpx;
  241. font-family: PingFang SC, PingFang SC;
  242. font-weight: 500;
  243. font-size: 26rpx;
  244. color: #999999;
  245. line-height: 48rpx;
  246. border: 1px solid #EEEEEE;
  247. }
  248. .no-task-btn {
  249. height: 48rpx;
  250. background: #03C1B8;
  251. border-radius: 98rpx;
  252. font-family: PingFang SC, PingFang SC;
  253. font-weight: 500;
  254. font-size: 26rpx;
  255. color: #FFFFFF;
  256. line-height: 48rpx;
  257. }
  258. }
  259. }
  260. }
  261. .more-tasks {
  262. text-align: center;
  263. font-weight: 500;
  264. font-size: 28rpx;
  265. color: #999999;
  266. }
  267. .task-list-empty {
  268. display: flex;
  269. justify-content: center;
  270. align-items: center;
  271. min-height: 230rpx;
  272. color: #8f9ca2;
  273. font-size: 28rpx;
  274. }
  275. }
  276. </style>