index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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 '@designer-hub/app/src/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: userInfo.value.userId.toString(),
  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: userInfo.value.userId.toString(),
  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. <!-- <wd-steps :active="1" vertical>
  121. <wd-step description="注册1个账号" />
  122. <wd-step description="登录账号并绑定手机" />
  123. <wd-step description="完善个人信息" />
  124. </wd-steps> -->
  125. <PageHelperEvo :request="getTodoPage" :query="todosQuery"></PageHelperEvo>
  126. <div
  127. class="flex items-center justify-center b-t b-t-solid b-t-[#f6f6f6] pt-3.5"
  128. @click="router.push('/pages/home/agent/todo/index')"
  129. >
  130. <div class="text-[#2357e9] text-xs font-normal font-['PingFang_SC'] leading-none">
  131. 全部待办
  132. </div>
  133. <wd-icon name="arrow-right" size="10" color="#2357e9" />
  134. </div>
  135. </div>
  136. </Card>
  137. </div>
  138. <div>
  139. <SectionHeading
  140. title="任务"
  141. path="/pages/home/tasks/index"
  142. end-text="查看全部"
  143. custom-class="mb-5"
  144. ></SectionHeading>
  145. <div class="flex overflow-x-auto whitespace-nowrap mx--4 px-4 gap-4 box-border">
  146. <Card v-if="!tasks.list.length">
  147. <wd-status-tip image="search" tip="当前暂无未开始/进行中的任务" />
  148. </Card>
  149. <template v-for="(it, i) in tasks.list" :key="i">
  150. <div class="inline-block">
  151. <div class="w-[calc(75vw)]"><TaskCard :options="it"></TaskCard></div>
  152. </div>
  153. </template>
  154. </div>
  155. </div>
  156. <div>
  157. <SectionHeading title="设计师" path="" custom-class="mb-5"></SectionHeading>
  158. <div class="flex flex-col gap-4">
  159. <template
  160. v-for="{ label, color, ...it } of [
  161. {
  162. label: '关系报备',
  163. color: 'white',
  164. path: '/pages/home/agent/report-infos/index',
  165. },
  166. { label: '重点跟进设计师', color: '#FF523F', path: '/pages/designer/index' },
  167. { label: '全部设计师', color: '#7199FF', path: '/pages/designer/index' },
  168. { label: '本月新增设计师', color: '#FFE786', path: '/pages/designer/index' },
  169. { label: '超过30天未跟进', color: '#89F4E3', path: '/pages/designer/index' },
  170. {
  171. label: '超过60天未产生积分设计师',
  172. color: '#FFBA6A',
  173. path: '/pages/designer/index',
  174. },
  175. {
  176. label: '超过60天未消耗积分设计师',
  177. color: '#C494FF',
  178. path: '/pages/designer/index',
  179. },
  180. { label: '未成交过设计师', color: '#FF9EE2', path: '/pages/designer/index' },
  181. ]"
  182. :key="label"
  183. >
  184. <div class="h-12 bg-white rounded-lg shadow flex items-center hover:bg-[#fff6f5]">
  185. <div
  186. class="w-1.5 h-12 rounded-tl-lg rounded-bl-lg shadow"
  187. :style="{ background: color }"
  188. ></div>
  189. <div class="flex-1 mx-3">
  190. <SectionHeading :title="label" :path="it.path" size="sm"></SectionHeading>
  191. </div>
  192. </div>
  193. </template>
  194. </div>
  195. </div>
  196. <div>
  197. <SectionHeading title="设计师最新动态" path="" custom-class="mb-5"></SectionHeading>
  198. <PageHelperEvo
  199. :request="getDeignerPointsActivities"
  200. :query="designerPointsActivitiesQuery"
  201. >
  202. <template #default="{ source }">
  203. <div class="flex flex-col gap-4">
  204. <template v-for="(it, i) in source.list" :key="i">
  205. <Card>
  206. <div
  207. class="text-black/90 text-sm font-normal font-['PingFang_SC'] leading-none"
  208. >
  209. {{ it.content }}
  210. </div>
  211. <div
  212. class="mt-3 text-black/30 text-xs font-normal font-['PingFang_SC'] leading-none"
  213. >
  214. {{ dayjs(it.createTime).format('YYYY-MM-DD hh:mm') }}
  215. </div>
  216. </Card>
  217. </template>
  218. </div>
  219. </template>
  220. </PageHelperEvo>
  221. </div>
  222. </div>
  223. </template>
  224. <template v-if="isMerchant">
  225. <div
  226. class="bg-white backdrop-blur-[60px] my-[16px] flex flex-col justify-center items-center p-[16px] mt-[20px]"
  227. >
  228. <div
  229. class="w-[68px] h-[68px] bg-[#2357e9] rounded-full mt-[37px] flex items-center justify-center"
  230. >
  231. <wd-img width="36px" height="36px" :src="scanIcon"></wd-img>
  232. </div>
  233. <div class="w-full mt-[45px]">
  234. <wd-button block :round="false" @click="handleScanning">
  235. <div
  236. class="text-center text-white text-base font-normal font-['PingFang_SC'] leading-normal"
  237. >
  238. 扫码验券
  239. </div>
  240. </wd-button>
  241. </div>
  242. </div>
  243. <div
  244. class="bg-white backdrop-blur-[60px] flex flex-col justify-center items-center p-[16px] mt-[20px]"
  245. >
  246. <div
  247. class="w-[68px] h-[68px] bg-[#2357e9] rounded-full mt-[34px] flex items-center justify-center"
  248. >
  249. <wd-img width="36px" height="36px" :src="bookIcon"></wd-img>
  250. </div>
  251. <div class="w-full flex items-center mt-[40px] gap-5">
  252. <div
  253. class="text-black/90 text-base font-normal font-['PingFang_SC'] leading-relaxed w-[96px]"
  254. >
  255. 输入订单金额
  256. </div>
  257. <div class="flex-1 bg-[#f5f7f9] rounded-lg flex items-center p-3.5">
  258. <wd-input
  259. custom-class="bg-transparent! flex-1"
  260. type="number"
  261. no-border
  262. placeholder="请输金额"
  263. v-model="orderAmount"
  264. />
  265. </div>
  266. </div>
  267. <div class="w-full flex items-center mt-[20px] gap-5">
  268. <div
  269. class="text-black/90 text-base font-normal font-['PingFang_SC'] leading-relaxed w-[96px]"
  270. >
  271. 需支付积分
  272. </div>
  273. <div class="text-[#ff2d2d] text-base font-normal font-['PingFang_SC'] leading-relaxed">
  274. {{ pointsAmount }} 积分
  275. </div>
  276. </div>
  277. <div class="w-full mt-[45px]">
  278. <wd-button block :round="false" @click="handle2Settlement">
  279. <div
  280. class="text-center text-white text-base font-normal font-['PingFang_SC'] leading-normal"
  281. >
  282. 积分结账
  283. </div>
  284. </wd-button>
  285. </div>
  286. </div>
  287. </template>
  288. </view>
  289. </template>
  290. <style></style>