index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <layout-page>
  3. <view style="position: relative;">
  4. <Calendar
  5. class="uni-calendar--hook"
  6. :selected="selected"
  7. :lunar="true"
  8. :range="false"
  9. :showMonth="true"
  10. @change="handleChange"
  11. />
  12. <view class="journal" v-if="journalData && Object.keys(journalData).length > 0">
  13. <view class="title">手账</view>
  14. <uni-card @click.stop="handleAddJournal(journalData.id, journalData.description)">
  15. <view class="d-flex align-center">
  16. <view class="line"></view>
  17. <view class="date">{{ journalData.date }}</view>
  18. </view>
  19. <view class="description ss-m-t-15">{{ journalData.description }}</view>
  20. </uni-card>
  21. </view>
  22. <view class="add-btn" @click.stop="handleAddJournal">
  23. <uni-icons type="plusempty" size="30" color="#fff"></uni-icons>
  24. </view>
  25. <uni-popup ref="popupRef" type="dialog">
  26. <view class="popupContent">
  27. <view class="content-box">
  28. <view class="text-center ss-p-y-30">
  29. <view class="yangli">{{ calendarInfo.yangli }}</view>
  30. <view class="yinli">{{ calendarInfo.yinli }}</view>
  31. <view class="d-flex align-center justify-center">
  32. <span style="color: #7f7f7f;">幸运色</span>
  33. <view class="luckyColor ss-m-l-20" :style="{ 'background-color': `${currentColor || '#2979ff'}` }"></view>
  34. </view>
  35. </view>
  36. <view class="center-box ss-p-y-30 ss-p-x-30">
  37. <view class="d-flex">
  38. <view class="yi d-flex align-center justify-center">宜</view>
  39. <view class="font-size-15" style="flex: 1; color: #c6b393;">{{ calendarInfo.yi }}</view>
  40. </view>
  41. <view class="d-flex ss-m-t-30">
  42. <view class="ji d-flex align-center justify-center">忌</view>
  43. <view class="font-size-15" style="flex: 1; color: #7f7f7f;">{{ calendarInfo.ji }}</view>
  44. </view>
  45. </view>
  46. <view class="bottom-box">
  47. <view class="bottom-box-item d-flex flex-column align-center justify-center">
  48. <view class="padding">
  49. <view class="label">五行</view>
  50. <view class="value">{{ calendarInfo.wuxing }}</view>
  51. </view>
  52. <view style="border-top: 1px solid #c2a08c; height: 1px; width: 100%;"></view>
  53. <view class="padding">
  54. <view class="label">吉神</view>
  55. <view class="value">{{ calendarInfo.jishen }}</view>
  56. </view>
  57. </view>
  58. <view class="bottom-box-item d-flex align-center justify-center">
  59. <view class="padding">
  60. <view class="label">彭祖</view>
  61. <view class="value">{{ calendarInfo.baiji }}</view>
  62. </view>
  63. </view>
  64. <view class="bottom-box-item d-flex flex-column align-center justify-center">
  65. <view class="padding">
  66. <view class="label">冲煞</view>
  67. <view class="value">{{ calendarInfo.chongsha }}</view>
  68. </view>
  69. <view style="border-top: 1px solid #c2a08c; height: 1px; width: 100%;"></view>
  70. <view class="padding">
  71. <view class="label">凶神</view>
  72. <view class="value">{{ calendarInfo.xiongshen }}</view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. <view class="text-center ss-m-t-50">
  79. <uni-icons type="close" size="40" color="#fff" @click="handleClose"></uni-icons>
  80. </view>
  81. </uni-popup>
  82. </view>
  83. </layout-page>
  84. </template>
  85. <script setup>
  86. import { onLoad } from '@dcloudio/uni-app'
  87. import { ref } from 'vue'
  88. import Calendar from '@/components/uni-calendar/components/uni-calendar/uni-calendar.vue'
  89. import { getDrawLots } from '@/api/drawLots.js'
  90. import layoutPage from '@/layout'
  91. import { showAuthModal, closeAuthModal } from '@/hooks/useModal'
  92. const journalData = ref({
  93. id: 1,
  94. date: '2025-08-27',
  95. description: '南京金陵酒店管理有限公司隶属于金陵饭店集团酒店业务板块,成立于2004年,已成为品牌化、连锁化、规模化发展的酒店管理专业机构。着力打造多层级品牌体系,构建涵盖高中端精品商务酒店、休闲度假酒店、主题文化酒店、智能公寓酒店等多样化产品线。公司秉承金陵饭店“细意浓情”服务理念,融合国际标准、传承中国文化、深耕本土特色,依托总部强大的支撑体系,为在管运营酒店赋能,为业主提供超值服务。“金陵”相继摘取中国质量奖——“全国质量工作先进单位标兵”,荣膺中国质量领域政府性荣誉——首届“中国质量奖”提名奖,十度蝉联世界品牌实验室评定的全球服务业奖项——“五星钻石奖”,位列中国饭店集团前30强,保持全国国有高星级酒店集团前三甲。国家旅游局在《饭店星评标准访查示范》中,将金陵饭店的管理模式和服务标准作为五星级酒店示范样板并拍摄成教学片,向全国酒店业推广。'
  96. })
  97. function getDate(date, AddDayCount = 0) {
  98. if (!date) {
  99. date = new Date()
  100. }
  101. if (typeof date !== 'object') {
  102. date = date.replace(/-/g, '/')
  103. }
  104. const dd = new Date(date)
  105. dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
  106. const y = dd.getFullYear()
  107. const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
  108. const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
  109. return {
  110. fullDate: y + '-' + m + '-' + d,
  111. year: y,
  112. month: m,
  113. date: d,
  114. day: dd.getDay()
  115. }
  116. }
  117. const selected = ref([])
  118. const setSelectedDates = () => {
  119. selected.value = [
  120. {
  121. date: getDate(new Date(),-20).fullDate,
  122. color: '#d3e3fd',
  123. url: 'https://menduner.citupro.com:3443/dev/2dbc20a5db2122e399b491638889ba9f8aea4e1c7a44463ee0df40b25f85b8cc.png'
  124. },
  125. {
  126. date: getDate(new Date(),-16).fullDate,
  127. color: '#f8bbd0',
  128. url: 'https://menduner.citupro.com:3443/dev/2dbc20a5db2122e399b491638889ba9f8aea4e1c7a44463ee0df40b25f85b8cc.png'
  129. },
  130. {
  131. date: getDate(new Date(),-12).fullDate,
  132. color: '#3bb19b',
  133. url: 'https://menduner.citupro.com:3443/dev/2dbc20a5db2122e399b491638889ba9f8aea4e1c7a44463ee0df40b25f85b8cc.png'
  134. },
  135. {
  136. date: getDate(new Date(),-7).fullDate,
  137. color: '#facd89',
  138. url: 'https://menduner.citupro.com:3443/dev/2dbc20a5db2122e399b491638889ba9f8aea4e1c7a44463ee0df40b25f85b8cc.png'
  139. },
  140. {
  141. date: getDate(new Date(),-3).fullDate,
  142. color: '#d7ccc8',
  143. url: 'https://menduner.citupro.com:3443/dev/2dbc20a5db2122e399b491638889ba9f8aea4e1c7a44463ee0df40b25f85b8cc.png'
  144. },
  145. {
  146. date: getDate(new Date(),-2).fullDate,
  147. color: '#c5cae9',
  148. url: 'https://menduner.citupro.com:3443/dev/2dbc20a5db2122e399b491638889ba9f8aea4e1c7a44463ee0df40b25f85b8cc.png'
  149. }
  150. ]
  151. }
  152. onLoad(() => {
  153. // showAuthModal()
  154. closeAuthModal()
  155. // 设置选中项
  156. setTimeout(() => {
  157. setSelectedDates()
  158. }, 2000)
  159. })
  160. const popupRef = ref()
  161. const currentColor = ref(null)
  162. const calendarInfo = ref({})
  163. const handleChange = async (e) => {
  164. if (e.isBackToday) return // 点击左上角“今日”按钮不弹窗
  165. try {
  166. const { result } = await getDrawLots({ date: e.fulldate })
  167. if (!result) return uni.showToast({ title: '黄历信息获取失败', icon: 'none' })
  168. console.log(result, '成功信息')
  169. calendarInfo.value = result || {}
  170. popupRef.value.open()
  171. currentColor.value = result?.color || e.extraInfo?.color
  172. } catch (error) {
  173. console.log(error, '错误信息')
  174. }
  175. }
  176. const handleClose = () => {
  177. popupRef.value.close()
  178. currentColor.value = null
  179. calendarInfo.value = {}
  180. }
  181. // 添加手账
  182. const handleAddJournal = (id, text) => {
  183. let url = `/pages/drawLots/journal`
  184. if (id) url += `?id=${id}&text=${text}`
  185. uni.navigateTo({
  186. url
  187. })
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. $commonColor: #c2a08c;
  192. $size: 25px;
  193. :deep {
  194. .uni-card {
  195. border-radius: 10px !important;
  196. }
  197. }
  198. .journal {
  199. margin-top: 30rpx;
  200. padding-bottom: 100px;
  201. .title {
  202. // color: #2979ff;
  203. color: #999;
  204. margin: 0 30px;
  205. }
  206. .date {
  207. font-size: 17px;
  208. font-weight: bold;
  209. }
  210. .line {
  211. width: 5px;
  212. height: 15px;
  213. border-radius: 4px;
  214. background-color: #2979ff;
  215. margin-right: 10px;
  216. }
  217. .description {
  218. display: -webkit-box;
  219. -webkit-box-orient: vertical;
  220. -webkit-line-clamp: 6;
  221. overflow: hidden;
  222. }
  223. }
  224. .add-btn {
  225. position: fixed;
  226. right: 20px;
  227. bottom: 50px;
  228. width: 60px;
  229. height: 60px;
  230. border-radius: 50%;
  231. background-color: #2979ff;
  232. display: flex;
  233. align-items: center;
  234. justify-content: center;
  235. }
  236. .popupContent {
  237. position: relative;
  238. background-color: #fff;
  239. width: 70vw;
  240. padding: 30rpx;
  241. .content-box {
  242. height: 100%;
  243. border: 1px solid $commonColor;
  244. border-radius: 6px;
  245. }
  246. .yangli {
  247. font-weight: bold;
  248. color: $commonColor;
  249. font-size: 30px;
  250. }
  251. .yinli {
  252. color: #7f7f7f;
  253. margin: 10px 0;
  254. }
  255. .center-box {
  256. border-top: 1px solid $commonColor;
  257. border-bottom: 1px solid $commonColor;
  258. .yi {
  259. width: $size;
  260. height: $size;
  261. background-color: #c39c87;
  262. border-radius: 50%;
  263. color: #fff;
  264. margin-right: 10px;
  265. font-size: 14px;
  266. }
  267. .ji {
  268. width: $size;
  269. height: $size;
  270. background-color: #bfbfbf;
  271. border-radius: 50%;
  272. color: #fff;
  273. margin-right: 10px;
  274. font-size: 14px;
  275. }
  276. }
  277. .bottom-box {
  278. display: flex;
  279. &-item {
  280. width: 33.3%;
  281. text-align: center;
  282. border-right: 1px solid $commonColor;
  283. &:nth-child(3n) {
  284. border-right: none;
  285. }
  286. .label {
  287. font-size: 17px;
  288. }
  289. .value {
  290. color: #7f7f7f;
  291. font-size: 14px;
  292. margin-top: 10px;
  293. }
  294. .padding {
  295. padding: 10px;
  296. }
  297. }
  298. }
  299. .luckyColor {
  300. width: 50rpx;
  301. height: 50rpx;
  302. border-radius: 50%;
  303. }
  304. }
  305. </style>