index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  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. uni.navigateTo({
  286. url: `/pagesMy/order/info?id=${item._id}&status=${item.status}`
  287. })
  288. },
  289. // 取消订单-未支付
  290. toCancel(e) {
  291. const that = this;
  292. uni.showModal({
  293. title: '提示',
  294. content: '确定取消订单吗?',
  295. success: async function(res) {
  296. if (res.confirm) {
  297. const arr = await that.$api(`/order/cancel`, 'POST', {
  298. order_id: e._id
  299. });
  300. if (arr.errcode == '0') {
  301. uni.showToast({
  302. title: '申请取消订单完成',
  303. icon: 'none'
  304. })
  305. that.clearPage();
  306. that.search();
  307. } else {
  308. uni.showToast({
  309. title: arr.errmsg,
  310. icon: 'none'
  311. })
  312. }
  313. }
  314. }
  315. });
  316. },
  317. // 支付
  318. async toPay(e) {
  319. const that = this;
  320. let system = that.system;
  321. if (system.uniPlatform == "mp-weixin") {
  322. uni.showLoading({
  323. title: '加载中'
  324. })
  325. // 支付信息
  326. let p2 = await that.$api('/pay/toPayOrder', 'POST', {
  327. order_id: e,
  328. type: '0'
  329. })
  330. if (p2.errcode == '0' && p2.data.paySign) {
  331. uni.requestPayment({
  332. "provider": "wxpay",
  333. ...p2.data,
  334. success: function(res) {
  335. uni.showToast({
  336. title: '支付成功',
  337. icon: 'none'
  338. })
  339. },
  340. fail: function(err) {
  341. uni.showToast({
  342. title: `支付失败`,
  343. icon: 'none'
  344. })
  345. },
  346. complete: function() {
  347. uni.hideLoading();
  348. that.clearPage();
  349. that.search();
  350. }
  351. })
  352. } else {
  353. uni.showToast({
  354. title: p2.errmsg || '错误信息',
  355. icon: 'none'
  356. })
  357. }
  358. } else if (res.data.uniPlatform == "app") {
  359. // app支付
  360. uni.requestPayment({
  361. provider: 'alipay',
  362. orderInfo: 'orderInfo',
  363. success: function(res) {
  364. console.log('success:' + JSON.stringify(res));
  365. },
  366. fail: function(err) {
  367. console.log('fail:' + JSON.stringify(err));
  368. }
  369. });
  370. } else {
  371. uni.showToast({
  372. title: `平台不支持支付`,
  373. icon: 'none'
  374. })
  375. }
  376. },
  377. // 取消订单-已支付
  378. toCancels(e) {
  379. const that = this;
  380. uni.showModal({
  381. title: '提示',
  382. content: '确定取消订单吗?',
  383. success: async function(res) {
  384. if (res.confirm) {
  385. let arr = await that.$api(`/afterSale`, 'POST', {
  386. order_detail: e._id,
  387. type: '4'
  388. })
  389. if (arr.errcode == '0') {
  390. uni.showToast({
  391. title: '申请取消订单完成',
  392. icon: 'none'
  393. })
  394. that.clearPage();
  395. that.search();
  396. } else {
  397. uni.showToast({
  398. title: arr.errmsg,
  399. icon: 'none'
  400. })
  401. }
  402. }
  403. }
  404. });
  405. },
  406. // 查看物流
  407. toLogi(e) {
  408. const that = this;
  409. that.clearPage();
  410. uni.navigateTo({
  411. url: `/pagesMy/logistics/index?id=${e._id}`
  412. })
  413. },
  414. // 确认收货
  415. async toConfirm(e) {
  416. const that = this;
  417. uni.showModal({
  418. title: '提示',
  419. content: '确定确认收货吗?',
  420. success: async function(res) {
  421. if (res.confirm) {
  422. const arr = await that.$api(`/orderDetail/${e._id}`, 'POST', {
  423. status: '3'
  424. });
  425. if (arr.errcode == '0') {
  426. uni.showToast({
  427. title: '确认收货成功',
  428. icon: 'none'
  429. })
  430. that.clearPage();
  431. that.search();
  432. } else {
  433. uni.showToast({
  434. title: arr.errmsg,
  435. icon: 'none'
  436. })
  437. }
  438. }
  439. }
  440. });
  441. },
  442. // 拒收
  443. async toReject(e) {
  444. const that = this;
  445. uni.showModal({
  446. title: '提示',
  447. content: '确定拒收快递吗?',
  448. success: async function(res) {
  449. if (res.confirm) {
  450. let arr = await that.$api(`/afterSale`, 'POST', {
  451. order_detail: e._id,
  452. type: '5'
  453. })
  454. if (arr.errcode == '0') {
  455. uni.showToast({
  456. title: '拒收申请完成',
  457. icon: 'none'
  458. })
  459. that.clearPage();
  460. that.search();
  461. } else {
  462. uni.showToast({
  463. title: arr.errmsg,
  464. icon: 'none'
  465. })
  466. }
  467. }
  468. }
  469. });
  470. },
  471. // 立即评价
  472. toAppraise(e) {
  473. const that = this;
  474. that.clearPage();
  475. uni.navigateTo({
  476. url: `/pagesMy/order/appraise?id=${e._id}`
  477. })
  478. },
  479. // 申请售后
  480. toAfter(e) {
  481. const that = this;
  482. that.clearPage();
  483. uni.navigateTo({
  484. url: `/pagesMy/order/service?id=${e._id}&&status=${e.status}`
  485. })
  486. },
  487. // 查询其他信息
  488. async searchOther() {
  489. const that = this;
  490. let res;
  491. // 查询状态
  492. res = await that.$api(`/dictData`, 'GET', {
  493. code: 'order_process'
  494. })
  495. if (res.errcode == '0') {
  496. that.$set(that, `statusList`, res.data);
  497. var menu = res.data.map((item) => {
  498. return {
  499. title: item.label,
  500. active: item.value
  501. }
  502. })
  503. that.$set(that.tabs, `menu`, menu)
  504. }
  505. },
  506. // 选择选项卡
  507. tabsChange(e) {
  508. const that = this;
  509. that.$set(that.tabs, `active`, e.active)
  510. that.$set(that, `status`, e.active);
  511. that.clearPage();
  512. that.search()
  513. },
  514. // 清空列表
  515. clearPage() {
  516. const that = this;
  517. that.$set(that, `list`, [])
  518. that.$set(that, `skip`, 0)
  519. that.$set(that, `limit`, 6)
  520. that.$set(that, `page`, 0)
  521. }
  522. },
  523. }
  524. </script>
  525. <style lang="scss">
  526. .main {
  527. display: flex;
  528. flex-direction: column;
  529. width: 100vw;
  530. height: 100vh;
  531. .one {
  532. padding: 2vw;
  533. input {
  534. padding: 2vw;
  535. background-color: var(--f1Color);
  536. font-size: var(--font14Size);
  537. border-radius: 5px;
  538. }
  539. }
  540. .two {
  541. position: relative;
  542. flex-grow: 1;
  543. background-color: var(--f9Color);
  544. .tabsList {
  545. position: relative;
  546. width: 100vw;
  547. height: 82vh;
  548. .list {
  549. background-color: #fff;
  550. border: 1px solid #ff0000;
  551. padding: 2vw;
  552. margin: 0 2vw 2vw 2vw;
  553. border-radius: 5px;
  554. .list_1 {
  555. .goods {
  556. .goodsList {
  557. border-bottom: 1px solid #f1f1f1;
  558. .shopname {
  559. display: flex;
  560. justify-content: space-between;
  561. margin: 0 0 2vw 0;
  562. .shop {
  563. text:last-child {
  564. padding: 0 0 0 2vw;
  565. }
  566. }
  567. .status {
  568. text-align: right;
  569. color: var(--ff0Color);
  570. margin: 0 0 1vw 0;
  571. }
  572. }
  573. .goodsList_1 {
  574. .market {
  575. display: flex;
  576. padding: 0 0 2vw 0;
  577. .market_1 {
  578. width: 20vw;
  579. height: 20vw;
  580. .image {
  581. width: 100%;
  582. height: 100%;
  583. border-radius: 5px;
  584. }
  585. }
  586. .market_2 {
  587. width: 55vw;
  588. padding: 0 0 0 2vw;
  589. .goodsname {
  590. font-size: 16px;
  591. margin: 0 0 1vw 0;
  592. }
  593. .specs {
  594. font-size: 14px;
  595. color: #858585;
  596. }
  597. }
  598. .market_3 {
  599. width: 15vw;
  600. text-align: right;
  601. }
  602. }
  603. }
  604. }
  605. }
  606. .other {
  607. padding: 0 0 2vw 0;
  608. margin: 2vw 0;
  609. text-align: right;
  610. border-bottom: 1px solid #f1f1f1;
  611. text {
  612. font-size: 14px;
  613. padding: 0 0 0 2vw;
  614. }
  615. }
  616. }
  617. .list_2 {
  618. .list_2_1 {
  619. display: flex;
  620. justify-content: space-between;
  621. margin: 0 0 2vw 0;
  622. .shopname {
  623. text:last-child {
  624. padding: 0 0 0 2vw;
  625. }
  626. }
  627. .status {
  628. color: var(--ff0Color);
  629. }
  630. }
  631. .list_2_2 {
  632. border-bottom: 1px solid #f1f1f1;
  633. .goods {
  634. display: flex;
  635. padding: 0 0 2vw 0;
  636. .goods_1 {
  637. width: 20vw;
  638. height: 20vw;
  639. .image {
  640. width: 100%;
  641. height: 100%;
  642. border-radius: 5px;
  643. }
  644. }
  645. .goods_2 {
  646. width: 55vw;
  647. padding: 0 0 0 2vw;
  648. .goodsname {
  649. font-size: 16px;
  650. margin: 0 0 1vw 0;
  651. }
  652. .specs {
  653. font-size: 14px;
  654. color: #858585;
  655. }
  656. }
  657. .goods_3 {
  658. width: 15vw;
  659. text-align: right;
  660. .price {
  661. color: #ff0000;
  662. }
  663. }
  664. }
  665. }
  666. .other {
  667. padding: 0 0 2vw 0;
  668. margin: 2vw 0;
  669. text-align: right;
  670. border-bottom: 1px solid #f1f1f1;
  671. text {
  672. font-size: 14px;
  673. padding: 0 0 0 2vw;
  674. }
  675. }
  676. }
  677. .btn {
  678. text-align: right;
  679. button {
  680. margin: 0 2vw 0 0;
  681. }
  682. }
  683. }
  684. }
  685. }
  686. }
  687. .scroll-view {
  688. position: absolute;
  689. top: 0;
  690. left: 0;
  691. right: 0;
  692. bottom: 0;
  693. .list-scroll-view {
  694. display: flex;
  695. flex-direction: column;
  696. }
  697. }
  698. .is_bottom {
  699. text-align: center;
  700. text {
  701. padding: 2vw 0;
  702. display: inline-block;
  703. color: #858585;
  704. font-size: 14px;
  705. }
  706. }
  707. </style>