promiseList.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view
  3. class="msgList"
  4. >
  5. <view class="mt30">
  6. <view class="msgItem" v-for="(item,index) in msgList" :key="index" @click="toPromiseInfo(item)">
  7. <view class="msgItemLeft">
  8. <image class="fixedTitle" src="/static/router_3.jpg"></image>
  9. </view>
  10. <view class="msgItemRight">
  11. <text class="msgItemTitle">我的承诺书</text>
  12. <text>{{item.created_at}}</text>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="loading" v-if="isMore">没有更多数据了</view>
  17. </view>
  18. </template>
  19. <script>
  20. import { promiseList } from "../../api/index.js"
  21. export default {
  22. data(){
  23. return {
  24. msgList:[],
  25. isMore:false,
  26. page_index:1,
  27. page_size:10,
  28. scrollType:true
  29. }
  30. },
  31. onShow() {
  32. this.create({
  33. page_index:1,
  34. page_size:10,
  35. })
  36. },
  37. onPullDownRefresh:function(){
  38. this.scrollType=true
  39. this.create({
  40. page_index:1,
  41. page_size:this.page_index*this.page_size,
  42. });
  43. },
  44. onReachBottom:function(){
  45. if(!this.isMore){
  46. this.page_index++;
  47. this.scrollType=false
  48. if(!this.loading){
  49. this.create({
  50. page_index:this.page_index,
  51. page_size:10
  52. })
  53. }
  54. }
  55. },
  56. methods:{
  57. create(params){
  58. const that = this
  59. this.$nextTick(function(){
  60. promiseList(params).then(res=>{
  61. uni.stopPullDownRefresh(); //停止下拉刷新动画
  62. const { error_code } = res
  63. if(error_code===200){
  64. const { data } = res
  65. if(data.length<1 || data.length<that.page_size){
  66. that.isMore=true
  67. }
  68. if(that.scrollType){
  69. that.msgList=data
  70. }else{
  71. that.msgList=that.msgList.concat(data)
  72. }
  73. }
  74. })
  75. })
  76. },
  77. toPromiseInfo(item){
  78. this.$store.commit("change_promise",{
  79. url:item.imageUrl,
  80. time:item.created_at
  81. })
  82. uni.navigateTo({
  83. url:`/pages/promiseInfo/promiseInfo`
  84. })
  85. }
  86. }
  87. }
  88. </script>
  89. <style lang="scss">
  90. page{
  91. width: 100%;
  92. height: 100%;
  93. background: $uni-bg-color-normal;
  94. }
  95. .msgList{
  96. width: 100%;
  97. height: 100%;
  98. }
  99. .mt30{
  100. padding-top: 30rpx;
  101. }
  102. .msgItem{
  103. width: 100%;
  104. height: 156rpx;
  105. background-color: $uni-bg-color;
  106. position: relative;
  107. overflow: hidden;
  108. display: flex;
  109. justify-content: space-between;
  110. align-items: center;
  111. margin-bottom: 30rpx;
  112. }
  113. .msgItem::after,.msgItem::before{
  114. content: "";
  115. display: block;
  116. width: 42rpx;
  117. height: 42rpx;
  118. border-radius: 50%;
  119. position: absolute;
  120. background: $uni-bg-color-normal;
  121. left: 138rpx;
  122. }
  123. .msgItem::before{
  124. top: 0;
  125. margin-top: -21rpx;
  126. }
  127. .msgItem::after{
  128. bottom: 0;
  129. margin-bottom: -21rpx;
  130. }
  131. .fixedTitle{
  132. display: block;
  133. width: 72rpx;
  134. height: 72rpx;
  135. background-size: 100% 100%;
  136. }
  137. .msgItemLeft{
  138. width: 159rpx;
  139. height: 100%;
  140. display: flex;
  141. justify-content: center;
  142. align-items: center;
  143. position: relative;
  144. }
  145. .msgItemLeft::after{
  146. content: "";
  147. display: block;
  148. width: 6rpx;
  149. height: 90rpx;
  150. background: url(../../static/border_circle.jpg);
  151. background-size: 100% 100%;
  152. position: absolute;
  153. top: 50%;
  154. right: 0;
  155. margin-top: -45rpx;
  156. margin-right: -3rpx;
  157. }
  158. .msgItemRight{
  159. width: calc(100% - 159rpx - 89rpx - 57rpx);
  160. padding: 0 89rpx 0 57rpx;
  161. overflow: hidden;
  162. text-overflow: ellipsis;
  163. font-size: 24rpx;
  164. color: #999999;
  165. }
  166. .msgItemTitle{
  167. font-size: 28rpx;
  168. color: #323332;
  169. margin-bottom: 10rpx;
  170. display: block;
  171. }
  172. .loading{
  173. font-size: 24rpx;
  174. text-align: center;
  175. padding-bottom: 10px;
  176. }
  177. </style>