mySupply.vue 5.3 KB

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