index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902
  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=='2'||item.status=='3'" size="mini" @tap.stop="toLogi(item)">查看物流</button>
  101. </view>
  102. </view>
  103. <view class="is_bottom" v-if="is_bottom">
  104. <text>{{config.bottom_title}}</text>
  105. </view>
  106. </view>
  107. </scroll-view>
  108. </view>
  109. </tabs>
  110. </view>
  111. </view>
  112. </mobile-frame>
  113. </template>
  114. <script>
  115. import tabs from '@/components/tabs/index.vue';
  116. export default {
  117. components: {
  118. tabs
  119. },
  120. data() {
  121. return {
  122. // 系统设置
  123. config: {},
  124. // 设备信息
  125. system: {},
  126. user: {},
  127. status: '',
  128. searchInfo: {},
  129. tabs: {
  130. active: '0',
  131. menu: [ //菜单列表
  132. {
  133. title: '未支付',
  134. active: '0'
  135. },
  136. {
  137. title: '已支付',
  138. active: '1'
  139. },
  140. {
  141. title: '发货中',
  142. active: '2'
  143. },
  144. {
  145. title: '已收货',
  146. active: '3'
  147. },
  148. {
  149. title: '取消订单',
  150. active: '-1'
  151. },
  152. {
  153. title: '申请售后',
  154. active: '-2'
  155. },
  156. {
  157. title: '售后处理中',
  158. active: '-3'
  159. },
  160. {
  161. title: '售后结束',
  162. active: '-4'
  163. }
  164. ]
  165. },
  166. list: [],
  167. total: 0,
  168. skip: 0,
  169. limit: 10,
  170. page: 0,
  171. // 数据是否触底
  172. is_bottom: false,
  173. scrollTop: 0,
  174. // 字典表
  175. statusList: []
  176. };
  177. },
  178. onLoad: function(e) {
  179. const that = this;
  180. that.$set(that, `status`, e.status || '0');
  181. that.searchConfig();
  182. that.searchOther();
  183. that.watchlogin();
  184. },
  185. onPullDownRefresh: async function() {
  186. const that = this;
  187. that.clearPage();
  188. await that.search();
  189. uni.stopPullDownRefresh();
  190. },
  191. methods: {
  192. // 查询基本设置
  193. searchConfig() {
  194. const that = this;
  195. uni.getStorage({
  196. key: 'config',
  197. success: function(res) {
  198. if (res.data) that.$set(that, `config`, res.data)
  199. // 设备平台信息
  200. let config = that.$config;
  201. that.$set(that, `system`, config.system);
  202. },
  203. fail: function(err) {
  204. console.log(err);
  205. }
  206. })
  207. },
  208. // 监听用户是否登录
  209. watchlogin() {
  210. const that = this;
  211. uni.getStorage({
  212. key: 'token',
  213. success: function(res) {
  214. let user = that.$jwt(res.data);
  215. if (user) {
  216. that.$set(that, `user`, user)
  217. that.search();
  218. }
  219. }
  220. })
  221. },
  222. async search() {
  223. const that = this;
  224. let user = that.user;
  225. let status = that.status;
  226. let info = {
  227. skip: that.skip,
  228. limit: that.limit,
  229. customer: user._id,
  230. status: status
  231. }
  232. let res;
  233. if (status == '0') {
  234. res = await that.$api(`/order`, 'GET', {
  235. ...info,
  236. ...that.searchInfo
  237. });
  238. } else {
  239. res = await that.$api(`/orderDetail`, 'GET', {
  240. ...info,
  241. ...that.searchInfo
  242. });
  243. }
  244. if (res.errcode == '0') {
  245. let list = [...that.list, ...res.data];
  246. for (let val of list) {
  247. val.zhStatus = that.searchStatus(val.status)
  248. }
  249. console.log(list);
  250. that.$set(that, `list`, list);
  251. that.$set(that, `total`, res.total)
  252. } else {
  253. uni.showToast({
  254. title: res.errmsg,
  255. icon: 'none'
  256. })
  257. }
  258. },
  259. // 查询状态
  260. searchStatus(e) {
  261. const that = this;
  262. let data = that.statusList.find((i) => i.value == e);
  263. if (data) return data.label
  264. else return '暂无'
  265. },
  266. // 分页
  267. toPage(e) {
  268. const that = this;
  269. let list = that.list;
  270. let limit = that.limit;
  271. if (that.total > list.length) {
  272. uni.showLoading({
  273. title: '加载中',
  274. mask: true
  275. })
  276. let page = that.page + 1;
  277. that.$set(that, `page`, page)
  278. let skip = page * limit;
  279. that.$set(that, `skip`, skip)
  280. that.search();
  281. uni.hideLoading();
  282. } else that.$set(that, `is_bottom`, true)
  283. },
  284. toScroll(e) {
  285. const that = this;
  286. let up = that.scrollTop;
  287. that.$set(that, `scrollTop`, e.detail.scrollTop);
  288. let num = Math.sign(up - e.detail.scrollTop);
  289. if (num == 1) that.$set(that, `is_bottom`, false);
  290. },
  291. // 输入框
  292. toInput(e) {
  293. const that = this;
  294. that.$set(that.searchInfo, `name`, e.detail.value)
  295. },
  296. // 订单详细信息
  297. toInfo(item) {
  298. uni.navigateTo({
  299. url: `/pagesMy/order/info?id=${item._id}&status=${item.status}`
  300. })
  301. },
  302. // 取消订单-未支付
  303. toCancel(e) {
  304. const that = this;
  305. uni.showModal({
  306. title: '提示',
  307. content: '确定取消订单吗?',
  308. success: async function(res) {
  309. if (res.confirm) {
  310. const arr = await that.$api(`/order/cancel`, 'POST', {
  311. order_id: e._id
  312. });
  313. if (arr.errcode == '0') {
  314. uni.showToast({
  315. title: '取消订单成功',
  316. icon: 'none'
  317. })
  318. that.clearPage();
  319. that.search();
  320. } else {
  321. uni.showToast({
  322. title: arr.errmsg,
  323. icon: 'none'
  324. })
  325. }
  326. }
  327. }
  328. });
  329. },
  330. // 支付
  331. async toPay(e) {
  332. const that = this;
  333. let system = that.system;
  334. if (system.uniPlatform == "mp-weixin") {
  335. uni.showLoading({
  336. title: '加载中'
  337. })
  338. // 支付信息
  339. let p2 = await that.$api('/pay/toPayOrder', 'POST', {
  340. order_id: e,
  341. type: '0'
  342. })
  343. if (p2.errcode == '0' && p2.data.paySign) {
  344. uni.requestPayment({
  345. "provider": "wxpay",
  346. ...p2.data,
  347. success: function(res) {
  348. uni.showToast({
  349. title: '支付成功',
  350. icon: 'none'
  351. })
  352. },
  353. fail: function(err) {
  354. uni.showToast({
  355. title: `支付失败`,
  356. icon: 'none'
  357. })
  358. },
  359. complete: function() {
  360. uni.hideLoading();
  361. that.clearPage();
  362. that.search();
  363. }
  364. })
  365. } else {
  366. uni.showToast({
  367. title: p2.errmsg || '错误信息',
  368. icon: 'none'
  369. })
  370. }
  371. } else if (res.data.uniPlatform == "app") {
  372. // app支付
  373. uni.requestPayment({
  374. provider: 'alipay',
  375. orderInfo: 'orderInfo',
  376. success: function(res) {
  377. console.log('success:' + JSON.stringify(res));
  378. },
  379. fail: function(err) {
  380. console.log('fail:' + JSON.stringify(err));
  381. }
  382. });
  383. } else {
  384. uni.showToast({
  385. title: `平台不支持支付`,
  386. icon: 'none'
  387. })
  388. }
  389. },
  390. // 查看物流
  391. toLogi(e) {
  392. uni.navigateTo({
  393. url: `/pagesMy/logistics/index?id=${e._id}`
  394. })
  395. },
  396. // 查询其他信息
  397. async searchOther() {
  398. const that = this;
  399. let res;
  400. // 查询状态
  401. res = await that.$api(`/dictData`, 'GET', {
  402. code: 'order_process'
  403. })
  404. if (res.errcode == '0') {
  405. that.$set(that, `statusList`, res.data);
  406. }
  407. },
  408. // 选择选项卡
  409. tabsChange(e) {
  410. const that = this;
  411. that.$set(that.tabs, `active`, e.active)
  412. that.$set(that, `status`, e.active);
  413. that.clearPage();
  414. that.search()
  415. },
  416. // 清空列表
  417. clearPage() {
  418. const that = this;
  419. that.$set(that, `list`, [])
  420. that.$set(that, `skip`, 0)
  421. that.$set(that, `limit`, 6)
  422. that.$set(that, `page`, 0)
  423. }
  424. },
  425. }
  426. </script>
  427. <style lang="scss">
  428. .main {
  429. display: flex;
  430. flex-direction: column;
  431. width: 100vw;
  432. height: 100vh;
  433. .one {
  434. padding: 2vw;
  435. input {
  436. padding: 2vw;
  437. background-color: var(--f1Color);
  438. font-size: var(--font14Size);
  439. border-radius: 5px;
  440. }
  441. }
  442. .two {
  443. position: relative;
  444. flex-grow: 1;
  445. background-color: var(--f9Color);
  446. .tabsList {
  447. position: relative;
  448. width: 100vw;
  449. height: 82vh;
  450. .list {
  451. background-color: #fff;
  452. border: 1px solid #ff0000;
  453. padding: 2vw;
  454. margin: 0 2vw 2vw 2vw;
  455. border-radius: 5px;
  456. .list_1 {
  457. .status {
  458. text-align: right;
  459. color: var(--ff0Color);
  460. margin: 0 0 1vw 0;
  461. }
  462. .goods {
  463. .goodsList {
  464. border-bottom: 1px solid #f1f1f1;
  465. .shopname {
  466. margin: 0 0 2vw 0;
  467. text:last-child {
  468. padding: 0 0 0 2vw;
  469. }
  470. }
  471. .goodsList_1 {
  472. .market {
  473. display: flex;
  474. padding: 0 0 2vw 0;
  475. .market_1 {
  476. width: 20vw;
  477. height: 20vw;
  478. .image {
  479. width: 100%;
  480. height: 100%;
  481. border-radius: 5px;
  482. }
  483. }
  484. .market_2 {
  485. width: 55vw;
  486. padding: 0 0 0 2vw;
  487. .goodsname {
  488. font-size: 16px;
  489. margin: 0 0 1vw 0;
  490. }
  491. .specs {
  492. font-size: 14px;
  493. color: #858585;
  494. }
  495. }
  496. .market_3 {
  497. width: 15vw;
  498. text-align: right;
  499. }
  500. }
  501. }
  502. }
  503. }
  504. .other {
  505. padding: 0 0 2vw 0;
  506. margin: 2vw 0;
  507. text-align: right;
  508. border-bottom: 1px solid #f1f1f1;
  509. text {
  510. font-size: 14px;
  511. padding: 0 0 0 2vw;
  512. }
  513. }
  514. }
  515. .list_2 {
  516. .list_2_1 {
  517. display: flex;
  518. justify-content: space-between;
  519. margin: 0 0 2vw 0;
  520. .shopname {
  521. text:last-child {
  522. padding: 0 0 0 2vw;
  523. }
  524. }
  525. .status {
  526. color: var(--ff0Color);
  527. }
  528. }
  529. .list_2_2 {
  530. border-bottom: 1px solid #f1f1f1;
  531. .goods {
  532. display: flex;
  533. padding: 0 0 2vw 0;
  534. .goods_1 {
  535. width: 20vw;
  536. height: 20vw;
  537. .image {
  538. width: 100%;
  539. height: 100%;
  540. border-radius: 5px;
  541. }
  542. }
  543. .goods_2 {
  544. width: 55vw;
  545. padding: 0 0 0 2vw;
  546. .goodsname {
  547. font-size: 16px;
  548. margin: 0 0 1vw 0;
  549. }
  550. .specs {
  551. font-size: 14px;
  552. color: #858585;
  553. }
  554. }
  555. .goods_3 {
  556. width: 15vw;
  557. text-align: right;
  558. }
  559. }
  560. }
  561. .other {
  562. padding: 0 0 2vw 0;
  563. margin: 2vw 0;
  564. text-align: right;
  565. border-bottom: 1px solid #f1f1f1;
  566. text {
  567. font-size: 14px;
  568. padding: 0 0 0 2vw;
  569. }
  570. }
  571. }
  572. .btn {
  573. text-align: right;
  574. }
  575. }
  576. // .list_2 {
  577. // background-color: #fff;
  578. // margin: 0 2vw 2vw 2vw;
  579. // padding: 2vw;
  580. // .status {
  581. // color: var(--ff0Color);
  582. // text-align: right;
  583. // margin: 0 0 1vw 0;
  584. // }
  585. // .goods {
  586. // margin: 0 0 1vw 0;
  587. // padding: 2vw;
  588. // border-bottom: 1px solid #f5f5f5;
  589. // .goods_1 {
  590. // margin: 0 0 2vw 0;
  591. // .shopname {
  592. // text:last-child {
  593. // padding: 0 0 0 2vw;
  594. // }
  595. // }
  596. // }
  597. // .goods_2 {
  598. // margin: 0 0 1vw 0;
  599. // .market {
  600. // display: flex;
  601. // .url {
  602. // width: 20vw;
  603. // .image {
  604. // width: 100%;
  605. // height: 20vw;
  606. // border-radius: 5px;
  607. // }
  608. // }
  609. // .goodsname {
  610. // display: flex;
  611. // flex-direction: column;
  612. // width: 60vw;
  613. // padding: 0 2vw;
  614. // .specs {
  615. // color: var(--f85Color);
  616. // font-size: var(--font12Size);
  617. // }
  618. // }
  619. // .goodsother {
  620. // width: 15vw;
  621. // text-align: right;
  622. // }
  623. // }
  624. // }
  625. // }
  626. // .other {
  627. // margin: 0 0 2vw 0;
  628. // text-align: right;
  629. // text {
  630. // font-size: 14px;
  631. // padding: 0 0 0 2vw;
  632. // }
  633. // }
  634. // .btn {
  635. // text-align: right;
  636. // margin: 2vw 0 0 0;
  637. // border-top: 1px solid #f1fff1;
  638. // button {
  639. // margin: 2vw 0 0 2vw;
  640. // }
  641. // .toPay {
  642. // border: 1px solid #ff0000;
  643. // color: #ff0000;
  644. // }
  645. // }
  646. // }
  647. // .list_3 {
  648. // .list_3_1 {
  649. // display: flex;
  650. // justify-content: space-between;
  651. // }
  652. // }
  653. // .list {
  654. // background-color: #fff;
  655. // margin: 0 2vw 2vw 2vw;
  656. // padding: 2vw;
  657. // .list_1 {
  658. // margin: 0 0 1vw 0;
  659. // display: flex;
  660. // flex-direction: row;
  661. // justify-content: space-between;
  662. // }
  663. // .list_2 {
  664. // margin: 0 0 1vw 0;
  665. // display: flex;
  666. // .l {
  667. // width: 20vw;
  668. // .image {
  669. // width: 100%;
  670. // height: 20vw;
  671. // border-radius: 5px;
  672. // }
  673. // }
  674. // .c {
  675. // width: 60vw;
  676. // padding: 0 2vw;
  677. // }
  678. // .r {
  679. // width: 15vw;
  680. // text-align: right;
  681. // }
  682. // }
  683. // .other {
  684. // margin: 0 0 2vw 0;
  685. // text-align: right;
  686. // text {
  687. // font-size: 14px;
  688. // padding: 0 0 0 2vw;
  689. // }
  690. // }
  691. // .btn {
  692. // text-align: right;
  693. // margin: 2vw 0 0 0;
  694. // border-top: 1px solid #f1fff1;
  695. // button {
  696. // margin: 2vw 0 0 2vw;
  697. // }
  698. // }
  699. // }
  700. }
  701. }
  702. }
  703. // .two {
  704. // position: relative;
  705. // flex-grow: 1;
  706. // background-color: var(--f9Color);
  707. // .two_1 {
  708. // background-color: var(--fffColor);
  709. // padding: 2vw;
  710. // display: flex;
  711. // flex-direction: row;
  712. // }
  713. // .two_2 {
  714. // display: flex;
  715. // flex-direction: column;
  716. // .list {
  717. // width: 100vw;
  718. // margin: 2vw 0 0 0;
  719. // background-color: var(--mainColor);
  720. // .list_1 {
  721. // display: flex;
  722. // flex-direction: row;
  723. // justify-content: space-between;
  724. // padding: 2vw;
  725. // .name {
  726. // font-size: var(--font14Size);
  727. // text {
  728. // margin: 0 1vw 0 0;
  729. // }
  730. // }
  731. // .status {
  732. // font-size: var(--font14Size);
  733. // color: var(--ff0Color);
  734. // }
  735. // }
  736. // .list_2 {
  737. // display: flex;
  738. // flex-direction: row;
  739. // justify-content: space-between;
  740. // padding: 2vw;
  741. // background-color: var(--f8Color);
  742. // .image {
  743. // width: 20vw;
  744. // height: 20vw;
  745. // margin: 0 2vw 0 0;
  746. // }
  747. // .other {
  748. // display: flex;
  749. // flex-direction: column;
  750. // flex-grow: 1;
  751. // .name {
  752. // font-size: var(--font14Size);
  753. // font-weight: bold;
  754. // margin: 0 0 2vw 0;
  755. // }
  756. // .other_1 {
  757. // font-size: var(--font12Size);
  758. // color: var(--f85Color);
  759. // }
  760. // }
  761. // .money {
  762. // font-size: var(--font12Size);
  763. // .num {
  764. // text-align: right;
  765. // }
  766. // }
  767. // }
  768. // .list_3 {
  769. // display: flex;
  770. // justify-content: flex-end;
  771. // padding: 2vw;
  772. // border-bottom: 0.5vw solid var(--f9Color);
  773. // font-size: var(--font12Size);
  774. // text {
  775. // margin: 0 1vw;
  776. // }
  777. // }
  778. // .list_4 {
  779. // padding: 2vw;
  780. // text-align: right;
  781. // button {
  782. // margin: 0 1vw 0 2vw;
  783. // }
  784. // }
  785. // }
  786. // }
  787. // }
  788. // }
  789. .scroll-view {
  790. position: absolute;
  791. top: 0;
  792. left: 0;
  793. right: 0;
  794. bottom: 0;
  795. .list-scroll-view {
  796. display: flex;
  797. flex-direction: column;
  798. }
  799. }
  800. .is_bottom {
  801. text-align: center;
  802. text {
  803. padding: 2vw 0;
  804. display: inline-block;
  805. color: #858585;
  806. font-size: 14px;
  807. }
  808. }
  809. </style>