handle.vue 15 KB

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