donate.vue 7.7 KB

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