index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  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" v-else-if="tabs.active=='0'" @tap="toInfo(item)">
  16. <view class="status">
  17. {{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'?'售后已结束':'未识别'}}
  18. </view>
  19. <view class="goods" v-for="(tag,indexs) in item.goods" :key="indexs">
  20. <view class="goods_1">
  21. <view class="shopname">
  22. <text class="iconfont icon-shangdian"></text>
  23. <text>{{tag.shop_name}}</text>
  24. </view>
  25. </view>
  26. <view class="goods_2">
  27. <view class="market" v-for="(tags,indexss) in tag.goods" :key="indexss">
  28. <view class="url">
  29. <image class="image" :src="tags.goods.file&&tags.goods.file.length>0?tags.goods.file[0].url:''" mode=""></image>
  30. </view>
  31. <view class="goodsname">
  32. {{tags.goods.name}}
  33. <view class="specs">
  34. {{tags.name}}
  35. </view>
  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" @tap.stop="toCancel(item)">取消订单</button>
  57. <button class="toPay" v-if="item.status=='0'" type="default" size="mini" @tap.stop="toPay(item)">付款</button>
  58. <button class="toConfirm" v-if="item.status=='2'" type="default" size="mini" @tap.stop="toConfirm(item)">确认收货</button>
  59. <button class="toAfter" v-if="item.status!='0'" type="default" size="mini" @tap.stop="toAfter(item)">申请售后</button>
  60. <button class="toAfter" v-if="item.status=='3'" type="default" size="mini" @tap.stop="toAfter(item)">申请退款</button>
  61. </view>
  62. </view>
  63. <view class="list_2 list_3" v-for="(item,index) in list" :key="index" @tap="toInfo(item)" v-else>
  64. <view class="list_3_1">
  65. <view class="goods_1">
  66. <view class="shopname">
  67. <text class="iconfont icon-shangdian"></text>
  68. <text>{{item.shop.name}}</text>
  69. </view>
  70. </view>
  71. <view class="status">
  72. {{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'?'售后已结束':'未识别'}}
  73. </view>
  74. </view>
  75. <view class="goods" v-for="(tag,indexs) in item.goods" :key="indexs">
  76. <view class="goods_2">
  77. <view class="market">
  78. <view class="url">
  79. <image class="image" :src="tag.goods.file&&tag.goods.file.length>0?tag.goods.file[0].url:''" mode=""></image>
  80. </view>
  81. <view class="goodsname">
  82. {{tag.goods.name}}
  83. <view class="specs">
  84. {{tag.name}}
  85. </view>
  86. </view>
  87. <view class="goodsother">
  88. <view v-if="item.type=='0'" class="price">
  89. ¥{{tag.sell_money}}
  90. </view>
  91. <view v-else class="price">
  92. ¥{{tag.group_config.money}}
  93. </view>
  94. <view class="num">
  95. ×{{tag.buy_num}}
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. <view class="other">
  102. <text>共{{item.buy_num_total||0}}件商品</text>
  103. <text>总价¥{{item.total_detail.goods_total}}</text>
  104. </view>
  105. <view class="btn">
  106. <button class="toCancel" v-if="item.status=='2'||item.status=='3'" type="default" size="mini" @tap.stop="toLogi(item)">查看物流</button>
  107. <button class="toCancel" v-if="item.status=='0'" type="default" size="mini" @tap.stop="toCancel(item)">取消订单</button>
  108. <button class="toPay" v-if="item.status=='0'" type="default" size="mini" @tap.stop="toPay(item)">付款</button>
  109. <button class="toConfirm" v-if="item.status=='2'" type="default" size="mini" @tap.stop="toConfirm(item)">确认收货</button>
  110. <button class="toAfter" v-if="item.status!='0'" type="default" size="mini" @tap.stop="toAfter(item)">申请售后</button>
  111. <button class="toAfter" v-if="item.status=='3'" type="default" size="mini" @tap.stop="toAfter(item)">申请退款</button>
  112. </view>
  113. </view>
  114. </view>
  115. </scroll-view>
  116. </view>
  117. </tabs>
  118. </view>
  119. </view>
  120. </mobile-frame>
  121. </template>
  122. <script>
  123. import tabs from '@/components/tabs/index.vue';
  124. export default {
  125. components: {
  126. tabs
  127. },
  128. data() {
  129. return {
  130. user: {},
  131. status: '',
  132. searchInfo: {},
  133. tabs: {
  134. active: '0',
  135. menu: [ //菜单列表
  136. // {
  137. // title: '全部订单',
  138. // active: '-0'
  139. // },
  140. {
  141. title: '待付款',
  142. active: '0'
  143. },
  144. {
  145. title: '待发货',
  146. active: '1'
  147. },
  148. {
  149. title: '待收货',
  150. active: '2'
  151. },
  152. {
  153. title: '已收货',
  154. active: '3'
  155. }
  156. ]
  157. },
  158. list: [],
  159. total: 0,
  160. skip: 0,
  161. limit: 5,
  162. page: 0
  163. };
  164. },
  165. onLoad: function(e) {
  166. const that = this;
  167. that.$set(that, `status`, e.status);
  168. // 监听用户是否登录
  169. that.watchLogin();
  170. },
  171. onShow: function() {},
  172. methods: {
  173. // 监听用户是否登录
  174. watchLogin() {
  175. const that = this;
  176. uni.getStorage({
  177. key: 'token',
  178. success: function(res) {
  179. let user = that.$jwt(res.data);
  180. if (user) that.$set(that, `user`, user);
  181. that.$set(that.tabs, `active`, that.status);
  182. that.search();
  183. },
  184. fail: function(err) {
  185. uni.navigateTo({
  186. url: `/pages/login/index`
  187. })
  188. }
  189. });
  190. },
  191. // 查询列表
  192. async search() {
  193. const that = this;
  194. let user = that.user;
  195. let status = that.status;
  196. if (status == '-0') {
  197. } else if (status == '0') {
  198. const res = await that.$api(`/order`, 'GET', {
  199. status: '0',
  200. customer: user._id
  201. });
  202. if (res.errcode == '0') {
  203. let list = [...that.list, ...res.data];
  204. that.$set(that, `list`, list)
  205. that.$set(that, `total`, res.total)
  206. } else {
  207. uni.showToast({
  208. title: res.errmsg,
  209. });
  210. }
  211. } else {
  212. const res = await that.$api(`/orderDetail`, 'GET', {
  213. status: that.status,
  214. customer: user._id
  215. });
  216. if (res.errcode == '0') {
  217. let list = [...that.list, ...res.data];
  218. that.$set(that, `list`, list)
  219. that.$set(that, `total`, res.total)
  220. } else {
  221. uni.showToast({
  222. title: res.errmsg,
  223. });
  224. }
  225. }
  226. },
  227. // 分页
  228. toPage(e) {
  229. const that = this;
  230. let list = that.list;
  231. let limit = that.limit;
  232. if (that.total > list.length) {
  233. uni.showLoading({
  234. title: '加载中',
  235. mask: true
  236. })
  237. let page = that.page + 1;
  238. that.$set(that, `page`, page)
  239. let skip = page * limit;
  240. that.$set(that, `skip`, skip)
  241. that.search();
  242. uni.hideLoading();
  243. } else uni.showToast({
  244. title: '没有更多数据了'
  245. });
  246. },
  247. // 输入框
  248. toInput(e) {
  249. const that = this;
  250. that.$set(that.searchInfo, `name`, e.detail.value)
  251. },
  252. // 订单详细
  253. toInfo(item) {
  254. uni.navigateTo({
  255. url: `/pagesMy/order/info?id=${item._id}&status=${item.status}`
  256. })
  257. },
  258. // 取消订单
  259. toCancel(e) {
  260. const that = this;
  261. uni.showModal({
  262. title: '提示',
  263. content: '确定取消订单吗?',
  264. success: async function(res) {
  265. if (res.confirm) {
  266. const arr = await that.$api(`/order/cancel`, 'POST', {
  267. order_id: e._id
  268. });
  269. if (arr.errcode == '0') {
  270. uni.showToast({
  271. title: '取消订单成功',
  272. icon: 'none'
  273. })
  274. that.clearPage();
  275. that.search();
  276. } else {
  277. uni.showToast({
  278. title: arr.errmsg,
  279. icon: 'none'
  280. })
  281. }
  282. }
  283. }
  284. });
  285. },
  286. // 付款
  287. toPay(e) {
  288. const that = this;
  289. uni.getStorage({
  290. key: 'system',
  291. success: async function(res) {
  292. // 微信小程序支付
  293. if (res.data.uniPlatform == "mp-weixin") {
  294. uni.showLoading({
  295. title: '加载中'
  296. })
  297. const res = await that.$api('/pay/toPayOrder', 'POST', {
  298. order_id: e,
  299. type: '0'
  300. })
  301. uni.requestPayment({
  302. "provider": "wxpay",
  303. ...res.data,
  304. success(res) {
  305. uni.showToast({
  306. title: '支付成功',
  307. icon: 'none'
  308. })
  309. uni.hideLoading();
  310. that.clearPage();
  311. that.search();
  312. },
  313. fail(e) {
  314. console.log('in fail');
  315. uni.hideLoading();
  316. that.clearPage();
  317. that.search();
  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. display: flex;
  465. flex-direction: column;
  466. width: 60vw;
  467. padding: 0 2vw;
  468. .specs {
  469. color: var(--f85Color);
  470. font-size: var(--font12Size);
  471. }
  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>