index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  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" @scroll="toScroll">
  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 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 v-if="item.status=='2'" type="default" size="mini" @tap.stop="toConfirm(item)">确认收货</button>
  59. <button v-if="item.status!='0'" type="default" size="mini" @tap.stop="toAfter(item)">申请售后</button>
  60. <button v-if="item.status=='3'&&!item.rate" type="default" size="mini" @tap.stop="toAppraise(item)">立即评价</button>
  61. <button v-if="item.status=='3'&&item.rate" type="default" size="mini" @tap.stop="toAppraise(item)">追加评价</button>
  62. </view>
  63. </view>
  64. <view class="list_2 list_3" v-for="(item,index) in list" :key="index" @tap="toInfo(item)" v-else>
  65. <view class="list_3_1">
  66. <view class="goods_1">
  67. <view class="shopname">
  68. <text class="iconfont icon-shangdian"></text>
  69. <text>{{item.shop.name}}</text>
  70. </view>
  71. </view>
  72. <view class="status">
  73. {{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'?'售后已结束':'未识别'}}
  74. </view>
  75. </view>
  76. <view class="goods" v-for="(tag,indexs) in item.goods" :key="indexs">
  77. <view class="goods_2">
  78. <view class="market">
  79. <view class="url">
  80. <image class="image" :src="tag.url" mode=""></image>
  81. </view>
  82. <view class="goodsname">
  83. {{tag.goods.name}}
  84. <view class="specs">
  85. {{tag.name}}
  86. </view>
  87. </view>
  88. <view class="goodsother">
  89. <view v-if="item.type=='0'" class="price">
  90. ¥{{tag.sell_money}}
  91. </view>
  92. <view v-else class="price">
  93. ¥{{tag.group_config.money}}
  94. </view>
  95. <view class="num">
  96. ×{{tag.buy_num}}
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. <view class="other">
  103. <text>共{{item.buy_num_total||0}}件商品</text>
  104. <text>总价¥{{item.real_pay}}</text>
  105. </view>
  106. <view class="btn">
  107. <button v-if="item.status=='2'||item.status=='3'" type="default" size="mini" @tap.stop="toLogi(item)">查看物流</button>
  108. <button v-if="item.status=='0'" type="default" size="mini" @tap.stop="toCancel(item)">取消订单</button>
  109. <button class="toPay" v-if="item.status=='0'" type="default" size="mini" @tap.stop="toPay(item)">付款</button>
  110. <button v-if="item.status=='2'" type="default" size="mini" @tap.stop="toConfirm(item)">确认收货</button>
  111. <button v-if="item.status!='0'" type="default" size="mini" @tap.stop="toAfter(item)">申请售后</button>
  112. <button v-if="item.status=='3'&&!item.rate" type="default" size="mini" @tap.stop="toAppraise(item)">立即评价</button>
  113. <button v-if="item.status=='3'&&item.rate" type="default" size="mini" @tap.stop="toAppraise(item)">追加评价</button>
  114. </view>
  115. </view>
  116. <view class="is_bottom" v-if="is_bottom">
  117. <text>我们也是有底线的!</text>
  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. title: '取消订单',
  163. active: '-1'
  164. }
  165. ]
  166. },
  167. list: [],
  168. total: 0,
  169. skip: 0,
  170. limit: 5,
  171. page: 0,
  172. // 数据是否触底
  173. is_bottom: false,
  174. scrollTop: 0,
  175. };
  176. },
  177. onLoad: function(e) {
  178. const that = this;
  179. that.$set(that, `status`, e.status);
  180. // 监听用户是否登录
  181. that.watchLogin();
  182. },
  183. onShow: function() {
  184. const that = this;
  185. that.clearPage();
  186. that.search();
  187. },
  188. methods: {
  189. // 监听用户是否登录
  190. watchLogin() {
  191. const that = this;
  192. uni.getStorage({
  193. key: 'token',
  194. success: function(res) {
  195. let user = that.$jwt(res.data);
  196. if (user) that.$set(that, `user`, user);
  197. that.$set(that.tabs, `active`, that.status);
  198. that.search();
  199. },
  200. fail: function(err) {
  201. uni.navigateTo({
  202. url: `/pages/login/index`
  203. })
  204. }
  205. });
  206. },
  207. // 查询列表
  208. async search() {
  209. const that = this;
  210. let user = that.user;
  211. let status = that.status;
  212. if (status == '-0') {
  213. } else if (status == '0') {
  214. const res = await that.$api(`/order`, 'GET', {
  215. status: '0',
  216. customer: user._id
  217. });
  218. if (res.errcode == '0') {
  219. let list = [...that.list, ...res.data];
  220. that.$set(that, `list`, list)
  221. that.$set(that, `total`, res.total)
  222. } else {
  223. uni.showToast({
  224. title: res.errmsg,
  225. });
  226. }
  227. } else {
  228. const res = await that.$api(`/orderDetail`, 'GET', {
  229. status: that.status,
  230. customer: user._id
  231. });
  232. if (res.errcode == '0') {
  233. let list = [...that.list, ...res.data];
  234. that.$set(that, `list`, list)
  235. that.$set(that, `total`, res.total)
  236. } else {
  237. uni.showToast({
  238. title: res.errmsg,
  239. });
  240. }
  241. }
  242. },
  243. // 分页
  244. toPage(e) {
  245. const that = this;
  246. let list = that.list;
  247. let limit = that.limit;
  248. if (that.total > list.length) {
  249. uni.showLoading({
  250. title: '加载中',
  251. mask: true
  252. })
  253. let page = that.page + 1;
  254. that.$set(that, `page`, page)
  255. let skip = page * limit;
  256. that.$set(that, `skip`, skip)
  257. that.search();
  258. uni.hideLoading();
  259. } else that.$set(that, `is_bottom`, true)
  260. },
  261. toScroll(e) {
  262. const that = this;
  263. let up = that.scrollTop;
  264. that.$set(that, `scrollTop`, e.detail.scrollTop);
  265. let num = Math.sign(up - e.detail.scrollTop);
  266. if (num == 1) that.$set(that, `is_bottom`, false);
  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. uni.showToast({
  336. title: `支付失败`,
  337. icon: 'none'
  338. })
  339. uni.hideLoading();
  340. that.clearPage();
  341. that.search();
  342. }
  343. })
  344. } else if (res.data.uniPlatform == "app") {
  345. // app支付
  346. uni.requestPayment({
  347. provider: 'alipay',
  348. orderInfo: 'orderInfo', //微信、支付宝订单数据 【注意微信的订单信息,键值应该全部是小写,不能采用驼峰命名】
  349. success: function(res) {
  350. console.log('success:' + JSON.stringify(res));
  351. },
  352. fail: function(err) {
  353. console.log('fail:' + JSON.stringify(err));
  354. }
  355. });
  356. } else {
  357. uni.showToast({
  358. title: `平台不支持支付`,
  359. icon: 'none'
  360. })
  361. }
  362. },
  363. fail: function(err) {}
  364. })
  365. },
  366. // 确认收货
  367. toConfirm(e) {
  368. const that = this;
  369. uni.showModal({
  370. title: '提示',
  371. content: '确定确认收货吗?',
  372. success: async function(res) {
  373. if (res.confirm) {
  374. const arr = await that.$api(`/orderDetail/${e._id}`, 'POST', {
  375. status: '3'
  376. });
  377. if (arr.errcode == '0') {
  378. uni.showToast({
  379. title: '确认收货成功',
  380. icon: 'none'
  381. })
  382. that.clearPage();
  383. that.search();
  384. } else {
  385. uni.showToast({
  386. title: arr.errmsg,
  387. icon: 'none'
  388. })
  389. }
  390. }
  391. }
  392. });
  393. },
  394. // 申请售后 申请退款
  395. toAfter(e) {
  396. if (e.status == '3') {
  397. uni.navigateTo({
  398. url: `/pagesMy/order/service?id=${e._id}`
  399. })
  400. } else {
  401. uni.navigateTo({
  402. url: `/pagesMy/order/noService?id=${e._id}`
  403. })
  404. }
  405. },
  406. // 查看物流
  407. toLogi(e) {
  408. uni.navigateTo({
  409. url: `/pagesMy/logistics/index?id=${e._id}`
  410. })
  411. },
  412. // 立即评价
  413. toAppraise(e) {
  414. if (e.rate) {
  415. uni.navigateTo({
  416. url: `/pagesMy/order/appraise?id=${e._id}&rate_id=${e.rate}`
  417. })
  418. } else {
  419. uni.navigateTo({
  420. url: `/pagesMy/order/appraise?id=${e._id}`
  421. })
  422. }
  423. },
  424. // 选择选项卡
  425. tabsChange(e) {
  426. const that = this;
  427. that.$set(that.tabs, `active`, e.active)
  428. that.$set(that, `status`, e.active);
  429. that.clearPage();
  430. that.search()
  431. },
  432. // 清空列表
  433. clearPage() {
  434. const that = this;
  435. that.$set(that, `list`, [])
  436. that.$set(that, `skip`, 0)
  437. that.$set(that, `limit`, 5)
  438. that.$set(that, `page`, 0)
  439. }
  440. }
  441. }
  442. </script>
  443. <style lang="scss">
  444. .main {
  445. display: flex;
  446. flex-direction: column;
  447. width: 100vw;
  448. height: 100vh;
  449. .one {
  450. padding: 2vw;
  451. input {
  452. padding: 2vw;
  453. background-color: var(--f1Color);
  454. font-size: var(--font14Size);
  455. border-radius: 5px;
  456. }
  457. }
  458. .two {
  459. position: relative;
  460. flex-grow: 1;
  461. background-color: var(--f9Color);
  462. .tabsList {
  463. position: relative;
  464. width: 100vw;
  465. height: 82vh;
  466. .list_2 {
  467. background-color: #fff;
  468. margin: 0 2vw 2vw 2vw;
  469. padding: 2vw;
  470. .status {
  471. color: var(--ff0Color);
  472. text-align: right;
  473. margin: 0 0 1vw 0;
  474. }
  475. .goods {
  476. margin: 0 0 1vw 0;
  477. padding: 2vw;
  478. border-bottom: 1px solid #f5f5f5;
  479. .goods_1 {
  480. margin: 0 0 2vw 0;
  481. .shopname {
  482. text:last-child {
  483. padding: 0 0 0 2vw;
  484. }
  485. }
  486. }
  487. .goods_2 {
  488. margin: 0 0 1vw 0;
  489. .market {
  490. display: flex;
  491. .url {
  492. width: 20vw;
  493. .image {
  494. width: 100%;
  495. height: 20vw;
  496. border-radius: 5px;
  497. }
  498. }
  499. .goodsname {
  500. display: flex;
  501. flex-direction: column;
  502. width: 60vw;
  503. padding: 0 2vw;
  504. .specs {
  505. color: var(--f85Color);
  506. font-size: var(--font12Size);
  507. }
  508. }
  509. .goodsother {
  510. width: 15vw;
  511. text-align: right;
  512. }
  513. }
  514. }
  515. }
  516. .other {
  517. margin: 0 0 2vw 0;
  518. text-align: right;
  519. text {
  520. font-size: 14px;
  521. padding: 0 0 0 2vw;
  522. }
  523. }
  524. .btn {
  525. text-align: right;
  526. margin: 2vw 0 0 0;
  527. border-top: 1px solid #f1fff1;
  528. button {
  529. margin: 2vw 0 0 2vw;
  530. }
  531. .toPay {
  532. border: 1px solid #ff0000;
  533. color: #ff0000;
  534. }
  535. }
  536. }
  537. .list_3 {
  538. .list_3_1 {
  539. display: flex;
  540. justify-content: space-between;
  541. }
  542. }
  543. // .list {
  544. // background-color: #fff;
  545. // margin: 0 2vw 2vw 2vw;
  546. // padding: 2vw;
  547. // .list_1 {
  548. // margin: 0 0 1vw 0;
  549. // display: flex;
  550. // flex-direction: row;
  551. // justify-content: space-between;
  552. // }
  553. // .list_2 {
  554. // margin: 0 0 1vw 0;
  555. // display: flex;
  556. // .l {
  557. // width: 20vw;
  558. // .image {
  559. // width: 100%;
  560. // height: 20vw;
  561. // border-radius: 5px;
  562. // }
  563. // }
  564. // .c {
  565. // width: 60vw;
  566. // padding: 0 2vw;
  567. // }
  568. // .r {
  569. // width: 15vw;
  570. // text-align: right;
  571. // }
  572. // }
  573. // .other {
  574. // margin: 0 0 2vw 0;
  575. // text-align: right;
  576. // text {
  577. // font-size: 14px;
  578. // padding: 0 0 0 2vw;
  579. // }
  580. // }
  581. // .btn {
  582. // text-align: right;
  583. // margin: 2vw 0 0 0;
  584. // border-top: 1px solid #f1fff1;
  585. // button {
  586. // margin: 2vw 0 0 2vw;
  587. // }
  588. // }
  589. // }
  590. }
  591. }
  592. }
  593. // .two {
  594. // position: relative;
  595. // flex-grow: 1;
  596. // background-color: var(--f9Color);
  597. // .two_1 {
  598. // background-color: var(--fffColor);
  599. // padding: 2vw;
  600. // display: flex;
  601. // flex-direction: row;
  602. // }
  603. // .two_2 {
  604. // display: flex;
  605. // flex-direction: column;
  606. // .list {
  607. // width: 100vw;
  608. // margin: 2vw 0 0 0;
  609. // background-color: var(--mainColor);
  610. // .list_1 {
  611. // display: flex;
  612. // flex-direction: row;
  613. // justify-content: space-between;
  614. // padding: 2vw;
  615. // .name {
  616. // font-size: var(--font14Size);
  617. // text {
  618. // margin: 0 1vw 0 0;
  619. // }
  620. // }
  621. // .status {
  622. // font-size: var(--font14Size);
  623. // color: var(--ff0Color);
  624. // }
  625. // }
  626. // .list_2 {
  627. // display: flex;
  628. // flex-direction: row;
  629. // justify-content: space-between;
  630. // padding: 2vw;
  631. // background-color: var(--f8Color);
  632. // .image {
  633. // width: 20vw;
  634. // height: 20vw;
  635. // margin: 0 2vw 0 0;
  636. // }
  637. // .other {
  638. // display: flex;
  639. // flex-direction: column;
  640. // flex-grow: 1;
  641. // .name {
  642. // font-size: var(--font14Size);
  643. // font-weight: bold;
  644. // margin: 0 0 2vw 0;
  645. // }
  646. // .other_1 {
  647. // font-size: var(--font12Size);
  648. // color: var(--f85Color);
  649. // }
  650. // }
  651. // .money {
  652. // font-size: var(--font12Size);
  653. // .num {
  654. // text-align: right;
  655. // }
  656. // }
  657. // }
  658. // .list_3 {
  659. // display: flex;
  660. // justify-content: flex-end;
  661. // padding: 2vw;
  662. // border-bottom: 0.5vw solid var(--f9Color);
  663. // font-size: var(--font12Size);
  664. // text {
  665. // margin: 0 1vw;
  666. // }
  667. // }
  668. // .list_4 {
  669. // padding: 2vw;
  670. // text-align: right;
  671. // button {
  672. // margin: 0 1vw 0 2vw;
  673. // }
  674. // }
  675. // }
  676. // }
  677. // }
  678. // }
  679. .scroll-view {
  680. position: absolute;
  681. top: 0;
  682. left: 0;
  683. right: 0;
  684. bottom: 0;
  685. .list-scroll-view {
  686. display: flex;
  687. flex-direction: column;
  688. }
  689. }
  690. .is_bottom {
  691. text-align: center;
  692. text {
  693. padding: 2vw 0;
  694. display: inline-block;
  695. }
  696. }
  697. </style>