integralOrderList.vue 10 KB

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