index.vue 15 KB

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