index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  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" v-for="(item,index) in list" :key="index" @tap="toInfo(item)">
  13. <view class="list_1" v-if="tabs.active=='0'">
  14. <view class="goods">
  15. <view class="goodsList" v-for="(tag,indexs) in item.goods" :key="indexs">
  16. <view class="shopname">
  17. <view class="shop">
  18. <text class="iconfont icon-shangdian"></text>
  19. <text>{{tag.shop_name}}</text>
  20. </view>
  21. <view class="status">
  22. {{item.zhStatus}}
  23. </view>
  24. </view>
  25. <view class="goodsList_1">
  26. <view class="market" v-for="(tags,indexss) in tag.goods"
  27. :key="indexss">
  28. <view class="market_1">
  29. <image class="image"
  30. :src="tags.goods.file&&tags.goods.file.length>0?tags.goods.file[0].url:''"
  31. mode=""></image>
  32. </view>
  33. <view class="market_2">
  34. <view class="goodsname textOver">
  35. {{tags.goods.name}}
  36. </view>
  37. <view class="specs">
  38. {{tags.name}}
  39. </view>
  40. </view>
  41. <view class="market_3">
  42. <view v-if="item.type=='0'" class="price">
  43. ¥{{tags.sell_money}}
  44. </view>
  45. <view v-else class="price">
  46. ¥{{tags.group_config.money}}
  47. </view>
  48. <view class="num">
  49. ×{{tags.buy_num}}
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="other">
  57. <text>共{{item.total_detail.freight_total}}件商品</text>
  58. <text>总价¥{{item.total_detail.goods_total}}</text>
  59. </view>
  60. </view>
  61. <view class="list_2" v-else>
  62. <view class="list_2_1">
  63. <view class="shopname">
  64. <text class="iconfont icon-shangdian"></text>
  65. <text>{{item.shop.name}}</text>
  66. </view>
  67. <view class="status">
  68. {{item.zhStatus}}
  69. </view>
  70. </view>
  71. <view class="list_2_2">
  72. <view class="goods" v-for="(tag,indexs) in item.goods" :key="indexs">
  73. <view class="goods_1">
  74. <image class="image" :src="tag.url" mode=""></image>
  75. </view>
  76. <view class="goods_2">
  77. <view class="goodsname textOver">
  78. {{tag.goods.name}}
  79. </view>
  80. <view class="specs">
  81. {{tag.name}}
  82. </view>
  83. </view>
  84. <view class="goods_3">
  85. <view v-if="item.type=='0'" class="price">
  86. ¥{{tag.sell_money}}
  87. </view>
  88. <view v-else class="price">
  89. ¥{{tag.group_config.money}}
  90. </view>
  91. <view class="num">
  92. ×{{tag.buy_num}}
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. <view class="other">
  98. <text>共{{item.buy_num_total||0}}件商品</text>
  99. <text>总价¥{{item.real_pay}}</text>
  100. </view>
  101. </view>
  102. <view class="btn">
  103. <button v-if="item.status=='0'" size="mini"
  104. @tap.stop="toCancel(item)">取消订单</button>
  105. <button v-if="item.status=='0'" size="mini" @tap.stop="toPay(item)">支付</button>
  106. <button v-if="item.status=='1'&&item.is_afterSale!=true" size="mini"
  107. @tap.stop="toCancels(item)">取消订单</button>
  108. <button v-if="item.status=='2'||item.status=='3'" size="mini"
  109. @tap.stop="toLogi(item)">查看物流</button>
  110. <button v-if="item.status=='2'&&item.is_afterSale!=true" size="mini"
  111. @tap.stop="toConfirm(item)">确认收货</button>
  112. <button v-if="item.status=='2'&&item.is_afterSale!=true" size="mini"
  113. @tap.stop="toReject(item)">拒收</button>
  114. <button v-if="item.status=='3'" size="mini"
  115. @tap.stop="toAfter(item)">申请售后</button>
  116. <button v-if="item.status=='3'" size="mini"
  117. @tap.stop="toAppraise(item)">立即评价</button>
  118. </view>
  119. </view>
  120. <view class="is_bottom" v-if="is_bottom">
  121. <text>{{config.bottom_title}}</text>
  122. </view>
  123. </view>
  124. </scroll-view>
  125. </view>
  126. </tabs>
  127. </view>
  128. </view>
  129. </mobile-frame>
  130. </template>
  131. <script>
  132. import tabs from '@/components/tabs/index.vue';
  133. export default {
  134. components: {
  135. tabs
  136. },
  137. data() {
  138. return {
  139. // 系统设置
  140. config: {},
  141. // 设备信息
  142. system: {},
  143. user: {},
  144. status: '',
  145. searchInfo: {},
  146. tabs: {
  147. active: '0',
  148. menu: []
  149. },
  150. list: [],
  151. total: 0,
  152. skip: 0,
  153. limit: 6,
  154. page: 0,
  155. // 数据是否触底
  156. is_bottom: false,
  157. scrollTop: 0,
  158. // 字典表
  159. statusList: []
  160. };
  161. },
  162. onLoad: async function(e) {
  163. const that = this;
  164. that.$set(that, `status`, e.status || '');
  165. that.$set(that.tabs, `active`, e.status || '');
  166. that.searchConfig();
  167. await that.searchOther();
  168. await that.watchlogin();
  169. },
  170. onPullDownRefresh: async function() {
  171. const that = this;
  172. that.clearPage();
  173. await that.search();
  174. uni.stopPullDownRefresh();
  175. },
  176. methods: {
  177. // 查询基本设置
  178. searchConfig() {
  179. const that = this;
  180. uni.getStorage({
  181. key: 'config',
  182. success: function(res) {
  183. if (res.data) that.$set(that, `config`, res.data)
  184. // 设备平台信息
  185. let config = that.$config;
  186. that.$set(that, `system`, config.system);
  187. },
  188. fail: function(err) {
  189. console.log(err);
  190. }
  191. })
  192. },
  193. // 监听用户是否登录
  194. watchlogin() {
  195. const that = this;
  196. uni.getStorage({
  197. key: 'token',
  198. success: function(res) {
  199. let user = that.$jwt(res.data);
  200. if (user) {
  201. that.$set(that, `user`, user)
  202. that.search();
  203. }
  204. }
  205. })
  206. },
  207. async search() {
  208. const that = this;
  209. let user = that.user;
  210. let status = that.status;
  211. let info = {
  212. skip: that.skip,
  213. limit: that.limit,
  214. customer: user._id,
  215. status: status
  216. }
  217. let res;
  218. if (status == '0') {
  219. res = await that.$api(`/order`, 'GET', {
  220. ...info,
  221. ...that.searchInfo
  222. });
  223. } else {
  224. res = await that.$api(`/orderDetail`, 'GET', {
  225. ...info,
  226. ...that.searchInfo
  227. });
  228. }
  229. if (res.errcode == '0') {
  230. let list = [...that.list, ...res.data];
  231. for (let val of list) {
  232. val.zhStatus = that.searchStatus(val.status)
  233. }
  234. that.$set(that, `list`, list);
  235. that.$set(that, `total`, res.total)
  236. } else {
  237. uni.showToast({
  238. title: res.errmsg,
  239. icon: 'none'
  240. })
  241. }
  242. },
  243. // 查询状态
  244. searchStatus(e) {
  245. const that = this;
  246. let data = that.statusList.find((i) => i.value == e);
  247. if (data) return data.label
  248. else return '暂无'
  249. },
  250. // 分页
  251. toPage(e) {
  252. const that = this;
  253. let list = that.list;
  254. let limit = that.limit;
  255. if (that.total > list.length) {
  256. uni.showLoading({
  257. title: '加载中',
  258. mask: true
  259. })
  260. let page = that.page + 1;
  261. that.$set(that, `page`, page)
  262. let skip = page * limit;
  263. that.$set(that, `skip`, skip)
  264. that.search();
  265. uni.hideLoading();
  266. } else that.$set(that, `is_bottom`, true)
  267. },
  268. toScroll(e) {
  269. const that = this;
  270. let up = that.scrollTop;
  271. that.$set(that, `scrollTop`, e.detail.scrollTop);
  272. let num = Math.sign(up - e.detail.scrollTop);
  273. if (num == 1) that.$set(that, `is_bottom`, false);
  274. },
  275. // 输入框
  276. toInput(e) {
  277. const that = this;
  278. that.$set(that.searchInfo, `name`, e.detail.value)
  279. },
  280. // 订单详细信息
  281. toInfo(item) {
  282. uni.navigateTo({
  283. url: `/pagesMy/order/info?id=${item._id}&status=${item.status}`
  284. })
  285. },
  286. // 取消订单-未支付
  287. toCancel(e) {
  288. const that = this;
  289. uni.showModal({
  290. title: '提示',
  291. content: '确定取消订单吗?',
  292. success: async function(res) {
  293. if (res.confirm) {
  294. const arr = await that.$api(`/order/cancel`, 'POST', {
  295. order_id: e._id
  296. });
  297. if (arr.errcode == '0') {
  298. uni.showToast({
  299. title: '申请取消订单完成',
  300. icon: 'none'
  301. })
  302. that.clearPage();
  303. that.search();
  304. } else {
  305. uni.showToast({
  306. title: arr.errmsg,
  307. icon: 'none'
  308. })
  309. }
  310. }
  311. }
  312. });
  313. },
  314. // 支付
  315. async toPay(e) {
  316. const that = this;
  317. let system = that.system;
  318. if (system.uniPlatform == "mp-weixin") {
  319. uni.showLoading({
  320. title: '加载中'
  321. })
  322. // 支付信息
  323. let p2 = await that.$api('/pay/toPayOrder', 'POST', {
  324. order_id: e,
  325. type: '0'
  326. })
  327. if (p2.errcode == '0' && p2.data.paySign) {
  328. uni.requestPayment({
  329. "provider": "wxpay",
  330. ...p2.data,
  331. success: function(res) {
  332. uni.showToast({
  333. title: '支付成功',
  334. icon: 'none'
  335. })
  336. },
  337. fail: function(err) {
  338. uni.showToast({
  339. title: `支付失败`,
  340. icon: 'none'
  341. })
  342. },
  343. complete: function() {
  344. uni.hideLoading();
  345. that.clearPage();
  346. that.search();
  347. }
  348. })
  349. } else {
  350. uni.showToast({
  351. title: p2.errmsg || '错误信息',
  352. icon: 'none'
  353. })
  354. }
  355. } else if (res.data.uniPlatform == "app") {
  356. // app支付
  357. uni.requestPayment({
  358. provider: 'alipay',
  359. orderInfo: 'orderInfo',
  360. success: function(res) {
  361. console.log('success:' + JSON.stringify(res));
  362. },
  363. fail: function(err) {
  364. console.log('fail:' + JSON.stringify(err));
  365. }
  366. });
  367. } else {
  368. uni.showToast({
  369. title: `平台不支持支付`,
  370. icon: 'none'
  371. })
  372. }
  373. },
  374. // 取消订单-已支付
  375. toCancels(e) {
  376. const that = this;
  377. uni.showModal({
  378. title: '提示',
  379. content: '确定取消订单吗?',
  380. success: async function(res) {
  381. if (res.confirm) {
  382. let arr = await that.$api(`/afterSale`, 'POST', {
  383. order_detail: e._id,
  384. type: '4'
  385. })
  386. if (arr.errcode == '0') {
  387. uni.showToast({
  388. title: '申请取消订单完成',
  389. icon: 'none'
  390. })
  391. that.clearPage();
  392. that.search();
  393. } else {
  394. uni.showToast({
  395. title: arr.errmsg,
  396. icon: 'none'
  397. })
  398. }
  399. }
  400. }
  401. });
  402. },
  403. // 查看物流
  404. toLogi(e) {
  405. uni.navigateTo({
  406. url: `/pagesMy/logistics/index?id=${e._id}`
  407. })
  408. },
  409. // 确认收货
  410. async toConfirm(e) {
  411. const that = this;
  412. uni.showModal({
  413. title: '提示',
  414. content: '确定确认收货吗?',
  415. success: async function(res) {
  416. if (res.confirm) {
  417. const arr = await that.$api(`/orderDetail/${e._id}`, 'POST', {
  418. status: '3'
  419. });
  420. if (arr.errcode == '0') {
  421. uni.showToast({
  422. title: '确认收货成功',
  423. icon: 'none'
  424. })
  425. that.clearPage();
  426. that.search();
  427. } else {
  428. uni.showToast({
  429. title: arr.errmsg,
  430. icon: 'none'
  431. })
  432. }
  433. }
  434. }
  435. });
  436. },
  437. // 拒收
  438. async toReject(e) {
  439. const that = this;
  440. uni.showModal({
  441. title: '提示',
  442. content: '确定拒收快递吗?',
  443. success: async function(res) {
  444. if (res.confirm) {
  445. let arr = await that.$api(`/afterSale`, 'POST', {
  446. order_detail: e._id,
  447. type: '5'
  448. })
  449. if (arr.errcode == '0') {
  450. uni.showToast({
  451. title: '拒收申请完成',
  452. icon: 'none'
  453. })
  454. that.clearPage();
  455. that.search();
  456. } else {
  457. uni.showToast({
  458. title: arr.errmsg,
  459. icon: 'none'
  460. })
  461. }
  462. }
  463. }
  464. });
  465. },
  466. // 立即评价 追评
  467. toAppraise(e) {
  468. uni.navigateTo({
  469. url: `/pagesMy/order/appraise?id=${e._id}`
  470. })
  471. },
  472. // 申请售后
  473. toAfter(e) {
  474. uni.navigateTo({
  475. url: `/pagesMy/order/service?id=${e._id}&&status=${e.status}`
  476. })
  477. },
  478. // 查询其他信息
  479. async searchOther() {
  480. const that = this;
  481. let res;
  482. // 查询状态
  483. res = await that.$api(`/dictData`, 'GET', {
  484. code: 'order_process'
  485. })
  486. if (res.errcode == '0') {
  487. that.$set(that, `statusList`, res.data);
  488. var menu = res.data.map((item) => {
  489. return {
  490. title: item.label,
  491. active: item.value
  492. }
  493. })
  494. that.$set(that.tabs, `menu`, menu)
  495. }
  496. },
  497. // 选择选项卡
  498. tabsChange(e) {
  499. const that = this;
  500. that.$set(that.tabs, `active`, e.active)
  501. that.$set(that, `status`, e.active);
  502. that.clearPage();
  503. that.search()
  504. },
  505. // 清空列表
  506. clearPage() {
  507. const that = this;
  508. that.$set(that, `list`, [])
  509. that.$set(that, `skip`, 0)
  510. that.$set(that, `limit`, 6)
  511. that.$set(that, `page`, 0)
  512. }
  513. },
  514. }
  515. </script>
  516. <style lang="scss">
  517. .main {
  518. display: flex;
  519. flex-direction: column;
  520. width: 100vw;
  521. height: 100vh;
  522. .one {
  523. padding: 2vw;
  524. input {
  525. padding: 2vw;
  526. background-color: var(--f1Color);
  527. font-size: var(--font14Size);
  528. border-radius: 5px;
  529. }
  530. }
  531. .two {
  532. position: relative;
  533. flex-grow: 1;
  534. background-color: var(--f9Color);
  535. .tabsList {
  536. position: relative;
  537. width: 100vw;
  538. height: 82vh;
  539. .list {
  540. background-color: #fff;
  541. border: 1px solid #ff0000;
  542. padding: 2vw;
  543. margin: 0 2vw 2vw 2vw;
  544. border-radius: 5px;
  545. .list_1 {
  546. .goods {
  547. .goodsList {
  548. border-bottom: 1px solid #f1f1f1;
  549. .shopname {
  550. display: flex;
  551. justify-content: space-between;
  552. margin: 0 0 2vw 0;
  553. .shop {
  554. text:last-child {
  555. padding: 0 0 0 2vw;
  556. }
  557. }
  558. .status {
  559. text-align: right;
  560. color: var(--ff0Color);
  561. margin: 0 0 1vw 0;
  562. }
  563. }
  564. .goodsList_1 {
  565. .market {
  566. display: flex;
  567. padding: 0 0 2vw 0;
  568. .market_1 {
  569. width: 20vw;
  570. height: 20vw;
  571. .image {
  572. width: 100%;
  573. height: 100%;
  574. border-radius: 5px;
  575. }
  576. }
  577. .market_2 {
  578. width: 55vw;
  579. padding: 0 0 0 2vw;
  580. .goodsname {
  581. font-size: 16px;
  582. margin: 0 0 1vw 0;
  583. }
  584. .specs {
  585. font-size: 14px;
  586. color: #858585;
  587. }
  588. }
  589. .market_3 {
  590. width: 15vw;
  591. text-align: right;
  592. }
  593. }
  594. }
  595. }
  596. }
  597. .other {
  598. padding: 0 0 2vw 0;
  599. margin: 2vw 0;
  600. text-align: right;
  601. border-bottom: 1px solid #f1f1f1;
  602. text {
  603. font-size: 14px;
  604. padding: 0 0 0 2vw;
  605. }
  606. }
  607. }
  608. .list_2 {
  609. .list_2_1 {
  610. display: flex;
  611. justify-content: space-between;
  612. margin: 0 0 2vw 0;
  613. .shopname {
  614. text:last-child {
  615. padding: 0 0 0 2vw;
  616. }
  617. }
  618. .status {
  619. color: var(--ff0Color);
  620. }
  621. }
  622. .list_2_2 {
  623. border-bottom: 1px solid #f1f1f1;
  624. .goods {
  625. display: flex;
  626. padding: 0 0 2vw 0;
  627. .goods_1 {
  628. width: 20vw;
  629. height: 20vw;
  630. .image {
  631. width: 100%;
  632. height: 100%;
  633. border-radius: 5px;
  634. }
  635. }
  636. .goods_2 {
  637. width: 55vw;
  638. padding: 0 0 0 2vw;
  639. .goodsname {
  640. font-size: 16px;
  641. margin: 0 0 1vw 0;
  642. }
  643. .specs {
  644. font-size: 14px;
  645. color: #858585;
  646. }
  647. }
  648. .goods_3 {
  649. width: 15vw;
  650. text-align: right;
  651. .price {
  652. color: #ff0000;
  653. }
  654. }
  655. }
  656. }
  657. .other {
  658. padding: 0 0 2vw 0;
  659. margin: 2vw 0;
  660. text-align: right;
  661. border-bottom: 1px solid #f1f1f1;
  662. text {
  663. font-size: 14px;
  664. padding: 0 0 0 2vw;
  665. }
  666. }
  667. }
  668. .btn {
  669. text-align: right;
  670. button {
  671. margin: 0 2vw 0 0;
  672. }
  673. }
  674. }
  675. }
  676. }
  677. }
  678. .scroll-view {
  679. position: absolute;
  680. top: 0;
  681. left: 0;
  682. right: 0;
  683. bottom: 0;
  684. .list-scroll-view {
  685. display: flex;
  686. flex-direction: column;
  687. }
  688. }
  689. .is_bottom {
  690. text-align: center;
  691. text {
  692. padding: 2vw 0;
  693. display: inline-block;
  694. color: #858585;
  695. font-size: 14px;
  696. }
  697. }
  698. </style>