index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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.image" mode="aspectFill" />
  12. </view>
  13. <view class="info">
  14. <view class="title">
  15. {{ field.title }}
  16. </view>
  17. <view class="time">
  18. <view>
  19. <view>开放时间</view>
  20. <view style="margin-top: 6rpx;">周一至周五:08:00~17:00</view>
  21. </view>
  22. <view class="field-btn-box">
  23. <button>今日已满</button>
  24. <button style="background: #00a8ea;">前往预约</button>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import md5 from "@/common/md5.js";
  34. export default {
  35. data() {
  36. return {
  37. fieldList: [],
  38. statusObj:{
  39. '1':'空闲',
  40. '2':'今日已满',
  41. '3':'今日可约'
  42. }
  43. };
  44. },
  45. onLoad() {
  46. this.getMyList();
  47. },
  48. methods: {
  49. toDetail(index) {
  50. uni.navigateTo({
  51. url: "/pages/makeField/viewDetail?id=" + '13',
  52. });
  53. },
  54. getMyList() {
  55. let md5Sign = md5(
  56. "method=" +
  57. "need" +
  58. "&timestamp=" +
  59. getApp().globalData.globalTimestamp +
  60. "&secret=" +
  61. getApp().globalData.secret
  62. );
  63. let url =
  64. getApp().globalData.shareUrl +
  65. "api/api.php" +
  66. "?method=need&source=need&action=list&timestamp=" +
  67. getApp().globalData.globalTimestamp +
  68. "&sign=" +
  69. md5Sign;
  70. let postData = {
  71. s_type: this.index == 2 ? 1 : 2,
  72. };
  73. uni.request({
  74. url: url,
  75. method: "POST",
  76. header: {
  77. "content-type": "application/x-www-form-urlencoded",
  78. },
  79. data: this.index == -1 || this.index == 0 ? {} : postData,
  80. success: (res) => {
  81. if (res.data.code === 200) {
  82. let list = res.data.data.list;
  83. /*
  84. supplyList: new Array(5).fill({
  85. image: "/static/supply/u1779.png",
  86. title: "移动式空气消毒机",
  87. time: "2021-08-30 14:50:00",
  88. state: 1,
  89. }),
  90. */
  91. this.fieldList = list.map((item) => {
  92. let ob = {
  93. image: "",
  94. title: "",
  95. time: "",
  96. state: "",
  97. id: "",
  98. };
  99. ob.id = item.id;
  100. ob.title = item.title;
  101. let time = this.$options.filters["globalTime"](item.addtime);
  102. let timeSecond = this.$options.filters["globalTimeSecond"](
  103. item.addtime
  104. );
  105. ob.time = time + " " + timeSecond;
  106. ob.state = item.type;
  107. // ob.image = "/static/nodata.svg";
  108. ob.image = item.attach_list[0]
  109. ? getApp().globalData.shareUrl + item.attach_list[0]
  110. : "/static/nodata.svg";
  111. return ob;
  112. });
  113. // console.log(res.data.data.list);
  114. }
  115. },
  116. fail: () => {
  117. console.log("连接失败");
  118. },
  119. });
  120. },
  121. },
  122. };
  123. </script>
  124. <style lang="scss" scope>
  125. .active {
  126. color: $uni-color-primary;
  127. }
  128. .content {
  129. font-size: 32rpx;
  130. margin: 0 5%;
  131. .supplyList {
  132. .supplyCard {
  133. display: flex;
  134. width: 92%;
  135. margin: 3% 0;
  136. padding: 2% 4%;
  137. height: 5%;
  138. border-radius: 30rpx;
  139. box-shadow: rgba(100, 100, 111, 0.2) 0rpx 14rpx 50rpx 0rpx;
  140. .image_content {
  141. margin-right: 5%;
  142. display: flex;
  143. align-items: center;
  144. image {
  145. width: 300rpx;
  146. height: 265rpx;
  147. object-fit: cover;
  148. border-radius: 6rpx;
  149. background-color: #e4e4e4;
  150. }
  151. }
  152. .info {
  153. width: 100%;
  154. display: flex;
  155. flex-flow: column;
  156. justify-content: space-between;
  157. // justify-content: space-around;
  158. .title {
  159. width: 100%;
  160. text-overflow: -o-ellipsis-lastline;
  161. overflow: hidden;
  162. text-overflow: ellipsis;
  163. display: -webkit-box;
  164. -webkit-line-clamp: 2;
  165. line-clamp: 2;
  166. -webkit-box-orient: vertical;
  167. font-size: 32rpx;
  168. }
  169. .time {
  170. font-weight: 100;
  171. font-size: 24rpx;
  172. color: #7f7f7f;
  173. height: 60%;
  174. display: flex;
  175. flex-direction: column;
  176. justify-content: space-around;
  177. margin-top: 20rpx;
  178. .field-btn-box {
  179. display: flex;
  180. justify-content: space-between;
  181. align-items: center;
  182. button{
  183. background: #95f204;
  184. color: #fff;
  185. font-size: 18rpx;
  186. margin: 0;
  187. };
  188. }
  189. }
  190. }
  191. }
  192. }
  193. }
  194. </style>