index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  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'" :disabled="disabled" 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. disabled:false
  165. };
  166. },
  167. onLoad: function(e) {
  168. const that = this;
  169. that.$set(that, `status`, e.status || '');
  170. that.$set(that.tabs, `active`, e.status || '');
  171. that.searchConfig();
  172. },
  173. onShow: async function(e) {
  174. const that = this;
  175. await that.searchOther();
  176. await that.watchlogin();
  177. },
  178. onPullDownRefresh: async function() {
  179. const that = this;
  180. that.clearPage();
  181. await that.search();
  182. uni.stopPullDownRefresh();
  183. },
  184. methods: {
  185. // 查询基本设置
  186. searchConfig() {
  187. const that = this;
  188. uni.getStorage({
  189. key: 'config',
  190. success: function(res) {
  191. if (res.data) that.$set(that, `config`, res.data)
  192. // 设备平台信息
  193. let config = that.$config;
  194. that.$set(that, `system`, config.system);
  195. },
  196. fail: function(err) {
  197. console.log(err);
  198. }
  199. })
  200. },
  201. // 监听用户是否登录
  202. watchlogin() {
  203. const that = this;
  204. uni.getStorage({
  205. key: 'token',
  206. success: function(res) {
  207. let user = that.$jwt(res.data);
  208. if (user) {
  209. that.$set(that, `user`, user)
  210. that.search();
  211. }
  212. }
  213. })
  214. },
  215. async search() {
  216. const that = this;
  217. let user = that.user;
  218. let status = that.status;
  219. let info = {
  220. skip: that.skip,
  221. limit: that.limit,
  222. customer: user._id,
  223. status: status
  224. }
  225. let res;
  226. if (status == '0') {
  227. res = await that.$api(`/order`, 'GET', {
  228. ...info,
  229. ...that.searchInfo
  230. });
  231. } else {
  232. res = await that.$api(`/orderDetail`, 'GET', {
  233. ...info,
  234. ...that.searchInfo
  235. });
  236. }
  237. if (res.errcode == '0') {
  238. let list = [...that.list, ...res.data];
  239. for (let val of list) {
  240. val.zhStatus = that.searchStatus(val.status)
  241. }
  242. that.$set(that, `list`, list);
  243. that.$set(that, `total`, res.total)
  244. } else {
  245. uni.showToast({
  246. title: res.errmsg,
  247. icon: 'none'
  248. })
  249. }
  250. },
  251. // 查询状态
  252. searchStatus(e) {
  253. const that = this;
  254. let data = that.statusList.find((i) => i.value == e);
  255. if (data) return data.label
  256. else return '暂无'
  257. },
  258. // 分页
  259. toPage(e) {
  260. const that = this;
  261. let list = that.list;
  262. let limit = that.limit;
  263. if (that.total > list.length) {
  264. uni.showLoading({
  265. title: '加载中',
  266. mask: true
  267. })
  268. let page = that.page + 1;
  269. that.$set(that, `page`, page)
  270. let skip = page * limit;
  271. that.$set(that, `skip`, skip)
  272. that.search();
  273. uni.hideLoading();
  274. } else that.$set(that, `is_bottom`, true)
  275. },
  276. toScroll(e) {
  277. const that = this;
  278. let up = that.scrollTop;
  279. that.$set(that, `scrollTop`, e.detail.scrollTop);
  280. let num = Math.sign(up - e.detail.scrollTop);
  281. if (num == 1) that.$set(that, `is_bottom`, false);
  282. },
  283. // 输入框
  284. toInput(e) {
  285. const that = this;
  286. if (that.searchInfo.goods) that.$set(that.searchInfo, `goods`, e.detail.value)
  287. else that.$set(that, `searchInfo`, {})
  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. that.$set(that, `disabled`, false)
  352. uni.showToast({
  353. title: `支付失败`,
  354. icon: 'none'
  355. })
  356. },
  357. complete: function() {
  358. uni.hideLoading();
  359. that.clearPage();
  360. that.search();
  361. }
  362. })
  363. } else {
  364. uni.showToast({
  365. title: p2.errmsg || '错误信息',
  366. icon: 'none'
  367. })
  368. }
  369. } else if (res.data.uniPlatform == "app") {
  370. // app支付
  371. uni.requestPayment({
  372. provider: 'alipay',
  373. orderInfo: 'orderInfo',
  374. success: function(res) {
  375. console.log('success:' + JSON.stringify(res));
  376. },
  377. fail: function(err) {
  378. console.log('fail:' + JSON.stringify(err));
  379. }
  380. });
  381. } else {
  382. uni.showToast({
  383. title: `平台不支持支付`,
  384. icon: 'none'
  385. })
  386. }
  387. },
  388. // 取消订单-已支付
  389. toCancels(e) {
  390. const that = this;
  391. uni.showModal({
  392. title: '提示',
  393. content: '确定取消订单吗?',
  394. success: async function(res) {
  395. if (res.confirm) {
  396. let arr = await that.$api(`/afterSale`, 'POST', {
  397. order_detail: e._id,
  398. type: '4'
  399. })
  400. if (arr.errcode == '0') {
  401. uni.showToast({
  402. title: '申请取消订单完成',
  403. icon: 'none'
  404. })
  405. that.clearPage();
  406. that.search();
  407. } else {
  408. uni.showToast({
  409. title: arr.errmsg,
  410. icon: 'none'
  411. })
  412. }
  413. }
  414. }
  415. });
  416. },
  417. // 查看物流
  418. toLogi(e) {
  419. const that = this;
  420. that.clearPage();
  421. uni.navigateTo({
  422. url: `/pagesMy/logistics/index?id=${e._id}&type=${'order'}`
  423. })
  424. },
  425. // 确认收货
  426. async toConfirm(e) {
  427. const that = this;
  428. uni.showModal({
  429. title: '提示',
  430. content: '确定确认收货吗?',
  431. success: async function(res) {
  432. if (res.confirm) {
  433. const arr = await that.$api(`/orderDetail/${e._id}`, 'POST', {
  434. status: '3'
  435. });
  436. if (arr.errcode == '0') {
  437. uni.showToast({
  438. title: '确认收货成功',
  439. icon: 'none'
  440. })
  441. that.clearPage();
  442. that.search();
  443. } else {
  444. uni.showToast({
  445. title: arr.errmsg,
  446. icon: 'none'
  447. })
  448. }
  449. }
  450. }
  451. });
  452. },
  453. // 拒收
  454. async toReject(e) {
  455. const that = this;
  456. uni.showModal({
  457. title: '提示',
  458. content: '确定拒收快递吗?',
  459. success: async function(res) {
  460. if (res.confirm) {
  461. let arr = await that.$api(`/afterSale`, 'POST', {
  462. order_detail: e._id,
  463. type: '5'
  464. })
  465. if (arr.errcode == '0') {
  466. uni.showToast({
  467. title: '拒收申请完成',
  468. icon: 'none'
  469. })
  470. that.clearPage();
  471. that.search();
  472. } else {
  473. uni.showToast({
  474. title: arr.errmsg,
  475. icon: 'none'
  476. })
  477. }
  478. }
  479. }
  480. });
  481. },
  482. // 立即评价
  483. toAppraise(e) {
  484. const that = this;
  485. that.clearPage();
  486. uni.navigateTo({
  487. url: `/pagesMy/order/appraise?id=${e._id}&status=${'0'}`
  488. })
  489. },
  490. // 申请售后
  491. toAfter(e) {
  492. const that = this;
  493. that.clearPage();
  494. uni.navigateTo({
  495. url: `/pagesMy/order/service?id=${e._id}&status=${e.status}`
  496. })
  497. },
  498. // 查询其他信息
  499. async searchOther() {
  500. const that = this;
  501. let res;
  502. // 查询状态
  503. res = await that.$api(`/dictData`, 'GET', {
  504. code: 'order_process'
  505. })
  506. if (res.errcode == '0') {
  507. that.$set(that, `statusList`, res.data);
  508. var menu = res.data.map((item) => {
  509. return {
  510. title: item.label,
  511. active: item.value
  512. }
  513. })
  514. that.$set(that.tabs, `menu`, menu)
  515. }
  516. },
  517. // 选择选项卡
  518. tabsChange(e) {
  519. const that = this;
  520. that.$set(that.tabs, `active`, e.active)
  521. that.$set(that, `status`, e.active);
  522. that.clearPage();
  523. that.search()
  524. },
  525. // 清空列表
  526. clearPage() {
  527. const that = this;
  528. that.$set(that, `list`, [])
  529. that.$set(that, `skip`, 0)
  530. that.$set(that, `limit`, 6)
  531. that.$set(that, `page`, 0)
  532. }
  533. },
  534. }
  535. </script>
  536. <style lang="scss">
  537. .main {
  538. display: flex;
  539. flex-direction: column;
  540. width: 100vw;
  541. height: 100vh;
  542. .one {
  543. padding: 2vw;
  544. input {
  545. padding: 2vw;
  546. background-color: var(--f1Color);
  547. font-size: var(--font14Size);
  548. border-radius: 5px;
  549. }
  550. }
  551. .two {
  552. position: relative;
  553. flex-grow: 1;
  554. background-color: var(--f9Color);
  555. .tabsList {
  556. position: relative;
  557. width: 100vw;
  558. height: 82vh;
  559. .list {
  560. background-color: #fff;
  561. border: 1px solid var(--f5Color);
  562. padding: 2vw;
  563. margin: 0 2vw 2vw 2vw;
  564. border-radius: 5px;
  565. .list_1 {
  566. .goods {
  567. .goodsList {
  568. border-bottom: 1px solid #f1f1f1;
  569. .shopname {
  570. display: flex;
  571. justify-content: space-between;
  572. margin: 0 0 2vw 0;
  573. .shop {
  574. text:last-child {
  575. padding: 0 0 0 2vw;
  576. }
  577. }
  578. .status {
  579. text-align: right;
  580. color: var(--ff0Color);
  581. margin: 0 0 1vw 0;
  582. }
  583. }
  584. .goodsList_1 {
  585. .market {
  586. display: flex;
  587. padding: 0 0 2vw 0;
  588. .market_1 {
  589. width: 20vw;
  590. height: 20vw;
  591. .image {
  592. width: 100%;
  593. height: 100%;
  594. border-radius: 5px;
  595. }
  596. }
  597. .market_2 {
  598. width: 55vw;
  599. padding: 0 0 0 2vw;
  600. .goodsname {
  601. font-size: 16px;
  602. margin: 0 0 1vw 0;
  603. }
  604. .specs {
  605. font-size: 14px;
  606. color: #858585;
  607. }
  608. .gift {
  609. margin: 0 1vw 0 0;
  610. font-size: 12px;
  611. color: #FFA500;
  612. border: 1px solid #FFA500;
  613. border-radius: 5px;
  614. padding: 0 1vw;
  615. }
  616. .act {
  617. font-size: 12px;
  618. border: 1px solid var(--fFB1Color);
  619. color: var(--fFB1Color);
  620. border-radius: 5px;
  621. padding: 0 1vw;
  622. }
  623. }
  624. .market_3 {
  625. width: 15vw;
  626. text-align: right;
  627. .price {
  628. color: #ff0000;
  629. }
  630. }
  631. }
  632. }
  633. }
  634. }
  635. .other {
  636. padding: 0 0 2vw 0;
  637. margin: 2vw 0;
  638. text-align: right;
  639. border-bottom: 1px solid #f1f1f1;
  640. text {
  641. font-size: 14px;
  642. padding: 0 0 0 2vw;
  643. }
  644. }
  645. }
  646. .list_2 {
  647. .list_2_1 {
  648. display: flex;
  649. justify-content: space-between;
  650. margin: 0 0 2vw 0;
  651. .shopname {
  652. text:last-child {
  653. padding: 0 0 0 2vw;
  654. }
  655. }
  656. .status {
  657. color: var(--ff0Color);
  658. }
  659. }
  660. .list_2_2 {
  661. border-bottom: 1px solid #f1f1f1;
  662. .goods {
  663. display: flex;
  664. padding: 0 0 2vw 0;
  665. .goods_1 {
  666. width: 20vw;
  667. height: 20vw;
  668. .image {
  669. width: 100%;
  670. height: 100%;
  671. border-radius: 5px;
  672. }
  673. }
  674. .goods_2 {
  675. width: 55vw;
  676. padding: 0 0 0 2vw;
  677. .goodsname {
  678. font-size: 16px;
  679. margin: 0 0 1vw 0;
  680. }
  681. .specs {
  682. font-size: 14px;
  683. color: #858585;
  684. }
  685. .gift {
  686. margin: 0 1vw 0 0;
  687. font-size: 12px;
  688. color: #FFA500;
  689. border: 1px solid #FFA500;
  690. border-radius: 5px;
  691. padding: 0 1vw;
  692. }
  693. .act {
  694. font-size: 12px;
  695. border: 1px solid var(--fFB1Color);
  696. color: var(--fFB1Color);
  697. border-radius: 5px;
  698. padding: 0 1vw;
  699. }
  700. }
  701. .goods_3 {
  702. width: 15vw;
  703. text-align: right;
  704. .price {
  705. color: #ff0000;
  706. }
  707. }
  708. }
  709. }
  710. .other {
  711. padding: 0 0 2vw 0;
  712. margin: 2vw 0;
  713. text-align: right;
  714. border-bottom: 1px solid #f1f1f1;
  715. text {
  716. font-size: 14px;
  717. padding: 0 0 0 2vw;
  718. }
  719. }
  720. }
  721. .btn {
  722. text-align: right;
  723. button {
  724. margin: 0 2vw 0 0;
  725. }
  726. }
  727. }
  728. }
  729. }
  730. }
  731. .scroll-view {
  732. position: absolute;
  733. top: 0;
  734. left: 0;
  735. right: 0;
  736. bottom: 0;
  737. .list-scroll-view {
  738. display: flex;
  739. flex-direction: column;
  740. }
  741. }
  742. .is_bottom {
  743. text-align: center;
  744. text {
  745. padding: 2vw 0;
  746. display: inline-block;
  747. color: #858585;
  748. font-size: 14px;
  749. }
  750. }
  751. </style>