index.vue 17 KB

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