index.vue 6.7 KB

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