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