donate.vue 8.8 KB

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