index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <route lang="json5">
  2. {
  3. layout: 'tabbar',
  4. style: {
  5. navigationBarTitleText: '首页',
  6. navigationBarBackgroundColor: '#fff',
  7. },
  8. }
  9. </route>
  10. <script lang="ts" setup>
  11. import useRequest from '../../hooks/useRequest'
  12. import dayjs from 'dayjs'
  13. import { getCircles, scanCodeCheckPaper } from '../../core/libs/requests'
  14. import SectionHeading from '@designer-hub/app/src/components/section-heading.vue'
  15. import Card from '@designer-hub/app/src/components/card.vue'
  16. import { merchantPageHeaderBg, scanIcon, bookIcon } from '@designer-hub/assets/src/svgs'
  17. import { useUserStore } from '../../store'
  18. import { storeToRefs } from 'pinia'
  19. import { qrCodeString2Object, requestToast } from '@designer-hub/app/src/core/utils/common'
  20. import { useRouter } from '@designer-hub/app/src/core/utils/router'
  21. import { QrCodeBusinessType } from '../../core/libs/enums'
  22. defineOptions({
  23. name: 'Home',
  24. })
  25. const router = useRouter()
  26. const userStore = useUserStore()
  27. const { isLogined, userInfo } = storeToRefs(userStore)
  28. // 测试 uni API 自动引入
  29. const { data } = useRequest(async () => ({ code: 0, msg: '', data: {} }) as IResData<any>, {
  30. initialData: {
  31. banners: [],
  32. hots: [
  33. {
  34. id: 1,
  35. title: '日本研学·东京艺术大学游学',
  36. img: '',
  37. start: dayjs('2024-07-15').toDate(),
  38. end: dayjs('2024-08-10').toDate(),
  39. },
  40. {
  41. id: 1,
  42. title: '日本研学·东京艺术大学游学',
  43. img: '',
  44. start: dayjs('2024-07-15').toDate(),
  45. end: dayjs('2024-08-10').toDate(),
  46. },
  47. ],
  48. dynamics: [
  49. {
  50. author: {
  51. avatar: 'https://via.placeholder.com/35x35',
  52. nickname: '苏小萌',
  53. level: '0',
  54. },
  55. content: '用心做好设计,为客户创造美好家居环境',
  56. images: ['https://via.placeholder.com/165x220'],
  57. tags: ['意大利游学设计班'],
  58. shares: 0,
  59. comments: 0,
  60. likes: 0,
  61. createdAt: dayjs('2024-07-15').toDate(),
  62. },
  63. {
  64. author: {
  65. avatar: 'https://via.placeholder.com/35x35',
  66. nickname: '苏小萌',
  67. level: '0',
  68. },
  69. content: '用心做好设计,为客户创造美好家居环境',
  70. images: ['https://via.placeholder.com/220x165'],
  71. tags: ['意大利游学设计班'],
  72. shares: 0,
  73. comments: 0,
  74. likes: 0,
  75. createdAt: dayjs('2024-07-15').toDate(),
  76. },
  77. {
  78. author: {
  79. avatar: 'https://via.placeholder.com/35x35',
  80. nickname: '苏小萌',
  81. level: '0',
  82. },
  83. content: '用心做好设计,为客户创造美好家居环境',
  84. images: [
  85. 'https://via.placeholder.com/104x104',
  86. 'https://via.placeholder.com/104x204',
  87. 'https://via.placeholder.com/204x104',
  88. ],
  89. tags: ['意大利游学设计班'],
  90. shares: 0,
  91. comments: 0,
  92. likes: 0,
  93. createdAt: dayjs('2024-07-15').toDate(),
  94. },
  95. ],
  96. studyTour: null,
  97. },
  98. })
  99. const { data: circlesData, run } = useRequest(() => getCircles({}), { initialData: { list: [] } })
  100. const orderAmount = ref()
  101. const pointsAmount = computed(() => orderAmount.value * 10)
  102. console.log(data.value)
  103. const toDesigner = () => {
  104. uni.navigateTo({ url: '/pages/designer/index' })
  105. }
  106. const handleScanning = async () => {
  107. console.log('handleScanning')
  108. const { result } = await uni.scanCode({ scanType: ['qrCode'] })
  109. const { type, options } = qrCodeString2Object(result)
  110. if (type !== QrCodeBusinessType.InStoreWriteOff) {
  111. uni.showToast({ title: '不支持此二维码/条码', icon: 'none', duration: 5000 })
  112. return
  113. }
  114. await requestToast(() => scanCodeCheckPaper({ orderNo: options.no }), {
  115. success: true,
  116. successTitle: '验券成功',
  117. })
  118. }
  119. const handle2Settlement = () => {
  120. if ((orderAmount.value ?? '') === '') {
  121. uni.showToast({ title: '请输入金额', icon: 'none', duration: 5000 })
  122. return
  123. }
  124. router.push(
  125. `/pages/home/merchant/settlement?orderAmount=${orderAmount.value}&pointsAmount=${pointsAmount.value}`,
  126. )
  127. }
  128. const toAddReporting = () => {
  129. uni.navigateTo({ url: '/pages/home/merchant/add-reporting-information' })
  130. }
  131. onShow(async () => {})
  132. onLoad(() => {
  133. console.log(isLogined.value)
  134. if (!isLogined.value) {
  135. uni.reLaunch({ url: '/pages/login/index' })
  136. }
  137. })
  138. onShareAppMessage(() => ({}))
  139. </script>
  140. <template>
  141. <view class="flex-grow relative">
  142. <template v-if="userInfo.appLoginType === 1">
  143. <div class="aspect-[0.96/1] absolute left-0 right-0 top--1">
  144. <wd-img
  145. width="100%"
  146. height="100%"
  147. :src="merchantPageHeaderBg"
  148. custom-class="vertical-bottom"
  149. ></wd-img>
  150. </div>
  151. 1
  152. <wd-navbar custom-class="bg-transparent!" safe-area-inset-top :bordered="false">
  153. <template #left>
  154. <div
  155. @click="toAddReporting"
  156. class="ml-1 text-center text-white text-lg font-normal font-['PingFang_SC'] leading-relaxed"
  157. >
  158. 今日待办
  159. </div>
  160. </template>
  161. </wd-navbar>
  162. <div class="flex flex-col gap-8 p-4 relative box-border">
  163. <div>
  164. <SectionHeading
  165. title="渠道任务"
  166. path="/pages/home/tasks/index"
  167. end-text="查看全部"
  168. custom-class="mb-5"
  169. ></SectionHeading>
  170. <Card><wd-status-tip image="search" tip="当前暂无未开始/进行中的任务" /></Card>
  171. </div>
  172. <div>
  173. <SectionHeading title="设计师" path="" custom-class="mb-5"></SectionHeading>
  174. <div class="flex flex-col gap-4">
  175. <template
  176. v-for="{ label, color } of [
  177. { label: '重点跟进设计师', color: '#FF523F' },
  178. { label: '全部设计师', color: '#7199FF' },
  179. { label: '本月新增设计师', color: '#FFE786' },
  180. { label: '超过30天未跟进', color: '#89F4E3' },
  181. { label: '超过60天未产生积分设计师', color: '#FFBA6A' },
  182. { label: '超过60天未消耗积分设计师', color: '#C494FF' },
  183. { label: '未成交过设计师', color: '#FF9EE2' },
  184. ]"
  185. :key="label"
  186. >
  187. <div
  188. class="h-12 bg-white rounded-lg shadow flex items-center hover:bg-[#fff6f5]"
  189. @click="toDesigner"
  190. >
  191. <div
  192. class="w-1.5 h-12 rounded-tl-lg rounded-bl-lg shadow"
  193. :style="{ background: color }"
  194. ></div>
  195. <div class="flex-1 mx-3">
  196. <SectionHeading
  197. :title="label"
  198. path="/pages/designer/index"
  199. size="sm"
  200. ></SectionHeading>
  201. </div>
  202. </div>
  203. </template>
  204. </div>
  205. </div>
  206. <div>
  207. <SectionHeading title="设计师最新动态" path="" custom-class="mb-5"></SectionHeading>
  208. <div class="flex flex-col gap-4">
  209. <template
  210. v-for="{ title, date } of [
  211. { title: '苏小萌报名了日本设计游学', date: new Date() },
  212. { title: '苏小萌报名了骑行活动', date: new Date() },
  213. { title: '苏小萌获取imola16000积分', date: new Date() },
  214. ]"
  215. :key="title"
  216. >
  217. <Card>
  218. <div class="text-black/90 text-sm font-normal font-['PingFang_SC'] leading-none">
  219. {{ title }}
  220. </div>
  221. <div
  222. class="mt-3 text-black/30 text-xs font-normal font-['PingFang_SC'] leading-none"
  223. >
  224. {{ dayjs(date).format('YYYY-MM-DD hh:mm') }}
  225. </div>
  226. </Card>
  227. </template>
  228. </div>
  229. </div>
  230. </div>
  231. </template>
  232. <template v-if="userInfo.appLoginType === 2">
  233. <div
  234. class="bg-white backdrop-blur-[60px] my-[16px] flex flex-col justify-center items-center p-[16px] mt-[20px]"
  235. >
  236. <div
  237. class="w-[68px] h-[68px] bg-[#2357e9] rounded-full mt-[37px] flex items-center justify-center"
  238. >
  239. <wd-img width="36px" height="36px" :src="scanIcon"></wd-img>
  240. </div>
  241. <div class="w-full mt-[45px]">
  242. <wd-button block :round="false" @click="handleScanning">
  243. <div
  244. class="text-center text-white text-base font-normal font-['PingFang_SC'] leading-normal"
  245. >
  246. 扫码验券
  247. </div>
  248. </wd-button>
  249. </div>
  250. </div>
  251. <div
  252. class="bg-white backdrop-blur-[60px] flex flex-col justify-center items-center p-[16px] mt-[20px]"
  253. >
  254. <div
  255. class="w-[68px] h-[68px] bg-[#2357e9] rounded-full mt-[34px] flex items-center justify-center"
  256. >
  257. <wd-img width="36px" height="36px" :src="bookIcon"></wd-img>
  258. </div>
  259. <div class="w-full flex items-center mt-[40px] gap-5">
  260. <div
  261. class="text-black/90 text-base font-normal font-['PingFang_SC'] leading-relaxed w-[96px]"
  262. >
  263. 输入订单金额
  264. </div>
  265. <div class="flex-1 bg-[#f5f7f9] rounded-lg flex items-center p-3.5">
  266. <wd-input
  267. custom-class="bg-transparent! flex-1"
  268. type="number"
  269. no-border
  270. placeholder="请输金额"
  271. v-model="orderAmount"
  272. />
  273. </div>
  274. </div>
  275. <div class="w-full flex items-center mt-[20px] gap-5">
  276. <div
  277. class="text-black/90 text-base font-normal font-['PingFang_SC'] leading-relaxed w-[96px]"
  278. >
  279. 需支付积分
  280. </div>
  281. <div class="text-[#ff2d2d] text-base font-normal font-['PingFang_SC'] leading-relaxed">
  282. {{ pointsAmount }} 积分
  283. </div>
  284. </div>
  285. <div class="w-full mt-[45px]">
  286. <wd-button block :round="false" @click="handle2Settlement">
  287. <div
  288. class="text-center text-white text-base font-normal font-['PingFang_SC'] leading-normal"
  289. >
  290. 积分结账
  291. </div>
  292. </wd-button>
  293. </div>
  294. </div>
  295. </template>
  296. </view>
  297. </template>
  298. <style></style>