mySupply.vue 5.4 KB

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