index.vue 14 KB

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