selectTime.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view class="content">
  3. <view class="supplyList">
  4. <view
  5. class="supplyCard"
  6. v-for="(field, i) in fieldList"
  7. :key="i"
  8. @tap="toDetail(field.id)"
  9. >
  10. <view class="image_content">
  11. <image :src="field.pic_path ? shareUrl + field.pic_path : '/static/nodata.svg'" mode="aspectFill" />
  12. </view>
  13. <view class="info">
  14. <view class="title">
  15. {{ field.name }}
  16. </view>
  17. <view class="time">
  18. <view style="margin-bottom: 10rpx;">
  19. <view>开放时间</view>
  20. <view style="margin-top: 6rpx;">{{field.open_days}}:{{field.open_hours}}</view>
  21. </view>
  22. <view class="field-btn-box">
  23. <button :class="{
  24. free: field.statusName == '空闲',
  25. full: field.statusName == '今日已满',
  26. can: field.statusName == '今日可约',}">
  27. {{field.statusName}}</button>
  28. <button style="background: #00a8ea;" :disabled="field.statusName == '今日已满'">前往预约</button>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import md5 from "@/common/md5.js";
  38. export default {
  39. data() {
  40. return {
  41. fieldList: [],
  42. shareUrl:getApp().globalData.shareUrl,
  43. areaId:''
  44. };
  45. },
  46. onLoad(option) {
  47. this.areaId = option.id || '4'
  48. this.getDaysTime(option.id);
  49. },
  50. methods: {
  51. toDetail(index) {
  52. uni.navigateTo({
  53. url: "/pages/makeField/viewDetail?id=" + index,
  54. });
  55. },
  56. getDaysTime(id) {
  57. let md5Sign = md5(
  58. "method=" +
  59. "area" +
  60. "&timestamp=" +
  61. getApp().globalData.globalTimestamp +
  62. "&secret=" +
  63. getApp().globalData.secret
  64. );
  65. let url =
  66. getApp().globalData.shareUrl +
  67. "api/api.php" +
  68. "?method=area&source=area&action=get_days&timestamp=" +
  69. getApp().globalData.globalTimestamp +
  70. "&sign=" +
  71. md5Sign;
  72. uni.request({
  73. url: url,
  74. method: "POST",
  75. header: {
  76. "content-type": "application/x-www-form-urlencoded",
  77. },
  78. data: {
  79. area_id :id,
  80. days:'30'
  81. },
  82. success: (res) => {
  83. if (res.data.code === 200) {
  84. console.log(res.data)
  85. this.getHoursTime(id);
  86. }
  87. },
  88. fail: () => {
  89. console.log("连接失败");
  90. },
  91. });
  92. },
  93. getHoursTime(id) {
  94. let md5Sign = md5(
  95. "method=" +
  96. "area" +
  97. "&timestamp=" +
  98. getApp().globalData.globalTimestamp +
  99. "&secret=" +
  100. getApp().globalData.secret
  101. );
  102. let url =
  103. getApp().globalData.shareUrl +
  104. "api/api.php" +
  105. "?method=area&source=area&action=get_hours&timestamp=" +
  106. getApp().globalData.globalTimestamp +
  107. "&sign=" +
  108. md5Sign;
  109. uni.request({
  110. url: url,
  111. method: "POST",
  112. header: {
  113. "content-type": "application/x-www-form-urlencoded",
  114. },
  115. data: {
  116. area_id :id,
  117. date :'2022-11-21',
  118. //order_id : 2 //如果是自己修改自己的预定,传入预定ID,否则可不传
  119. },
  120. success: (res) => {
  121. if (res.data.code === 200) {
  122. console.log(res.data)
  123. }
  124. },
  125. fail: () => {
  126. console.log("连接失败");
  127. },
  128. });
  129. },
  130. },
  131. };
  132. </script>
  133. <style lang="scss" scope>
  134. .active {
  135. color: $uni-color-primary;
  136. }
  137. .content {
  138. font-size: 32rpx;
  139. margin: 0 5%;
  140. .supplyList {
  141. .supplyCard {
  142. display: flex;
  143. width: 92%;
  144. margin: 3% 0;
  145. padding: 2% 4%;
  146. height: 5%;
  147. border-radius: 30rpx;
  148. box-shadow: rgba(100, 100, 111, 0.2) 0rpx 14rpx 50rpx 0rpx;
  149. .image_content {
  150. margin-right: 5%;
  151. display: flex;
  152. align-items: center;
  153. image {
  154. width: 300rpx;
  155. height: 265rpx;
  156. object-fit: cover;
  157. border-radius: 6rpx;
  158. background-color: #e4e4e4;
  159. }
  160. }
  161. .info {
  162. width: 100%;
  163. display: flex;
  164. flex-flow: column;
  165. justify-content: space-between;
  166. // justify-content: space-around;
  167. .title {
  168. width: 100%;
  169. text-overflow: -o-ellipsis-lastline;
  170. overflow: hidden;
  171. text-overflow: ellipsis;
  172. display: -webkit-box;
  173. -webkit-line-clamp: 2;
  174. line-clamp: 2;
  175. -webkit-box-orient: vertical;
  176. font-size: 32rpx;
  177. }
  178. .time {
  179. font-weight: 100;
  180. font-size: 24rpx;
  181. color: #7f7f7f;
  182. height: 60%;
  183. display: flex;
  184. flex-direction: column;
  185. justify-content: space-around;
  186. // margin-top: 20rpx;
  187. .field-btn-box {
  188. display: flex;
  189. justify-content: space-between;
  190. align-items: center;
  191. button{
  192. background: #95f204;
  193. color: #fff;
  194. font-size: 18rpx;
  195. margin: 0;
  196. };
  197. .free {
  198. background: #95f204;
  199. };
  200. .full {
  201. background: #f59a23;
  202. }
  203. .can {
  204. background: #5498ff;
  205. }
  206. }
  207. }
  208. }
  209. }
  210. }
  211. }
  212. </style>