index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  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 || '0');
  184. that.searchConfig();
  185. that.searchOther();
  186. that.watchlogin();
  187. },
  188. onPullDownRefresh: async function() {
  189. const that = this;
  190. that.clearPage();
  191. await that.search();
  192. uni.stopPullDownRefresh();
  193. },
  194. methods: {
  195. // 查询基本设置
  196. searchConfig() {
  197. const that = this;
  198. uni.getStorage({
  199. key: 'config',
  200. success: function(res) {
  201. if (res.data) that.$set(that, `config`, res.data)
  202. // 设备平台信息
  203. let config = that.$config;
  204. that.$set(that, `system`, config.system);
  205. },
  206. fail: function(err) {
  207. console.log(err);
  208. }
  209. })
  210. },
  211. // 监听用户是否登录
  212. watchlogin() {
  213. const that = this;
  214. uni.getStorage({
  215. key: 'token',
  216. success: function(res) {
  217. let user = that.$jwt(res.data);
  218. if (user) {
  219. that.$set(that, `user`, user)
  220. that.search();
  221. }
  222. }
  223. })
  224. },
  225. async search() {
  226. const that = this;
  227. let user = that.user;
  228. let status = that.status;
  229. let info = {
  230. skip: that.skip,
  231. limit: that.limit,
  232. customer: user._id,
  233. status: status
  234. }
  235. let res;
  236. if (status == '0') {
  237. res = await that.$api(`/order`, 'GET', {
  238. ...info,
  239. ...that.searchInfo
  240. });
  241. } else {
  242. res = await that.$api(`/orderDetail`, 'GET', {
  243. ...info,
  244. ...that.searchInfo
  245. });
  246. }
  247. if (res.errcode == '0') {
  248. let list = [...that.list, ...res.data];
  249. for (let val of list) {
  250. val.zhStatus = that.searchStatus(val.status)
  251. }
  252. that.$set(that, `list`, list);
  253. that.$set(that, `total`, res.total)
  254. } else {
  255. uni.showToast({
  256. title: res.errmsg,
  257. icon: 'none'
  258. })
  259. }
  260. },
  261. // 查询状态
  262. searchStatus(e) {
  263. const that = this;
  264. let data = that.statusList.find((i) => i.value == e);
  265. if (data) return data.label
  266. else return '暂无'
  267. },
  268. // 分页
  269. toPage(e) {
  270. const that = this;
  271. let list = that.list;
  272. let limit = that.limit;
  273. if (that.total > list.length) {
  274. uni.showLoading({
  275. title: '加载中',
  276. mask: true
  277. })
  278. let page = that.page + 1;
  279. that.$set(that, `page`, page)
  280. let skip = page * limit;
  281. that.$set(that, `skip`, skip)
  282. that.search();
  283. uni.hideLoading();
  284. } else that.$set(that, `is_bottom`, true)
  285. },
  286. toScroll(e) {
  287. const that = this;
  288. let up = that.scrollTop;
  289. that.$set(that, `scrollTop`, e.detail.scrollTop);
  290. let num = Math.sign(up - e.detail.scrollTop);
  291. if (num == 1) that.$set(that, `is_bottom`, false);
  292. },
  293. // 输入框
  294. toInput(e) {
  295. const that = this;
  296. that.$set(that.searchInfo, `name`, e.detail.value)
  297. },
  298. // 订单详细信息
  299. toInfo(item) {
  300. uni.navigateTo({
  301. url: `/pagesMy/order/info?id=${item._id}&status=${item.status}`
  302. })
  303. },
  304. // 取消订单-未支付
  305. toCancel(e) {
  306. const that = this;
  307. uni.showModal({
  308. title: '提示',
  309. content: '确定取消订单吗?',
  310. success: async function(res) {
  311. if (res.confirm) {
  312. const arr = await that.$api(`/order/cancel`, 'POST', {
  313. order_id: e._id
  314. });
  315. if (arr.errcode == '0') {
  316. uni.showToast({
  317. title: '申请取消订单完成',
  318. icon: 'none'
  319. })
  320. that.clearPage();
  321. that.search();
  322. } else {
  323. uni.showToast({
  324. title: arr.errmsg,
  325. icon: 'none'
  326. })
  327. }
  328. }
  329. }
  330. });
  331. },
  332. // 支付
  333. async toPay(e) {
  334. const that = this;
  335. let system = that.system;
  336. if (system.uniPlatform == "mp-weixin") {
  337. uni.showLoading({
  338. title: '加载中'
  339. })
  340. // 支付信息
  341. let p2 = await that.$api('/pay/toPayOrder', 'POST', {
  342. order_id: e,
  343. type: '0'
  344. })
  345. if (p2.errcode == '0' && p2.data.paySign) {
  346. uni.requestPayment({
  347. "provider": "wxpay",
  348. ...p2.data,
  349. success: function(res) {
  350. uni.showToast({
  351. title: '支付成功',
  352. icon: 'none'
  353. })
  354. },
  355. fail: function(err) {
  356. uni.showToast({
  357. title: `支付失败`,
  358. icon: 'none'
  359. })
  360. },
  361. complete: function() {
  362. uni.hideLoading();
  363. that.clearPage();
  364. that.search();
  365. }
  366. })
  367. } else {
  368. uni.showToast({
  369. title: p2.errmsg || '错误信息',
  370. icon: 'none'
  371. })
  372. }
  373. } else if (res.data.uniPlatform == "app") {
  374. // app支付
  375. uni.requestPayment({
  376. provider: 'alipay',
  377. orderInfo: 'orderInfo',
  378. success: function(res) {
  379. console.log('success:' + JSON.stringify(res));
  380. },
  381. fail: function(err) {
  382. console.log('fail:' + JSON.stringify(err));
  383. }
  384. });
  385. } else {
  386. uni.showToast({
  387. title: `平台不支持支付`,
  388. icon: 'none'
  389. })
  390. }
  391. },
  392. // 取消订单-已支付
  393. toCancels(e) {
  394. const that = this;
  395. uni.showModal({
  396. title: '提示',
  397. content: '确定取消订单吗?',
  398. success: async function(res) {
  399. if (res.confirm) {
  400. let arr = await that.$api(`/afterSale`, 'POST', {
  401. order_detail: e._id,
  402. type: '4'
  403. })
  404. if (arr.errcode == '0') {
  405. uni.showToast({
  406. title: '申请取消订单完成',
  407. icon: 'none'
  408. })
  409. that.clearPage();
  410. that.search();
  411. } else {
  412. uni.showToast({
  413. title: arr.errmsg,
  414. icon: 'none'
  415. })
  416. }
  417. }
  418. }
  419. });
  420. },
  421. // 查看物流
  422. toLogi(e) {
  423. uni.navigateTo({
  424. url: `/pagesMy/logistics/index?id=${e._id}`
  425. })
  426. },
  427. // 确认收货
  428. async toConfirm(e) {
  429. const that = this;
  430. uni.showModal({
  431. title: '提示',
  432. content: '确定确认收货吗?',
  433. success: async function(res) {
  434. if (res.confirm) {
  435. const arr = await that.$api(`/orderDetail/${e._id}`, 'POST', {
  436. status: '3'
  437. });
  438. if (arr.errcode == '0') {
  439. uni.showToast({
  440. title: '确认收货成功',
  441. icon: 'none'
  442. })
  443. that.clearPage();
  444. that.search();
  445. } else {
  446. uni.showToast({
  447. title: arr.errmsg,
  448. icon: 'none'
  449. })
  450. }
  451. }
  452. }
  453. });
  454. },
  455. // 申请售后
  456. toAfter(e) {
  457. uni.navigateTo({
  458. url: `/pagesMy/order/service?id=${e._id}&&status=${e.status}`
  459. })
  460. },
  461. // 查询其他信息
  462. async searchOther() {
  463. const that = this;
  464. let res;
  465. // 查询状态
  466. res = await that.$api(`/dictData`, 'GET', {
  467. code: 'order_process'
  468. })
  469. if (res.errcode == '0') {
  470. that.$set(that, `statusList`, res.data);
  471. }
  472. },
  473. // 选择选项卡
  474. tabsChange(e) {
  475. const that = this;
  476. that.$set(that.tabs, `active`, e.active)
  477. that.$set(that, `status`, e.active);
  478. that.clearPage();
  479. that.search()
  480. },
  481. // 清空列表
  482. clearPage() {
  483. const that = this;
  484. that.$set(that, `list`, [])
  485. that.$set(that, `skip`, 0)
  486. that.$set(that, `limit`, 6)
  487. that.$set(that, `page`, 0)
  488. }
  489. },
  490. }
  491. </script>
  492. <style lang="scss">
  493. .main {
  494. display: flex;
  495. flex-direction: column;
  496. width: 100vw;
  497. height: 100vh;
  498. .one {
  499. padding: 2vw;
  500. input {
  501. padding: 2vw;
  502. background-color: var(--f1Color);
  503. font-size: var(--font14Size);
  504. border-radius: 5px;
  505. }
  506. }
  507. .two {
  508. position: relative;
  509. flex-grow: 1;
  510. background-color: var(--f9Color);
  511. .tabsList {
  512. position: relative;
  513. width: 100vw;
  514. height: 82vh;
  515. .list {
  516. background-color: #fff;
  517. border: 1px solid #ff0000;
  518. padding: 2vw;
  519. margin: 0 2vw 2vw 2vw;
  520. border-radius: 5px;
  521. .list_1 {
  522. .status {
  523. text-align: right;
  524. color: var(--ff0Color);
  525. margin: 0 0 1vw 0;
  526. }
  527. .goods {
  528. .goodsList {
  529. border-bottom: 1px solid #f1f1f1;
  530. .shopname {
  531. margin: 0 0 2vw 0;
  532. text:last-child {
  533. padding: 0 0 0 2vw;
  534. }
  535. }
  536. .goodsList_1 {
  537. .market {
  538. display: flex;
  539. padding: 0 0 2vw 0;
  540. .market_1 {
  541. width: 20vw;
  542. height: 20vw;
  543. .image {
  544. width: 100%;
  545. height: 100%;
  546. border-radius: 5px;
  547. }
  548. }
  549. .market_2 {
  550. width: 55vw;
  551. padding: 0 0 0 2vw;
  552. .goodsname {
  553. font-size: 16px;
  554. margin: 0 0 1vw 0;
  555. }
  556. .specs {
  557. font-size: 14px;
  558. color: #858585;
  559. }
  560. }
  561. .market_3 {
  562. width: 15vw;
  563. text-align: right;
  564. }
  565. }
  566. }
  567. }
  568. }
  569. .other {
  570. padding: 0 0 2vw 0;
  571. margin: 2vw 0;
  572. text-align: right;
  573. border-bottom: 1px solid #f1f1f1;
  574. text {
  575. font-size: 14px;
  576. padding: 0 0 0 2vw;
  577. }
  578. }
  579. }
  580. .list_2 {
  581. .list_2_1 {
  582. display: flex;
  583. justify-content: space-between;
  584. margin: 0 0 2vw 0;
  585. .shopname {
  586. text:last-child {
  587. padding: 0 0 0 2vw;
  588. }
  589. }
  590. .status {
  591. color: var(--ff0Color);
  592. }
  593. }
  594. .list_2_2 {
  595. border-bottom: 1px solid #f1f1f1;
  596. .goods {
  597. display: flex;
  598. padding: 0 0 2vw 0;
  599. .goods_1 {
  600. width: 20vw;
  601. height: 20vw;
  602. .image {
  603. width: 100%;
  604. height: 100%;
  605. border-radius: 5px;
  606. }
  607. }
  608. .goods_2 {
  609. width: 55vw;
  610. padding: 0 0 0 2vw;
  611. .goodsname {
  612. font-size: 16px;
  613. margin: 0 0 1vw 0;
  614. }
  615. .specs {
  616. font-size: 14px;
  617. color: #858585;
  618. }
  619. }
  620. .goods_3 {
  621. width: 15vw;
  622. text-align: right;
  623. }
  624. }
  625. }
  626. .other {
  627. padding: 0 0 2vw 0;
  628. margin: 2vw 0;
  629. text-align: right;
  630. border-bottom: 1px solid #f1f1f1;
  631. text {
  632. font-size: 14px;
  633. padding: 0 0 0 2vw;
  634. }
  635. }
  636. }
  637. .btn {
  638. text-align: right;
  639. button {
  640. margin: 0 2vw 0 0;
  641. }
  642. }
  643. }
  644. }
  645. }
  646. }
  647. .scroll-view {
  648. position: absolute;
  649. top: 0;
  650. left: 0;
  651. right: 0;
  652. bottom: 0;
  653. .list-scroll-view {
  654. display: flex;
  655. flex-direction: column;
  656. }
  657. }
  658. .is_bottom {
  659. text-align: center;
  660. text {
  661. padding: 2vw 0;
  662. display: inline-block;
  663. color: #858585;
  664. font-size: 14px;
  665. }
  666. }
  667. </style>