share-log.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <!-- 分享记录 -->
  2. <template>
  3. <view class="page_box">
  4. <!-- 标题栏 -->
  5. <view class="head_box">
  6. <view class="nav-box">
  7. <!-- 标题栏 -->
  8. <shopro-navbar back-icon-color="#fff" :background="{}" :backTextStyle="{ color: '#fff', fontSize: '40rpx', fontWeight: '500' }" backText="分享记录"></shopro-navbar>
  9. </view>
  10. <!-- 分类tab -->
  11. <view class="tab-box u-flex">
  12. <view class="tab-item u-flex-1 " v-for="(tab, index) in tabsList" :key="tab.value" @tap="onTab(tab.value)">
  13. <text class="tab-title" :class="{ 'title-active': tabCurrent === tab.value }">{{ tab.name }}</text>
  14. <text class="underline" :class="{ 'underline-active': tabCurrent === tab.value }"></text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="content_box">
  19. <scroll-view scroll-y="true" @scrolltolower="loadMore" class="scroll-box">
  20. <!-- 分享记录列表 -->
  21. <view class="log-list u-flex" v-for="item in shareLogList" :key="item.id">
  22. <view class="log-avatar-wrap"><image class="log-avatar" :src="item.user.avatar" mode=""></image></view>
  23. <view class="item-right">
  24. <view class="name">{{ item.user.nickname }}</view>
  25. <view class="content u-flex">
  26. <view class="content-img-wrap" v-if="item.type_data"><image class="content-img" :src="item.type_data.image" mode=""></image></view>
  27. <view class="content-text">{{ item.msg }}</view>
  28. </view>
  29. <view class="item-bottom u-flex u-row-between">
  30. <view class="time">{{ $u.timeFormat(item.createtime, 'yyyy年mm月dd日 hh:MM') }}</view>
  31. <view class="from-text">来自{{ typeObj[item.type] }}分享</view>
  32. </view>
  33. </view>
  34. </view>
  35. <!-- 缺省页 -->
  36. <shopro-empty v-if="isEmpty" :image="$IMG_URL + '/imgs/empty/no_data.png'" tipText="暂无数据"></shopro-empty>
  37. <!-- 更多 -->
  38. <u-loadmore v-if="shareLogList.length" height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc" />
  39. </scroll-view>
  40. </view>
  41. <view class="foot_box"></view>
  42. </view>
  43. </template>
  44. <script>
  45. export default {
  46. components: {},
  47. data() {
  48. return {
  49. shareLogList: [], //分享记录
  50. tabCurrent: 'all', //默认
  51. tabsList: [
  52. {
  53. name: '全部',
  54. value: 'all'
  55. },
  56. {
  57. name: '名片',
  58. value: 'index'
  59. },
  60. {
  61. name: '商品',
  62. value: 'goods'
  63. },
  64. {
  65. name: '拼团',
  66. value: 'groupon'
  67. }
  68. ],
  69. typeObj: {
  70. index: '名片',
  71. goods: '商品',
  72. groupon: '拼团'
  73. },
  74. loadStatus: 'loadmore', //loadmore-加载前的状态,loading-加载中的状态,nomore-没有更多的状态
  75. currentPage: 1,
  76. lastPage: 1,
  77. isEmpty: false
  78. };
  79. },
  80. computed: {},
  81. onLoad() {
  82. this.getShareLog();
  83. },
  84. onPullDownRefresh() {
  85. this.currentPage = 1;
  86. this.lastPage = 1;
  87. this.shareLogList = [];
  88. this.getShareLog();
  89. },
  90. methods: {
  91. // 切换分类
  92. onTab(type) {
  93. if (this.tabCurrent !== type) {
  94. this.tabCurrent = type;
  95. this.currentPage = 1;
  96. this.lastPage = 1;
  97. this.shareLogList = [];
  98. this.getShareLog();
  99. }
  100. },
  101. // 分享记录数据
  102. getShareLog() {
  103. let that = this;
  104. that.loadStatus = 'loading';
  105. that.$http('commission.share', {
  106. type: that.tabCurrent,
  107. page: that.currentPage
  108. }).then(res => {
  109. uni.stopPullDownRefresh();
  110. if (res.code === 1) {
  111. that.shareLogList = [...that.shareLogList, ...res.data.data];
  112. that.lastPage = res.data.last_page;
  113. that.isEmpty = !that.shareLogList.length;
  114. that.loadStatus = that.currentPage < res.data.last_page ? 'loadmore' : 'nomore';
  115. }
  116. });
  117. },
  118. // 加载更多
  119. loadMore() {
  120. if (this.currentPage < this.lastPage) {
  121. this.currentPage += 1;
  122. this.getShareLog();
  123. }
  124. }
  125. }
  126. };
  127. </script>
  128. <style lang="scss">
  129. // nav
  130. .head_box {
  131. height: 280rpx;
  132. background: url($IMG_URL+'/imgs/commission/share_head_bg.png') no-repeat;
  133. background-size: 100% auto;
  134. position: relative;
  135. }
  136. // 分类
  137. .tab-box {
  138. background-color: #fff;
  139. border-radius: 20rpx 20rpx 0px 0px;
  140. position: absolute;
  141. width: 100%;
  142. bottom: 0;
  143. .tab-item {
  144. height: 100%;
  145. display: flex;
  146. flex-direction: column;
  147. align-items: center;
  148. justify-content: center;
  149. .tab-title {
  150. color: #666;
  151. font-weight: 500;
  152. font-size: 28rpx;
  153. line-height: 90rpx;
  154. }
  155. .title-active {
  156. color: #333;
  157. }
  158. .underline {
  159. display: block;
  160. width: 68rpx;
  161. height: 4rpx;
  162. background: #fff;
  163. border-radius: 2rpx;
  164. }
  165. .underline-active {
  166. background: #5e49c3;
  167. display: block;
  168. width: 68rpx;
  169. height: 4rpx;
  170. border-radius: 2rpx;
  171. }
  172. }
  173. }
  174. // 分享记录列表
  175. .log-list {
  176. background-color: #fff;
  177. padding: 30rpx;
  178. margin: 10rpx 0;
  179. align-items: flex-start;
  180. .log-avatar-wrap {
  181. margin-right: 14rpx;
  182. .log-avatar {
  183. width: 40rpx;
  184. height: 40rpx;
  185. border-radius: 50%;
  186. }
  187. }
  188. .item-right {
  189. flex: 1;
  190. .name {
  191. font-size: 26rpx;
  192. font-weight: 500;
  193. color: #7f7aa5;
  194. margin-bottom: 30rpx;
  195. }
  196. .content {
  197. background: rgba(241, 241, 241, 0.46);
  198. border-radius: 2rpx;
  199. padding: 10rpx;
  200. margin-bottom: 20rpx;
  201. .content-img-wrap {
  202. margin-right: 16rpx;
  203. width: 80rpx;
  204. height: 80rpx;
  205. .content-img {
  206. width: 80rpx;
  207. height: 80rpx;
  208. border-radius: 6rpx;
  209. }
  210. }
  211. .content-text {
  212. font-size: 24rpx;
  213. font-weight: 500;
  214. color: #333333;
  215. }
  216. }
  217. .item-bottom {
  218. width: 100%;
  219. .time {
  220. font-size: 22rpx;
  221. font-weight: 500;
  222. color: #c8c8c8;
  223. }
  224. .from-text {
  225. font-size: 22rpx;
  226. font-weight: 500;
  227. color: #c8c8c8;
  228. }
  229. }
  230. }
  231. }
  232. </style>