index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <input type="text" v-model="searchInfo.name" @input="toInput" placeholder="搜索商品">
  6. </view>
  7. <view class="two">
  8. <tabs :tabs="tabs" @tabsChange="tabsChange">
  9. <view class="tabsList">
  10. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
  11. <view class="list-scroll-view">
  12. <view class="list_1" v-if="tabs.active=='-0'">
  13. 全部订单
  14. </view>
  15. <view class="list_2" v-for="(item,index) in list" :key="index"
  16. v-else-if="tabs.active=='0'" @tap="toInfo(item)">
  17. <view class="status">
  18. {{item.status=='0'?'待付款':item.status=='1'?'已支付':item.status=='-1'?'取消订单':item.status=='2'?'发货中':item.status=='-2'?'已退款':item.status=='3'?'已收货':item.status=='-3'?'申请售后':item.status=='-4'?'正在售后中':item.status=='-5'?'售后已结束':'未识别'}}
  19. </view>
  20. <view class="goods" v-for="(tag,indexs) in item.goods" :key="indexs">
  21. <view class="goods_1">
  22. <view class="shopname">
  23. <text class="iconfont icon-shangdian"></text>
  24. <text>{{tag.shop_name}}</text>
  25. </view>
  26. </view>
  27. <view class="goods_2">
  28. <view class="market" v-for="(tags,indexss) in tag.goods" :key="indexss">
  29. <view class="url">
  30. <image class="image"
  31. :src="tags.goods.file&&tags.goods.file.length>0?tags.goods.file[0].url:''"
  32. mode=""></image>
  33. </view>
  34. <view class="goodsname">
  35. {{tags.name}}
  36. </view>
  37. <view class="goodsother">
  38. <view class="price">
  39. ¥{{tags.sell_money}}
  40. </view>
  41. <view class="num">
  42. ×{{tags.buy_num}}
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="other">
  49. <text>共{{item.total_detail.freight_total}}件商品</text>
  50. <text>总价¥{{item.total_detail.goods_total}}</text>
  51. </view>
  52. <view class="btn">
  53. <button class="toCancel" v-if="item.status=='0'" type="default" size="mini"
  54. @tap.stop="toCancel(item)">取消订单</button>
  55. <button class="toPay" v-if="item.status=='0'" type="default" size="mini"
  56. @tap.stop="toPay(item)">付款</button>
  57. <button class="toConfirm" v-if="item.status=='2'" type="default" size="mini"
  58. @tap.stop="toConfirm(item)">确认收货</button>
  59. <button class="toAfter" v-if="item.status!='0'" type="default" size="mini"
  60. @tap.stop="toAfter(item)">申请售后</button>
  61. <button class="toAfter" v-if="item.status=='3'" type="default" size="mini"
  62. @tap.stop="toAfter(item)">申请退款</button>
  63. </view>
  64. </view>
  65. <view class="list_2 list_3" v-for="(item,index) in list" :key="index"
  66. @tap="toInfo(item)" v-else>
  67. <view class="list_3_1">
  68. <view class="goods_1">
  69. <view class="shopname">
  70. <text class="iconfont icon-shangdian"></text>
  71. <text>{{item.shop.name}}</text>
  72. </view>
  73. </view>
  74. <view class="status">
  75. {{item.status=='0'?'待付款':item.status=='1'?'已支付':item.status=='-1'?'取消订单':item.status=='2'?'发货中':item.status=='-2'?'已退款':item.status=='3'?'已收货':item.status=='-3'?'申请售后':item.status=='-4'?'正在售后中':item.status=='-5'?'售后已结束':'未识别'}}
  76. </view>
  77. </view>
  78. <view class="goods" v-for="(tag,indexs) in item.goods" :key="indexs">
  79. <view class="goods_2">
  80. <view class="market">
  81. <view class="url">
  82. <image class="image"
  83. :src="tag.goods.file&&tag.goods.file.length>0?tag.goods.file[0].url:''"
  84. mode=""></image>
  85. </view>
  86. <view class="goodsname">
  87. {{tag.name}}
  88. </view>
  89. <view class="goodsother">
  90. <view class="price">
  91. ¥{{tag.sell_money}}
  92. </view>
  93. <view class="num">
  94. ×{{tag.buy_num}}
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. <view class="other">
  101. <text>共{{item.buy_num_total||0}}件商品</text>
  102. <text>总价¥{{item.total_detail.goods_total}}</text>
  103. </view>
  104. <view class="btn">
  105. <button class="toCancel" v-if="item.status=='2'||item.status=='3'"
  106. type="default" size="mini" @tap.stop="toLogi(item)">查看物流</button>
  107. <button class="toCancel" v-if="item.status=='0'" type="default" size="mini"
  108. @tap.stop="toCancel(item)">取消订单</button>
  109. <button class="toPay" v-if="item.status=='0'" type="default" size="mini"
  110. @tap.stop="toPay(item)">付款</button>
  111. <button class="toConfirm" v-if="item.status=='2'" type="default" size="mini"
  112. @tap.stop="toConfirm(item)">确认收货</button>
  113. <button class="toAfter" v-if="item.status!='0'" type="default" size="mini"
  114. @tap.stop="toAfter(item)">申请售后</button>
  115. <button class="toAfter" v-if="item.status=='3'" type="default" size="mini"
  116. @tap.stop="toAfter(item)">申请退款</button>
  117. </view>
  118. </view>
  119. </view>
  120. </scroll-view>
  121. </view>
  122. </tabs>
  123. </view>
  124. </view>
  125. </mobile-frame>
  126. </template>
  127. <script>
  128. import tabs from '@/components/tabs/index.vue';
  129. export default {
  130. components: {
  131. tabs
  132. },
  133. data() {
  134. return {
  135. user: {},
  136. status: '',
  137. searchInfo: {},
  138. tabs: {
  139. active: '0',
  140. menu: [ //菜单列表
  141. // {
  142. // title: '全部订单',
  143. // active: '-0'
  144. // },
  145. {
  146. title: '待付款',
  147. active: '0'
  148. },
  149. {
  150. title: '待发货',
  151. active: '1'
  152. },
  153. {
  154. title: '待收货',
  155. active: '2'
  156. },
  157. {
  158. title: '已收货',
  159. active: '3'
  160. }
  161. ]
  162. },
  163. list: [],
  164. total: 0,
  165. skip: 0,
  166. limit: 5,
  167. page: 0
  168. };
  169. },
  170. onLoad: function(e) {
  171. const that = this;
  172. that.$set(that, `status`, e.status);
  173. // 监听用户是否登录
  174. that.watchLogin();
  175. },
  176. onShow: function() {},
  177. methods: {
  178. // 监听用户是否登录
  179. watchLogin() {
  180. const that = this;
  181. uni.getStorage({
  182. key: 'token',
  183. success: function(res) {
  184. let user = that.$jwt(res.data);
  185. if (user) that.$set(that, `user`, user);
  186. that.$set(that.tabs, `active`, that.status);
  187. that.search();
  188. },
  189. fail: function(err) {
  190. uni.navigateTo({
  191. url: `/pages/login/index`
  192. })
  193. }
  194. });
  195. },
  196. // 查询列表
  197. async search() {
  198. const that = this;
  199. let user = that.user;
  200. let status = that.status;
  201. if (status == '-0') {
  202. } else if (status == '0') {
  203. const res = await that.$api(`/order`, 'GET', {
  204. status: '0',
  205. customer: user._id
  206. });
  207. if (res.errcode == '0') {
  208. let list = [...that.list, ...res.data];
  209. that.$set(that, `list`, list)
  210. that.$set(that, `total`, res.total)
  211. } else {
  212. uni.showToast({
  213. title: res.errmsg,
  214. });
  215. }
  216. } else {
  217. const res = await that.$api(`/orderDetail`, 'GET', {
  218. status: that.status,
  219. customer: user._id
  220. });
  221. if (res.errcode == '0') {
  222. let list = [...that.list, ...res.data];
  223. that.$set(that, `list`, list)
  224. that.$set(that, `total`, res.total)
  225. } else {
  226. uni.showToast({
  227. title: res.errmsg,
  228. });
  229. }
  230. }
  231. },
  232. // 分页
  233. toPage(e) {
  234. const that = this;
  235. let list = that.list;
  236. let limit = that.limit;
  237. if (that.total > list.length) {
  238. uni.showLoading({
  239. title: '加载中',
  240. mask: true
  241. })
  242. let page = that.page + 1;
  243. that.$set(that, `page`, page)
  244. let skip = page * limit;
  245. that.$set(that, `skip`, skip)
  246. that.search();
  247. uni.hideLoading();
  248. } else uni.showToast({
  249. title: '没有更多数据了'
  250. });
  251. },
  252. // 输入框
  253. toInput(e) {
  254. const that = this;
  255. that.$set(that.searchInfo, `name`, e.detail.value)
  256. },
  257. // 订单详细
  258. toInfo(item) {
  259. uni.navigateTo({
  260. url: `/pagesMy/order/info?id=${item._id}&status=${item.status}`
  261. })
  262. },
  263. // 取消订单
  264. toCancel(e) {
  265. const that = this;
  266. uni.showModal({
  267. title: '提示',
  268. content: '确定取消订单吗?',
  269. success: async function(res) {
  270. if (res.confirm) {
  271. const arr = await that.$api(`/order/cancel`, 'POST', {
  272. order_id: e._id
  273. });
  274. if (arr.errcode == '0') {
  275. uni.showToast({
  276. title: '取消订单成功',
  277. icon: 'none'
  278. })
  279. that.clearPage();
  280. that.search();
  281. } else {
  282. uni.showToast({
  283. title: arr.errmsg,
  284. icon: 'none'
  285. })
  286. }
  287. }
  288. }
  289. });
  290. },
  291. // 付款
  292. toPay(e) {
  293. const that = this;
  294. uni.getStorage({
  295. key: 'system',
  296. success: async function(res) {
  297. // 微信小程序支付
  298. if (res.data.uniPlatform == "mp-weixin") {
  299. const res = await that.$api('/pay/toPayOrder', 'POST', {
  300. order_id: e,
  301. type: '0'
  302. })
  303. console.log(res);
  304. uni.requestPayment({
  305. "provider": "wxpay",
  306. ...res.data,
  307. success(res) {
  308. uni.showToast({
  309. title: '支付成功',
  310. icon: 'none'
  311. })
  312. that.clearPage();
  313. that.search();
  314. },
  315. fail(e) {
  316. console.log('in fail');
  317. console.log(e)
  318. }
  319. })
  320. } else if (res.data.uniPlatform == "app") {
  321. // app支付
  322. uni.requestPayment({
  323. provider: 'alipay',
  324. orderInfo: 'orderInfo', //微信、支付宝订单数据 【注意微信的订单信息,键值应该全部是小写,不能采用驼峰命名】
  325. success: function(res) {
  326. console.log('success:' + JSON.stringify(res));
  327. },
  328. fail: function(err) {
  329. console.log('fail:' + JSON.stringify(err));
  330. }
  331. });
  332. } else {
  333. uni.showToast({
  334. title: `平台不支持支付`,
  335. icon: 'none'
  336. })
  337. }
  338. },
  339. fail: function(err) {}
  340. })
  341. },
  342. // 确认收货
  343. toConfirm(e) {
  344. const that = this;
  345. uni.showModal({
  346. title: '提示',
  347. content: '确定确认收货吗?',
  348. success: async function(res) {
  349. if (res.confirm) {
  350. const arr = await that.$api(`/orderDetail/${e._id}`, 'POST', {
  351. status: '3'
  352. });
  353. if (arr.errcode == '0') {
  354. uni.showToast({
  355. title: '确认收货成功',
  356. icon: 'none'
  357. })
  358. that.clearPage();
  359. that.search();
  360. } else {
  361. uni.showToast({
  362. title: arr.errmsg,
  363. icon: 'none'
  364. })
  365. }
  366. }
  367. }
  368. });
  369. },
  370. // 申请售后 申请退款
  371. toAfter(e) {
  372. if (e.status == '3') {
  373. uni.navigateTo({
  374. url: `/pagesMy/order/service?id=${e._id}`
  375. })
  376. } else {
  377. uni.navigateTo({
  378. url: `/pagesMy/order/noService?id=${e._id}`
  379. })
  380. }
  381. },
  382. // 查看物流
  383. toLogi(e) {
  384. uni.navigateTo({
  385. url: `/pagesMy/logistics/index?id=${e._id}`
  386. })
  387. },
  388. // 选择选项卡
  389. tabsChange(e) {
  390. const that = this;
  391. that.$set(that.tabs, `active`, e.active)
  392. that.$set(that, `status`, e.active);
  393. that.clearPage();
  394. that.search()
  395. },
  396. // 清空列表
  397. clearPage() {
  398. const that = this;
  399. that.$set(that, `list`, [])
  400. that.$set(that, `skip`, 0)
  401. that.$set(that, `limit`, 5)
  402. that.$set(that, `page`, 0)
  403. }
  404. }
  405. }
  406. </script>
  407. <style lang="scss">
  408. .main {
  409. display: flex;
  410. flex-direction: column;
  411. width: 100vw;
  412. height: 100vh;
  413. .one {
  414. padding: 2vw;
  415. input {
  416. padding: 2vw;
  417. background-color: var(--f1Color);
  418. font-size: var(--font14Size);
  419. border-radius: 5px;
  420. }
  421. }
  422. .two {
  423. position: relative;
  424. flex-grow: 1;
  425. background-color: var(--f9Color);
  426. .tabsList {
  427. position: relative;
  428. width: 100vw;
  429. height: 82vh;
  430. .list_2 {
  431. background-color: #fff;
  432. margin: 0 2vw 2vw 2vw;
  433. padding: 2vw;
  434. .status {
  435. color: var(--ff0Color);
  436. text-align: right;
  437. margin: 0 0 1vw 0;
  438. }
  439. .goods {
  440. margin: 0 0 1vw 0;
  441. padding: 2vw;
  442. border-bottom: 1px solid #f5f5f5;
  443. .goods_1 {
  444. margin: 0 0 2vw 0;
  445. .shopname {
  446. text:last-child {
  447. padding: 0 0 0 2vw;
  448. }
  449. }
  450. }
  451. .goods_2 {
  452. margin: 0 0 1vw 0;
  453. .market {
  454. display: flex;
  455. .url {
  456. width: 20vw;
  457. .image {
  458. width: 100%;
  459. height: 20vw;
  460. border-radius: 5px;
  461. }
  462. }
  463. .goodsname {
  464. width: 60vw;
  465. padding: 0 2vw;
  466. }
  467. .goodsother {
  468. width: 15vw;
  469. text-align: right;
  470. }
  471. }
  472. }
  473. }
  474. .other {
  475. margin: 0 0 2vw 0;
  476. text-align: right;
  477. text {
  478. font-size: 14px;
  479. padding: 0 0 0 2vw;
  480. }
  481. }
  482. .btn {
  483. text-align: right;
  484. margin: 2vw 0 0 0;
  485. border-top: 1px solid #f1fff1;
  486. button {
  487. margin: 2vw 0 0 2vw;
  488. }
  489. .toPay {
  490. border: 1px solid #ff0000;
  491. color: #ff0000;
  492. }
  493. }
  494. }
  495. .list_3 {
  496. .list_3_1 {
  497. display: flex;
  498. justify-content: space-between;
  499. }
  500. }
  501. // .list {
  502. // background-color: #fff;
  503. // margin: 0 2vw 2vw 2vw;
  504. // padding: 2vw;
  505. // .list_1 {
  506. // margin: 0 0 1vw 0;
  507. // display: flex;
  508. // flex-direction: row;
  509. // justify-content: space-between;
  510. // }
  511. // .list_2 {
  512. // margin: 0 0 1vw 0;
  513. // display: flex;
  514. // .l {
  515. // width: 20vw;
  516. // .image {
  517. // width: 100%;
  518. // height: 20vw;
  519. // border-radius: 5px;
  520. // }
  521. // }
  522. // .c {
  523. // width: 60vw;
  524. // padding: 0 2vw;
  525. // }
  526. // .r {
  527. // width: 15vw;
  528. // text-align: right;
  529. // }
  530. // }
  531. // .other {
  532. // margin: 0 0 2vw 0;
  533. // text-align: right;
  534. // text {
  535. // font-size: 14px;
  536. // padding: 0 0 0 2vw;
  537. // }
  538. // }
  539. // .btn {
  540. // text-align: right;
  541. // margin: 2vw 0 0 0;
  542. // border-top: 1px solid #f1fff1;
  543. // button {
  544. // margin: 2vw 0 0 2vw;
  545. // }
  546. // }
  547. // }
  548. }
  549. }
  550. }
  551. // .two {
  552. // position: relative;
  553. // flex-grow: 1;
  554. // background-color: var(--f9Color);
  555. // .two_1 {
  556. // background-color: var(--fffColor);
  557. // padding: 2vw;
  558. // display: flex;
  559. // flex-direction: row;
  560. // }
  561. // .two_2 {
  562. // display: flex;
  563. // flex-direction: column;
  564. // .list {
  565. // width: 100vw;
  566. // margin: 2vw 0 0 0;
  567. // background-color: var(--mainColor);
  568. // .list_1 {
  569. // display: flex;
  570. // flex-direction: row;
  571. // justify-content: space-between;
  572. // padding: 2vw;
  573. // .name {
  574. // font-size: var(--font14Size);
  575. // text {
  576. // margin: 0 1vw 0 0;
  577. // }
  578. // }
  579. // .status {
  580. // font-size: var(--font14Size);
  581. // color: var(--ff0Color);
  582. // }
  583. // }
  584. // .list_2 {
  585. // display: flex;
  586. // flex-direction: row;
  587. // justify-content: space-between;
  588. // padding: 2vw;
  589. // background-color: var(--f8Color);
  590. // .image {
  591. // width: 20vw;
  592. // height: 20vw;
  593. // margin: 0 2vw 0 0;
  594. // }
  595. // .other {
  596. // display: flex;
  597. // flex-direction: column;
  598. // flex-grow: 1;
  599. // .name {
  600. // font-size: var(--font14Size);
  601. // font-weight: bold;
  602. // margin: 0 0 2vw 0;
  603. // }
  604. // .other_1 {
  605. // font-size: var(--font12Size);
  606. // color: var(--f85Color);
  607. // }
  608. // }
  609. // .money {
  610. // font-size: var(--font12Size);
  611. // .num {
  612. // text-align: right;
  613. // }
  614. // }
  615. // }
  616. // .list_3 {
  617. // display: flex;
  618. // justify-content: flex-end;
  619. // padding: 2vw;
  620. // border-bottom: 0.5vw solid var(--f9Color);
  621. // font-size: var(--font12Size);
  622. // text {
  623. // margin: 0 1vw;
  624. // }
  625. // }
  626. // .list_4 {
  627. // padding: 2vw;
  628. // text-align: right;
  629. // button {
  630. // margin: 0 1vw 0 2vw;
  631. // }
  632. // }
  633. // }
  634. // }
  635. // }
  636. // }
  637. .scroll-view {
  638. position: absolute;
  639. top: 0;
  640. left: 0;
  641. right: 0;
  642. bottom: 0;
  643. .list-scroll-view {
  644. display: flex;
  645. flex-direction: column;
  646. }
  647. }
  648. </style>