integralOrderList.vue 11 KB

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