index.vue 18 KB

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