index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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 { data: tasks, run: setTasks } = useRequest(
  47. () => getTasks({ brokerId: userInfo.value.userId }),
  48. { initialData: { list: [], total: 0 } },
  49. )
  50. const toDesigner = () => {
  51. uni.navigateTo({ url: '/pages/designer/index' })
  52. }
  53. const handleScanning = async () => {
  54. console.log('handleScanning')
  55. const { result } = await uni.scanCode({ scanType: ['qrCode'] })
  56. const { type, options } = qrCodeString2Object(result)
  57. if (type !== QrCodeBusinessType.InStoreWriteOff) {
  58. uni.showToast({ title: '不支持此二维码/条码', icon: 'none', duration: 5000 })
  59. return
  60. }
  61. await requestToast(() => scanCodeCheckPaper({ orderNo: options.no }), {
  62. success: true,
  63. successTitle: '验券成功',
  64. })
  65. }
  66. const handle2Settlement = () => {
  67. if ((orderAmount.value ?? '') === '') {
  68. uni.showToast({ title: '请输入金额', icon: 'none', duration: 5000 })
  69. return
  70. }
  71. router.push(
  72. `/pages/home/merchant/settlement?orderAmount=${orderAmount.value}&pointsAmount=${pointsAmount.value}`,
  73. )
  74. }
  75. const toAddReporting = () => {
  76. uni.navigateTo({ url: '/pages/home/merchant/add-reporting-information' })
  77. }
  78. onShow(async () => {
  79. isAgent.value && (await Promise.all([setTasks()]))
  80. })
  81. onLoad(() => {
  82. console.log(isLogined.value)
  83. if (!isLogined.value) {
  84. uni.reLaunch({ url: '/pages/login/index' })
  85. }
  86. })
  87. onShareAppMessage(() => ({}))
  88. </script>
  89. <template>
  90. <view class="flex-grow relative">
  91. <template v-if="isAgent">
  92. <div class="aspect-[0.96/1] absolute left-0 right-0 top--1">
  93. <wd-img
  94. width="100%"
  95. height="100%"
  96. :src="merchantPageHeaderBg"
  97. custom-class="vertical-bottom"
  98. ></wd-img>
  99. </div>
  100. <wd-navbar custom-class="bg-transparent!" safe-area-inset-top :bordered="false">
  101. <template #left>
  102. <div
  103. @click="toAddReporting"
  104. class="ml-1 text-center text-white text-lg font-normal font-['PingFang_SC'] leading-relaxed"
  105. >
  106. 今日待办
  107. </div>
  108. </template>
  109. </wd-navbar>
  110. <div class="flex flex-col gap-8 p-4 relative box-border">
  111. <div>
  112. <div class="text-white text-sm font-normal font-['PingFang_SC'] leading-relaxed my-2.5">
  113. {{ dayjs().format('YYYY-MM-DD') }}
  114. </div>
  115. <Card>
  116. <div>
  117. <!-- <wd-steps :active="1" vertical>
  118. <wd-step description="注册1个账号" />
  119. <wd-step description="登录账号并绑定手机" />
  120. <wd-step description="完善个人信息" />
  121. </wd-steps> -->
  122. <PageHelperEvo :request="getTodoPage" :query="todosQuery"></PageHelperEvo>
  123. <div
  124. class="flex items-center justify-center b-t b-t-solid b-t-[#f6f6f6] pt-3.5"
  125. @click="router.push('/pages/home/agent/todo/index')"
  126. >
  127. <div class="text-[#2357e9] text-xs font-normal font-['PingFang_SC'] leading-none">
  128. 全部待办
  129. </div>
  130. <wd-icon name="arrow-right" size="10" color="#2357e9" />
  131. </div>
  132. </div>
  133. </Card>
  134. </div>
  135. <div>
  136. <SectionHeading
  137. title="任务"
  138. path="/pages/home/tasks/index"
  139. end-text="查看全部"
  140. custom-class="mb-5"
  141. ></SectionHeading>
  142. <div class="flex overflow-x-auto whitespace-nowrap mx--4 px-4 gap-4 box-border">
  143. <Card v-if="!tasks.list.length">
  144. <wd-status-tip image="search" tip="当前暂无未开始/进行中的任务" />
  145. </Card>
  146. <template v-for="(it, i) in tasks.list" :key="i">
  147. <div class="inline-block">
  148. <div class="w-[calc(75vw)]"><TaskCard :options="it"></TaskCard></div>
  149. </div>
  150. </template>
  151. </div>
  152. </div>
  153. <div>
  154. <SectionHeading title="设计师" path="" custom-class="mb-5"></SectionHeading>
  155. <div class="flex flex-col gap-4">
  156. <template
  157. v-for="{ label, color, ...it } of [
  158. {
  159. label: '关系报备',
  160. color: 'white',
  161. path: '/pages/home/agent/report-infos/index',
  162. },
  163. { label: '重点跟进设计师', color: '#FF523F', path: '/pages/designer/index' },
  164. { label: '全部设计师', color: '#7199FF', path: '/pages/designer/index' },
  165. { label: '本月新增设计师', color: '#FFE786', path: '/pages/designer/index' },
  166. { label: '超过30天未跟进', color: '#89F4E3', path: '/pages/designer/index' },
  167. {
  168. label: '超过60天未产生积分设计师',
  169. color: '#FFBA6A',
  170. path: '/pages/designer/index',
  171. },
  172. {
  173. label: '超过60天未消耗积分设计师',
  174. color: '#C494FF',
  175. path: '/pages/designer/index',
  176. },
  177. { label: '未成交过设计师', color: '#FF9EE2', path: '/pages/designer/index' },
  178. ]"
  179. :key="label"
  180. >
  181. <div class="h-12 bg-white rounded-lg shadow flex items-center hover:bg-[#fff6f5]">
  182. <div
  183. class="w-1.5 h-12 rounded-tl-lg rounded-bl-lg shadow"
  184. :style="{ background: color }"
  185. ></div>
  186. <div class="flex-1 mx-3">
  187. <SectionHeading :title="label" :path="it.path" size="sm"></SectionHeading>
  188. </div>
  189. </div>
  190. </template>
  191. </div>
  192. </div>
  193. <div>
  194. <SectionHeading title="设计师最新动态" path="" custom-class="mb-5"></SectionHeading>
  195. <PageHelperEvo
  196. :request="getDeignerPointsActivities"
  197. :query="{ brokerId: userInfo.userId }"
  198. >
  199. <template #default="{ source }">
  200. <div class="flex flex-col gap-4">
  201. <template v-for="(it, i) in source.list" :key="i">
  202. <Card>
  203. <div
  204. class="text-black/90 text-sm font-normal font-['PingFang_SC'] leading-none"
  205. >
  206. {{ it.content }}
  207. </div>
  208. <div
  209. class="mt-3 text-black/30 text-xs font-normal font-['PingFang_SC'] leading-none"
  210. >
  211. {{ dayjs(it.createTime).format('YYYY-MM-DD hh:mm') }}
  212. </div>
  213. </Card>
  214. </template>
  215. </div>
  216. </template>
  217. </PageHelperEvo>
  218. </div>
  219. </div>
  220. </template>
  221. <template v-if="isMerchant">
  222. <div
  223. class="bg-white backdrop-blur-[60px] my-[16px] flex flex-col justify-center items-center p-[16px] mt-[20px]"
  224. >
  225. <div
  226. class="w-[68px] h-[68px] bg-[#2357e9] rounded-full mt-[37px] flex items-center justify-center"
  227. >
  228. <wd-img width="36px" height="36px" :src="scanIcon"></wd-img>
  229. </div>
  230. <div class="w-full mt-[45px]">
  231. <wd-button block :round="false" @click="handleScanning">
  232. <div
  233. class="text-center text-white text-base font-normal font-['PingFang_SC'] leading-normal"
  234. >
  235. 扫码验券
  236. </div>
  237. </wd-button>
  238. </div>
  239. </div>
  240. <div
  241. class="bg-white backdrop-blur-[60px] flex flex-col justify-center items-center p-[16px] mt-[20px]"
  242. >
  243. <div
  244. class="w-[68px] h-[68px] bg-[#2357e9] rounded-full mt-[34px] flex items-center justify-center"
  245. >
  246. <wd-img width="36px" height="36px" :src="bookIcon"></wd-img>
  247. </div>
  248. <div class="w-full flex items-center mt-[40px] gap-5">
  249. <div
  250. class="text-black/90 text-base font-normal font-['PingFang_SC'] leading-relaxed w-[96px]"
  251. >
  252. 输入订单金额
  253. </div>
  254. <div class="flex-1 bg-[#f5f7f9] rounded-lg flex items-center p-3.5">
  255. <wd-input
  256. custom-class="bg-transparent! flex-1"
  257. type="number"
  258. no-border
  259. placeholder="请输金额"
  260. v-model="orderAmount"
  261. />
  262. </div>
  263. </div>
  264. <div class="w-full flex items-center mt-[20px] gap-5">
  265. <div
  266. class="text-black/90 text-base font-normal font-['PingFang_SC'] leading-relaxed w-[96px]"
  267. >
  268. 需支付积分
  269. </div>
  270. <div class="text-[#ff2d2d] text-base font-normal font-['PingFang_SC'] leading-relaxed">
  271. {{ pointsAmount }} 积分
  272. </div>
  273. </div>
  274. <div class="w-full mt-[45px]">
  275. <wd-button block :round="false" @click="handle2Settlement">
  276. <div
  277. class="text-center text-white text-base font-normal font-['PingFang_SC'] leading-normal"
  278. >
  279. 积分结账
  280. </div>
  281. </wd-button>
  282. </div>
  283. </div>
  284. </template>
  285. </view>
  286. </template>
  287. <style></style>