index.vue 17 KB

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