index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  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">
  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.name}}
  33. </view>
  34. <view class="goodsother">
  35. <view class="price">
  36. ¥{{tags.sell_money}}
  37. </view>
  38. <view class="num">
  39. ×{{tags.buy_num}}
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="other">
  46. <text>共{{item.total_detail.freight_total}}件商品</text>
  47. <text>总价¥{{item.total_detail.goods_total}}</text>
  48. </view>
  49. <view class="btn">
  50. <button class="toCancel" v-if="item.status=='0'" type="default" size="mini" @click="toCancel(item)">取消订单</button>
  51. <button class="toPay" v-if="item.status=='0'" type="default" size="mini" @click="toPay(item)">付款</button>
  52. <button class="toAfter" v-if="item.status!='0'" type="default" size="mini" @click="toAfter(item)">申请售后</button>
  53. <button class="toAfter" v-if="item.status=='3'" type="default" size="mini" @click="toAfter(item)">申请退款</button>
  54. </view>
  55. </view>
  56. <view class="list_2 list_3" v-for="(item,index) in list" :key="index" @tap="toInfo(item)" v-else>
  57. <view class="list_3_1">
  58. <view class="goods_1">
  59. <view class="shopname">
  60. <text class="iconfont icon-shangdian"></text>
  61. <text>{{item.shop.name}}</text>
  62. </view>
  63. </view>
  64. <view class="status">
  65. {{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'?'售后已结束':'未识别'}}
  66. </view>
  67. </view>
  68. <view class="goods" v-for="(tag,indexs) in item.goods" :key="indexs">
  69. <view class="goods_2">
  70. <view class="market">
  71. <view class="url">
  72. <image class="image" :src="tag.goods.file&&tag.goods.file.length>0?tag.goods.file[0].url:''" mode=""></image>
  73. </view>
  74. <view class="goodsname">
  75. {{tag.name}}
  76. </view>
  77. <view class="goodsother">
  78. <view class="price">
  79. ¥{{tag.sell_money}}
  80. </view>
  81. <view class="num">
  82. ×{{tag.buy_num}}
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <view class="other">
  89. <text>共{{item.buy_num_total||0}}件商品</text>
  90. <text>总价¥{{item.total_detail.goods_total}}</text>
  91. </view>
  92. <view class="btn">
  93. <button class="toCancel" v-if="item.status=='2'||item.status=='3'" type="default" size="mini" @click="toLogi(item)">查看物流</button>
  94. <button class="toCancel" v-if="item.status=='0'" type="default" size="mini" @click="toCancel(item)">取消订单</button>
  95. <button class="toPay" v-if="item.status=='0'" type="default" size="mini" @click="toPay(item)">付款</button>
  96. <button class="toAfter" v-if="item.status!='0'" type="default" size="mini" @click="toAfter(item)">申请售后</button>
  97. <button class="toAfter" v-if="item.status=='3'" type="default" size="mini" @click="toAfter(item)">申请退款</button>
  98. </view>
  99. </view>
  100. </view>
  101. </scroll-view>
  102. </view>
  103. </tabs>
  104. </view>
  105. </view>
  106. </mobile-frame>
  107. </template>
  108. <script>
  109. import tabs from '@/components/tabs/index.vue';
  110. export default {
  111. components: {
  112. tabs
  113. },
  114. data() {
  115. return {
  116. user: {},
  117. status: '',
  118. searchInfo: {},
  119. tabs: {
  120. active: '0',
  121. menu: [ //菜单列表
  122. // {
  123. // title: '全部订单',
  124. // active: '-0'
  125. // },
  126. {
  127. title: '待付款',
  128. active: '0'
  129. },
  130. {
  131. title: '待发货',
  132. active: '1'
  133. },
  134. {
  135. title: '待收货',
  136. active: '2'
  137. },
  138. {
  139. title: '已收货',
  140. active: '3'
  141. }
  142. ]
  143. },
  144. list: [],
  145. total: 0,
  146. skip: 0,
  147. limit: 5,
  148. page: 0
  149. };
  150. },
  151. onLoad: function(e) {
  152. const that = this;
  153. that.$set(that, `status`, e.status);
  154. // 监听用户是否登录
  155. that.watchLogin();
  156. },
  157. onShow: function() {},
  158. methods: {
  159. // 监听用户是否登录
  160. watchLogin() {
  161. const that = this;
  162. uni.getStorage({
  163. key: 'token',
  164. success: function(res) {
  165. let user = that.$jwt(res.data);
  166. if (user) that.$set(that, `user`, user);
  167. that.$set(that.tabs, `active`, that.status);
  168. that.search();
  169. },
  170. fail: function(err) {
  171. uni.navigateTo({
  172. url: `/pages/login/index`
  173. })
  174. }
  175. });
  176. },
  177. // 查询列表
  178. async search() {
  179. const that = this;
  180. let user = that.user;
  181. let status = that.status;
  182. if (status == '-0') {
  183. } else if (status == '0') {
  184. const res = await that.$api(`/order`, 'GET', {
  185. status: '0',
  186. customer: user._id
  187. });
  188. if (res.errcode == '0') {
  189. let list = [...that.list, ...res.data];
  190. that.$set(that, `list`, list)
  191. that.$set(that, `total`, res.total)
  192. } else {
  193. uni.showToast({
  194. title: res.errmsg,
  195. });
  196. }
  197. } else {
  198. const res = await that.$api(`/orderDetail`, 'GET', {
  199. status: that.status,
  200. customer: user._id
  201. });
  202. if (res.errcode == '0') {
  203. let list = [...that.list, ...res.data];
  204. that.$set(that, `list`, list)
  205. that.$set(that, `total`, res.total)
  206. } else {
  207. uni.showToast({
  208. title: res.errmsg,
  209. });
  210. }
  211. }
  212. },
  213. // 分页
  214. toPage(e) {
  215. const that = this;
  216. let list = that.list;
  217. let limit = that.limit;
  218. if (that.total > list.length) {
  219. uni.showLoading({
  220. title: '加载中',
  221. mask: true
  222. })
  223. let page = that.page + 1;
  224. that.$set(that, `page`, page)
  225. let skip = page * limit;
  226. that.$set(that, `skip`, skip)
  227. that.search();
  228. uni.hideLoading();
  229. } else uni.showToast({
  230. title: '没有更多数据了'
  231. });
  232. },
  233. // 输入框
  234. toInput(e) {
  235. const that = this;
  236. that.$set(that.searchInfo, `name`, e.detail.value)
  237. },
  238. // 订单详细
  239. toInfo(item) {
  240. uni.navigateTo({
  241. url: `/pagesMy/order/info?id=${item._id}&status=${item.status}`
  242. })
  243. },
  244. // 取消订单
  245. toCancel(e) {
  246. const that = this;
  247. uni.showModal({
  248. title: '提示',
  249. content: '确定取消订单吗?',
  250. success: async function(res) {
  251. if (res.confirm) {
  252. const arr = await that.$api(`/order/cancel`, 'POST', {
  253. order_id: e._id
  254. });
  255. if (arr.errcode == '0') {
  256. uni.showToast({
  257. title: '取消订单成功',
  258. icon: 'none'
  259. })
  260. that.clearPage();
  261. that.search();
  262. } else {
  263. uni.showToast({
  264. title: arr.errmsg,
  265. icon: 'none'
  266. })
  267. }
  268. }
  269. }
  270. });
  271. },
  272. // 付款
  273. toPay(e) {
  274. const that = this;
  275. uni.getStorage({
  276. key: 'system',
  277. success: async function(res) {
  278. // 微信小程序支付
  279. if (res.data.uniPlatform == "mp-weixin") {
  280. const res = await that.$api('/pay/toPayOrder', 'POST', {
  281. order_id: e,
  282. type: '0'
  283. })
  284. console.log(res);
  285. uni.requestPayment({
  286. "provider": "wxpay",
  287. ...res.data,
  288. success(res) {
  289. uni.showToast({
  290. title: '支付成功',
  291. icon: 'none'
  292. })
  293. that.clearPage();
  294. that.search();
  295. },
  296. fail(e) {
  297. console.log('in fail');
  298. console.log(e)
  299. }
  300. })
  301. } else if (res.data.uniPlatform == "app") {
  302. // app支付
  303. uni.requestPayment({
  304. provider: 'alipay',
  305. orderInfo: 'orderInfo', //微信、支付宝订单数据 【注意微信的订单信息,键值应该全部是小写,不能采用驼峰命名】
  306. success: function(res) {
  307. console.log('success:' + JSON.stringify(res));
  308. },
  309. fail: function(err) {
  310. console.log('fail:' + JSON.stringify(err));
  311. }
  312. });
  313. } else {
  314. uni.showToast({
  315. title: `平台不支持支付`,
  316. icon: 'none'
  317. })
  318. }
  319. },
  320. fail: function(err) {}
  321. })
  322. },
  323. // 申请售后 申请退款
  324. toAfter(e) {
  325. if (e.status == '3') {
  326. uni.navigateTo({
  327. url: `/pagesMy/order/service?id=${e._id}`
  328. })
  329. } else {
  330. uni.navigateTo({
  331. url: `/pagesMy/order/noService?id=${e._id}`
  332. })
  333. }
  334. },
  335. // 查看物流
  336. toLogi(e) {
  337. console.log(e);
  338. },
  339. // 选择选项卡
  340. tabsChange(e) {
  341. const that = this;
  342. that.$set(that.tabs, `active`, e.active)
  343. that.$set(that, `status`, e.active);
  344. that.clearPage();
  345. that.search()
  346. },
  347. // 清空列表
  348. clearPage() {
  349. const that = this;
  350. that.$set(that, `list`, [])
  351. that.$set(that, `skip`, 0)
  352. that.$set(that, `limit`, 5)
  353. that.$set(that, `page`, 0)
  354. }
  355. }
  356. }
  357. </script>
  358. <style lang="scss">
  359. .main {
  360. display: flex;
  361. flex-direction: column;
  362. width: 100vw;
  363. height: 100vh;
  364. .one {
  365. padding: 2vw;
  366. input {
  367. padding: 2vw;
  368. background-color: var(--f1Color);
  369. font-size: var(--font14Size);
  370. border-radius: 5px;
  371. }
  372. }
  373. .two {
  374. position: relative;
  375. flex-grow: 1;
  376. background-color: var(--f9Color);
  377. .tabsList {
  378. position: relative;
  379. width: 100vw;
  380. height: 82vh;
  381. .list_2 {
  382. background-color: #fff;
  383. margin: 0 2vw 2vw 2vw;
  384. padding: 2vw;
  385. .status {
  386. color: var(--ff0Color);
  387. text-align: right;
  388. margin: 0 0 1vw 0;
  389. }
  390. .goods {
  391. margin: 0 0 1vw 0;
  392. padding: 2vw;
  393. border-bottom: 1px solid #f5f5f5;
  394. .goods_1 {
  395. margin: 0 0 2vw 0;
  396. .shopname {
  397. text:last-child {
  398. padding: 0 0 0 2vw;
  399. }
  400. }
  401. }
  402. .goods_2 {
  403. margin: 0 0 1vw 0;
  404. .market {
  405. display: flex;
  406. .url {
  407. width: 20vw;
  408. .image {
  409. width: 100%;
  410. height: 20vw;
  411. border-radius: 5px;
  412. }
  413. }
  414. .goodsname {
  415. width: 60vw;
  416. padding: 0 2vw;
  417. }
  418. .goodsother {
  419. width: 15vw;
  420. text-align: right;
  421. }
  422. }
  423. }
  424. }
  425. .other {
  426. margin: 0 0 2vw 0;
  427. text-align: right;
  428. text {
  429. font-size: 14px;
  430. padding: 0 0 0 2vw;
  431. }
  432. }
  433. .btn {
  434. text-align: right;
  435. margin: 2vw 0 0 0;
  436. border-top: 1px solid #f1fff1;
  437. button {
  438. margin: 2vw 0 0 2vw;
  439. }
  440. .toPay {
  441. border: 1px solid #ff0000;
  442. color: #ff0000;
  443. }
  444. }
  445. }
  446. .list_3 {
  447. .list_3_1 {
  448. display: flex;
  449. justify-content: space-between;
  450. }
  451. }
  452. // .list {
  453. // background-color: #fff;
  454. // margin: 0 2vw 2vw 2vw;
  455. // padding: 2vw;
  456. // .list_1 {
  457. // margin: 0 0 1vw 0;
  458. // display: flex;
  459. // flex-direction: row;
  460. // justify-content: space-between;
  461. // }
  462. // .list_2 {
  463. // margin: 0 0 1vw 0;
  464. // display: flex;
  465. // .l {
  466. // width: 20vw;
  467. // .image {
  468. // width: 100%;
  469. // height: 20vw;
  470. // border-radius: 5px;
  471. // }
  472. // }
  473. // .c {
  474. // width: 60vw;
  475. // padding: 0 2vw;
  476. // }
  477. // .r {
  478. // width: 15vw;
  479. // text-align: right;
  480. // }
  481. // }
  482. // .other {
  483. // margin: 0 0 2vw 0;
  484. // text-align: right;
  485. // text {
  486. // font-size: 14px;
  487. // padding: 0 0 0 2vw;
  488. // }
  489. // }
  490. // .btn {
  491. // text-align: right;
  492. // margin: 2vw 0 0 0;
  493. // border-top: 1px solid #f1fff1;
  494. // button {
  495. // margin: 2vw 0 0 2vw;
  496. // }
  497. // }
  498. // }
  499. }
  500. }
  501. }
  502. // .two {
  503. // position: relative;
  504. // flex-grow: 1;
  505. // background-color: var(--f9Color);
  506. // .two_1 {
  507. // background-color: var(--fffColor);
  508. // padding: 2vw;
  509. // display: flex;
  510. // flex-direction: row;
  511. // }
  512. // .two_2 {
  513. // display: flex;
  514. // flex-direction: column;
  515. // .list {
  516. // width: 100vw;
  517. // margin: 2vw 0 0 0;
  518. // background-color: var(--mainColor);
  519. // .list_1 {
  520. // display: flex;
  521. // flex-direction: row;
  522. // justify-content: space-between;
  523. // padding: 2vw;
  524. // .name {
  525. // font-size: var(--font14Size);
  526. // text {
  527. // margin: 0 1vw 0 0;
  528. // }
  529. // }
  530. // .status {
  531. // font-size: var(--font14Size);
  532. // color: var(--ff0Color);
  533. // }
  534. // }
  535. // .list_2 {
  536. // display: flex;
  537. // flex-direction: row;
  538. // justify-content: space-between;
  539. // padding: 2vw;
  540. // background-color: var(--f8Color);
  541. // .image {
  542. // width: 20vw;
  543. // height: 20vw;
  544. // margin: 0 2vw 0 0;
  545. // }
  546. // .other {
  547. // display: flex;
  548. // flex-direction: column;
  549. // flex-grow: 1;
  550. // .name {
  551. // font-size: var(--font14Size);
  552. // font-weight: bold;
  553. // margin: 0 0 2vw 0;
  554. // }
  555. // .other_1 {
  556. // font-size: var(--font12Size);
  557. // color: var(--f85Color);
  558. // }
  559. // }
  560. // .money {
  561. // font-size: var(--font12Size);
  562. // .num {
  563. // text-align: right;
  564. // }
  565. // }
  566. // }
  567. // .list_3 {
  568. // display: flex;
  569. // justify-content: flex-end;
  570. // padding: 2vw;
  571. // border-bottom: 0.5vw solid var(--f9Color);
  572. // font-size: var(--font12Size);
  573. // text {
  574. // margin: 0 1vw;
  575. // }
  576. // }
  577. // .list_4 {
  578. // padding: 2vw;
  579. // text-align: right;
  580. // button {
  581. // margin: 0 1vw 0 2vw;
  582. // }
  583. // }
  584. // }
  585. // }
  586. // }
  587. // }
  588. .scroll-view {
  589. position: absolute;
  590. top: 0;
  591. left: 0;
  592. right: 0;
  593. bottom: 0;
  594. .list-scroll-view {
  595. display: flex;
  596. flex-direction: column;
  597. }
  598. }
  599. </style>