integralOrderList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <template>
  2. <view class="content">
  3. <view class="top-fixed">
  4. <u-tabs
  5. :current="current"
  6. :scrollable="true"
  7. :list="tabs"
  8. lineColor="#DA251C"
  9. @change="tabChange">
  10. </u-tabs>
  11. </view>
  12. <!-- 订单列表 -->
  13. <mescroll-body top="88rpx" bottom="0" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  14. <view class="order-list">
  15. <view v-for="(item,index) in dataList" :key="index" class="item" >
  16. <!-- 订单号,状态 -->
  17. <view class="ordersn-box" @click="showDetail(item)">
  18. <view class="num">订单号:{{item.orderCode}}</view>
  19. <view class="status-box">
  20. <text class="text success" v-if="item.status>1&&item.status<5">
  21. {{utils.getDictLabel2Name(orderStatusOptions,item.status)}}
  22. </text>
  23. <text class="text info" v-else>
  24. {{utils.getDictLabel2Name(orderStatusOptions,item.status)}}
  25. </text>
  26. </view>
  27. </view>
  28. <view class="drug-list" >
  29. <view @click="showDetail(item)" v-for="(subItem,subIndex) in item.items" :key="subIndex" class="drug-item" >
  30. <view class="img-box">
  31. <image :src="subItem.imgUrl==''?'https://hdtobs.obs.cn-north-4.myhuaweicloud.com/miniapp/drug.svg':subItem.imgUrl" mode="aspectFill"></image>
  32. </view>
  33. <view class="drug-info" >
  34. <view>
  35. <view class="name-box ellipsis2">
  36. {{subItem.goodsName}}
  37. </view>
  38. </view>
  39. <view class="num-box">
  40. <view class="price">
  41. <text class="num" >{{subItem.integral}}</text>
  42. <text class="unit">积分</text>
  43. <text class="num" v-show="subItem.cash>0">+{{subItem.cash}}</text>
  44. <text class="unit" v-show="subItem.cash>0">元</text>
  45. </view>
  46. <view class="amount" >x{{subItem.num}}</view>
  47. </view>
  48. </view>
  49. </view>
  50. <!-- 实付金额、按钮 -->
  51. <view class="bottom-box">
  52. <view class="amount-paid">
  53. <!-- <text class="label">使用积分:</text> -->
  54. <view class="price-box">
  55. <view class="num" >{{item.integral}}</view>
  56. <view class="unit">积分</view>
  57. <view class="unit" v-show="item.payMoney>0">+</view>
  58. <view class="num" v-show="item.payMoney>0">{{item.payMoney}}</view>
  59. <view class="unit" v-show="item.payMoney>0">元</view>
  60. </view>
  61. </view>
  62. <view class="btn-box">
  63. <view class="btn pay" v-if="item.status==4" @click.stop="pay(item)">去支付</view>
  64. <view class="btn cancel" v-if="item.status==4" @click.stop="cancelPay(item)">取消订单</view>
  65. <!-- <view class="btn cancel">
  66. 联系客服
  67. <button class='contact-btn' open-type="contact">
  68. </button>
  69. </view> -->
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </mescroll-body>
  76. </view>
  77. </template>
  78. <script>
  79. import {getDictByKey} from '@/api/common.js'
  80. import {getIntegralOrderList,cannelOrder} from '@/api/integral.js'
  81. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  82. // import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  83. export default {
  84. mixins: [MescrollMixin],
  85. data() {
  86. return {
  87. orderStatusOptions:[],
  88. searchKey:"",
  89. status:"0",
  90. tabs: [
  91. {name:"全部",id:"0"},
  92. {name:"待支付",id:"4"},
  93. {name:"待发货",id:"1"},
  94. {name:"待收货",id:"2"},
  95. {name:"已完成",id:"3"},
  96. {name:"已取消",id:"5"}
  97. ],
  98. mescroll:null,
  99. // 上拉加载的配置
  100. upOption: {
  101. onScroll:false,
  102. use: true, // 是否启用上拉加载; 默认true
  103. page: {
  104. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  105. size: 10 // 每页数据的数量,默认10
  106. },
  107. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  108. textNoMore:"已经到底了",
  109. empty: {
  110. icon:'https://hdtobs.obs.cn-north-4.myhuaweicloud.com/hdt/empty_icon.png',
  111. tip: '暂无数据'
  112. }
  113. },
  114. // 列表数据
  115. dataList: [],
  116. current: 0
  117. }
  118. },
  119. onLoad(option) {
  120. this.current = option.current || 0
  121. this.status = this.tabs[this.current].id
  122. this.getDictByKey("sys_integral_order_status");
  123. },
  124. onShow() {
  125. if(this.mescroll) {
  126. this.mescroll.resetUpScroll()
  127. }
  128. },
  129. methods: {
  130. getDictByKey(key){
  131. var data={key:key}
  132. getDictByKey(data).then(
  133. res => {
  134. if(res.code==200){
  135. if(key=="sys_integral_order_status"){
  136. this.orderStatusOptions=res.data;
  137. }
  138. }
  139. },
  140. err => {
  141. }
  142. );
  143. },
  144. tabChange(item) {
  145. this.status = item.id
  146. this.mescroll.resetUpScroll()
  147. },
  148. mescrollInit(mescroll) {
  149. this.mescroll = mescroll;
  150. },
  151. /*下拉刷新的回调 */
  152. downCallback(mescroll) {
  153. mescroll.resetUpScroll()
  154. },
  155. upCallback(page) {
  156. //联网加载数据
  157. var that = this;
  158. var data = {
  159. keyword:this.searchKey,
  160. status:this.status,
  161. pageNum: page.num,
  162. pageSize: page.size
  163. };
  164. getIntegralOrderList(data).then(res => {
  165. if(res.code==200){
  166. res.data.list = res.data.list.map(v => ({
  167. ...v,
  168. items: [].concat(JSON.parse(v.itemJson || '[]')).filter(Boolean)
  169. }));
  170. //设置列表数据
  171. if (page.num == 1) {
  172. that.dataList = res.data.list;
  173. } else {
  174. that.dataList = that.dataList.concat(res.data.list);
  175. }
  176. that.mescroll.endBySize(res.data.list.length, res.data.total);
  177. }else{
  178. uni.showToast({
  179. icon:'none',
  180. title: "请求失败",
  181. });
  182. that.dataList = null;
  183. that.mescroll.endErr();
  184. }
  185. });
  186. },
  187. // 查看订单详情
  188. showDetail(item) {
  189. uni.navigateTo({
  190. url: './integralOrderDetails?orderId=' + item.orderId
  191. })
  192. },
  193. pay(item) {
  194. uni.navigateTo({
  195. url: '/pages_user/integralPayment?orderId='+item.orderId
  196. })
  197. },
  198. cancelPay(item) {
  199. cannelOrder({orderId:item.orderId}).then(res=>{
  200. if(res.code ==200) {
  201. uni.showToast({
  202. title: '取消成功',
  203. icon: 'none'
  204. })
  205. this.mescroll.resetUpScroll()
  206. } else {
  207. uni.showToast({
  208. title: res.msg,
  209. icon: 'none'
  210. })
  211. }
  212. })
  213. }
  214. }
  215. }
  216. </script>
  217. <style scoped lang="scss">
  218. ::v-deep .u-tabs__wrapper__nav__item{
  219. padding: 0 26rpx !important;
  220. }
  221. .top-fixed{
  222. width: 100%;
  223. position: fixed;
  224. top: 0;
  225. left: 50%;
  226. transform: translateX(-50%);
  227. z-index: 10;
  228. height: 88upx;
  229. background-color: #fff;
  230. }
  231. .order-list{
  232. padding: 20upx;
  233. .item{
  234. background: #FFFFFF;
  235. border-radius: 16upx;
  236. padding: 0 30upx;
  237. margin-bottom: 20upx;
  238. .ordersn-box{
  239. display: flex;
  240. align-items: center;
  241. justify-content: space-between;
  242. padding: 34upx 0 20upx;
  243. .num{
  244. font-size: 26upx;
  245. font-family: PingFang SC;
  246. font-weight: 500;
  247. color: #999999;
  248. line-height: 1;
  249. }
  250. .status-box{
  251. display: flex;
  252. align-items: center;
  253. .text{
  254. font-size: 28upx;
  255. font-family: PingFang SC;
  256. font-weight: 500;
  257. line-height: 1;
  258. &.success{
  259. color: #DA251C;
  260. }
  261. &.black{
  262. color: #111111;
  263. }
  264. &.info{
  265. color: #999999;
  266. }
  267. }
  268. }
  269. }
  270. .drug-list{
  271. .drug-item{
  272. padding: 30upx 0;
  273. border-bottom: 1px soli #F0F0F0;
  274. display: flex;
  275. align-items: center;
  276. .img-box{
  277. width: 160upx;
  278. height: 160upx;
  279. margin-right: 30upx;
  280. flex-shrink: 0;
  281. image{
  282. width: 100%;
  283. height: 100%;
  284. }
  285. }
  286. .drug-info{
  287. width: calc(100% - 190upx);
  288. height: 160upx;
  289. display: flex;
  290. flex-direction: column;
  291. justify-content: space-between;
  292. .name-box{
  293. font-size: 28upx;
  294. font-family: PingFang SC;
  295. font-weight: 500;
  296. color: #111111;
  297. line-height: 40upx;
  298. .tag{
  299. display: inline-block;
  300. padding: 0 6upx;
  301. height: 30upx;
  302. background: linear-gradient(90deg, #DA251C 0%, #E2C99E 100%);
  303. border-radius: 4upx;
  304. margin-right: 10upx;
  305. font-size: 22upx;
  306. font-family: PingFang SC;
  307. font-weight: bold;
  308. color: #FFFFFF;
  309. line-height: 30upx;
  310. float: left;
  311. margin-top: 7upx;
  312. }
  313. }
  314. .spec{
  315. font-size: 24upx;
  316. font-family: PingFang SC;
  317. font-weight: 500;
  318. color: #999999;
  319. line-height: 1;
  320. margin-top: 10upx;
  321. }
  322. .num-box{
  323. display: flex;
  324. align-items: center;
  325. justify-content: space-between;
  326. .price{
  327. display: flex;
  328. align-items: flex-end;
  329. .unit{
  330. font-size: 24upx;
  331. font-family: PingFang SC;
  332. font-weight: 500;
  333. color: #111111;
  334. line-height: 1.2;
  335. margin-right: 4upx;
  336. }
  337. .num{
  338. font-size: 32upx;
  339. font-family: PingFang SC;
  340. font-weight: 500;
  341. color: #111111;
  342. line-height: 1;
  343. }
  344. }
  345. .amount{
  346. font-size: 24upx;
  347. font-family: PingFang SC;
  348. font-weight: 500;
  349. color: #999999;
  350. line-height: 1;
  351. }
  352. }
  353. }
  354. }
  355. .bottom-box{
  356. height: 110upx;
  357. display: flex;
  358. align-items: center;
  359. justify-content: space-between;
  360. .amount-paid{
  361. display: flex;
  362. align-items: center;
  363. .label{
  364. font-size: 24upx;
  365. font-family: PingFang SC;
  366. font-weight: 500;
  367. color: #999999;
  368. line-height: 1;
  369. }
  370. .price-box{
  371. display: flex;
  372. align-items: flex-end;
  373. .unit{
  374. font-size: 24upx;
  375. font-family: PingFang SC;
  376. font-weight: 500;
  377. color: #FF6633;
  378. line-height: 1.2;
  379. margin-right: 4upx;
  380. }
  381. .num{
  382. font-size: 32upx;
  383. font-family: PingFang SC;
  384. font-weight: bold;
  385. color: #FF6633;
  386. line-height: 1;
  387. }
  388. }
  389. }
  390. .btn-box{
  391. box-sizing: border-box;
  392. display: flex;
  393. align-items: center;
  394. .btn{
  395. position: relative;
  396. width: 155upx;
  397. height: 64upx;
  398. line-height: 64upx;
  399. font-size: 26upx;
  400. font-family: PingFang SC;
  401. font-weight: 500;
  402. text-align: center;
  403. border-radius: 32upx;
  404. margin-left: 15upx;
  405. &:first-child{
  406. margin-left: 0;
  407. }
  408. &.cancel{
  409. border: 1px solid #DDDDDD;
  410. color: #666666;
  411. }
  412. &.pay{
  413. background: #DA251C;
  414. color: #FFFFFF;
  415. }
  416. .contact-btn {
  417. top: 0;
  418. position: absolute;
  419. width:100%;
  420. height:100%;
  421. opacity: 0;
  422. }
  423. }
  424. }
  425. }
  426. }
  427. }
  428. }
  429. </style>