index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <!-- 首页 -->
  2. <template>
  3. <s-layout title="" navbar="inner" :bgStyle="state.page" :navbarStyle="state.navigationBar" opacityBgUi=""
  4. showRecordTextButton showLeftLogoutButton>
  5. <view class="home_page" :style="[{ marginTop: `-${sheep?.$platform?.navbar}px` }]">
  6. <view class="home_data">
  7. <view class="name">{{ state.lastTaskInfo.name }}</view>
  8. <view class="data_item">
  9. <view class="label">拨打数量:</view>
  10. <view class="val">{{ $helper.priceFormat(state.lastTaskInfo.lingCount) }}</view>
  11. </view>
  12. <view class="data_item">
  13. <view class="label">接通率:</view>
  14. <view class="val">{{ ((state.lastTaskInfo.answerRate || 0) * 100).toFixed(2) * 100 / 100 }}%</view>
  15. </view>
  16. <!-- <view class="data_item">
  17. <view class="label">高意向数量:</view>
  18. <view class="val">{{$helper.priceFormat(state.lastTaskInfo.highIntentionCount)}}</view>
  19. </view> -->
  20. </view>
  21. <view class="create_btn" @tap="sheep.$router.go('/pages/task/create')">新建任务</view>
  22. <view v-if="state.showTask" class="task_list">
  23. <view class="task_item" @tap="onTaskDetail(state.lastTaskInfo.id)">
  24. <view v-if="state.lastTaskInfo.status === 0" class="close-icon" @tap.stop="state.showDel = true"></view>
  25. <view class="title">
  26. <view v-if="state.lastTaskInfo.status !== 10" class="status"
  27. :class="{ 'status0': state.lastTaskInfo.status === 0, 'status1': state.lastTaskInfo.status === 1 || state.lastTaskInfo.status === 2 }">
  28. {{ state.lastTaskInfo.status === 2 ? '已执行' : (state.lastTaskInfo.status === 1 ? '执行中' :
  29. (state.lastTaskInfo.status === 0 ? '待执行' : '已失效')) }}
  30. </view>
  31. <view class="name">{{ state.lastTaskInfo.name }} </view>
  32. </view>
  33. <view class="des">{{ state.lastTaskInfo.typeName }}</view>
  34. <view class="time">{{ formatDate(state.lastTaskInfo.planTime, 'YYYY-MM-DD HH:mm') }}</view>
  35. </view>
  36. </view>
  37. <su-popup :show="state.showDel" round="20" type="center" :isMaskClick="false" :showClose="false"
  38. @close="state.showDel = false">
  39. <view class="tips_wrap">
  40. <view class="tips_cont">
  41. <view class="label">提示</view>
  42. <view class="cont">{{ state.lastTaskInfo.name }}将失效</view>
  43. </view>
  44. <view class="group_btn">
  45. <view class="item_btn cancel_btn" @tap="state.showDel = false">取消</view>
  46. <view class="item_btn logout-btn" @tap="onTaskDel">确认</view>
  47. </view>
  48. </view>
  49. </su-popup>
  50. </view>
  51. </s-layout>
  52. </template>
  53. <script setup>
  54. import $helper from '@/common/helper'
  55. import { watch, computed, reactive } from 'vue'
  56. import { onShow, onLoad, onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app'
  57. import sheep from '@/common'
  58. import taskApi from '@/common/api/member/task'
  59. import { formatDate } from '@/common/helper/utils'
  60. const state = reactive({
  61. navigationBar: {},
  62. page: {
  63. backgroundColor: '#FAFAFA',
  64. backgroundImage: '/static/homeTopBg.png'
  65. },
  66. lastTaskInfo: {
  67. id: 1,
  68. name: '暂无任务',
  69. lingCount: 0,
  70. answerRate: 0,
  71. highIntentionCount: 0,
  72. type: {
  73. name: '话术1'
  74. },
  75. planTime: '2025-7-9 19:00',
  76. status: 1
  77. },
  78. showTask: false,
  79. showDel: false
  80. })
  81. // 隐藏原生tabBar
  82. uni.hideTabBar({
  83. fail: () => { },
  84. })
  85. const isLogin = computed(() => sheep.$store('user').isLogin)
  86. watch(isLogin, (newValue, oldValue) => {
  87. if (newValue) {
  88. getLastTask()
  89. } else {
  90. state.showTask = false
  91. state.lastTaskInfo = {
  92. name: '暂无任务',
  93. lingCount: 0,
  94. answerRate: 0,
  95. highIntentionCount: 0,
  96. type: {
  97. name: '话术1'
  98. },
  99. planTime: '2025-7-9 19:00',
  100. status: 1
  101. }
  102. }
  103. }, {
  104. deep: true // 深度监听
  105. })
  106. onShow(async () => {
  107. //onShow中获取,保证跳转后页面为最新状态
  108. if (!!uni.getStorageSync("token")) {
  109. await getLastTask()
  110. }
  111. })
  112. onLoad((options) => {
  113. })
  114. async function onTaskDel() {
  115. let res = await taskApi.taskDel({
  116. id: state.lastTaskInfo.id
  117. })
  118. if (res.code === 1) {
  119. getLastTask()
  120. state.showDel = false
  121. uni.showToast({
  122. title: '删除成功',
  123. icon: 'none'
  124. })
  125. } else {
  126. }
  127. }
  128. // 详情
  129. function onTaskDetail(id) {
  130. if (!id) {
  131. return
  132. }
  133. sheep.$router.go('/pages/task/details', {
  134. id,
  135. })
  136. }
  137. async function getLastTask() {
  138. let res = await taskApi.lastTaskDetail()
  139. if (res.code === 1 && res.data) {
  140. state.lastTaskInfo = res.data
  141. state.showTask = true
  142. } else {
  143. state.showTask = false
  144. }
  145. }
  146. // 下拉刷新
  147. onPullDownRefresh(() => {
  148. if (!!uni.getStorageSync("token")) {
  149. getLastTask()
  150. }
  151. setTimeout(function () {
  152. uni.stopPullDownRefresh();
  153. }, 800);
  154. });
  155. onPageScroll(() => { });
  156. </script>
  157. <style lang="scss" scoped>
  158. .home_page {
  159. width: 690rpx;
  160. margin: 0 auto;
  161. background: url('/static/homeBg.png') no-repeat top/100% auto;
  162. .home_data {
  163. width: 690rpx;
  164. height: 1093rpx;
  165. .name {
  166. font-family: Source Han Sans SC, Source Han Sans SC;
  167. font-weight: bold;
  168. font-size: 48rpx;
  169. color: #222222;
  170. line-height: 80rpx;
  171. padding: 222rpx 30rpx 78rpx;
  172. }
  173. .data_item {
  174. margin-bottom: 60rpx;
  175. padding: 0 70rpx;
  176. .label {
  177. font-weight: 400;
  178. font-size: 32rpx;
  179. color: #222222;
  180. line-height: 40rpx;
  181. }
  182. .val {
  183. font-weight: bold;
  184. font-size: 68rpx;
  185. color: #35E89A;
  186. line-height: 88rpx;
  187. margin-top: 20rpx;
  188. }
  189. }
  190. }
  191. .create_btn {
  192. width: 630rpx;
  193. height: 104rpx;
  194. background: #222222;
  195. border-radius: 40rpx;
  196. font-weight: bold;
  197. font-size: 32rpx;
  198. color: #FFFFFF;
  199. line-height: 104rpx;
  200. text-align: center;
  201. margin: 40rpx auto 30rpx;
  202. }
  203. .task_list {
  204. .task_item {
  205. position: relative;
  206. background: #FFFFFF;
  207. border-radius: 30rpx;
  208. padding: 30rpx;
  209. box-sizing: border-box;
  210. margin-bottom: 30rpx;
  211. .close-icon {
  212. width: 48rpx;
  213. height: 48rpx;
  214. position: absolute;
  215. top: 20rpx;
  216. right: 20rpx;
  217. background: url('/static/close-icon.png') no-repeat center/48rpx 48rpx;
  218. }
  219. .title {
  220. display: flex;
  221. align-items: center;
  222. margin-bottom: 10rpx;
  223. .status {
  224. height: 40rpx;
  225. border-radius: 10rpx;
  226. padding: 0 10rpx;
  227. font-weight: 400;
  228. font-size: 20rpx;
  229. background: #E6E6E6;
  230. color: #999999;
  231. line-height: 40rpx;
  232. margin-right: 8rpx;
  233. }
  234. .status0 {
  235. background: #FFEFBA;
  236. color: #E28F48;
  237. }
  238. .status1 {
  239. background: #A3FFD7;
  240. color: #26B978;
  241. }
  242. .status2 {
  243. background: #E6E6E6;
  244. color: #999999;
  245. }
  246. .name {
  247. font-weight: bold;
  248. font-size: 32rpx;
  249. color: #222222;
  250. line-height: 48rpx;
  251. }
  252. }
  253. .des {
  254. font-weight: 400;
  255. font-size: 28rpx;
  256. color: #666666;
  257. line-height: 40rpx;
  258. margin-bottom: 10rpx;
  259. }
  260. .time {
  261. font-weight: 400;
  262. font-size: 24rpx;
  263. color: #CCCCCC;
  264. line-height: 34rpx;
  265. }
  266. }
  267. }
  268. }
  269. </style>