index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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 { requestToast } from '@designer-hub/app/src/core/utils/common'
  20. import { useRouter } from '@designer-hub/app/src/core/utils/router'
  21. defineOptions({
  22. name: 'Home',
  23. })
  24. const router = useRouter()
  25. const userStore = useUserStore()
  26. const { isLogined, userInfo } = storeToRefs(userStore)
  27. // 测试 uni API 自动引入
  28. const { data } = useRequest(async () => ({ code: 0, msg: '', data: {} }) as IResData<any>, {
  29. initialData: {
  30. banners: [],
  31. hots: [
  32. {
  33. id: 1,
  34. title: '日本研学·东京艺术大学游学',
  35. img: '',
  36. start: dayjs('2024-07-15').toDate(),
  37. end: dayjs('2024-08-10').toDate(),
  38. },
  39. {
  40. id: 1,
  41. title: '日本研学·东京艺术大学游学',
  42. img: '',
  43. start: dayjs('2024-07-15').toDate(),
  44. end: dayjs('2024-08-10').toDate(),
  45. },
  46. ],
  47. dynamics: [
  48. {
  49. author: {
  50. avatar: 'https://via.placeholder.com/35x35',
  51. nickname: '苏小萌',
  52. level: '0',
  53. },
  54. content: '用心做好设计,为客户创造美好家居环境',
  55. images: ['https://via.placeholder.com/165x220'],
  56. tags: ['意大利游学设计班'],
  57. shares: 0,
  58. comments: 0,
  59. likes: 0,
  60. createdAt: dayjs('2024-07-15').toDate(),
  61. },
  62. {
  63. author: {
  64. avatar: 'https://via.placeholder.com/35x35',
  65. nickname: '苏小萌',
  66. level: '0',
  67. },
  68. content: '用心做好设计,为客户创造美好家居环境',
  69. images: ['https://via.placeholder.com/220x165'],
  70. tags: ['意大利游学设计班'],
  71. shares: 0,
  72. comments: 0,
  73. likes: 0,
  74. createdAt: dayjs('2024-07-15').toDate(),
  75. },
  76. {
  77. author: {
  78. avatar: 'https://via.placeholder.com/35x35',
  79. nickname: '苏小萌',
  80. level: '0',
  81. },
  82. content: '用心做好设计,为客户创造美好家居环境',
  83. images: [
  84. 'https://via.placeholder.com/104x104',
  85. 'https://via.placeholder.com/104x204',
  86. 'https://via.placeholder.com/204x104',
  87. ],
  88. tags: ['意大利游学设计班'],
  89. shares: 0,
  90. comments: 0,
  91. likes: 0,
  92. createdAt: dayjs('2024-07-15').toDate(),
  93. },
  94. ],
  95. studyTour: null,
  96. },
  97. })
  98. const { data: circlesData, run } = useRequest(() => getCircles({}), { initialData: { list: [] } })
  99. const orderAmount = ref()
  100. const pointsAmount = computed(() => orderAmount.value * 10)
  101. console.log(data.value)
  102. const toDesigner = () => {
  103. uni.navigateTo({ url: '/pages/designer/index' })
  104. }
  105. const toSettlement = async () => {
  106. console.log('11')
  107. await uni.navigateTo({ url: '/pages/home/merchant/settlement' })
  108. }
  109. const handleScanning = async () => {
  110. console.log('handleScanning')
  111. const { result } = await uni.scanCode({ scanType: ['qrCode'] })
  112. console.log(result)
  113. await requestToast(() => scanCodeCheckPaper({ orderNo: result }), {
  114. success: true,
  115. successTitle: '验券成功',
  116. })
  117. }
  118. onShow(async () => {
  119. // await run()
  120. console.log(circlesData.value)
  121. })
  122. onLoad(() => {
  123. console.log(isLogined.value)
  124. if (!isLogined.value) {
  125. uni.reLaunch({ url: '/pages/login/index' })
  126. }
  127. })
  128. onShareAppMessage(() => ({}))
  129. </script>
  130. <template>
  131. <view class="flex-grow relative">
  132. <template v-if="userInfo.appLoginType === 1">
  133. <div class="aspect-[0.96/1] absolute left-0 right-0 top--1">
  134. <wd-img
  135. width="100%"
  136. height="100%"
  137. :src="merchantPageHeaderBg"
  138. custom-class="vertical-bottom"
  139. ></wd-img>
  140. </div>
  141. 1
  142. <wd-navbar custom-class="bg-transparent!" safe-area-inset-top :bordered="false">
  143. <template #left>
  144. <div
  145. class="ml-1 text-center text-white text-lg font-normal font-['PingFang_SC'] leading-relaxed"
  146. >
  147. 今日待办
  148. </div>
  149. </template>
  150. </wd-navbar>
  151. <div class="flex flex-col gap-8 p-4 relative box-border">
  152. <div>
  153. <SectionHeading
  154. title="渠道任务"
  155. path="/pages/home/tasks/index"
  156. end-text="查看全部"
  157. custom-class="mb-5"
  158. ></SectionHeading>
  159. <Card><wd-status-tip image="search" tip="当前暂无未开始/进行中的任务" /></Card>
  160. </div>
  161. <div>
  162. <SectionHeading title="设计师" path="" custom-class="mb-5"></SectionHeading>
  163. <div class="flex flex-col gap-4">
  164. <template
  165. v-for="{ label, color } of [
  166. { label: '重点跟进设计师', color: '#FF523F' },
  167. { label: '全部设计师', color: '#7199FF' },
  168. { label: '本月新增设计师', color: '#FFE786' },
  169. { label: '超过30天未跟进', color: '#89F4E3' },
  170. { label: '超过60天未产生积分设计师', color: '#FFBA6A' },
  171. { label: '超过60天未消耗积分设计师', color: '#C494FF' },
  172. { label: '未成交过设计师', color: '#FF9EE2' },
  173. ]"
  174. :key="label"
  175. >
  176. <div
  177. class="h-12 bg-white rounded-lg shadow flex items-center hover:bg-[#fff6f5]"
  178. @click="toDesigner"
  179. >
  180. <div
  181. class="w-1.5 h-12 rounded-tl-lg rounded-bl-lg shadow"
  182. :style="{ background: color }"
  183. ></div>
  184. <div class="flex-1 mx-3">
  185. <SectionHeading
  186. :title="label"
  187. path="/pages/designer/index"
  188. size="sm"
  189. ></SectionHeading>
  190. </div>
  191. </div>
  192. </template>
  193. </div>
  194. </div>
  195. <div>
  196. <SectionHeading title="设计师最新动态" path="" custom-class="mb-5"></SectionHeading>
  197. <div class="flex flex-col gap-4">
  198. <template
  199. v-for="{ title, date } of [
  200. { title: '苏小萌报名了日本设计游学', date: new Date() },
  201. { title: '苏小萌报名了骑行活动', date: new Date() },
  202. { title: '苏小萌获取imola16000积分', date: new Date() },
  203. ]"
  204. :key="title"
  205. >
  206. <Card>
  207. <div class="text-black/90 text-sm font-normal font-['PingFang_SC'] leading-none">
  208. {{ title }}
  209. </div>
  210. <div
  211. class="mt-3 text-black/30 text-xs font-normal font-['PingFang_SC'] leading-none"
  212. >
  213. {{ dayjs(date).format('YYYY-MM-DD hh:mm') }}
  214. </div>
  215. </Card>
  216. </template>
  217. </div>
  218. </div>
  219. </div>
  220. </template>
  221. <template v-if="userInfo.appLoginType === 2">
  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
  276. block
  277. :round="false"
  278. @click="
  279. router.push(
  280. `/pages/home/merchant/settlement?orderAmount=${orderAmount}&pointsAmount=${pointsAmount}`,
  281. )
  282. "
  283. >
  284. <div
  285. class="text-center text-white text-base font-normal font-['PingFang_SC'] leading-normal"
  286. >
  287. 积分结账
  288. </div>
  289. </wd-button>
  290. </div>
  291. </div>
  292. </template>
  293. </view>
  294. </template>
  295. <style></style>