index.vue 17 KB

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