index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  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. if (e.rate) {
  476. uni.navigateTo({
  477. url: `/pagesMy/order/appraise?id=${e._id}&rate_id=${e.rate}`
  478. })
  479. } else {
  480. uni.navigateTo({
  481. url: `/pagesMy/order/appraise?id=${e._id}`
  482. })
  483. }
  484. },
  485. // 申请售后
  486. toAfter(e) {
  487. const that = this;
  488. that.clearPage();
  489. uni.navigateTo({
  490. url: `/pagesMy/order/service?id=${e._id}&&status=${e.status}`
  491. })
  492. },
  493. // 查询其他信息
  494. async searchOther() {
  495. const that = this;
  496. let res;
  497. // 查询状态
  498. res = await that.$api(`/dictData`, 'GET', {
  499. code: 'order_process'
  500. })
  501. if (res.errcode == '0') {
  502. that.$set(that, `statusList`, res.data);
  503. var menu = res.data.map((item) => {
  504. return {
  505. title: item.label,
  506. active: item.value
  507. }
  508. })
  509. that.$set(that.tabs, `menu`, menu)
  510. }
  511. },
  512. // 选择选项卡
  513. tabsChange(e) {
  514. const that = this;
  515. that.$set(that.tabs, `active`, e.active)
  516. that.$set(that, `status`, e.active);
  517. that.clearPage();
  518. that.search()
  519. },
  520. // 清空列表
  521. clearPage() {
  522. const that = this;
  523. that.$set(that, `list`, [])
  524. that.$set(that, `skip`, 0)
  525. that.$set(that, `limit`, 6)
  526. that.$set(that, `page`, 0)
  527. }
  528. },
  529. }
  530. </script>
  531. <style lang="scss">
  532. .main {
  533. display: flex;
  534. flex-direction: column;
  535. width: 100vw;
  536. height: 100vh;
  537. .one {
  538. padding: 2vw;
  539. input {
  540. padding: 2vw;
  541. background-color: var(--f1Color);
  542. font-size: var(--font14Size);
  543. border-radius: 5px;
  544. }
  545. }
  546. .two {
  547. position: relative;
  548. flex-grow: 1;
  549. background-color: var(--f9Color);
  550. .tabsList {
  551. position: relative;
  552. width: 100vw;
  553. height: 82vh;
  554. .list {
  555. background-color: #fff;
  556. border: 1px solid #ff0000;
  557. padding: 2vw;
  558. margin: 0 2vw 2vw 2vw;
  559. border-radius: 5px;
  560. .list_1 {
  561. .goods {
  562. .goodsList {
  563. border-bottom: 1px solid #f1f1f1;
  564. .shopname {
  565. display: flex;
  566. justify-content: space-between;
  567. margin: 0 0 2vw 0;
  568. .shop {
  569. text:last-child {
  570. padding: 0 0 0 2vw;
  571. }
  572. }
  573. .status {
  574. text-align: right;
  575. color: var(--ff0Color);
  576. margin: 0 0 1vw 0;
  577. }
  578. }
  579. .goodsList_1 {
  580. .market {
  581. display: flex;
  582. padding: 0 0 2vw 0;
  583. .market_1 {
  584. width: 20vw;
  585. height: 20vw;
  586. .image {
  587. width: 100%;
  588. height: 100%;
  589. border-radius: 5px;
  590. }
  591. }
  592. .market_2 {
  593. width: 55vw;
  594. padding: 0 0 0 2vw;
  595. .goodsname {
  596. font-size: 16px;
  597. margin: 0 0 1vw 0;
  598. }
  599. .specs {
  600. font-size: 14px;
  601. color: #858585;
  602. }
  603. }
  604. .market_3 {
  605. width: 15vw;
  606. text-align: right;
  607. }
  608. }
  609. }
  610. }
  611. }
  612. .other {
  613. padding: 0 0 2vw 0;
  614. margin: 2vw 0;
  615. text-align: right;
  616. border-bottom: 1px solid #f1f1f1;
  617. text {
  618. font-size: 14px;
  619. padding: 0 0 0 2vw;
  620. }
  621. }
  622. }
  623. .list_2 {
  624. .list_2_1 {
  625. display: flex;
  626. justify-content: space-between;
  627. margin: 0 0 2vw 0;
  628. .shopname {
  629. text:last-child {
  630. padding: 0 0 0 2vw;
  631. }
  632. }
  633. .status {
  634. color: var(--ff0Color);
  635. }
  636. }
  637. .list_2_2 {
  638. border-bottom: 1px solid #f1f1f1;
  639. .goods {
  640. display: flex;
  641. padding: 0 0 2vw 0;
  642. .goods_1 {
  643. width: 20vw;
  644. height: 20vw;
  645. .image {
  646. width: 100%;
  647. height: 100%;
  648. border-radius: 5px;
  649. }
  650. }
  651. .goods_2 {
  652. width: 55vw;
  653. padding: 0 0 0 2vw;
  654. .goodsname {
  655. font-size: 16px;
  656. margin: 0 0 1vw 0;
  657. }
  658. .specs {
  659. font-size: 14px;
  660. color: #858585;
  661. }
  662. }
  663. .goods_3 {
  664. width: 15vw;
  665. text-align: right;
  666. .price {
  667. color: #ff0000;
  668. }
  669. }
  670. }
  671. }
  672. .other {
  673. padding: 0 0 2vw 0;
  674. margin: 2vw 0;
  675. text-align: right;
  676. border-bottom: 1px solid #f1f1f1;
  677. text {
  678. font-size: 14px;
  679. padding: 0 0 0 2vw;
  680. }
  681. }
  682. }
  683. .btn {
  684. text-align: right;
  685. button {
  686. margin: 0 2vw 0 0;
  687. }
  688. }
  689. }
  690. }
  691. }
  692. }
  693. .scroll-view {
  694. position: absolute;
  695. top: 0;
  696. left: 0;
  697. right: 0;
  698. bottom: 0;
  699. .list-scroll-view {
  700. display: flex;
  701. flex-direction: column;
  702. }
  703. }
  704. .is_bottom {
  705. text-align: center;
  706. text {
  707. padding: 2vw 0;
  708. display: inline-block;
  709. color: #858585;
  710. font-size: 14px;
  711. }
  712. }
  713. </style>