integralOrderList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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="#FF5C03"
  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() {
  114. this.getDictByKey("sys_integral_order_status");
  115. },
  116. methods: {
  117. getDictByKey(key){
  118. var data={key:key}
  119. getDictByKey(data).then(
  120. res => {
  121. if(res.code==200){
  122. if(key=="sys_integral_order_status"){
  123. this.orderStatusOptions=res.data;
  124. }
  125. }
  126. },
  127. err => {
  128. }
  129. );
  130. },
  131. tabChange(item) {
  132. this.status = item.id
  133. this.mescroll.resetUpScroll()
  134. },
  135. mescrollInit(mescroll) {
  136. this.mescroll = mescroll;
  137. },
  138. /*下拉刷新的回调 */
  139. downCallback(mescroll) {
  140. mescroll.resetUpScroll()
  141. },
  142. upCallback(page) {
  143. //联网加载数据
  144. var that = this;
  145. var data = {
  146. keyword:this.searchKey,
  147. status:this.status,
  148. pageNum: page.num,
  149. pageSize: page.size
  150. };
  151. getIntegralOrderList(data).then(res => {
  152. if(res.code==200){
  153. res.data.list.forEach(function(value, index, array){
  154. value.items=[];
  155. var parsedData=value.itemJson?JSON.parse(value.itemJson):{}
  156. if (Array.isArray(parsedData)) {
  157. value.items = parsedData;
  158. } else {
  159. value.items.push(parsedData);
  160. }
  161. // 解析quantityCart字符串为数组,用于匹配每个商品的数量
  162. if (value.quantityCart && typeof value.quantityCart === 'string') {
  163. value.quantityCartArray = value.quantityCart.split(',').map(q => q.trim());
  164. } else if (Array.isArray(value.quantityCart)) {
  165. value.quantityCartArray = value.quantityCart;
  166. } else {
  167. value.quantityCartArray = [];
  168. }
  169. console.log(value.items)
  170. })
  171. //设置列表数据
  172. if (page.num == 1) {
  173. that.dataList = res.data.list;
  174. } else {
  175. that.dataList = that.dataList.concat(res.data.list);
  176. }
  177. that.mescroll.endBySize(res.data.list.length, res.data.total);
  178. }else{
  179. uni.showToast({
  180. icon:'none',
  181. title: "请求失败",
  182. });
  183. that.dataList = null;
  184. that.mescroll.endErr();
  185. }
  186. });
  187. },
  188. // 获取商品数量
  189. getItemQuantity(item, subItem, subIndex) {
  190. // 优先使用商品项自己的quantity字段
  191. if (subItem && subItem.quantity !== undefined && subItem.quantity !== null) {
  192. return subItem.quantity;
  193. }
  194. // 如果quantityCart是数组,使用对应索引的数量
  195. if (item.quantityCartArray && Array.isArray(item.quantityCartArray) && item.quantityCartArray[subIndex] !== undefined) {
  196. return item.quantityCartArray[subIndex];
  197. }
  198. // 如果quantityCart是字符串,解析后使用对应索引的数量
  199. if (item.quantityCart && typeof item.quantityCart === 'string') {
  200. const quantities = item.quantityCart.split(',').map(q => q.trim());
  201. if (quantities[subIndex] !== undefined) {
  202. return quantities[subIndex];
  203. }
  204. }
  205. // 如果只有一个商品,直接使用quantityCart
  206. if (item.items && item.items.length === 1 && item.quantityCart) {
  207. if (typeof item.quantityCart === 'string') {
  208. return item.quantityCart.split(',')[0].trim();
  209. }
  210. return item.quantityCart;
  211. }
  212. // 默认返回1
  213. return 1;
  214. },
  215. // 查看订单详情
  216. showDetail(item) {
  217. uni.navigateTo({
  218. url: './integralOrderDetails?orderId=' + item.orderId
  219. })
  220. },
  221. }
  222. }
  223. </script>
  224. <style scoped lang="scss">
  225. .top-fixed{
  226. width: 100%;
  227. position: absolute;
  228. top: 0;
  229. left: 0;
  230. z-index: 10;
  231. height: 88upx;
  232. background-color: #fff;
  233. }
  234. .order-list{
  235. padding: 20upx;
  236. .item{
  237. background: #FFFFFF;
  238. border-radius: 16upx;
  239. padding: 0 30upx;
  240. margin-bottom: 20upx;
  241. .ordersn-box{
  242. display: flex;
  243. align-items: center;
  244. justify-content: space-between;
  245. padding: 34upx 0 20upx;
  246. .num{
  247. font-size: 26upx;
  248. font-family: PingFang SC;
  249. font-weight: 500;
  250. color: #999999;
  251. line-height: 1;
  252. }
  253. .status-box{
  254. display: flex;
  255. align-items: center;
  256. .text{
  257. font-size: 28upx;
  258. font-family: PingFang SC;
  259. font-weight: 500;
  260. line-height: 1;
  261. &.success{
  262. color: #FF5C03;
  263. }
  264. &.black{
  265. color: #111111;
  266. }
  267. &.info{
  268. color: #999999;
  269. }
  270. }
  271. }
  272. }
  273. .drug-list{
  274. .drug-item{
  275. padding: 30upx 0;
  276. border-bottom: 1px soli #F0F0F0;
  277. display: flex;
  278. align-items: center;
  279. .img-box{
  280. width: 160upx;
  281. height: 160upx;
  282. margin-right: 30upx;
  283. flex-shrink: 0;
  284. image{
  285. width: 100%;
  286. height: 100%;
  287. }
  288. }
  289. .drug-info{
  290. width: calc(100% - 190upx);
  291. height: 160upx;
  292. display: flex;
  293. flex-direction: column;
  294. justify-content: space-between;
  295. .name-box{
  296. font-size: 28upx;
  297. font-family: PingFang SC;
  298. font-weight: 500;
  299. color: #111111;
  300. line-height: 40upx;
  301. .tag{
  302. display: inline-block;
  303. padding: 0 6upx;
  304. height: 30upx;
  305. background: linear-gradient(90deg, #C39A58 0%, #E2C99E 100%);
  306. border-radius: 4upx;
  307. margin-right: 10upx;
  308. font-size: 22upx;
  309. font-family: PingFang SC;
  310. font-weight: bold;
  311. color: #FFFFFF;
  312. line-height: 30upx;
  313. float: left;
  314. margin-top: 7upx;
  315. }
  316. }
  317. .spec{
  318. font-size: 24upx;
  319. font-family: PingFang SC;
  320. font-weight: 500;
  321. color: #999999;
  322. line-height: 1;
  323. margin-top: 10upx;
  324. }
  325. .num-box{
  326. display: flex;
  327. align-items: center;
  328. justify-content: space-between;
  329. .price{
  330. display: flex;
  331. align-items: flex-end;
  332. .unit{
  333. font-size: 24upx;
  334. font-family: PingFang SC;
  335. font-weight: 500;
  336. color: #111111;
  337. line-height: 1.2;
  338. margin-right: 4upx;
  339. }
  340. .num{
  341. font-size: 32upx;
  342. font-family: PingFang SC;
  343. font-weight: 500;
  344. color: #111111;
  345. line-height: 1;
  346. }
  347. }
  348. .amount{
  349. font-size: 24upx;
  350. font-family: PingFang SC;
  351. font-weight: 500;
  352. color: #999999;
  353. line-height: 1;
  354. }
  355. }
  356. }
  357. }
  358. .bottom-box{
  359. height: 110upx;
  360. display: flex;
  361. align-items: center;
  362. justify-content: space-between;
  363. .amount-paid{
  364. display: flex;
  365. align-items: center;
  366. .label{
  367. font-size: 24upx;
  368. font-family: PingFang SC;
  369. font-weight: 500;
  370. color: #999999;
  371. line-height: 1;
  372. }
  373. .price-box{
  374. display: flex;
  375. align-items: flex-end;
  376. .unit{
  377. font-size: 24upx;
  378. font-family: PingFang SC;
  379. font-weight: 500;
  380. color: #FF6633;
  381. line-height: 1.2;
  382. margin-right: 4upx;
  383. }
  384. .num{
  385. font-size: 32upx;
  386. font-family: PingFang SC;
  387. font-weight: bold;
  388. color: #FF6633;
  389. line-height: 1;
  390. }
  391. }
  392. }
  393. .btn-box{
  394. box-sizing: border-box;
  395. display: flex;
  396. align-items: center;
  397. .btn{
  398. position: relative;
  399. width: 155upx;
  400. height: 64upx;
  401. line-height: 64upx;
  402. font-size: 26upx;
  403. font-family: PingFang SC;
  404. font-weight: 500;
  405. text-align: center;
  406. border-radius: 32upx;
  407. margin-left: 15upx;
  408. &:first-child{
  409. margin-left: 0;
  410. }
  411. &.cancel{
  412. border: 1px solid #DDDDDD;
  413. color: #666666;
  414. }
  415. &.pay{
  416. background: #FF5C03;
  417. color: #FFFFFF;
  418. }
  419. .contact-btn {
  420. top: 0;
  421. position: absolute;
  422. width:100%;
  423. height:100%;
  424. opacity: 0;
  425. }
  426. }
  427. }
  428. }
  429. }
  430. }
  431. }
  432. </style>