index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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.toFixed(2) }}</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/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. // 支付方式弹窗
  139. showPayPopup: false,
  140. statusText: "payStatus"
  141. }
  142. },
  143. /**
  144. * 生命周期函数--监听页面加载
  145. */
  146. onLoad(options) {
  147. // 初始化当前选中的标签
  148. this.initCurTab(options)
  149. },
  150. /**
  151. * 生命周期函数--监听页面显示
  152. */
  153. onShow() {
  154. this.onRefreshList();
  155. },
  156. methods: {
  157. // 初始化当前选中的标签
  158. initCurTab(options) {
  159. const app = this
  160. if (options.dataType) {
  161. console.log("options === ", options);
  162. const index = app.tabs.findIndex(item => item.value == options.dataType)
  163. app.curTab = index > -1 ? index : 0
  164. }
  165. },
  166. /**
  167. * 上拉加载的回调 (页面初始化时也会执行一次)
  168. * 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10
  169. * @param {Object} page
  170. */
  171. upCallback(page) {
  172. const app = this
  173. // 设置列表数据
  174. app.getOrderList(page.num)
  175. .then(list => {
  176. const curPageLen = list.content.length;
  177. const totalSize = list.totalElements;
  178. app.mescroll.endBySize(curPageLen, totalSize);
  179. })
  180. .catch(() => app.mescroll.endErr())
  181. },
  182. // 获取订单列表
  183. getOrderList(pageNo = 1) {
  184. const app = this
  185. return new Promise((resolve, reject) => {
  186. OrderApi.list({ dataType: app.getTabValue(), page: pageNo }, { load: false })
  187. .then(result => {
  188. // 合并新数据
  189. const newList = result.data;
  190. app.list.content = getMoreListData(newList, app.list, pageNo);
  191. resolve(newList);
  192. })
  193. })
  194. },
  195. // 点击跳转到首页
  196. onTargetIndex() {
  197. this.$navTo('pages/index/index')
  198. },
  199. // 获取当前标签项的值
  200. getTabValue() {
  201. return this.tabs[this.curTab].value
  202. },
  203. // 切换标签项
  204. onChangeTab(index) {
  205. const app = this
  206. // 设置当前选中的标签
  207. app.curTab = index
  208. // 刷新订单列表
  209. app.onRefreshList()
  210. },
  211. // 刷新订单列表
  212. onRefreshList() {
  213. this.list = getEmptyPaginateObj()
  214. setTimeout(() => {
  215. this.mescroll.resetUpScroll()
  216. }, 120)
  217. },
  218. // 跳转到订单详情页
  219. handleTargetDetail(orderId) {
  220. this.$navTo('pages/order/detail', { orderId })
  221. }
  222. }
  223. }
  224. </script>
  225. <style lang="scss" scoped>
  226. // 项目内容
  227. .order-item {
  228. margin: 10rpx auto 10rpx auto;
  229. padding: 20rpx 20rpx;
  230. width: 94%;
  231. border: 3rpx solid #e8e8e8;
  232. box-shadow: 5rpx 5rpx 5rpx 5rpx rgba(0.05, 0.05, 0.05, 0.05);
  233. border-radius: 16rpx;
  234. background: #fff;
  235. .A{
  236. color:$uni-text-color-active;
  237. }
  238. .B{
  239. color:$uni-text-color;
  240. }
  241. }
  242. // 项目顶部
  243. .item-top {
  244. display: flex;
  245. justify-content: space-between;
  246. font-size: 26rpx;
  247. margin-bottom: 40rpx;
  248. .order-type {
  249. font-weight: bold;
  250. margin-left: 20rpx;
  251. }
  252. .state-text {
  253. color: $uni-text-color-active;
  254. }
  255. }
  256. // 商品列表
  257. .goods-list {
  258. // 商品项
  259. .goods-item {
  260. display: flex;
  261. margin-bottom: 10rpx;
  262. border-bottom: 3rpx solid #e8e8e8;
  263. padding: 20rpx;
  264. // 商品图片
  265. .goods-image {
  266. width: 180rpx;
  267. height: 143rpx;
  268. .image {
  269. display: block;
  270. width: 100%;
  271. height: 100%;
  272. border-radius: 8rpx;
  273. }
  274. }
  275. // 商品内容
  276. .goods-content {
  277. flex: 1;
  278. padding-left: 16rpx;
  279. padding-top: 16rpx;
  280. .goods-title {
  281. font-size: 26rpx;
  282. max-height: 76rpx;
  283. }
  284. .goods-props {
  285. margin-top: 14rpx;
  286. height: 40rpx;
  287. color: #ababab;
  288. font-size: 24rpx;
  289. overflow: hidden;
  290. .goods-props-item {
  291. display: inline-block;
  292. margin-right: 14rpx;
  293. padding: 4rpx 16rpx;
  294. border-radius: 12rpx;
  295. background-color: #F5F5F5;
  296. width: auto;
  297. }
  298. }
  299. }
  300. // 交易信息
  301. .goods-trade {
  302. padding-top: 16rpx;
  303. width: 150rpx;
  304. text-align: right;
  305. color: $uni-text-color-grey;
  306. font-size: 26rpx;
  307. .goods-price {
  308. vertical-align: bottom;
  309. margin-bottom: 16rpx;
  310. .unit {
  311. margin-right: -2rpx;
  312. font-size: 24rpx;
  313. }
  314. }
  315. }
  316. }
  317. }
  318. // 备注信息
  319. .remark {
  320. padding: 12rpx 0 12rpx 20rpx;
  321. border-radius: 5rpx;
  322. height: 60rpx;
  323. }
  324. // 订单合计
  325. .order-total {
  326. font-size: 26rpx;
  327. vertical-align: bottom;
  328. text-align: right;
  329. height: 40rpx;
  330. margin-top: 30rpx;
  331. margin-bottom: 30rpx;
  332. .unit {
  333. margin-left: 8rpx;
  334. margin-right: -2rpx;
  335. font-size: 26rpx;
  336. }
  337. .money {
  338. font-size: 28rpx;
  339. }
  340. }
  341. // 订单操作
  342. .order-handle {
  343. height: 50rpx;
  344. .order-time {
  345. color: #777;
  346. float: left;
  347. margin-left: 20rpx;
  348. }
  349. .btn-group {
  350. .btn-item {
  351. border-radius: 10rpx;
  352. padding: 8rpx 24rpx;
  353. font-size: 28rpx;
  354. float: right;
  355. color: #ffffff;
  356. background: #f9211c;
  357. border: 1rpx solid #f9211c;
  358. margin-left: 25rpx;
  359. }
  360. }
  361. }
  362. </style>