index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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" @change="onChangeTab" />
  7. <!-- 订单列表 -->
  8. <view class="order-list">
  9. <view class="order-item" v-for="(item, index) in list.content" :key="index">
  10. <view class="item-top" @click="handleTargetDetail(item.id)">
  11. <view class="item-top-left">
  12. <text class="order-type">{{ item.typeName }}</text>
  13. </view>
  14. <view class="item-top-right">
  15. <text :class="item.status">{{ item.statusText }}</text>
  16. </view>
  17. </view>
  18. <!-- 商品列表 -->
  19. <view class="goods-list" v-if="item.goods" @click="handleTargetDetail(item.id)">
  20. <view class="goods-item" v-for="(goods, idx) in item.goods" :key="idx">
  21. <!-- 商品图片 -->
  22. <view class="goods-image">
  23. <image class="image" :src="goods.image"></image>
  24. </view>
  25. <!-- 商品信息 -->
  26. <view class="goods-content">
  27. <view class="goods-title twolist-hidden"><text>{{ goods.name }}</text></view>
  28. <view class="goods-props clearfix">
  29. <view class="goods-props-item" v-for="(props, idx) in goods.specList" :key="idx">
  30. <text>{{ props.specValue }}</text>
  31. </view>
  32. </view>
  33. </view>
  34. <!-- 交易信息 -->
  35. <view class="goods-trade">
  36. <view class="goods-price">
  37. <text class="unit">¥</text>
  38. <text class="value">{{ goods.price }}</text>
  39. </view>
  40. <view class="goods-num">
  41. <text>×{{ goods.num }}</text>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <!-- 备注信息 -->
  47. <view v-if="item.remark" class="remark" @click="handleTargetDetail(item.id)">
  48. <text>备注:</text>
  49. <text>{{ item.remark ? item.remark : '--'}}</text>
  50. </view>
  51. <!-- 订单合计 -->
  52. <view class="order-total" @click="handleTargetDetail(item.id)">
  53. <text>总金额</text>
  54. <text class="unit">¥</text>
  55. <text class="money">{{ item.amount }}</text>
  56. </view>
  57. <!-- 订单操作 -->
  58. <view class="order-handle">
  59. <view class="order-time">
  60. <text class="time">{{ item.createTime }}</text>
  61. </view>
  62. <view class="btn-group">
  63. <view class="btn-item" @click="handleTargetDetail(item.id)">详情</view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </mescroll-body>
  69. </view>
  70. </template>
  71. <script>
  72. import {
  73. DeliveryStatusEnum,
  74. DeliveryTypeEnum,
  75. OrderStatusEnum,
  76. PayStatusEnum,
  77. PayTypeEnum,
  78. ReceiptStatusEnum
  79. } from '@/common/enum/order'
  80. import MescrollBody from '@/components/mescroll-uni/mescroll-body.vue'
  81. import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins'
  82. import { getEmptyPaginateObj, getMoreListData } from '@/utils/app'
  83. import * as OrderApi from '@/api/merchant/order'
  84. import { wxPayment } from '@/utils/app'
  85. // 每页记录数量
  86. const pageSize = 15
  87. // tab栏数据
  88. const tabs = [{
  89. name: `全部`,
  90. value: 'all'
  91. }, {
  92. name: `待支付`,
  93. value: 'toPay'
  94. }, {
  95. name: `已支付`,
  96. value: 'paid'
  97. }, {
  98. name: `已取消`,
  99. value: 'cancel'
  100. }]
  101. export default {
  102. components: {
  103. MescrollBody
  104. },
  105. mixins: [MescrollMixin],
  106. data() {
  107. return {
  108. // 枚举类
  109. DeliveryStatusEnum,
  110. DeliveryTypeEnum,
  111. OrderStatusEnum,
  112. PayStatusEnum,
  113. PayTypeEnum,
  114. ReceiptStatusEnum,
  115. // 当前页面参数
  116. options: { dataType: 'all' },
  117. // tab栏数据
  118. tabs,
  119. // 当前标签索引
  120. curTab: 0,
  121. // 订单列表数据
  122. list: getEmptyPaginateObj(),
  123. // 正在加载
  124. isLoading: false,
  125. // 上拉加载配置
  126. upOption: {
  127. // 首次自动执行
  128. auto: true,
  129. // 每页数据的数量; 默认10
  130. page: { size: pageSize },
  131. // 数量要大于12条才显示无更多数据
  132. noMoreSize: 12,
  133. // 空布局
  134. empty: {
  135. tip: '亲,暂无订单记录'
  136. }
  137. },
  138. // 控制首次触发onShow事件时不刷新列表
  139. canReset: false,
  140. // 支付方式弹窗
  141. showPayPopup: false,
  142. statusText: "payStatus"
  143. }
  144. },
  145. /**
  146. * 生命周期函数--监听页面加载
  147. */
  148. onLoad(options) {
  149. // 初始化当前选中的标签
  150. this.initCurTab(options)
  151. },
  152. /**
  153. * 生命周期函数--监听页面显示
  154. */
  155. onShow() {
  156. this.canReset && this.onRefreshList()
  157. this.canReset = true
  158. },
  159. methods: {
  160. // 初始化当前选中的标签
  161. initCurTab(options) {
  162. const app = this
  163. if (options.dataType) {
  164. console.log("options == ", options);
  165. const index = app.tabs.findIndex(item => item.value == options.dataType)
  166. app.curTab = index > -1 ? index : 0
  167. }
  168. },
  169. /**
  170. * 上拉加载的回调 (页面初始化时也会执行一次)
  171. * 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10
  172. * @param {Object} page
  173. */
  174. upCallback(page) {
  175. const app = this
  176. // 设置列表数据
  177. app.getOrderList(page.num)
  178. .then(list => {
  179. const curPageLen = list.content.length
  180. const totalSize = list.totalElements
  181. app.mescroll.endBySize(curPageLen, totalSize)
  182. })
  183. .catch(() => app.mescroll.endErr())
  184. },
  185. // 获取订单列表
  186. getOrderList(pageNo = 1) {
  187. const app = this
  188. return new Promise((resolve, reject) => {
  189. OrderApi.list({ dataType: app.getTabValue(), page: pageNo }, { load: false })
  190. .then(result => {
  191. // 合并新数据
  192. const newList = result.data;
  193. app.list.content = getMoreListData(newList, app.list, pageNo);
  194. resolve(newList)
  195. })
  196. })
  197. },
  198. // 点击跳转到首页
  199. onTargetIndex() {
  200. this.$navTo('pages/index/index')
  201. },
  202. // 获取当前标签项的值
  203. getTabValue() {
  204. return this.tabs[this.curTab].value
  205. },
  206. // 切换标签项
  207. onChangeTab(index) {
  208. const app = this
  209. // 设置当前选中的标签
  210. app.curTab = index
  211. // 刷新订单列表
  212. app.onRefreshList()
  213. },
  214. // 刷新订单列表
  215. onRefreshList() {
  216. this.list = getEmptyPaginateObj()
  217. setTimeout(() => {
  218. this.mescroll.resetUpScroll()
  219. }, 120)
  220. },
  221. // 跳转到订单详情页
  222. handleTargetDetail(orderId) {
  223. this.$navTo('pages/order/detail', { orderId })
  224. }
  225. }
  226. }
  227. </script>
  228. <style lang="scss" scoped>
  229. // 项目内容
  230. .order-item {
  231. margin: 10rpx auto 10rpx auto;
  232. padding: 20rpx 20rpx;
  233. width: 94%;
  234. border: 3rpx solid #e8e8e8;
  235. box-shadow: 5rpx 5rpx 5rpx 5rpx rgba(0.05, 0.05, 0.05, 0.05);
  236. border-radius: 16rpx;
  237. background: #fff;
  238. .A{
  239. color:$uni-text-color-active;
  240. }
  241. .B{
  242. color:$uni-text-color;
  243. }
  244. }
  245. // 项目顶部
  246. .item-top {
  247. display: flex;
  248. justify-content: space-between;
  249. font-size: 26rpx;
  250. margin-bottom: 40rpx;
  251. .order-type {
  252. font-weight: bold;
  253. margin-left: 20rpx;
  254. }
  255. .state-text {
  256. color: $uni-text-color-active;
  257. }
  258. }
  259. // 商品列表
  260. .goods-list {
  261. // 商品项
  262. .goods-item {
  263. display: flex;
  264. margin-bottom: 10rpx;
  265. border-bottom: 3rpx solid #e8e8e8;
  266. padding: 20rpx;
  267. // 商品图片
  268. .goods-image {
  269. width: 180rpx;
  270. height: 143rpx;
  271. .image {
  272. display: block;
  273. width: 100%;
  274. height: 100%;
  275. border-radius: 8rpx;
  276. }
  277. }
  278. // 商品内容
  279. .goods-content {
  280. flex: 1;
  281. padding-left: 16rpx;
  282. padding-top: 16rpx;
  283. .goods-title {
  284. font-size: 26rpx;
  285. max-height: 76rpx;
  286. }
  287. .goods-props {
  288. margin-top: 14rpx;
  289. height: 40rpx;
  290. color: #ababab;
  291. font-size: 24rpx;
  292. overflow: hidden;
  293. .goods-props-item {
  294. display: inline-block;
  295. margin-right: 14rpx;
  296. padding: 4rpx 16rpx;
  297. border-radius: 12rpx;
  298. background-color: #F5F5F5;
  299. width: auto;
  300. }
  301. }
  302. }
  303. // 交易信息
  304. .goods-trade {
  305. padding-top: 16rpx;
  306. width: 150rpx;
  307. text-align: right;
  308. color: $uni-text-color-grey;
  309. font-size: 26rpx;
  310. .goods-price {
  311. vertical-align: bottom;
  312. margin-bottom: 16rpx;
  313. .unit {
  314. margin-right: -2rpx;
  315. font-size: 24rpx;
  316. }
  317. }
  318. }
  319. }
  320. }
  321. // 备注信息
  322. .remark {
  323. padding: 12rpx 0 12rpx 20rpx;
  324. border-radius: 5rpx;
  325. height: 60rpx;
  326. }
  327. // 订单合计
  328. .order-total {
  329. font-size: 26rpx;
  330. vertical-align: bottom;
  331. text-align: right;
  332. height: 40rpx;
  333. margin-top: 30rpx;
  334. margin-bottom: 30rpx;
  335. .unit {
  336. margin-left: 8rpx;
  337. margin-right: -2rpx;
  338. font-size: 26rpx;
  339. }
  340. .money {
  341. font-size: 28rpx;
  342. }
  343. }
  344. // 订单操作
  345. .order-handle {
  346. height: 50rpx;
  347. .order-time {
  348. color: #777;
  349. float: left;
  350. margin-left: 20rpx;
  351. }
  352. .btn-group {
  353. .btn-item {
  354. border-radius: 10rpx;
  355. padding: 8rpx 24rpx;
  356. font-size: 28rpx;
  357. float: right;
  358. color: #ffffff;
  359. background: #f9211c;
  360. border: 1rpx solid #f9211c;
  361. margin-left: 25rpx;
  362. }
  363. }
  364. }
  365. </style>