index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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. // 获取token参数
  114. if (options.token) {
  115. sheep.$store('user').setToken(options.token)
  116. sheep.$store('task').resetTaskData()
  117. }
  118. })
  119. async function onTaskDel() {
  120. let res = await taskApi.taskDel({
  121. id: state.lastTaskInfo.id
  122. })
  123. if (res.code === 1) {
  124. getLastTask()
  125. state.showDel = false
  126. uni.showToast({
  127. title: '删除成功',
  128. icon: 'none'
  129. })
  130. } else {
  131. }
  132. }
  133. // 详情
  134. function onTaskDetail(id) {
  135. if (!id) {
  136. return
  137. }
  138. sheep.$router.go('/pages/task/details', {
  139. id,
  140. })
  141. }
  142. async function getLastTask() {
  143. let res = await taskApi.lastTaskDetail()
  144. if (res.code === 1 && res.data) {
  145. state.lastTaskInfo = res.data
  146. state.showTask = true
  147. } else {
  148. state.showTask = false
  149. }
  150. }
  151. // 下拉刷新
  152. onPullDownRefresh(() => {
  153. if (!!uni.getStorageSync("token")) {
  154. getLastTask()
  155. }
  156. setTimeout(function () {
  157. uni.stopPullDownRefresh();
  158. }, 800);
  159. });
  160. onPageScroll(() => { });
  161. </script>
  162. <style lang="scss" scoped>
  163. .home_page {
  164. width: 690rpx;
  165. margin: 0 auto;
  166. background: url('/static/homeBg.png') no-repeat top/100% auto;
  167. .home_data {
  168. width: 690rpx;
  169. height: 1093rpx;
  170. .name {
  171. font-family: Source Han Sans SC, Source Han Sans SC;
  172. font-weight: bold;
  173. font-size: 48rpx;
  174. color: #222222;
  175. line-height: 80rpx;
  176. padding: 222rpx 30rpx 78rpx;
  177. }
  178. .data_item {
  179. margin-bottom: 60rpx;
  180. padding: 0 70rpx;
  181. .label {
  182. font-weight: 400;
  183. font-size: 32rpx;
  184. color: #222222;
  185. line-height: 40rpx;
  186. }
  187. .val {
  188. font-weight: bold;
  189. font-size: 68rpx;
  190. color: #35E89A;
  191. line-height: 88rpx;
  192. margin-top: 20rpx;
  193. }
  194. }
  195. }
  196. .create_btn {
  197. width: 630rpx;
  198. height: 104rpx;
  199. background: #222222;
  200. border-radius: 40rpx;
  201. font-weight: bold;
  202. font-size: 32rpx;
  203. color: #FFFFFF;
  204. line-height: 104rpx;
  205. text-align: center;
  206. margin: 40rpx auto 30rpx;
  207. }
  208. .task_list {
  209. .task_item {
  210. position: relative;
  211. background: #FFFFFF;
  212. border-radius: 30rpx;
  213. padding: 30rpx;
  214. box-sizing: border-box;
  215. margin-bottom: 30rpx;
  216. .close-icon {
  217. width: 48rpx;
  218. height: 48rpx;
  219. position: absolute;
  220. top: 20rpx;
  221. right: 20rpx;
  222. background: url('/static/close-icon.png') no-repeat center/48rpx 48rpx;
  223. }
  224. .title {
  225. display: flex;
  226. align-items: center;
  227. margin-bottom: 10rpx;
  228. .status {
  229. height: 40rpx;
  230. border-radius: 10rpx;
  231. padding: 0 10rpx;
  232. font-weight: 400;
  233. font-size: 20rpx;
  234. background: #E6E6E6;
  235. color: #999999;
  236. line-height: 40rpx;
  237. margin-right: 8rpx;
  238. }
  239. .status0 {
  240. background: #FFEFBA;
  241. color: #E28F48;
  242. }
  243. .status1 {
  244. background: #A3FFD7;
  245. color: #26B978;
  246. }
  247. .status2 {
  248. background: #E6E6E6;
  249. color: #999999;
  250. }
  251. .name {
  252. font-weight: bold;
  253. font-size: 32rpx;
  254. color: #222222;
  255. line-height: 48rpx;
  256. }
  257. }
  258. .des {
  259. font-weight: 400;
  260. font-size: 28rpx;
  261. color: #666666;
  262. line-height: 40rpx;
  263. margin-bottom: 10rpx;
  264. }
  265. .time {
  266. font-weight: 400;
  267. font-size: 24rpx;
  268. color: #CCCCCC;
  269. line-height: 34rpx;
  270. }
  271. }
  272. }
  273. }
  274. </style>