index.vue 19 KB

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