index.vue 17 KB

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