index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  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 = that.$api(`/afterSale`, 'POST', {
  401. order_detail: e._id,
  402. type: '4'
  403. })
  404. if (res.errcode == '0') {
  405. console.log(res);
  406. } else {
  407. uni.showToast({
  408. title: res.errmsg,
  409. icon: 'none'
  410. })
  411. }
  412. }
  413. }
  414. });
  415. },
  416. // 查看物流
  417. toLogi(e) {
  418. uni.navigateTo({
  419. url: `/pagesMy/logistics/index?id=${e._id}`
  420. })
  421. },
  422. // 确认收货
  423. async toConfirm(e) {
  424. const that = this;
  425. uni.showModal({
  426. title: '提示',
  427. content: '确定确认收货吗?',
  428. success: async function(res) {
  429. if (res.confirm) {
  430. const arr = await that.$api(`/orderDetail/${e._id}`, 'POST', {
  431. status: '3'
  432. });
  433. if (arr.errcode == '0') {
  434. uni.showToast({
  435. title: '确认收货成功',
  436. icon: 'none'
  437. })
  438. that.clearPage();
  439. that.search();
  440. } else {
  441. uni.showToast({
  442. title: arr.errmsg,
  443. icon: 'none'
  444. })
  445. }
  446. }
  447. }
  448. });
  449. },
  450. // 申请售后
  451. toAfter(e) {
  452. uni.navigateTo({
  453. url: `/pagesMy/order/service?id=${e._id}&&status=${e.status}`
  454. })
  455. },
  456. // 查询其他信息
  457. async searchOther() {
  458. const that = this;
  459. let res;
  460. // 查询状态
  461. res = await that.$api(`/dictData`, 'GET', {
  462. code: 'order_process'
  463. })
  464. if (res.errcode == '0') {
  465. that.$set(that, `statusList`, res.data);
  466. }
  467. },
  468. // 选择选项卡
  469. tabsChange(e) {
  470. const that = this;
  471. that.$set(that.tabs, `active`, e.active)
  472. that.$set(that, `status`, e.active);
  473. that.clearPage();
  474. that.search()
  475. },
  476. // 清空列表
  477. clearPage() {
  478. const that = this;
  479. that.$set(that, `list`, [])
  480. that.$set(that, `skip`, 0)
  481. that.$set(that, `limit`, 6)
  482. that.$set(that, `page`, 0)
  483. }
  484. },
  485. }
  486. </script>
  487. <style lang="scss">
  488. .main {
  489. display: flex;
  490. flex-direction: column;
  491. width: 100vw;
  492. height: 100vh;
  493. .one {
  494. padding: 2vw;
  495. input {
  496. padding: 2vw;
  497. background-color: var(--f1Color);
  498. font-size: var(--font14Size);
  499. border-radius: 5px;
  500. }
  501. }
  502. .two {
  503. position: relative;
  504. flex-grow: 1;
  505. background-color: var(--f9Color);
  506. .tabsList {
  507. position: relative;
  508. width: 100vw;
  509. height: 82vh;
  510. .list {
  511. background-color: #fff;
  512. border: 1px solid #ff0000;
  513. padding: 2vw;
  514. margin: 0 2vw 2vw 2vw;
  515. border-radius: 5px;
  516. .list_1 {
  517. .status {
  518. text-align: right;
  519. color: var(--ff0Color);
  520. margin: 0 0 1vw 0;
  521. }
  522. .goods {
  523. .goodsList {
  524. border-bottom: 1px solid #f1f1f1;
  525. .shopname {
  526. margin: 0 0 2vw 0;
  527. text:last-child {
  528. padding: 0 0 0 2vw;
  529. }
  530. }
  531. .goodsList_1 {
  532. .market {
  533. display: flex;
  534. padding: 0 0 2vw 0;
  535. .market_1 {
  536. width: 20vw;
  537. height: 20vw;
  538. .image {
  539. width: 100%;
  540. height: 100%;
  541. border-radius: 5px;
  542. }
  543. }
  544. .market_2 {
  545. width: 55vw;
  546. padding: 0 0 0 2vw;
  547. .goodsname {
  548. font-size: 16px;
  549. margin: 0 0 1vw 0;
  550. }
  551. .specs {
  552. font-size: 14px;
  553. color: #858585;
  554. }
  555. }
  556. .market_3 {
  557. width: 15vw;
  558. text-align: right;
  559. }
  560. }
  561. }
  562. }
  563. }
  564. .other {
  565. padding: 0 0 2vw 0;
  566. margin: 2vw 0;
  567. text-align: right;
  568. border-bottom: 1px solid #f1f1f1;
  569. text {
  570. font-size: 14px;
  571. padding: 0 0 0 2vw;
  572. }
  573. }
  574. }
  575. .list_2 {
  576. .list_2_1 {
  577. display: flex;
  578. justify-content: space-between;
  579. margin: 0 0 2vw 0;
  580. .shopname {
  581. text:last-child {
  582. padding: 0 0 0 2vw;
  583. }
  584. }
  585. .status {
  586. color: var(--ff0Color);
  587. }
  588. }
  589. .list_2_2 {
  590. border-bottom: 1px solid #f1f1f1;
  591. .goods {
  592. display: flex;
  593. padding: 0 0 2vw 0;
  594. .goods_1 {
  595. width: 20vw;
  596. height: 20vw;
  597. .image {
  598. width: 100%;
  599. height: 100%;
  600. border-radius: 5px;
  601. }
  602. }
  603. .goods_2 {
  604. width: 55vw;
  605. padding: 0 0 0 2vw;
  606. .goodsname {
  607. font-size: 16px;
  608. margin: 0 0 1vw 0;
  609. }
  610. .specs {
  611. font-size: 14px;
  612. color: #858585;
  613. }
  614. }
  615. .goods_3 {
  616. width: 15vw;
  617. text-align: right;
  618. }
  619. }
  620. }
  621. .other {
  622. padding: 0 0 2vw 0;
  623. margin: 2vw 0;
  624. text-align: right;
  625. border-bottom: 1px solid #f1f1f1;
  626. text {
  627. font-size: 14px;
  628. padding: 0 0 0 2vw;
  629. }
  630. }
  631. }
  632. .btn {
  633. text-align: right;
  634. button {
  635. margin: 0 2vw 0 0;
  636. }
  637. }
  638. }
  639. }
  640. }
  641. }
  642. .scroll-view {
  643. position: absolute;
  644. top: 0;
  645. left: 0;
  646. right: 0;
  647. bottom: 0;
  648. .list-scroll-view {
  649. display: flex;
  650. flex-direction: column;
  651. }
  652. }
  653. .is_bottom {
  654. text-align: center;
  655. text {
  656. padding: 2vw 0;
  657. display: inline-block;
  658. color: #858585;
  659. font-size: 14px;
  660. }
  661. }
  662. </style>