mySupply.vue 5.3 KB

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