selectTime.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <view>
  3. <lxCalendar @change="changeTime" :dot_lists="list"></lxCalendar>
  4. <view class="hours-box">
  5. <view class="hours-title">可选时间段</view>
  6. <view class="hours-content">
  7. <view v-for="(hour,index) in hourList" :key="index"
  8. :class="hourListSelceted[index] ? 'selected' : 'default'"
  9. v-show="hour.enable" @click="selectHour(index,hour.hour)">{{hour.show}}</button>
  10. </view>
  11. </view>
  12. </view>
  13. <view class="share-box">
  14. <view class="button">
  15. <button @click="goSubmit()" class="start" >
  16. 提交资料
  17. </button>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import md5 from "@/common/md5.js";
  24. import lxCalendar from '@/components/lx-calendar/lx-calendar.vue'
  25. export default {
  26. components:{
  27. lxCalendar,
  28. },
  29. data() {
  30. return {
  31. fieldList: [],
  32. shareUrl:getApp().globalData.shareUrl,
  33. areaId:'',
  34. list: [],
  35. hourList:[],
  36. hourListSelceted:[],
  37. selectDate:getApp().globalData.nowTime,
  38. selectedHour:[],
  39. };
  40. },
  41. onLoad(option) {
  42. this.areaId = option.id || '4'
  43. this.getDaysTime(option.id);
  44. },
  45. methods: {
  46. changeTime(e){
  47. this.selectDate = e.fulldate;
  48. this.getHoursTime(this.areaId,this.selectDate)
  49. },
  50. selectHour(index,param){
  51. this.hourListSelceted.splice(index,1,!this.hourListSelceted[index])
  52. },
  53. goSubmit(){
  54. if(!this.hourListSelceted.includes(true)) {
  55. uni.showToast({
  56. title:'请选择时间段',
  57. icon:'none'
  58. })
  59. }else {
  60. let filterArr = []
  61. this.hourListSelceted.forEach((item,index)=>{
  62. if(item){
  63. filterArr.push(this.hourList[index].hour)
  64. }
  65. })
  66. filterArr.join(',')
  67. uni.navigateTo({
  68. url: "/pages/makeField/fieldForm?id=" + this.areaId +'&day=' + this.selectDate +'&hour=' + filterArr,
  69. });
  70. }
  71. },
  72. getDaysTime(id) {
  73. let md5Sign = md5(
  74. "method=" +
  75. "area" +
  76. "&timestamp=" +
  77. getApp().globalData.globalTimestamp +
  78. "&secret=" +
  79. getApp().globalData.secret
  80. );
  81. let url =
  82. getApp().globalData.shareUrl +
  83. "api/api.php" +
  84. "?method=area&source=area&action=get_days&timestamp=" +
  85. getApp().globalData.globalTimestamp +
  86. "&sign=" +
  87. md5Sign;
  88. uni.request({
  89. url: url,
  90. method: "POST",
  91. header: {
  92. "content-type": "application/x-www-form-urlencoded",
  93. },
  94. data: {
  95. area_id :id,
  96. days:'30'
  97. },
  98. success: (res) => {
  99. if (res.data.code === 200) {
  100. let dayList = res.data.data;
  101. this.list = dayList;
  102. this.getHoursTime(id,this.selectDate)
  103. }
  104. },
  105. fail: () => {
  106. console.log("连接失败");
  107. },
  108. });
  109. },
  110. getHoursTime(id,time) {
  111. let md5Sign = md5(
  112. "method=" +
  113. "area" +
  114. "&timestamp=" +
  115. getApp().globalData.globalTimestamp +
  116. "&secret=" +
  117. getApp().globalData.secret
  118. );
  119. let url =
  120. getApp().globalData.shareUrl +
  121. "api/api.php" +
  122. "?method=area&source=area&action=get_hours&timestamp=" +
  123. getApp().globalData.globalTimestamp +
  124. "&sign=" +
  125. md5Sign;
  126. uni.request({
  127. url: url,
  128. method: "POST",
  129. header: {
  130. "content-type": "application/x-www-form-urlencoded",
  131. },
  132. data: {
  133. area_id :id,
  134. date :time,
  135. //order_id : 2 //如果是自己修改自己的预定,传入预定ID,否则可不传
  136. },
  137. success: (res) => {
  138. if (res.data.code === 200) {
  139. let hourArr = res.data.data;
  140. let hourCss = [];
  141. hourArr.forEach((item,index)=>{
  142. hourCss.push(false)
  143. })
  144. this.hourListSelceted = hourCss;
  145. this.hourList = res.data.data
  146. }
  147. },
  148. fail: () => {
  149. console.log("连接失败");
  150. },
  151. });
  152. },
  153. },
  154. };
  155. </script>
  156. <style lang="scss" scope>
  157. .calendar-box {
  158. display: flex;
  159. justify-content: center;
  160. }
  161. .hours-box {
  162. margin-top: 30rpx;
  163. .hours-title {
  164. padding-left: 20rpx;
  165. font-weight: 600;
  166. font-size: 26rpx;
  167. }
  168. .hours-content {
  169. display: flex;
  170. flex-wrap: wrap;
  171. justify-content: space-around;
  172. align-items: center;
  173. margin-top: 20rpx;
  174. view {
  175. width: 45%;
  176. height: 80rpx;
  177. background: #f4f4f4;
  178. text-align: center;
  179. line-height: 80rpx;
  180. margin-bottom: 20rpx;
  181. border-radius: 10rpx;
  182. font-size: 24rpx;
  183. }
  184. }
  185. .selected {
  186. background: #5398ff!important;
  187. color:#fff;
  188. }
  189. .default{
  190. background: #f4f4f4!important;
  191. color:#000
  192. }
  193. }
  194. .share-box {
  195. box-sizing: border-box;
  196. height: 150rpx;
  197. width: 100%;
  198. align-items: center;
  199. justify-content: space-evenly;
  200. position: fixed;
  201. bottom: 0;
  202. display: flex;
  203. background: #ffffff;
  204. .share {
  205. display: flex;
  206. justify-content: center;
  207. align-items: center;
  208. width: 60rpx;
  209. height: 60rpx;
  210. position: relative;
  211. button::after {
  212. border: none;
  213. }
  214. image {
  215. width: 100%;
  216. height: 100%;
  217. position: absolute;
  218. }
  219. .shareCount {
  220. display: flex;
  221. justify-content: center;
  222. align-items: center;
  223. position: absolute;
  224. top: -20%;
  225. right: -25%;
  226. color: #ffffff;
  227. height: 30rpx;
  228. width: 30rpx;
  229. padding: 3rpx;
  230. font-size: 16rpx;
  231. border-radius: 50%;
  232. background: #fe3637;
  233. }
  234. }
  235. .button {
  236. height: 100rpx;
  237. width: 75%;
  238. display: flex;
  239. justify-content: center;
  240. button {
  241. width: 80%;
  242. height: 80%;
  243. border: 1px solid;
  244. outline: none;
  245. background: none;
  246. font-size: 30rpx;
  247. background-color: transparent;
  248. border-color: none;
  249. color: #00a8ea;
  250. }
  251. }
  252. }
  253. </style>