index.vue 18 KB

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