index.vue 18 KB

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