selectTime.vue 5.9 KB

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