index.vue 17 KB

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