orderList.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <view>
  3. <scroll-view class="tabs" :scroll-x="true" scroll-with-animation :scroll-into-view=" 'tab-' + scrollIntoView">
  4. <view
  5. :id="'tab-' + index"
  6. :class="index == active ? 'tabs-item active':'tabs-item'"
  7. v-for="(item, index) in tabList" :key="index"
  8. @tap="handleTab(index)">{{item.name}}</view>
  9. </scroll-view>
  10. <mescroll-body ref="mescrollRef" style="background-color: #FAFAFA;" @init="mescrollInit" top="0" bottom="0" :down="downOption" @down="downCallback" :up="upOption"
  11. @up="upCallback" @emptyclick="emptyClick">
  12. <view class="orderlist" v-for="(item, index) in dataList" :key="index">
  13. <view class="orderlist-item">
  14. <view class="orderlist-item-orderno">
  15. <view class="orderlist-item-num">订单号:{{item.orderCode}}</view>
  16. <view class="orderlist-item-status" :style="{color: item.status == 2 ? '#E69A22':''}">
  17. {{getStatus(item.status)}}
  18. </view>
  19. </view>
  20. <view class="orderlist-item-goodbox">
  21. <image class="orderlist-item-goods" :src="item.imgUrl" mode="aspectFill"></image>
  22. <view class="orderlist-item-info">
  23. <text class="textOne orderlist-item-name">{{item.courseName}}</text>
  24. <text class="textTwo orderlist-item-desc">{{item.videoName}}</text>
  25. <view class="orderlist-item-buyinfo">
  26. <text class="people">45708 人已购</text>
  27. <text>x1</text>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="orderlist-item-price">
  32. 订单金额:
  33. <text class="price-unit">¥</text>
  34. <text class="price-integer">{{item.payPrice||0.00}}</text>
  35. <!-- <text class="price-decimal">.00</text> -->
  36. </view>
  37. </view>
  38. </view>
  39. </mescroll-body>
  40. </view>
  41. </template>
  42. <script>
  43. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  44. import mescrollBody from "@/uni_modules/mescroll-uni/components/mescroll-body/mescroll-body.vue";
  45. import { getCourseOrderList} from '@/api/course'
  46. export default {
  47. mixins: [MescrollMixin], // 使用mixin
  48. data() {
  49. return {
  50. tabList: [
  51. {name: '全部'},
  52. {name: '待付款'},
  53. {name: '已付款'},
  54. {name: '退款中'},
  55. {name: '已退款'}
  56. ],
  57. active: 0,
  58. scrollIntoView: 0,
  59. status: 1,
  60. downOption: { //下拉刷新
  61. use:true,
  62. auto: true // 不自动加载 (mixin已处理第一个tab触发downCallback)
  63. },
  64. totalNum:0,
  65. upOption: { //上拉加载
  66. auto: false, // 不自动加载
  67. page: {
  68. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  69. size: 10 // 每页数据的数量
  70. },
  71. noMoreSize: 5, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  72. empty:{
  73. tip: '~ 暂无数据 ~', // 提示
  74. btnText: '刷新重试',
  75. icon:"/static/images/icon_img_empty.png"
  76. }
  77. },
  78. dataList:[],
  79. }
  80. },
  81. onLoad(options) {
  82. this.active=options.status;
  83. this.status=options.status;
  84. },
  85. methods: {
  86. /*下拉刷新的回调 */
  87. downCallback() {
  88. this.refreshPage();
  89. },
  90. /*上拉加载的回调*/
  91. upCallback(page) {
  92. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  93. let params={};
  94. if(this.status>0){
  95. params["status"]=this.status;
  96. }
  97. getCourseOrderList(params,page.num).then(res => {
  98. if(res.code==200){
  99. setTimeout(()=>{
  100. this.mescroll.endByPage(res.data.list.length, res.data.pages);
  101. if(page.num == 1) this.dataList = []; //如果是第一页需手动制空列表
  102. this.dataList=this.dataList.concat(res.data.list); //追加新数据
  103. this.totalNum=res.data.total;
  104. },300);
  105. }else{
  106. this.mescroll.endByPage(0, 1);
  107. }
  108. },
  109. rej => {}
  110. ).catch(()=>{
  111. //联网失败, 结束加载
  112. this.mescroll.endErr();
  113. });
  114. },
  115. refreshPage(){
  116. this.mescroll.hideTopBtn();
  117. this.mescroll.resetUpScroll(true);
  118. },
  119. getStatus(status){
  120. let statusStr="";
  121. if(status==1){
  122. statusStr="待付款";
  123. }else if(status==2){
  124. statusStr="已付款";
  125. }
  126. else if(status==3){
  127. statusStr="退款中";
  128. }
  129. else{
  130. statusStr="已退款";
  131. }
  132. return statusStr;
  133. },
  134. handleTab(index) {
  135. if(this.active == index) return
  136. this.active = index;
  137. this.status=index;
  138. this.scrollIntoView = index
  139. this.refreshPage();
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. @mixin u-flex($flexD, $alignI, $justifyC) {
  146. display: flex;
  147. flex-direction: $flexD;
  148. align-items: $alignI;
  149. justify-content: $justifyC;
  150. }
  151. .tabs {
  152. height: 100rpx;
  153. background: #FFFFFF;
  154. border-bottom: 1rpx solid #ECECEC;
  155. font-family: PingFang SC, PingFang SC;
  156. font-weight: 400;
  157. font-size: 28rpx;
  158. color: #757575;
  159. white-space: nowrap;
  160. width: 100%;
  161. .tabs-item {
  162. display: inline-block;
  163. min-width: 64rpx;
  164. width: 20%;
  165. line-height: 100rpx;
  166. position: relative;
  167. text-align: center;
  168. }
  169. .active {
  170. font-weight: 500;
  171. font-size: 28rpx;
  172. color: #222222;
  173. &::after {
  174. content: "";
  175. width: 48rpx;
  176. height: 6rpx;
  177. background: #FF5C03;
  178. border-radius: 3rpx 3rpx 3rpx 3rpx;
  179. position: absolute;
  180. bottom: 2rpx;
  181. left: 50%;
  182. transform: translateX(-50%);
  183. }
  184. }
  185. }
  186. .orderlist {
  187. padding: 20rpx 24rpx;
  188. font-family: PingFang SC, PingFang SC;
  189. font-weight: 400;
  190. font-size: 26rpx;
  191. color: #999999;
  192. &-item {
  193. padding: 30rpx 24rpx;
  194. background: #FFFFFF;
  195. border-radius: 16rpx 16rpx 16rpx 16rpx;
  196. &-orderno {
  197. @include u-flex(row, center, space-between);
  198. }
  199. &-goodbox {
  200. margin-top: 26rpx;
  201. @include u-flex(row, flex-start, flex-start);
  202. flex: 1;
  203. }
  204. &-goods {
  205. flex-shrink: 0;
  206. width: 180rpx;
  207. height: 180rpx;
  208. margin-right: 26rpx;
  209. }
  210. &-info {
  211. flex: 1;
  212. overflow: hidden;
  213. display: flex;
  214. flex-direction: column
  215. }
  216. &-name {
  217. font-weight: 500;
  218. font-size: 28rpx;
  219. color: #222222;
  220. }
  221. &-desc {
  222. font-weight: 500;
  223. font-size: 28rpx;
  224. color: #222222;
  225. font-weight: 400;
  226. font-size: 24rpx;
  227. color: #999999;
  228. margin-top: 8rpx;
  229. }
  230. &-buyinfo {
  231. margin-top: 18rpx;
  232. @include u-flex(row, center, space-between);
  233. .people {
  234. font-weight: 400;
  235. font-size: 22rpx;
  236. color: #E69A22;
  237. }
  238. }
  239. &-price {
  240. font-weight: 400;
  241. font-size: 24rpx;
  242. color: #757575;
  243. padding: 30rpx 0 4rpx 0;
  244. }
  245. .price-unit {
  246. font-family: Roboto, Roboto;
  247. font-weight: 600;
  248. font-size: 20rpx;
  249. color: #FF5C03;
  250. }
  251. .price-integer {
  252. font-family: Roboto, Roboto;
  253. font-weight: bold;
  254. font-size: 36rpx;
  255. color: #FF5C03;
  256. }
  257. .price-decimal {
  258. font-family: Roboto, Roboto;
  259. font-weight: bold;
  260. font-size: 26rpx;
  261. color: #FF5C03;
  262. }
  263. }
  264. }
  265. </style>