index.vue 6.6 KB

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