index.vue 6.7 KB

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