index.vue 18 KB

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