index.vue 17 KB

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