donate.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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="loaded && 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: 10,
  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. this.list = []
  103. this.loadDate()
  104. }else {
  105. }
  106. },
  107. bindStatusChange(e) {
  108. console.log(e.target);
  109. this.status = this.statuss[e.target.value].name;
  110. if (this.select_status !== this.statuss[e.target.value].id) {
  111. this.page = 1
  112. this.loadingType = 'more'
  113. this.loaded = false
  114. this.select_status = this.statuss[e.target.value].id;
  115. this.list = []
  116. this.loadDate()
  117. }else {
  118. }
  119. },
  120. join(id) {
  121. console.log(id);
  122. uni.navigateTo({
  123. url: '/pages/donate/donateDetail?id=' + id
  124. });
  125. console.log('dddddddddd');
  126. },
  127. loadDate() {
  128. if (this.loadingType === 'noMore' || this.loadingType == 'loading') {
  129. return
  130. }
  131. this.loadingType = 'loading'
  132. getProjectList({
  133. project_area: this.select_area,
  134. page: this.page,
  135. status: this.select_status,
  136. limit: this.limit
  137. }).then(({
  138. data
  139. }) => {
  140. console.log(data, '+++++++++++++++++999+++++++++++++++++++')
  141. // this.list.push(data.list)
  142. this.page++;
  143. // console.log(this.page)
  144. let list = [];
  145. if(data.list.length !=0) {
  146. list = data.list.map(item => {
  147. getProjectInfo({
  148. id: item.id
  149. }).then(res => {
  150. // let data = JSON.parse(res.msg);
  151. let data = res.data
  152. console.log(res, '9999999999999999999999999999999999999999')
  153. item.project_progress = data.project_progress;
  154. item.info = item.info.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/g, '')
  155. .replace(/<[^>]+>/g, '');
  156. console.log(item);
  157. this.list.push(item);
  158. console.log(this.list, '/////////////////////////////////////');
  159. return item;
  160. });
  161. })
  162. }
  163. // this.list.push(list)
  164. console.log(this.list.length, '5555555');
  165. if (this.limit == data.list.length) {
  166. this.loadingType = 'more';
  167. return
  168. } else {
  169. this.loadingType = 'noMore';
  170. }
  171. this.$set(this, 'loaded', true);
  172. });
  173. },
  174. getAllArea() {
  175. getAllArea().then(({
  176. data
  177. }) => {
  178. console.log(data, '6666666666');
  179. this.areas = this.areas.concat(data);
  180. });
  181. },
  182. isShow() {
  183. console.log()
  184. },
  185. getHeight() {
  186. var _this = this;
  187. uni.getSystemInfo({
  188. success: resu => {
  189. const query = uni.createSelectorQuery();
  190. query.select('.item-wrapper').boundingClientRect();
  191. query.exec(function(res) {
  192. console.log(res, 'ddddddddddddd');
  193. _this.height = resu.windowHeight - res[0].top + 'px';
  194. console.log('打印页面的剩余高度', _this.height);
  195. });
  196. },
  197. fail: res => {}
  198. });
  199. }
  200. }
  201. };
  202. </script>
  203. <style lang="scss" scoped>
  204. .donate-wrapper {
  205. padding-top: 25rpx;
  206. }
  207. .top-select {
  208. font-size: 30rpx;
  209. font-family: PingFang SC;
  210. font-weight: 500;
  211. color: #333333;
  212. height: 63rpx;
  213. line-height: 63rpx;
  214. padding: 0 20rpx 0 19rpx;
  215. margin-bottom: 20rpx;
  216. .select {
  217. padding-left: 40rpx;
  218. background: #ffffff;
  219. border-radius: 5rpx;
  220. font-size: 26rpx;
  221. font-family: PingFang SC;
  222. font-weight: 500;
  223. color: #999999;
  224. line-height: 63rpx;
  225. position: relative;
  226. &::after {
  227. content: '';
  228. width: 0;
  229. height: 0;
  230. border-left: 10rpx solid transparent;
  231. border-right: 10rpx solid transparent;
  232. border-top: 10rpx solid #808080;
  233. position: absolute;
  234. right: 30rpx;
  235. bottom: 26rpx;
  236. }
  237. }
  238. .area {
  239. width: 355rpx;
  240. height: 63rpx;
  241. margin: 0 10rpx 0 24rpx;
  242. }
  243. .status {
  244. margin: 0 10rpx 0 24rpx;
  245. width: 204rpx;
  246. height: 63rpx;
  247. }
  248. .action {
  249. color: #000;
  250. }
  251. }
  252. .item-wrapper {
  253. padding: 0 20rpx;
  254. .item {
  255. width: 710rpx;
  256. height: 280rpx;
  257. background: #ffffff;
  258. box-shadow: 0px 0px 20rpx 0rpx rgba(50, 50, 52, 0.06);
  259. border-radius: 8rpx;
  260. padding: 40rpx 20rpx;
  261. margin-bottom: 20rpx;
  262. .item-left {
  263. width: 190rpx;
  264. height: 200rpx;
  265. border-radius: 10rpx;
  266. image {
  267. width: 190rpx;
  268. height: 200rpx;
  269. border-radius: 10rpx;
  270. }
  271. }
  272. .item-right {
  273. padding-left: 22rpx;
  274. position: relative;
  275. .item-title {
  276. width: 316rpx;
  277. font-size: 30rpx;
  278. font-family: PingFang SC;
  279. font-weight: 500;
  280. color: #333333;
  281. overflow: hidden;
  282. text-overflow: ellipsis;
  283. white-space: nowrap;
  284. display: block;
  285. line-height: 1;
  286. padding-bottom: 14rpx;
  287. }
  288. .item-content {
  289. width: 416rpx;
  290. font-size: 22rpx;
  291. font-family: PingFang SC;
  292. font-weight: 400;
  293. color: #999999;
  294. line-height: 1.5;
  295. }
  296. .item-status {
  297. font-size: 24rpx;
  298. font-family: PingFang SC;
  299. font-weight: 500;
  300. color: #666666;
  301. line-height: 1.5;
  302. position: absolute;
  303. left: 22rpx;
  304. bottom: 0;
  305. text {
  306. color: #e80000;
  307. font-weight: bold;
  308. }
  309. }
  310. .item-btn {
  311. width: 160rpx;
  312. height: 60rpx;
  313. background: #f2f2f2;
  314. border-radius: 30px;
  315. font-size: 28rpx;
  316. font-family: PingFang SC;
  317. font-weight: 500;
  318. color: #999999;
  319. line-height: 60rpx;
  320. text-align: center;
  321. position: absolute;
  322. right: -42rpx;
  323. bottom: -9rpx;
  324. }
  325. .btn-active {
  326. background: #fa7e67;
  327. color: #fff;
  328. box-shadow: 0px 2px 20px 0px rgba(250, 126, 103, 0.5);
  329. }
  330. }
  331. }
  332. }
  333. </style>