index.vue 18 KB

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