donate.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <view class="donate-wrapper">
  3. <view class="top-select flex" style=" position: relative; z-index: 99;">
  4. <view class="">选择项目状态</view>
  5. <picker @change="bindStatusChange" :range="statuss" range-key="name">
  6. <view class="status select" :class="{ action: status }">{{ status }}</view>
  7. </picker>
  8. </view>
  9. <scroll-view scroll-y="true" :style="{ height: height }" class="item-wrapper" @scrolltolower="loadDate">
  10. <!-- <view class="item-wrapper"> -->
  11. <empty v-if="list.length === 0 "></empty>
  12. <template>
  13. <view class="item flex" v-for="item in list" @click="join(item.id)" :key="item.id">
  14. <view class="item-left"><image :src="$store.state.baseURL + item.image" mode=""></image></view>
  15. <view class="item-right">
  16. <view class="item-title clamp">{{ item.title }}</view>
  17. <view class="item-content clamp2">{{ item.info }}</view>
  18. <view class="item-status">
  19. 捐赠进度
  20. <text>{{ item.project_progress*100 }}%</text>
  21. </view>
  22. <view class="item-btn" :class="{ 'btn-active': item.status == 2 }">{{ item.status == 3 ? '已结束' : item.status == 1?'未开始':'我要捐赠'}}</view>
  23. </view>
  24. </view>
  25. </template>
  26. <uni-load-more :status="loadingType"></uni-load-more>
  27. <!-- </view> -->
  28. </scroll-view>
  29. </view>
  30. </template>
  31. <script>
  32. import empty from '../../components/empty.vue';
  33. import { getProjectList, getProjectInfo, getAllArea } from '../../api/money.js';
  34. export default {
  35. components: {
  36. empty
  37. },
  38. data() {
  39. return {
  40. areas: [],
  41. area: '',
  42. select_area: null,
  43. area_id: 0,
  44. statuss: [{id: -2,name: '全部'},{id: 2,name: '进行中'}, {id: 3,name: '已结束'}],
  45. status: '全部',
  46. select_status: -2,
  47. list: [],
  48. height: 0,
  49. loadingType: 'more',
  50. page: 1,
  51. loaded: false,
  52. limit: 5
  53. // showList: []
  54. };
  55. },
  56. onReady(res) {
  57. this.getHeight()
  58. },
  59. onShow() {
  60. },
  61. computed: {
  62. },
  63. onLoad() {
  64. this.loadDate();
  65. // this.getAllArea();
  66. },
  67. methods: {
  68. bindAreaChange(e) {
  69. console.log(e.target);
  70. this.area = this.areas[e.target.value].name;
  71. if(this.select_area !== this.areas[e.target.value].id){
  72. this.page = 1
  73. this.loadingType = 'more'
  74. this.loaded = false
  75. this.select_area = this.areas[e.target.value].id;
  76. }
  77. this.list = []
  78. uni.showLoading({
  79. title: '加载中...'
  80. })
  81. this.loadDate()
  82. },
  83. bindStatusChange(e) {
  84. console.log(e.target);
  85. this.status = this.statuss[e.target.value].name;
  86. if(this.select_status !== this.statuss[e.target.value].id){
  87. this.page = 1
  88. this.loadingType = 'more'
  89. this.loaded = false
  90. this.select_status = this.statuss[e.target.value].id;
  91. }
  92. this.list = []
  93. this.loadDate()
  94. },
  95. join(id) {
  96. console.log(id);
  97. uni.navigateTo({
  98. url: '/pages/donate/donateDetail?id=' + id
  99. });
  100. console.log('dddddddddd');
  101. },
  102. loadDate() {
  103. if(this.loadingType === 'noMore'){
  104. return
  105. }
  106. getProjectList({
  107. // project_area: this.select_area,
  108. page: this.page,
  109. status: this.select_status,
  110. limit: this.limit
  111. }).then(({ data }) => {
  112. console.log(data,'+++++++++++++++++999+++++++++++++++++++')
  113. // this.list.push(data.list)
  114. this.page++;
  115. // console.log(this.page)
  116. let list = [];
  117. this.list = this.list.concat(data.list)
  118. // .map(item => {
  119. // getProjectInfo({
  120. // id: item.id
  121. // }).then(res => {
  122. // // let data = JSON.parse(res.msg);
  123. // let data = res.data
  124. // console.log(res,'9999999999999999999999999999999999999999')
  125. // item.project_progress = data.project_progress;
  126. // item.info = item.info.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/g, '').replace(/<[^>]+>/g, '');
  127. // console.log(item);
  128. // this.list.push(item);
  129. // console.log(this.list, '/////////////////////////////////////');
  130. // return item;
  131. // });
  132. // });
  133. console.log(this.list.length, '5555555');
  134. if(this.limit == data.list.length) {
  135. this.loadingType = 'more';
  136. return
  137. }else {
  138. this.loadingType = 'noMore';
  139. }
  140. this.$set(this, 'loaded', true);
  141. });
  142. },
  143. getAllArea() {
  144. getAllArea().then(({ data }) => {
  145. console.log(data, '6666666666');
  146. this.areas = data;
  147. });
  148. },
  149. isShow() {
  150. console.log()
  151. },
  152. getHeight() {
  153. var _this = this;
  154. uni.getSystemInfo({
  155. success: resu => {
  156. const query = uni.createSelectorQuery();
  157. query.select('.item-wrapper').boundingClientRect();
  158. query.exec(function(res) {
  159. console.log(res, 'ddddddddddddd');
  160. _this.height = resu.windowHeight - res[0].top + 'px';
  161. console.log('打印页面的剩余高度', _this.height);
  162. });
  163. },
  164. fail: res => {}
  165. });
  166. }
  167. }
  168. };
  169. </script>
  170. <style lang="scss" scoped>
  171. .donate-wrapper {
  172. padding-top: 25rpx;
  173. }
  174. .top-select {
  175. font-size: 30rpx;
  176. font-family: PingFang SC;
  177. font-weight: 500;
  178. color: #333333;
  179. height: 63rpx;
  180. line-height: 63rpx;
  181. padding: 0 20rpx 0 19rpx;
  182. margin-bottom: 20rpx;
  183. .select {
  184. padding-left: 40rpx;
  185. background: #ffffff;
  186. border-radius: 5rpx;
  187. font-size: 26rpx;
  188. font-family: PingFang SC;
  189. font-weight: 500;
  190. color: #999999;
  191. line-height: 63rpx;
  192. position: relative;
  193. &::after {
  194. content: '';
  195. width: 0;
  196. height: 0;
  197. border-left: 10rpx solid transparent;
  198. border-right: 10rpx solid transparent;
  199. border-top: 10rpx solid #808080;
  200. position: absolute;
  201. right: 30rpx;
  202. bottom: 26rpx;
  203. }
  204. }
  205. .area {
  206. width: 355rpx;
  207. height: 63rpx;
  208. margin: 0 10rpx 0 24rpx;
  209. }
  210. .status {
  211. width: 204rpx;
  212. height: 63rpx;
  213. margin: 0 10rpx 0 24rpx;
  214. }
  215. .action {
  216. color: #000;
  217. }
  218. }
  219. .item-wrapper {
  220. padding: 0 20rpx;
  221. .item {
  222. width: 710rpx;
  223. height: 280rpx;
  224. background: #ffffff;
  225. box-shadow: 0px 0px 20rpx 0rpx rgba(50, 50, 52, 0.06);
  226. border-radius: 8rpx;
  227. padding: 40rpx 20rpx;
  228. margin-bottom: 20rpx;
  229. .item-left {
  230. width: 190rpx;
  231. height: 200rpx;
  232. border-radius: 10rpx;
  233. image {
  234. width: 190rpx;
  235. height: 200rpx;
  236. border-radius: 10rpx;
  237. }
  238. }
  239. .item-right {
  240. padding-left: 22rpx;
  241. position: relative;
  242. .item-title {
  243. width: 316rpx;
  244. font-size: 30rpx;
  245. font-family: PingFang SC;
  246. font-weight: 500;
  247. color: #333333;
  248. overflow: hidden;
  249. text-overflow: ellipsis;
  250. white-space: nowrap;
  251. display: block;
  252. line-height: 1;
  253. padding-bottom: 14rpx;
  254. }
  255. .item-content {
  256. width: 416rpx;
  257. font-size: 22rpx;
  258. font-family: PingFang SC;
  259. font-weight: 400;
  260. color: #999999;
  261. line-height: 1.5;
  262. }
  263. .item-status {
  264. font-size: 24rpx;
  265. font-family: PingFang SC;
  266. font-weight: 500;
  267. color: #666666;
  268. line-height: 1.5;
  269. position: absolute;
  270. left: 22rpx;
  271. bottom: 0;
  272. text {
  273. color: #e80000;
  274. font-weight: bold;
  275. }
  276. }
  277. .item-btn {
  278. width: 160rpx;
  279. height: 60rpx;
  280. background: #f2f2f2;
  281. border-radius: 30px;
  282. font-size: 28rpx;
  283. font-family: PingFang SC;
  284. font-weight: 500;
  285. color: #999999;
  286. line-height: 60rpx;
  287. text-align: center;
  288. position: absolute;
  289. right: -42rpx;
  290. bottom: -9rpx;
  291. }
  292. .btn-active {
  293. background: #fa7e67;
  294. color: #fff;
  295. box-shadow: 0px 2px 20px 0px rgba(250, 126, 103, 0.5);
  296. }
  297. }
  298. }
  299. }
  300. </style>