index.vue 15 KB

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