donate.vue 8.5 KB

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