index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="container">
  3. <mescroll-body ref="mescrollRef" :sticky="true" @init="mescrollInit" :down="{ native: true }" @down="downCallback"
  4. :up="upOption" @up="upCallback">
  5. <!-- tab栏 -->
  6. <u-tabs :list="tabs" :is-scroll="false" :current="curTab" active-color="#FA2209" :duration="0.2"
  7. @change="onChangeTab" />
  8. <!-- 转赠记录 -->
  9. <view class="widget-list">
  10. <view class="widget-detail" v-for="(item, index) in list.content" :key="index">
  11. <view class="row-block dis-flex flex-y-center">
  12. <view class="flex-box">{{ item.createTime }}</view>
  13. <view class="flex-box t-r">
  14. <text class="mobile">{{ item.mobile.substr(0, 3) + '****' + item.mobile.substr(7) }}</text>
  15. </view>
  16. </view>
  17. <view class="detail-goods row-block dis-flex">
  18. <view class="goods-right flex-box">
  19. <view class="goods-name">
  20. <text class="twolist-hidden">{{ item.couponNames }}</text>
  21. </view>
  22. <view class="goods-props clearfix">
  23. <view class="goods-props-item">
  24. <text>¥{{ item.money }}</text>
  25. </view>
  26. </view>
  27. <view class="goods-num t-r">
  28. <text class="f-26 col-8">×{{ item.num }}</text>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="detail-order row-block">
  33. <view class="item dis-flex flex-x-end flex-y-center">
  34. <text class="">转赠总金额:</text>
  35. <text class="col-m">¥{{ item.money * item.num }}</text>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </mescroll-body>
  41. </view>
  42. </template>
  43. <script>
  44. import MescrollBody from '@/components/mescroll-uni/mescroll-body.vue'
  45. import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins'
  46. import Empty from '@/components/empty'
  47. import { getEmptyPaginateObj, getMoreListData } from '@/utils/app'
  48. import * as giveApi from '@/api/give'
  49. // 每页记录数量
  50. const pageSize = 15
  51. // tab栏数据
  52. const tabs = [{
  53. name: '收到',
  54. value: 'gived'
  55. }, {
  56. name: '赠出',
  57. value: 'give'
  58. }]
  59. export default {
  60. components: {
  61. MescrollBody,
  62. Empty
  63. },
  64. mixins: [MescrollMixin],
  65. data() {
  66. return {
  67. // 订单列表数据
  68. list: getEmptyPaginateObj(),
  69. // 正在加载
  70. isLoading: false,
  71. // tabs栏数据
  72. tabs,
  73. // 当前标签索引
  74. curTab: 0,
  75. // 上拉加载配置
  76. upOption: {
  77. // 首次自动执行
  78. auto: true,
  79. // 每页数据的数量; 默认10
  80. page: { size: pageSize },
  81. // 数量要大于2条才显示无更多数据
  82. noMoreSize: 2,
  83. // 空布局
  84. empty: {
  85. tip: '亲,暂无转赠记录'
  86. }
  87. },
  88. // 控制首次触发onShow事件时不刷新列表
  89. canReset: false,
  90. }
  91. },
  92. /**
  93. * 生命周期函数--监听页面加载
  94. */
  95. onLoad(options) {
  96. // empty
  97. },
  98. /**
  99. * 生命周期函数--监听页面显示
  100. */
  101. onShow() {
  102. this.canReset && this.onRefreshList()
  103. this.canReset = true
  104. },
  105. methods: {
  106. /**
  107. * 上拉加载的回调 (页面初始化时也会执行一次)
  108. * 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10
  109. * @param {Object} page
  110. */
  111. upCallback(page) {
  112. const app = this
  113. // 设置列表数据
  114. app.getGiveLogList(page.num)
  115. .then(list => {
  116. const curPageLen = list.content.length
  117. const totalSize = list.totalElements
  118. app.mescroll.endBySize(curPageLen, totalSize)
  119. })
  120. .catch(() => app.mescroll.endErr())
  121. },
  122. // 获取转赠列表
  123. getGiveLogList(pageNo = 1) {
  124. const app = this
  125. return new Promise((resolve, reject) => {
  126. giveApi.giveLog({ type: app.getTabValue(), page: pageNo }, { load: false })
  127. .then(result => {
  128. // 合并新数据
  129. const newList = result.data
  130. app.list.content = getMoreListData(newList, app.list, pageNo)
  131. resolve(newList)
  132. })
  133. })
  134. },
  135. // 切换标签项
  136. onChangeTab(index) {
  137. const app = this
  138. // 设置当前选中的标签
  139. app.curTab = index
  140. // 刷新列表
  141. app.onRefreshList()
  142. },
  143. // 刷新订单列表
  144. onRefreshList() {
  145. this.list = getEmptyPaginateObj()
  146. setTimeout(() => {
  147. this.mescroll.resetUpScroll()
  148. }, 120)
  149. },
  150. // 获取当前标签项的值
  151. getTabValue() {
  152. return this.tabs[this.curTab].value
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. .widget-detail {
  159. box-sizing: border-box;
  160. background: #fff;
  161. margin-bottom: 10rpx;
  162. border: solid 2px #f5f5f5;
  163. padding: 30rpx;
  164. .row-block {
  165. padding: 0 20rpx;
  166. min-height: 50rpx;
  167. }
  168. .detail-goods {
  169. padding: 20rpx;
  170. .goods-right {
  171. padding: 15rpx 0;
  172. }
  173. .mobile {
  174. color: #888888;
  175. }
  176. .goods-name {
  177. margin-bottom: 10rpx;
  178. font-size: 34rpx;
  179. }
  180. .goods-props {
  181. margin-top: 14rpx;
  182. height: 40rpx;
  183. color: #ababab;
  184. font-size: 24rpx;
  185. overflow: hidden;
  186. .goods-props-item {
  187. display: inline-block;
  188. margin-right: 14rpx;
  189. padding: 4rpx 16rpx;
  190. border-radius: 12rpx;
  191. background-color: #F5F5F5;
  192. width: auto;
  193. }
  194. }
  195. }
  196. .detail-operate {
  197. padding-bottom: 20rpx;
  198. .detail-btn {
  199. border-radius: 4px;
  200. border: 1rpx solid #ccc;
  201. padding: 8rpx 20rpx;
  202. font-size: 28rpx;
  203. color: #555;
  204. margin-left: 10rpx;
  205. }
  206. }
  207. .detail-order {
  208. padding: 10rpx 20rpx;
  209. font-size: 26rpx;
  210. line-height: 50rpx;
  211. height: 50rpx;
  212. .item {
  213. margin-bottom: 10rpx;
  214. &:last-child {
  215. margin-bottom: 0;
  216. }
  217. }
  218. }
  219. }
  220. // 空数据按钮
  221. .empty-ipt {
  222. width: 220rpx;
  223. margin: 10px auto;
  224. font-size: 28rpx;
  225. height: 64rpx;
  226. line-height: 64rpx;
  227. text-align: center;
  228. color: #fff;
  229. border-radius: 5rpx;
  230. background: linear-gradient(to right, $fuint-theme, $fuint-theme);
  231. }
  232. </style>