index.vue 16 KB

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