buyOrder.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. <template>
  2. <view class="content">
  3. <view class="top-fixed">
  4. <!-- tab切换 -->
  5. <view class="pub-tab-box">
  6. <view class="tab-inner">
  7. <view
  8. v-for="(item,index) in orderStatus"
  9. :key="index"
  10. :class="item.val == orderStatusValue?'item active':'item'"
  11. @click="orderStatusChange(item)"
  12. >
  13. <view class="text">
  14. {{ item.name }}
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="consu-list">
  21. <mescroll-body top="88upx" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  22. <view v-if="orderStatusValue==0">
  23. <view v-for="(item,index) in dataList" :key="index" class="item" >
  24. <view class="item-top">
  25. <view class="item-title">
  26. <view class="ask-text">{{item.productName}}</view>
  27. <view class="fs28">X {{item.purchaseQuantity}}</view>
  28. </view>
  29. <view class="ask-time">购买次数:{{item.purchaseTimes}}</view>
  30. <view class="ask-time">购买时间:{{utils.timeFormat(item.createTime,'yyyy-mm-dd hh:MM')}}</view>
  31. <view class="ask-time">备注:{{item.remark||''}}</view>
  32. </view>
  33. <view class="bottom-box">
  34. <view class="amount-paid">
  35. <text class="label">订单金额:</text>
  36. <view class="price-box">
  37. <view class="unit">¥</view>
  38. <view class="num">{{item.amount.toFixed(2)}}</view>
  39. </view>
  40. </view>
  41. <view class="btn-box">
  42. <view class="btn cancel" @click="deleteService(item)">删除</view>
  43. <view class="btn pay" @click="showDetail(orderStatusValue,item)">编辑</view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <view v-if="orderStatusValue==1">
  49. <view v-for="(item,index) in dataList" :key="index" class="item" >
  50. <view class="item-top">
  51. <view class="item-title">
  52. <view class="ask-text">{{item.product}}</view>
  53. <!-- <view class="fs28">X {{item.freeServiceTimes}}</view> -->
  54. </view>
  55. <view class="ask-time">服务次数:{{item.freeServiceTimes}}</view>
  56. <view class="ask-time">购买时间:{{utils.timeFormat(item.createTime,'yyyy-mm-dd hh:MM')}}</view>
  57. <view class="ask-time">备注:{{item.remark||''}}</view>
  58. </view>
  59. <view class="bottom-box">
  60. <view class="amount-paid">
  61. <text class="label">订单金额:</text>
  62. <view class="price-box">
  63. <view class="unit">¥</view>
  64. <view class="num">{{item.price.toFixed(2)}}</view>
  65. </view>
  66. </view>
  67. <view class="btn-box">
  68. <view class="btn cancel" @click="deleteCompetitor(item)">删除</view>
  69. <view class="btn pay" @click="showDetail(orderStatusValue,item)">编辑</view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <view class="h160"></view>
  75. </mescroll-body>
  76. </view>
  77. <view class="btn-box2">
  78. <view class="sub-btn" @click="navgetTo(orderStatusValue)">
  79. <image src="/static/images/health/nav_add_icon24.png" class="w48 h48"></image>
  80. <text>新增</text>
  81. </view>
  82. </view>
  83. </view>
  84. </template>
  85. <script>
  86. import {getServiceList,getCompetitorList,deleteCompetitor,deleteService} from '@/api/companyUser.js'
  87. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  88. export default {
  89. mixins: [MescrollMixin],
  90. data() {
  91. return {
  92. orderStatus:[
  93. {name:"购买服务信息",val:0},
  94. {name:"购买竞品信息",val:1},
  95. ],
  96. orderStatusValue:0,
  97. mescroll:null,
  98. // 上拉加载的配置
  99. upOption: {
  100. onScroll:true,
  101. use: true, // 是否启用上拉加载; 默认true
  102. page: {
  103. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  104. size: 10 // 每页数据的数量,默认10
  105. },
  106. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  107. empty: {
  108. icon:'https://user.test.ylrztop.com/images/empty_icon.png',
  109. tip: '暂无数据'
  110. }
  111. },
  112. // 列表数据
  113. dataList: [],
  114. }
  115. },
  116. onLoad(options) {
  117. this.userId=options.userId;
  118. this.companyUserId=options.companyUserId;
  119. uni.$on('refreshBuyOrder', () => {
  120. this.mescroll.resetUpScroll()
  121. })
  122. },
  123. methods: {
  124. navgetTo(index){
  125. uni.navigateTo({
  126. url: index==0?'/pages_company/addServe?type=add&userId='+this.userId+"&companyUserId="+this.companyUserId:'/pages_company/addCompetitors?type=add&userId='+this.userId+"&companyUserId="+this.companyUserId
  127. })
  128. },
  129. // tab切换
  130. orderStatusChange(item) {
  131. this.orderStatusValue = item.val
  132. this.mescroll.resetUpScroll()
  133. },
  134. mescrollInit(mescroll) {
  135. this.mescroll = mescroll;
  136. },
  137. /*下拉刷新的回调 */
  138. downCallback(mescroll) {
  139. mescroll.resetUpScroll()
  140. },
  141. upCallback(page) {
  142. if(this.orderStatusValue==0){
  143. this.getServiceList(page)
  144. }else if(this.orderStatusValue==1){
  145. this.getCompetitorList(page)
  146. }
  147. },
  148. getServiceList(page){
  149. //联网加载数据
  150. var that = this;
  151. var data = {
  152. userId:this.userId,
  153. // status:this.orderStatusValue,
  154. pageNum: page.num,
  155. pageSize: page.size
  156. };
  157. getServiceList(data).then(res => {
  158. if(res.code==200){
  159. //设置列表数据
  160. if (page.num == 1) {
  161. that.dataList = res.data.list;
  162. } else {
  163. that.dataList = that.dataList.concat(res.data.list);
  164. }
  165. that.mescroll.endBySize(res.data.list.length, res.data.total);
  166. }else{
  167. uni.showToast({
  168. icon:'none',
  169. title: "请求失败",
  170. });
  171. that.dataList = null;
  172. that.mescroll.endErr();
  173. }
  174. });
  175. },
  176. getCompetitorList(page){
  177. //联网加载数据
  178. var that = this;
  179. var data = {
  180. // status:this.orderStatusValue,
  181. userId:this.userId,
  182. // companyUserId:this.companyUserId,
  183. pageNum: page.num,
  184. pageSize: page.size
  185. };
  186. getCompetitorList(data).then(res => {
  187. if(res.code==200){
  188. //设置列表数据
  189. if (page.num == 1) {
  190. that.dataList = res.data.list;
  191. } else {
  192. that.dataList = that.dataList.concat(res.data.list);
  193. }
  194. that.mescroll.endBySize(res.data.list.length, res.data.total);
  195. }else{
  196. uni.showToast({
  197. icon:'none',
  198. title: "请求失败",
  199. });
  200. that.dataList = null;
  201. that.mescroll.endErr();
  202. }
  203. });
  204. },
  205. //删除商品
  206. deleteService(item){
  207. var that=this;
  208. uni.showModal({
  209. title: '提示',
  210. content: '确定删除商品订单吗',
  211. success: function (res) {
  212. if (res.confirm) {
  213. var data = {
  214. id:item.id
  215. };
  216. deleteService(data).then(res => {
  217. if(res.code==200){
  218. uni.showToast({
  219. icon:'success',
  220. title: '订单已删除',
  221. });
  222. that.mescroll.resetUpScroll()
  223. }else{
  224. uni.showToast({
  225. icon:'none',
  226. title: res.msg,
  227. });
  228. }
  229. });
  230. }
  231. else if (res.cancel) {
  232. }
  233. }
  234. });
  235. },
  236. //删除竞品
  237. deleteCompetitor(item){
  238. var that=this;
  239. uni.showModal({
  240. title: '提示',
  241. content: '确定删除竞品订单吗',
  242. success: function (res) {
  243. if (res.confirm) {
  244. var data = {
  245. id:item.id
  246. };
  247. deleteCompetitor(data).then(res => {
  248. if(res.code==200){
  249. uni.showToast({
  250. icon:'success',
  251. title: '订单已删除',
  252. });
  253. that.mescroll.resetUpScroll()
  254. }else{
  255. uni.showToast({
  256. icon:'none',
  257. title: res.msg,
  258. });
  259. }
  260. });
  261. }
  262. else if (res.cancel) {
  263. }
  264. }
  265. });
  266. },
  267. showDetail(index,item) {
  268. uni.navigateTo({
  269. url: index==0?'/pages_company/addServe?type=edit&id='+item.id+'&userId='+this.userId+"&companyUserId="+this.companyUserId:'/pages_company/addCompetitors?type=edit&id='+item.id+'&userId='+this.userId+"&companyUserId="+this.companyUserId
  270. })
  271. }
  272. }
  273. }
  274. </script>
  275. <style lang="scss">
  276. .content{
  277. padding: 20upx;
  278. .top-fixed{
  279. width: 100%;
  280. position: fixed;
  281. top: 0;
  282. left: 0;
  283. z-index: 10;
  284. }
  285. .pub-tab-box{
  286. box-sizing: border-box;
  287. width: 100%;
  288. padding: 0 40upx;
  289. background-color: #FFFFFF;
  290. .tab-inner{
  291. height: 88upx;
  292. line-height: 88upx;
  293. display: flex;
  294. align-items: center;
  295. justify-content: center;
  296. overflow-x: auto;
  297. }
  298. .item{
  299. font-size: 28upx;
  300. white-space: nowrap;
  301. line-height: 1;
  302. font-family: PingFang SC;
  303. font-weight: 500;
  304. color: #666666;
  305. margin-right: 60upx;
  306. display: flex;
  307. align-items: center;
  308. justify-content: center;
  309. &:last-child{
  310. margin-right: 0;
  311. }
  312. &.active{
  313. font-weight: bold;
  314. color: #333333;
  315. &::after {
  316. content: "";
  317. width: 48rpx;
  318. height: 8rpx;
  319. background: linear-gradient(120deg, #31A1FE 0%, #008FD3 100%);
  320. position: absolute;
  321. bottom: 0;
  322. border-radius: 6upx 6upx 0upx 0;
  323. }
  324. }
  325. .text{
  326. position: relative;
  327. z-index: 1;
  328. }
  329. .tab-bg{
  330. width: 72upx;
  331. height: 28upx;
  332. position: absolute;
  333. top: 17upx;
  334. left: 50%;
  335. transform: translateX(-36upx);
  336. z-index: -1;
  337. }
  338. }
  339. }
  340. .btn-box2{
  341. z-index: 9999;
  342. width: 100%;
  343. padding: 30upx;
  344. position: fixed;
  345. bottom: 0;
  346. left: 0;
  347. box-sizing: border-box;
  348. // background: #FFFFFF;
  349. .sub-btn{
  350. width: 100%;
  351. height: 88upx;
  352. line-height: 88upx;
  353. text-align: center;
  354. font-size: 30upx;
  355. font-family: PingFang SC;
  356. font-weight: bold;
  357. color: #FFFFFF;
  358. background: #008FD3;
  359. border-radius: 44upx;
  360. display: flex;
  361. align-items: center;
  362. justify-content: center;
  363. image{
  364. margin-right: 16rpx;
  365. }
  366. }
  367. }
  368. .consu-list{
  369. .item{
  370. background: #FFFFFF;
  371. border-radius: 16upx;
  372. padding: 32rpx;
  373. position: relative;
  374. margin-bottom: 20upx;
  375. .item-top{
  376. padding-bottom:40rpx ;
  377. border-bottom: 1px solid #ECECEC;
  378. .item-title{
  379. display: flex;
  380. align-items: center;
  381. justify-content: space-between;
  382. margin-bottom: 12rpx;
  383. }
  384. .ask-text{
  385. font-family: PingFang SC;
  386. font-weight: 500;
  387. font-size: 36rpx;
  388. color: #222426;
  389. text-align: left;
  390. }
  391. .ask-time{
  392. font-size: 24rpx;
  393. color: #898E91;
  394. text-align: left;
  395. line-height: 40rpx;
  396. }
  397. }
  398. .ordersn-box{
  399. display: flex;
  400. align-items: center;
  401. justify-content: space-between;
  402. padding: 0upx 0 20upx;
  403. .num{
  404. font-size: 26upx;
  405. font-family: PingFang SC;
  406. font-weight: 500;
  407. color: #999999;
  408. line-height: 1;
  409. }
  410. .status-box{
  411. display: flex;
  412. align-items: center;
  413. .recom-box{
  414. width: 108upx;
  415. height: 30upx;
  416. line-height: 30upx;
  417. text-align: left;
  418. padding-left: 8upx;
  419. font-size: 22upx;
  420. font-family: PingFang SC;
  421. font-weight: 500;
  422. color: #FFFFFF;
  423. // background-image: url(../../static/images/recom.png);
  424. background-repeat: no-repeat;
  425. background-size: 100% 100%;
  426. margin-right: 8upx;
  427. }
  428. .text{
  429. font-size: 28upx;
  430. font-family: PingFang SC;
  431. font-weight: 500;
  432. line-height: 1;
  433. &.success{
  434. color: #0bb3f2;
  435. }
  436. &.black{
  437. color: #111111;
  438. }
  439. &.info{
  440. color: #999999;
  441. }
  442. }
  443. }
  444. }
  445. .doctor-info{
  446. display: flex;
  447. align-items: center;
  448. .img-box{
  449. width: 80upx;
  450. height: 80upx;
  451. background: #E0FFF8;
  452. border-radius: 50%;
  453. overflow: hidden;
  454. margin-right: 20upx;
  455. image{
  456. width: 100%;
  457. height: 100%;
  458. }
  459. }
  460. .name{
  461. font-size: 28upx;
  462. font-family: PingFang SC;
  463. font-weight: 500;
  464. color: #666666;
  465. line-height: 48upx;
  466. text{
  467. margin-right: 10upx;
  468. }
  469. }
  470. }
  471. .patient-text{
  472. font-size: 24upx;
  473. font-family: PingFang SC;
  474. font-weight: 500;
  475. color: #999999;
  476. margin-bottom: 24upx;
  477. }
  478. .bottom-box{
  479. height: 80upx;
  480. display: flex;
  481. align-items: center;
  482. justify-content: space-between;
  483. margin-top: 20rpx;
  484. .amount-paid{
  485. display: flex;
  486. align-items: center;
  487. .label{
  488. font-size: 24upx;
  489. font-family: PingFang SC;
  490. font-weight: 500;
  491. color: #999999;
  492. line-height: 1;
  493. }
  494. .price-box{
  495. display: flex;
  496. align-items: flex-end;
  497. .unit{
  498. font-size: 24upx;
  499. font-family: PingFang SC;
  500. font-weight: 600;
  501. color: #FF5030;
  502. line-height: 1.2;
  503. margin-right: 4upx;
  504. }
  505. .num{
  506. font-size: 36upx;
  507. font-family: PingFang SC;
  508. font-weight: bold;
  509. color: #FF5030;
  510. line-height: 1;
  511. }
  512. }
  513. }
  514. .btn-box{
  515. box-sizing: border-box;
  516. display: flex;
  517. align-items: center;
  518. .btn{
  519. width: 128rpx;
  520. height: 60rpx;
  521. line-height: 60upx;
  522. font-size: 24upx;
  523. font-family: PingFang SC;
  524. text-align: center;
  525. border-radius: 32upx;
  526. margin-left: 15upx;
  527. &:first-child{
  528. margin-left: 0;
  529. }
  530. &.cancel{
  531. border: 1px solid #B2B2B2;
  532. color: #666666;
  533. }
  534. &.pay{
  535. border: 1px solid #008FD3;
  536. color: #008FD3;
  537. }
  538. }
  539. }
  540. }
  541. }
  542. }
  543. }
  544. </style>