index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  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||tags.sell_money}}
  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. <text v-if="tag.gift.length>0" class="gift">赠品</text>
  86. <text v-if="tag.sp_price" class="act">特价</text>
  87. </view>
  88. <view class="goods_3">
  89. <view v-if="item.type=='0'" class="price">
  90. ¥{{tag.price||tag.sell_money}}
  91. </view>
  92. <view v-else class="price">
  93. ¥{{tag.group_config.money}}
  94. </view>
  95. <view class="num">
  96. ×{{tag.buy_num}}
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. <view class="other">
  102. <text>共{{item.buy_num_total||0}}件商品</text>
  103. <text>实付款¥{{item.real_pay}}</text>
  104. </view>
  105. </view>
  106. <view class="btn">
  107. <button v-if="item.status=='0'" size="mini"
  108. @tap.stop="toCancel(item)">取消订单</button>
  109. <button v-if="item.status=='0'" size="mini" @tap.stop="toPay(item)">支付</button>
  110. <button v-if="item.status=='1'&&item.is_afterSale!=true" size="mini"
  111. @tap.stop="toCancels(item)">取消订单</button>
  112. <button v-if="item.status=='2'||item.status=='3'||item.status=='2-'" size="mini"
  113. @tap.stop="toLogi(item)">查看物流</button>
  114. <button v-if="item.status=='2'&&item.is_afterSale!=true" size="mini"
  115. @tap.stop="toConfirm(item)">确认收货</button>
  116. <button v-if="item.status=='2'||item.status=='2-'&&item.is_afterSale!=true"
  117. size="mini" @tap.stop="toReject(item)">拒收</button>
  118. <button v-if="item.status=='3'" size="mini"
  119. @tap.stop="toAfter(item)">申请售后</button>
  120. <button v-if="item.status=='3'" type="default" size="mini"
  121. @tap.stop="toAppraise(item)">{{item.rate?'追加评价':'立即评价'}}</button>
  122. </view>
  123. </view>
  124. <view class="is_bottom" v-if="is_bottom">
  125. <text>{{config.bottom_title}}</text>
  126. </view>
  127. </view>
  128. </scroll-view>
  129. </view>
  130. </tabs>
  131. </view>
  132. </view>
  133. </mobile-frame>
  134. </template>
  135. <script>
  136. import tabs from '@/components/tabs/index.vue';
  137. export default {
  138. components: {
  139. tabs
  140. },
  141. data() {
  142. return {
  143. // 系统设置
  144. config: {},
  145. // 设备信息
  146. system: {},
  147. user: {},
  148. status: '',
  149. searchInfo: {},
  150. tabs: {
  151. active: '0',
  152. menu: []
  153. },
  154. list: [],
  155. total: 0,
  156. skip: 0,
  157. limit: 6,
  158. page: 0,
  159. // 数据是否触底
  160. is_bottom: false,
  161. scrollTop: 0,
  162. // 字典表
  163. statusList: []
  164. };
  165. },
  166. onLoad: function(e) {
  167. const that = this;
  168. that.$set(that, `status`, e.status || '');
  169. that.$set(that.tabs, `active`, e.status || '');
  170. that.searchConfig();
  171. },
  172. onShow: async function(e) {
  173. const that = this;
  174. await that.searchOther();
  175. await that.watchlogin();
  176. },
  177. onPullDownRefresh: async function() {
  178. const that = this;
  179. that.clearPage();
  180. await that.search();
  181. uni.stopPullDownRefresh();
  182. },
  183. methods: {
  184. // 查询基本设置
  185. searchConfig() {
  186. const that = this;
  187. uni.getStorage({
  188. key: 'config',
  189. success: function(res) {
  190. if (res.data) that.$set(that, `config`, res.data)
  191. // 设备平台信息
  192. let config = that.$config;
  193. that.$set(that, `system`, config.system);
  194. },
  195. fail: function(err) {
  196. console.log(err);
  197. }
  198. })
  199. },
  200. // 监听用户是否登录
  201. watchlogin() {
  202. const that = this;
  203. uni.getStorage({
  204. key: 'token',
  205. success: function(res) {
  206. let user = that.$jwt(res.data);
  207. if (user) {
  208. that.$set(that, `user`, user)
  209. that.search();
  210. }
  211. }
  212. })
  213. },
  214. async search() {
  215. const that = this;
  216. let user = that.user;
  217. let status = that.status;
  218. let info = {
  219. skip: that.skip,
  220. limit: that.limit,
  221. customer: user._id,
  222. status: status
  223. }
  224. let res;
  225. if (status == '0') {
  226. res = await that.$api(`/order`, 'GET', {
  227. ...info,
  228. ...that.searchInfo
  229. });
  230. } else {
  231. res = await that.$api(`/orderDetail`, 'GET', {
  232. ...info,
  233. ...that.searchInfo
  234. });
  235. }
  236. if (res.errcode == '0') {
  237. let list = [...that.list, ...res.data];
  238. for (let val of list) {
  239. val.zhStatus = that.searchStatus(val.status)
  240. }
  241. that.$set(that, `list`, list);
  242. that.$set(that, `total`, res.total)
  243. } else {
  244. uni.showToast({
  245. title: res.errmsg,
  246. icon: 'none'
  247. })
  248. }
  249. },
  250. // 查询状态
  251. searchStatus(e) {
  252. const that = this;
  253. let data = that.statusList.find((i) => i.value == e);
  254. if (data) return data.label
  255. else return '暂无'
  256. },
  257. // 分页
  258. toPage(e) {
  259. const that = this;
  260. let list = that.list;
  261. let limit = that.limit;
  262. if (that.total > list.length) {
  263. uni.showLoading({
  264. title: '加载中',
  265. mask: true
  266. })
  267. let page = that.page + 1;
  268. that.$set(that, `page`, page)
  269. let skip = page * limit;
  270. that.$set(that, `skip`, skip)
  271. that.search();
  272. uni.hideLoading();
  273. } else that.$set(that, `is_bottom`, true)
  274. },
  275. toScroll(e) {
  276. const that = this;
  277. let up = that.scrollTop;
  278. that.$set(that, `scrollTop`, e.detail.scrollTop);
  279. let num = Math.sign(up - e.detail.scrollTop);
  280. if (num == 1) that.$set(that, `is_bottom`, false);
  281. },
  282. // 输入框
  283. toInput(e) {
  284. const that = this;
  285. if (that.searchInfo.goods) that.$set(that.searchInfo, `goods`, e.detail.value)
  286. else that.$set(that, `searchInfo`, {})
  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}&type=${'order'}`
  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}&status=${'0'}`
  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. margin: 0 1vw 0 0;
  608. font-size: 12px;
  609. color: #FFA500;
  610. border: 1px solid #FFA500;
  611. border-radius: 5px;
  612. padding: 0 1vw;
  613. }
  614. .act {
  615. font-size: 12px;
  616. border: 1px solid var(--fFB1Color);
  617. color: var(--fFB1Color);
  618. border-radius: 5px;
  619. padding: 0 1vw;
  620. }
  621. }
  622. .market_3 {
  623. width: 15vw;
  624. text-align: right;
  625. .price {
  626. color: #ff0000;
  627. }
  628. }
  629. }
  630. }
  631. }
  632. }
  633. .other {
  634. padding: 0 0 2vw 0;
  635. margin: 2vw 0;
  636. text-align: right;
  637. border-bottom: 1px solid #f1f1f1;
  638. text {
  639. font-size: 14px;
  640. padding: 0 0 0 2vw;
  641. }
  642. }
  643. }
  644. .list_2 {
  645. .list_2_1 {
  646. display: flex;
  647. justify-content: space-between;
  648. margin: 0 0 2vw 0;
  649. .shopname {
  650. text:last-child {
  651. padding: 0 0 0 2vw;
  652. }
  653. }
  654. .status {
  655. color: var(--ff0Color);
  656. }
  657. }
  658. .list_2_2 {
  659. border-bottom: 1px solid #f1f1f1;
  660. .goods {
  661. display: flex;
  662. padding: 0 0 2vw 0;
  663. .goods_1 {
  664. width: 20vw;
  665. height: 20vw;
  666. .image {
  667. width: 100%;
  668. height: 100%;
  669. border-radius: 5px;
  670. }
  671. }
  672. .goods_2 {
  673. width: 55vw;
  674. padding: 0 0 0 2vw;
  675. .goodsname {
  676. font-size: 16px;
  677. margin: 0 0 1vw 0;
  678. }
  679. .specs {
  680. font-size: 14px;
  681. color: #858585;
  682. }
  683. .gift {
  684. margin: 0 1vw 0 0;
  685. font-size: 12px;
  686. color: #FFA500;
  687. border: 1px solid #FFA500;
  688. border-radius: 5px;
  689. padding: 0 1vw;
  690. }
  691. .act {
  692. font-size: 12px;
  693. border: 1px solid var(--fFB1Color);
  694. color: var(--fFB1Color);
  695. border-radius: 5px;
  696. padding: 0 1vw;
  697. }
  698. }
  699. .goods_3 {
  700. width: 15vw;
  701. text-align: right;
  702. .price {
  703. color: #ff0000;
  704. }
  705. }
  706. }
  707. }
  708. .other {
  709. padding: 0 0 2vw 0;
  710. margin: 2vw 0;
  711. text-align: right;
  712. border-bottom: 1px solid #f1f1f1;
  713. text {
  714. font-size: 14px;
  715. padding: 0 0 0 2vw;
  716. }
  717. }
  718. }
  719. .btn {
  720. text-align: right;
  721. button {
  722. margin: 0 2vw 0 0;
  723. }
  724. }
  725. }
  726. }
  727. }
  728. }
  729. .scroll-view {
  730. position: absolute;
  731. top: 0;
  732. left: 0;
  733. right: 0;
  734. bottom: 0;
  735. .list-scroll-view {
  736. display: flex;
  737. flex-direction: column;
  738. }
  739. }
  740. .is_bottom {
  741. text-align: center;
  742. text {
  743. padding: 2vw 0;
  744. display: inline-block;
  745. color: #858585;
  746. font-size: 14px;
  747. }
  748. }
  749. </style>