index.vue 18 KB

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