donate.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <view class="donate-wrapper">
  3. <view class="top-select flex">
  4. <view class="">选择地区</view>
  5. <picker @change="bindAreaChange" :range="areas">
  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. <view class="item-wrapper">
  13. <view class="item flex" v-for="item in showList">
  14. <view class="item-left"><image :src="item.img" mode=""></image></view>
  15. <view class="item-right">
  16. <view class="item-title clamp">{{ item.title }}</view>
  17. <view class="item-content clamp2">{{ item.info }}</view>
  18. <view class="item-status">
  19. 捐赠进度
  20. <text>{{ item.project_progress }}%</text>
  21. </view>
  22. <view class="item-btn" :class="{ 'btn-active': item.status === 0 }" @click="join(item.id)">{{ item.status === 0 ? '我要捐赠' : '已结束' }}</view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import { getProjectList, getProjectInfo ,getAllArea} from '../../api/money.js';
  30. export default {
  31. data() {
  32. return {
  33. areas: ['沙市区红十字会', '荆州区红十字会', '石首区红十字会', '洪湖区红十字会', '松滋区红十字会', '监利区红十字会', '公安县红十字会', '江陵县红十字会'],
  34. area: '',
  35. area_id: 0,
  36. statuss: ['全部', '进行中', '已结束'],
  37. status: '全部',
  38. status_id: 0,
  39. list: [],
  40. showList: []
  41. };
  42. },
  43. async onLoad() {
  44. let a = await this.loadDate();
  45. this.showList = this.list;
  46. this.getAllArea()
  47. },
  48. methods: {
  49. bindAreaChange(e) {
  50. console.log(e.target);
  51. this.area = this.areas[e.target.value];
  52. },
  53. bindStatusChange(e) {
  54. console.log(e.target);
  55. if (this.status !== this.statuss[e.target.value]) {
  56. this.status = this.statuss[e.target.value];
  57. if(this.status == '全部') {
  58. this.showList = this.list
  59. }else if(this.status == '进行中'){
  60. this.showList = this.list.map( item => {
  61. return item
  62. })
  63. }
  64. }
  65. },
  66. join(id) {
  67. console.log(id);
  68. uni.navigateTo({
  69. url: '/pages/donate/donateDetail?id=' + id
  70. });
  71. console.log('dddddddddd');
  72. },
  73. loadDate() {
  74. getProjectList({
  75. page: 1,
  76. limit: 1000
  77. }).then(({ data }) => {
  78. // console.log(res,'+++++++++++++++++')
  79. let list = [];
  80. data.list.map(item => {
  81. getProjectInfo({
  82. id: item.id
  83. }).then(res => {
  84. let data = JSON.parse(res.msg);
  85. // console.log( data.project_progress,'999999999999999')
  86. item.project_progress = data.project_progress;
  87. item.info = item.info.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/g,'').replace(/<[^>]+>/g, '');
  88. console.log(item);
  89. this.list.push(item);
  90. return item;
  91. });
  92. });
  93. console.log(this.list, '5555555');
  94. });
  95. },
  96. select(area,status) {
  97. if(atea!== '') {
  98. }
  99. },
  100. getAllArea() {
  101. getAllArea().then(res => {
  102. console.log(res,'6666666666')
  103. })
  104. }
  105. }
  106. };
  107. </script>
  108. <style lang="scss" scoped>
  109. .donate-wrapper {
  110. padding-top: 25rpx;
  111. }
  112. .top-select {
  113. font-size: 30rpx;
  114. font-family: PingFang SC;
  115. font-weight: 500;
  116. color: #333333;
  117. height: 63rpx;
  118. line-height: 63rpx;
  119. padding: 0 20rpx 0 19rpx;
  120. margin-bottom: 20rpx;
  121. .select {
  122. padding-left: 40rpx;
  123. background: #ffffff;
  124. border-radius: 5rpx;
  125. font-size: 26rpx;
  126. font-family: PingFang SC;
  127. font-weight: 500;
  128. color: #999999;
  129. line-height: 63rpx;
  130. position: relative;
  131. &::after {
  132. content: '';
  133. width: 0;
  134. height: 0;
  135. border-left: 10rpx solid transparent;
  136. border-right: 10rpx solid transparent;
  137. border-top: 10rpx solid #808080;
  138. position: absolute;
  139. right: 30rpx;
  140. bottom: 26rpx;
  141. }
  142. }
  143. .area {
  144. width: 355rpx;
  145. height: 63rpx;
  146. margin: 0 10rpx 0 24rpx;
  147. }
  148. .status {
  149. width: 204rpx;
  150. height: 63rpx;
  151. }
  152. .action {
  153. color: #000;
  154. }
  155. }
  156. .item-wrapper {
  157. padding: 0 20rpx;
  158. .item {
  159. width: 710rpx;
  160. height: 280rpx;
  161. background: #ffffff;
  162. box-shadow: 0px 0px 20rpx 0rpx rgba(50, 50, 52, 0.06);
  163. border-radius: 8rpx;
  164. padding: 40rpx 20rpx;
  165. margin-bottom: 20rpx;
  166. .item-left {
  167. width: 190rpx;
  168. height: 200rpx;
  169. border-radius: 10rpx;
  170. image {
  171. width: 190rpx;
  172. height: 200rpx;
  173. border-radius: 10rpx;
  174. }
  175. }
  176. .item-right {
  177. padding-left: 22rpx;
  178. position: relative;
  179. .item-title {
  180. width: 316rpx;
  181. font-size: 30rpx;
  182. font-family: PingFang SC;
  183. font-weight: 500;
  184. color: #333333;
  185. overflow: hidden;
  186. text-overflow: ellipsis;
  187. white-space: nowrap;
  188. display: block;
  189. line-height: 1;
  190. padding-bottom: 14rpx;
  191. }
  192. .item-content {
  193. width: 416rpx;
  194. font-size: 22rpx;
  195. font-family: PingFang SC;
  196. font-weight: 400;
  197. color: #999999;
  198. line-height: 1.5;
  199. }
  200. .item-status {
  201. font-size: 24rpx;
  202. font-family: PingFang SC;
  203. font-weight: 500;
  204. color: #666666;
  205. line-height: 1.5;
  206. position: absolute;
  207. left: 22rpx;
  208. bottom: 0;
  209. text {
  210. color: #e80000;
  211. font-weight: bold;
  212. }
  213. }
  214. .item-btn {
  215. width: 160rpx;
  216. height: 60rpx;
  217. background: #f2f2f2;
  218. border-radius: 30px;
  219. font-size: 28rpx;
  220. font-family: PingFang SC;
  221. font-weight: 500;
  222. color: #999999;
  223. line-height: 60rpx;
  224. text-align: center;
  225. position: absolute;
  226. right: -42rpx;
  227. bottom: -9rpx;
  228. }
  229. .btn-active {
  230. background: #fa7e67;
  231. color: #fff;
  232. box-shadow: 0px 2px 20px 0px rgba(250, 126, 103, 0.5);
  233. }
  234. }
  235. }
  236. }
  237. </style>