百富门答题小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

248 lines
6.0 KiB

5 months ago
  1. <template>
  2. <view class="home">
  3. <view class="content" style="padding-top: 25vh;">
  4. <span class="font-bold">预约日期和时间</span>
  5. <view class="flex-center mt-60" style="gap: 50rpx;">
  6. <view class="time-wrapper">
  7. <span style="color: #dcb066;">2024</span>
  8. </view>
  9. <view class="time-wrapper">
  10. 9月20日
  11. </view>
  12. <view class="time-wrapper">
  13. 0800
  14. </view>
  15. </view>
  16. <span class="font-bold mt-60">预约信息</span>
  17. <view class="flex-center mt-40" style="gap: 30rpx;">
  18. <view class="flex-center">
  19. <input class="time-wrapper1" type="text" v-model="firstName" />
  20. <span></span>
  21. </view>
  22. <view class="flex-center">
  23. <input class="time-wrapper1" type="text" v-model="lastName" />
  24. <span></span>
  25. </view>
  26. <view class="">
  27. <uv-drop-down ref="dropDown" sign="dropDown_1" text-active-color="#3c9cff"
  28. :extra-icon="{name:'arrow-down-fill',color:'#666',size:'26rpx'}"
  29. :extra-active-icon="{name:'arrow-up-fill',color:'#3c9cff',size:'26rpx'}"
  30. :defaultValue="defaultValue" :custom-style="{padding: '0 30rpx'}" @click="selectMenu">
  31. <uv-drop-down-item name="order" type="2" :label="dropItem('order').label"
  32. :value="dropItem('order').value">
  33. </uv-drop-down-item>
  34. <uv-drop-down-item name="type" type="2" :label="dropItem('type').label"
  35. :value="dropItem('type').value">
  36. </uv-drop-down-item>
  37. <uv-drop-down-item name="vip_type" type="1" label='VIP文档' :value="dropItem('vip_type').value">
  38. </uv-drop-down-item>
  39. </uv-drop-down>
  40. <uv-drop-down-popup sign="dropDown_1" :click-overlay-on-close="true"
  41. :currentDropItem="currentDropItem" @clickItem="clickItem"
  42. @popupChange="change"></uv-drop-down-popup>
  43. </view>
  44. </view>
  45. <view class="flex-col query" style="gap: 0rpx;">
  46. <view class="flex-sa">
  47. <view class="btn3" @click="pre">
  48. 返回
  49. </view>
  50. <view class="btn3" @click="next">
  51. 取消预约
  52. </view>
  53. </view>
  54. <text class="second-color">欢快无限饮&nbsp;&nbsp;饮酒有限度</text>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. export default {
  61. data() {
  62. return {
  63. firstName: '',
  64. lastName: '',
  65. // 表示value等于这些值,就属于默认值
  66. defaultValue: [0, 'all', '0'],
  67. // 筛选结果
  68. result: [{
  69. name: 'order',
  70. label: '最新发布',
  71. value: 'new'
  72. }],
  73. // { name: 'order', label: '最新发布', value: 'new' }
  74. activeName: 'order',
  75. order: {
  76. label: '综合排序',
  77. value: 'all',
  78. activeIndex: 0,
  79. color: '#333',
  80. activeColor: '#2878ff',
  81. child: [{
  82. label: '综合排序',
  83. value: 'all'
  84. }, {
  85. label: '最新发布',
  86. value: 'new'
  87. }, {
  88. label: '低价优先',
  89. value: 'money'
  90. }]
  91. },
  92. type: {
  93. label: '文档格式',
  94. value: 'all',
  95. activeIndex: 0,
  96. color: '#333',
  97. activeColor: '#2878ff',
  98. child: [{
  99. label: '全部',
  100. value: 'all'
  101. }, {
  102. label: 'PDF',
  103. value: 'pdf'
  104. }, {
  105. label: 'WROD',
  106. value: 'word'
  107. }, {
  108. label: 'PPT',
  109. value: 'ppt'
  110. }]
  111. },
  112. vip_type: {
  113. label: 'VIP文档',
  114. value: 0,
  115. activeIndex: 0
  116. }
  117. }
  118. },
  119. onPageScroll() {
  120. // 滚动后及时更新位置
  121. this.$refs.dropDown.init();
  122. },
  123. computed: {
  124. dropItem(name) {
  125. return (name) => {
  126. const result = {};
  127. const find = this.result.find(item => item.name === name);
  128. if (find) {
  129. result.label = find.label;
  130. result.value = find.value;
  131. } else {
  132. result.label = this[name].label;
  133. result.value = this[name].value;
  134. }
  135. return result;
  136. }
  137. },
  138. // 获取当前下拉筛选项
  139. currentDropItem() {
  140. return this[this.activeName];
  141. }
  142. },
  143. methods: {
  144. pre() {
  145. uni.navigateTo({
  146. url: '/pages/index/greetP5'
  147. })
  148. },
  149. next() {
  150. uni.navigateTo({
  151. url: '/pages/index/selectAppointment'
  152. })
  153. },
  154. change(e) {
  155. console.log('弹窗打开状态:', e);
  156. },
  157. /**
  158. * 点击每个筛选项回调
  159. * @param {Object} e { name, active, type } = e
  160. */
  161. selectMenu(e) {
  162. const {
  163. name,
  164. active,
  165. type
  166. } = e;
  167. this.activeName = name;
  168. // type 等于1 的需要特殊处理:type不等于1可以忽略
  169. if (type == 1) {
  170. this.clickItem({
  171. name: 'vip_type',
  172. label: 'VIP文档',
  173. value: e.active ? 1 : 0
  174. });
  175. } else {
  176. const find = this.result.find(item => item.name == this.activeName);
  177. if (find) {
  178. const findIndex = this[this.activeName].child.findIndex(item => item.label == find.label && item
  179. .value == find.value);
  180. this[this.activeName].activeIndex = findIndex;
  181. } else {
  182. this[this.activeName].activeIndex = 0;
  183. }
  184. }
  185. },
  186. /**
  187. * 点击菜单回调处理
  188. * @param {Object} item 选中项 { label,value } = e
  189. */
  190. clickItem(e) {
  191. // 下面有重新赋值,所以用let
  192. let {
  193. label,
  194. value
  195. } = e;
  196. const findIndex = this.result.findIndex(item => item.name == this.activeName);
  197. if (this.defaultValue.indexOf(value) > -1 && this[this.activeName].label) {
  198. label = this[this.activeName].label;
  199. }
  200. // 已经存在筛选项
  201. if (findIndex > -1) {
  202. this.$set(this.result, findIndex, {
  203. name: this.activeName,
  204. label,
  205. value
  206. })
  207. } else {
  208. this.result.push({
  209. name: this.activeName,
  210. label,
  211. value
  212. });
  213. }
  214. this.result = this.result.filter(item => this.defaultValue.indexOf(item.value) == -1);
  215. uni.showModal({
  216. content: `筛选的值:${JSON.stringify(this.result)}`
  217. })
  218. }
  219. }
  220. }
  221. </script>
  222. <style lang="scss" scoped>
  223. .query {
  224. position: relative;
  225. bottom: -45vh;
  226. }
  227. .mt-30 {
  228. padding-top: 30vh;
  229. }
  230. .time-wrapper {
  231. border: 4rpx solid #dcb066;
  232. padding: 16rpx 26rpx;
  233. border-radius: 20rpx;
  234. }
  235. .time-wrapper1 {
  236. border: 4rpx solid #dcb066;
  237. margin-right: 20rpx;
  238. padding: 14rpx 20rpx;
  239. width: 80rpx;
  240. border-radius: 15rpx;
  241. text-align: center;
  242. }
  243. </style>