index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <route lang="json5">
  2. {
  3. layout: 'tabbar',
  4. style: {
  5. navigationBarTitleText: '首页',
  6. navigationBarBackgroundColor: '#fff',
  7. navigationStyle: 'custom',
  8. },
  9. }
  10. </route>
  11. <script lang="ts" setup>
  12. import dayjs from 'dayjs'
  13. import {
  14. getDeignerPointsActivities,
  15. getTaskList,
  16. getTodoPage,
  17. getTodos,
  18. scanCodeCheckPaper,
  19. } from '../../core/libs/requests'
  20. import SectionHeading from '@/components/section-heading.vue'
  21. import Card from '@designer-hub/app/src/components/card.vue'
  22. import { merchantPageHeaderBg, scanIcon, bookIcon } from '@designer-hub/assets/src/svgs'
  23. import { useUserStore } from '../../store'
  24. import { storeToRefs } from 'pinia'
  25. import { qrCodeString2Object, requestToast } from '@designer-hub/app/src/core/utils/common'
  26. import { QrCodeBusinessType } from '../../core/libs/enums'
  27. import { useRouter } from '../../composables/router'
  28. import PageHelperEvo from '@/components/page-helper-evo.vue'
  29. import TaskCard from '../agent/components/task-card.vue'
  30. import { getTasks } from '../../core/libs/agent-requests'
  31. defineOptions({
  32. name: 'Home',
  33. })
  34. const router = useRouter()
  35. const userStore = useUserStore()
  36. const { isLogined, userInfo, isAgent, isMerchant } = storeToRefs(userStore)
  37. const orderAmount = ref()
  38. const pointsAmount = computed(() => orderAmount.value * 10)
  39. const todosQuery = computed(() => ({
  40. brokerId: String(userInfo.value.userId),
  41. executionTime: [
  42. dayjs().startOf('days').format('YYYY-MM-DD HH:mm:ss'),
  43. dayjs().endOf('days').format('YYYY-MM-DD HH:mm:ss'),
  44. ].join(','),
  45. }))
  46. const designerPointsActivitiesQuery = computed(() => ({
  47. brokerId: String(userInfo.value.userId),
  48. }))
  49. const { data: tasks, run: setTasks } = useRequest(
  50. () => getTasks({ brokerId: userInfo.value.userId }),
  51. { initialData: { list: [], total: 0 } },
  52. )
  53. const toDesigner = () => {
  54. uni.navigateTo({ url: '/pages/designer/index' })
  55. }
  56. const handleScanning = async () => {
  57. console.log('handleScanning')
  58. const { result } = await uni.scanCode({ scanType: ['qrCode'] })
  59. const { type, options } = qrCodeString2Object(result)
  60. if (type !== QrCodeBusinessType.InStoreWriteOff) {
  61. uni.showToast({ title: '不支持此二维码/条码', icon: 'none', duration: 5000 })
  62. return
  63. }
  64. await requestToast(() => scanCodeCheckPaper({ orderNo: options.no }), {
  65. success: true,
  66. successTitle: '验券成功',
  67. })
  68. }
  69. const handle2Settlement = () => {
  70. if ((orderAmount.value ?? '') === '') {
  71. uni.showToast({ title: '请输入金额', icon: 'none', duration: 5000 })
  72. return
  73. }
  74. router.push(
  75. `/pages/home/merchant/settlement?orderAmount=${orderAmount.value}&pointsAmount=${pointsAmount.value}`,
  76. )
  77. }
  78. const toAddReporting = () => {
  79. uni.navigateTo({ url: '/pages/home/merchant/add-reporting-information' })
  80. }
  81. onShow(async () => {
  82. isAgent.value && (await Promise.all([setTasks()]))
  83. })
  84. onLoad(() => {
  85. console.log(isLogined.value)
  86. if (!isLogined.value) {
  87. uni.reLaunch({ url: '/pages/login/index' })
  88. }
  89. })
  90. onShareAppMessage(() => ({}))
  91. </script>
  92. <template>
  93. <view class="flex-grow relative">
  94. <template v-if="isAgent">
  95. <div class="aspect-[0.96/1] absolute left-0 right-0 top--1">
  96. <wd-img
  97. width="100%"
  98. height="100%"
  99. :src="merchantPageHeaderBg"
  100. custom-class="vertical-bottom"
  101. ></wd-img>
  102. </div>
  103. <wd-navbar custom-class="bg-transparent!" safe-area-inset-top :bordered="false">
  104. <template #left>
  105. <div
  106. @click="toAddReporting"
  107. class="ml-1 text-center text-white text-lg font-normal font-['PingFang_SC'] leading-relaxed"
  108. >
  109. 今日待办
  110. </div>
  111. </template>
  112. </wd-navbar>
  113. <div class="flex flex-col gap-8 p-4 relative box-border">
  114. <div>
  115. <div class="text-white text-sm font-normal font-['PingFang_SC'] leading-relaxed my-2.5">
  116. {{ dayjs().format('YYYY-MM-DD') }}
  117. </div>
  118. <Card>
  119. <div>
  120. <PageHelperEvo :request="getTodoPage" :query="todosQuery">
  121. <template #default="{ source }">
  122. <div class="flex flex-col py-6">
  123. <template v-for="(it, index) in source?.list" :key="index">
  124. <div>
  125. <div class="flex items-center gap-4">
  126. <div
  127. class="w-14 text-end text-black text-base font-normal font-['PingFang SC'] leading-none"
  128. >
  129. {{ dayjs(it.executionTime).format('HH:mm') }}
  130. </div>
  131. <div class="w-3 h-3 relative">
  132. <div
  133. class="w-3 h-3 left-0 top-0 absolute rounded-full"
  134. :class="`${it.status === 1 ? 'bg-[#517df8]/10' : 'bg-[#5e5e5e]/10'}`"
  135. ></div>
  136. <div
  137. class="w-1.5 h-1.5 left-[3px] top-[3px] absolute rounded-full"
  138. :class="`${it.status === 1 ? 'bg-[#517df8]' : 'bg-[#a8a8a8]'}`"
  139. ></div>
  140. </div>
  141. <div
  142. class="text-black/60 text-sm font-normal font-['PingFang SC'] leading-none"
  143. >
  144. {{ it.content }}
  145. </div>
  146. </div>
  147. <div v-if="index < (source?.list?.length ?? 0) - 1" class="flex gap-4">
  148. <div class="w-14"></div>
  149. <div class="w-3 flex justify-center">
  150. <div class="w-.25 h-10 bg-[#EDEDED]"></div>
  151. </div>
  152. <div></div>
  153. </div>
  154. </div>
  155. </template>
  156. </div>
  157. </template>
  158. </PageHelperEvo>
  159. <div
  160. class="flex items-center justify-center b-t b-t-solid b-t-[#f6f6f6] pt-3.5"
  161. @click="router.push('/pages/agent/todo/index')"
  162. >
  163. <div class="text-[#2357e9] text-xs font-normal font-['PingFang_SC'] leading-none">
  164. 全部待办
  165. </div>
  166. <wd-icon name="arrow-right" size="10" color="#2357e9" />
  167. </div>
  168. </div>
  169. </Card>
  170. </div>
  171. <div>
  172. <SectionHeading
  173. title="任务"
  174. path="/pages/agent/tasks/index"
  175. end-text="查看全部"
  176. custom-class="mb-5"
  177. ></SectionHeading>
  178. <div class="flex overflow-x-auto whitespace-nowrap mx--4 px-4 gap-4 box-border">
  179. <Card v-if="!tasks.list.length">
  180. <wd-status-tip image="search" tip="当前暂无未开始/进行中的任务" />
  181. </Card>
  182. <template v-for="(it, i) in tasks.list" :key="i">
  183. <div class="inline-block">
  184. <div class="w-[calc(75vw)]"><TaskCard :options="it"></TaskCard></div>
  185. </div>
  186. </template>
  187. </div>
  188. </div>
  189. <div>
  190. <SectionHeading title="设计师" path="" custom-class="mb-5"></SectionHeading>
  191. <div class="flex flex-col gap-4">
  192. <template
  193. v-for="{ label, color, ...it } of [
  194. {
  195. label: '关系报备',
  196. color: 'white',
  197. path: '/pages/agent/report-infos/index',
  198. },
  199. {
  200. label: '全部设计师',
  201. color: '#7199FF',
  202. path: '/pages/agent/designer/index?title=全部设计师',
  203. },
  204. {
  205. label: '重点跟进设计师',
  206. color: '#FF523F',
  207. path: '/pages/agent/designer/index?title=重点跟进设计师&tags=1',
  208. },
  209. {
  210. label: '本月新增设计师',
  211. color: '#FFE786',
  212. path: '/pages/agent/designer/index?title=本月新增设计师&tags=2',
  213. },
  214. {
  215. label: '超过30天未跟进',
  216. color: '#89F4E3',
  217. path: '/pages/agent/designer/index?title=超过30天未跟进&tags=3',
  218. },
  219. {
  220. label: '超过60天未产生积分设计师',
  221. color: '#FFBA6A',
  222. path: '/pages/agent/designer/index?title=超过60天未产生积分设计师&tags=4',
  223. },
  224. {
  225. label: '超过60天未消耗积分设计师',
  226. color: '#C494FF',
  227. path: '/pages/agent/designer/index?title=超过60天未消耗积分设计师&tags=5',
  228. },
  229. {
  230. label: '未成交过设计师',
  231. color: '#FF9EE2',
  232. path: '/pages/agent/designer/index?title=未成交过设计师&tags=6',
  233. },
  234. ]"
  235. :key="label"
  236. >
  237. <div class="h-12 bg-white rounded-lg shadow flex items-center hover:bg-[#fff6f5]">
  238. <div
  239. class="w-1.5 h-12 rounded-tl-lg rounded-bl-lg shadow"
  240. :style="{ background: color }"
  241. ></div>
  242. <div class="flex-1 mx-3">
  243. <SectionHeading :title="label" :path="it.path" size="sm"></SectionHeading>
  244. </div>
  245. </div>
  246. </template>
  247. </div>
  248. </div>
  249. <div>
  250. <SectionHeading title="设计师最新动态" path="" custom-class="mb-5"></SectionHeading>
  251. <PageHelperEvo
  252. :request="getDeignerPointsActivities"
  253. :query="designerPointsActivitiesQuery"
  254. >
  255. <template #default="{ source }">
  256. <div class="flex flex-col gap-4">
  257. <template v-for="(it, i) in source?.list" :key="i">
  258. <Card>
  259. <div
  260. class="text-black/90 text-sm font-normal font-['PingFang_SC'] leading-none"
  261. >
  262. {{ it.content }}
  263. </div>
  264. <div
  265. class="mt-3 text-black/30 text-xs font-normal font-['PingFang_SC'] leading-none"
  266. >
  267. {{ dayjs(it.createTime).format('YYYY-MM-DD hh:mm') }}
  268. </div>
  269. </Card>
  270. </template>
  271. </div>
  272. </template>
  273. </PageHelperEvo>
  274. </div>
  275. </div>
  276. </template>
  277. <template v-if="isMerchant">
  278. <div
  279. class="bg-white backdrop-blur-[60px] my-[16px] flex flex-col justify-center items-center p-[16px] mt-[20px]"
  280. >
  281. <div
  282. class="w-[68px] h-[68px] bg-[#2357e9] rounded-full mt-[37px] flex items-center justify-center"
  283. >
  284. <wd-img width="36px" height="36px" :src="scanIcon"></wd-img>
  285. </div>
  286. <div class="w-full mt-[45px]">
  287. <wd-button block :round="false" @click="handleScanning">
  288. <div
  289. class="text-center text-white text-base font-normal font-['PingFang_SC'] leading-normal"
  290. >
  291. 扫码验券
  292. </div>
  293. </wd-button>
  294. </div>
  295. </div>
  296. <div
  297. class="bg-white backdrop-blur-[60px] flex flex-col justify-center items-center p-[16px] mt-[20px]"
  298. >
  299. <div
  300. class="w-[68px] h-[68px] bg-[#2357e9] rounded-full mt-[34px] flex items-center justify-center"
  301. >
  302. <wd-img width="36px" height="36px" :src="bookIcon"></wd-img>
  303. </div>
  304. <div class="w-full flex items-center mt-[40px] gap-5">
  305. <div
  306. class="text-black/90 text-base font-normal font-['PingFang_SC'] leading-relaxed w-[96px]"
  307. >
  308. 输入订单金额
  309. </div>
  310. <div class="flex-1 bg-[#f5f7f9] rounded-lg flex items-center p-3.5">
  311. <wd-input
  312. custom-class="bg-transparent! flex-1"
  313. type="number"
  314. no-border
  315. placeholder="请输金额"
  316. v-model="orderAmount"
  317. />
  318. </div>
  319. </div>
  320. <div class="w-full flex items-center mt-[20px] gap-5">
  321. <div
  322. class="text-black/90 text-base font-normal font-['PingFang_SC'] leading-relaxed w-[96px]"
  323. >
  324. 需支付积分
  325. </div>
  326. <div class="text-[#ff2d2d] text-base font-normal font-['PingFang_SC'] leading-relaxed">
  327. {{ pointsAmount }} 积分
  328. </div>
  329. </div>
  330. <div class="w-full mt-[45px]">
  331. <wd-button block :round="false" @click="handle2Settlement">
  332. <div
  333. class="text-center text-white text-base font-normal font-['PingFang_SC'] leading-normal"
  334. >
  335. 积分结账
  336. </div>
  337. </wd-button>
  338. </div>
  339. </div>
  340. </template>
  341. </view>
  342. </template>
  343. <style></style>