donate.vue 8.6 KB

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