index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <view class="content">
  3. <view class="picker">
  4. <picker
  5. @change="bindPickerChange"
  6. :value="index"
  7. :range="array"
  8. range-key="name"
  9. >
  10. <view class="picker_title">
  11. <view class="pickername">
  12. <view v-if="index != -1">
  13. {{ array[index].name }}
  14. </view>
  15. <view v-else>类型</view>
  16. </view>
  17. <view class="triangle-down"></view>
  18. </view>
  19. </picker>
  20. </view>
  21. <view class="supplyList">
  22. <view
  23. class="supplyCard"
  24. v-for="(supply, i) in supplyList"
  25. :key="i"
  26. @tap="toDetail(supply.id)"
  27. >
  28. <view class="image_content">
  29. <image :src="supply.image" />
  30. </view>
  31. <view class="info">
  32. <view class="title">
  33. {{ supply.title }}
  34. </view>
  35. <view class="time">发布时间:{{ supply.time }}</view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="menus">
  40. <navigator url="/pages/supply/putSupply">
  41. <view class="menu">
  42. <view>
  43. <image src="/static/supply/putSupply.png" />
  44. </view>
  45. <view class="menu_title">发布供需</view>
  46. </view>
  47. </navigator>
  48. <navigator url="/pages/supply/mySupply">
  49. <view class="menu">
  50. <view>
  51. <image src="/static/supply/mySupply.png" />
  52. </view>
  53. <view class="menu_title">我的供需</view>
  54. </view>
  55. </navigator>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import md5 from "@/common/md5.js";
  61. export default {
  62. data() {
  63. return {
  64. supplyList: [],
  65. array: [{ name: "全部" }, { name: "供需" }, { name: "需求" }],
  66. index: -1,
  67. };
  68. },
  69. onLoad() {
  70. this.getMyList();
  71. },
  72. methods: {
  73. bindPickerChange(e) {
  74. this.index = e.detail.value;
  75. this.getMyList();
  76. },
  77. toDetail(index) {
  78. uni.navigateTo({
  79. url: "/pages/supply/supply_detail?id=" + index,
  80. });
  81. },
  82. getMyList() {
  83. let md5Sign = md5(
  84. "method=" +
  85. "need" +
  86. "&timestamp=" +
  87. getApp().globalData.globalTimestamp +
  88. "&secret=" +
  89. getApp().globalData.secret
  90. );
  91. let url =
  92. getApp().globalData.shareUrl +
  93. "api/api.php" +
  94. "?method=need&source=need&action=list&timestamp=" +
  95. getApp().globalData.globalTimestamp +
  96. "&sign=" +
  97. md5Sign;
  98. let postData = {
  99. s_type:this.index==2?1:2
  100. }
  101. uni.request({
  102. url: url,
  103. method: "POST",
  104. header: {
  105. "content-type": "application/x-www-form-urlencoded",
  106. },
  107. data: this.index==-1||this.index==0?{}:postData,
  108. success: (res) => {
  109. if (res.data.code === 200) {
  110. let list = res.data.data.list;
  111. /*
  112. supplyList: new Array(5).fill({
  113. image: "/static/supply/u1779.png",
  114. title: "移动式空气消毒机",
  115. time: "2021-08-30 14:50:00",
  116. state: 1,
  117. }),
  118. */
  119. this.supplyList = list.map((item) => {
  120. let ob = {
  121. image: "",
  122. title: "",
  123. time: "",
  124. state: "",
  125. id: "",
  126. };
  127. ob.id = item.id;
  128. ob.title = item.title;
  129. let time = this.$options.filters["globalTime"](item.addtime);
  130. let timeSecond = this.$options.filters["globalTimeSecond"](
  131. item.addtime
  132. );
  133. ob.time = time + " " + timeSecond;
  134. ob.state = item.type;
  135. ob.image = item.url;
  136. return ob;
  137. });
  138. console.log(res.data.data.list);
  139. }
  140. },
  141. fail: () => {
  142. console.log("连接失败");
  143. },
  144. });
  145. },
  146. },
  147. };
  148. </script>
  149. <style lang="scss" scope>
  150. .content {
  151. font-size: 30rpx;
  152. margin: 0 5%;
  153. .picker {
  154. position: fixed;
  155. top: 3%;
  156. left: 5%;
  157. .picker_title {
  158. width: 100rpx;
  159. display: flex;
  160. align-items: center;
  161. justify-content: space-between;
  162. .triangle-down {
  163. width: 0;
  164. height: 0;
  165. border-top: 15rpx solid rgb(173, 173, 173);
  166. border-left: 15rpx solid transparent;
  167. border-right: 15rpx solid transparent;
  168. }
  169. .pickername {
  170. font-weight: 100;
  171. }
  172. }
  173. }
  174. .supplyList {
  175. margin-top: 12%;
  176. .supplyCard {
  177. display: flex;
  178. width: 92%;
  179. margin: 2% 0;
  180. padding: 2% 4%;
  181. height: 5%;
  182. border-radius: 30rpx;
  183. box-shadow: rgba(100, 100, 111, 0.2) 0rpx 14rpx 50rpx 0rpx;
  184. .image_content {
  185. margin-right: 5%;
  186. image {
  187. width: 100rpx;
  188. height: 100rpx;
  189. border-radius: 20rpx;
  190. background-color: rgb(228, 228, 228);
  191. }
  192. }
  193. .info {
  194. display: flex;
  195. flex-flow: column;
  196. justify-content: space-around;
  197. .time {
  198. font-weight: 100;
  199. font-size: 25rpx;
  200. }
  201. }
  202. }
  203. }
  204. .menus {
  205. z-index: 999;
  206. display: flex;
  207. justify-content: space-around;
  208. width: 80%;
  209. // height: 6%;
  210. position: fixed;
  211. top: 85%;
  212. left: 50%;
  213. padding: 4%;
  214. border-radius: 40rpx;
  215. box-shadow: rgba(100, 100, 111, 0.2) 0rpx 14rpx 50rpx 0rpx;
  216. transform: translateX(-50%);
  217. background-color: #fff;
  218. image {
  219. width: 50rpx;
  220. height: 50rpx;
  221. border-radius: 10rpx;
  222. }
  223. .menu {
  224. display: flex;
  225. flex-flow: column;
  226. align-items: center;
  227. .menu_title {
  228. text-align: center;
  229. font-size: 25rpx;
  230. }
  231. }
  232. }
  233. }
  234. </style>