mySupply.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view class="content">
  3. <view class="supply-box">
  4. <view class="supply-item-box">
  5. <view
  6. v-for="(item, idx) in titleList"
  7. :key="idx"
  8. :class="{ active: active === idx }"
  9. class="supply-item-name"
  10. @click="active = idx"
  11. >
  12. {{ item }}
  13. </view>
  14. </view>
  15. <view class="supply-content">
  16. <view
  17. class="supplyCard"
  18. v-for="(supply, i) in supplyList"
  19. :key="i"
  20. @tap="toDetail(i)"
  21. >
  22. <view class="image_content">
  23. <image :src="supply.image" />
  24. </view>
  25. <view class="info">
  26. <view class="title">
  27. {{ supply.title }}
  28. </view>
  29. <view class="time">发布时间:{{ supply.time }}</view>
  30. </view>
  31. <view class="state">
  32. <image src="/static/appeal/waited.svg" />
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import md5 from "@/common/md5.js";
  41. export default {
  42. data() {
  43. return {
  44. titleList: ["我的供需", "我的需求"],
  45. active: 0,
  46. supplyList:[],
  47. };
  48. },
  49. onLoad() {
  50. this.getMyList();
  51. },
  52. methods: {
  53. toDetail(index) {
  54. uni.navigateTo({
  55. url: "/pages/supply/supply_detail?id=" + index,
  56. });
  57. },
  58. getMyList() {
  59. let md5Sign = md5(
  60. "method=" +
  61. "need" +
  62. "&timestamp=" +
  63. getApp().globalData.globalTimestamp +
  64. "&secret=" +
  65. getApp().globalData.secret
  66. );
  67. let url =
  68. getApp().globalData.shareUrl +
  69. "api/api.php" +
  70. "?method=need&source=need&action=my_list&timestamp=" +
  71. getApp().globalData.globalTimestamp +
  72. "&sign=" +
  73. md5Sign;
  74. uni.request({
  75. url: url,
  76. method: "POST",
  77. header: {
  78. "content-type": "application/x-www-form-urlencoded",
  79. },
  80. data: {
  81. openId: getApp().globalData.open_id,
  82. s_type: this.active == 0 ? 2 : 1,
  83. },
  84. success: (res) => {
  85. if (res.data.code === 200) {
  86. let list = res.data.data.list;
  87. /*
  88. supplyList: new Array(5).fill({
  89. image: "/static/supply/u1779.png",
  90. title: "移动式空气消毒机",
  91. time: "2021-08-30 14:50:00",
  92. state: 1,
  93. }),
  94. */
  95. this.supplyList = list.map((item) => {
  96. let ob = {
  97. image: "",
  98. title: "",
  99. time: "",
  100. state: "",
  101. id: "",
  102. };
  103. ob.id = item.id;
  104. ob.title = item.title;
  105. let time = this.$options.filters["globalTime"](item.addtime);
  106. let timeSecond = this.$options.filters["globalTimeSecond"](
  107. item.addtime
  108. );
  109. ob.time = time + " " + timeSecond;
  110. ob.state = item.type;
  111. ob.image = item.url;
  112. return ob;
  113. });
  114. console.log(res.data.data.list);
  115. }
  116. },
  117. fail: () => {
  118. console.log("连接失败");
  119. },
  120. });
  121. },
  122. },
  123. watch: {
  124. active() {
  125. this.getMyList();
  126. },
  127. },
  128. };
  129. </script>
  130. <style lang="scss">
  131. .content {
  132. display: flex;
  133. flex-direction: column;
  134. align-items: center;
  135. justify-content: center;
  136. box-sizing: border-box;
  137. padding: 5%;
  138. .supply-box {
  139. width: 100%;
  140. display: flex;
  141. flex-direction: column;
  142. .supply-title {
  143. width: 100%;
  144. p {
  145. background-color: #02a7f0;
  146. width: 190rpx;
  147. height: 70rpx;
  148. color: #ffffff;
  149. border-radius: 0 40rpx 40rpx 0rpx;
  150. font-size: 28rpx;
  151. display: flex;
  152. justify-content: center;
  153. align-items: center;
  154. }
  155. }
  156. .supply-item-box {
  157. display: flex;
  158. justify-content: space-evenly;
  159. margin: 0 20rpx;
  160. margin-top: 10rpx;
  161. .supply-item-name {
  162. padding-bottom: 10rpx;
  163. font-size: 27rpx;
  164. }
  165. .active {
  166. font-weight: 600;
  167. border-bottom: 7rpx solid #02a7f0;
  168. }
  169. }
  170. .supply-content {
  171. width: 100%;
  172. display: flex;
  173. box-sizing: border-box;
  174. flex-direction: column;
  175. font-size: 25rpx;
  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. .state {
  194. margin-left: 100rpx;
  195. image {
  196. width: 100rpx;
  197. height: 80rpx;
  198. }
  199. }
  200. .info {
  201. display: flex;
  202. flex-flow: column;
  203. justify-content: space-around;
  204. .time {
  205. font-weight: 100;
  206. font-size: 25rpx;
  207. }
  208. }
  209. }
  210. }
  211. }
  212. }
  213. </style>