index.vue 9.6 KB

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