new_file.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view>
  3. <!-- 服务选择 -->
  4. <template v-if="userType == 1">
  5. <view class="Wrapper-grid">
  6. <up-grid :border="false" col="3" @click="handleGridClick">
  7. <up-grid-item v-for="(item, index) in serviceList1" :key="index"
  8. :custom-style="{ padding: '20rpx' }">
  9. <!-- 图标 -->
  10. <image :src="item.icon" class="service-img" mode="aspectFit" />
  11. <!-- 文本 -->
  12. <text class="grid-text">{{ item.name }}</text>
  13. </up-grid-item>
  14. </up-grid>
  15. <up-toast ref="uToastRef" />
  16. </view>
  17. </template>
  18. <template v-else-if="userType == 2">
  19. <view class="Wrapper-grid">
  20. <up-grid :border="false" col="4" @click="handleGridClick">
  21. <up-grid-item v-for="(item, index) in serviceList2" :key="index"
  22. :custom-style="{ padding: '20rpx' }">
  23. <!-- 图标 -->
  24. <image :src="item.icon" class="service-img" mode="aspectFit" />
  25. <!-- 文本 -->
  26. <text class="grid-text">111{{ item.name }}</text>
  27. </up-grid-item>
  28. </up-grid>
  29. <up-toast ref="uToastRef" />
  30. </view>
  31. </template>
  32. <Calendar ref="calendar" class="uni-calendar--hook" :clear-date="false" :date="info.date" :insert="info.insert"
  33. :lunar="info.lunar" :range="info.range" @change="change"
  34. @confirm="confirm" :selected="selected" />
  35. </view>
  36. </template>
  37. <script setup>
  38. import {
  39. ref,
  40. onMounted,
  41. watch,
  42. computed
  43. } from 'vue';
  44. import {
  45. typeOptionSelect
  46. } from "@/api/volunteerDetailsApi/details.js"
  47. import dayjs from 'dayjs';
  48. import { workDate } from '@/api/volunteer.js'
  49. import Calendar from '../../components/uni-calendar/components/uni-calendar/uni-calendar.vue'
  50. // Toast 控制宫格
  51. const uToastRef = ref(null);
  52. const userType = uni.getStorageSync('userType') //读取本地存储
  53. const calendar =ref(null)
  54. const datas = ref(["2025-04-10","2025-04-11",]);
  55. const info = ref({
  56. lunar: true,
  57. range: false,
  58. insert: false,
  59. // mode:'multiple',//multiple:多选
  60. })
  61. const selected = ref([])
  62. // 普通用户
  63. const serviceList1 = ref([
  64. {
  65. icon: '/static/img/统一知识平台-营运@1x.png',
  66. name: '家庭辅导'
  67. },
  68. {
  69. icon: '/static/img/编组.png',
  70. name: '陪伴陪聊'
  71. },
  72. {
  73. icon: '/static/img/清空.png',
  74. name: '家庭助理'
  75. },
  76. {
  77. icon: '/static/img/构建.png',
  78. name: '健康管理'
  79. },
  80. {
  81. icon: '/static/img/报事报修@6x.png',
  82. name: '家庭清洁'
  83. },
  84. {
  85. icon: '/static/img/报事报修@6x.png',
  86. name: '家务帮手'
  87. },
  88. ]);
  89. //志愿者
  90. const serviceList2 = ref([{
  91. icon: '/static/img/统一知识平台-营运@1x.png',
  92. name: '家庭辅导注册',
  93. key:2,
  94. },
  95. {
  96. icon: '/static/img/编组.png',
  97. name: '陪伴陪聊注册',
  98. key:1,
  99. },
  100. {
  101. icon: '/static/img/清空.png',
  102. name: '家庭助理注册',
  103. key:3,
  104. },
  105. {
  106. icon: '/static/img/构建.png',
  107. name: '健康管理注册',
  108. key:4
  109. },
  110. {
  111. icon: '/static/img/报事报修@6x.png',
  112. name: '家庭清洁注册',
  113. key:5
  114. },
  115. {
  116. icon: '/static/img/报事报修@6x.png',
  117. name: '家务帮手注册',
  118. key:6
  119. },
  120. {
  121. icon: '/static/img/清空.png',
  122. name: '时间管理',
  123. key:7
  124. },
  125. ]);
  126. //选中的日期展示格式;
  127. const formatter = (day) => {
  128. const d = dayjs(day.date).format('YYYY-MM-DD')
  129. for (let i = 0; i < datas.value.length; i++) {
  130. const e = datas.value[i].split(' ');
  131. if(e[0] === d){
  132. console.log('e',e,e[0] === d,d);
  133. console.log(day,d.e);
  134. day.bottomInfo = 'xx'
  135. // day.dot = true
  136. }
  137. }
  138. return day
  139. }
  140. // 宫格点击事件
  141. const handleGridClick = async (index) => {
  142. console.log('userType',userType);
  143. if (userType == 1) {
  144. const res = await typeOptionSelect()
  145. console.log((res, '获取健值成功'))
  146. uni.navigateTo({
  147. url: '/pages_home/pages/client/details'
  148. });
  149. return
  150. }
  151. if (uToastRef.value) {
  152. const data = serviceList2.value[index]
  153. if (data.key !== 7) {
  154. uni.navigateTo({
  155. url: `/pages/register/register?data=${encodeURIComponent(JSON.stringify(data))}`
  156. });
  157. return;
  158. }
  159. calendar.value.open();
  160. }
  161. };
  162. const change = (e) => {
  163. console.log('change', e);
  164. selected.value = [...selected.value,
  165. {
  166. date: e.fulldate,
  167. info: `${e.time.startTime}~${e.time.endTime}`,
  168. time:e.time
  169. }
  170. ]
  171. }
  172. const confirm = () => {
  173. const parmas = selected.value.map(item => {
  174. return {
  175. workDate: item.date,
  176. workStartTime: item.startTime,
  177. workEndTime: item.endTime
  178. }
  179. })
  180. console.log('确定',parmas);
  181. workDate(parmas).then(res => {
  182. if(res.code == 200){
  183. uni.showToast({
  184. title: '修改成功',
  185. icon: 'none'
  186. })
  187. close();
  188. return;
  189. }
  190. uni.showToast({
  191. title: res.msg,
  192. icon: 'none'
  193. })
  194. })
  195. };
  196. const close = () => {
  197. calendar.value.close();
  198. }
  199. onMounted(() => {
  200. });
  201. </script>
  202. <style scoped>
  203. .Wrapper-grid {
  204. margin-top: 170rpx;
  205. }
  206. /* 图标样式 */
  207. .service-img {
  208. width: 80rpx;
  209. height: 80rpx;
  210. margin-bottom: 15rpx;
  211. }
  212. /* 文本样式 */
  213. .grid-text {
  214. font-size: 24rpx;
  215. color: #333;
  216. text-align: center;
  217. margin-top: 10rpx;
  218. }
  219. </style>