donate.vue 8.0 KB

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