handle.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <input type="text" v-model="searchInfo.customer" @input="toInput" placeholder="搜索购买用户名称">
  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>
  81. </mobile-frame>
  82. </template>
  83. <script>
  84. export default {
  85. data() {
  86. return {
  87. // 系统设置
  88. config: {},
  89. // 设备信息
  90. system: {},
  91. user: {},
  92. id: '',
  93. searchInfo: {},
  94. list: [],
  95. total: 0,
  96. skip: 0,
  97. limit: 6,
  98. page: 0,
  99. // 数据是否触底
  100. is_bottom: false,
  101. scrollTop: 0,
  102. // 字典表
  103. statusList: []
  104. };
  105. },
  106. onLoad: function(e) {
  107. const that = this;
  108. that.$set(that, `id`, e.id || '');
  109. that.searchConfig();
  110. },
  111. onShow: async function(e) {
  112. const that = this;
  113. await that.searchOther();
  114. await that.watchlogin();
  115. },
  116. onPullDownRefresh: async function() {
  117. const that = this;
  118. that.clearPage();
  119. await that.search();
  120. uni.stopPullDownRefresh();
  121. },
  122. methods: {
  123. // 查询基本设置
  124. searchConfig() {
  125. const that = this;
  126. uni.getStorage({
  127. key: 'config',
  128. success: function(res) {
  129. if (res.data) that.$set(that, `config`, res.data)
  130. // 设备平台信息
  131. let config = that.$config;
  132. that.$set(that, `system`, config.system);
  133. },
  134. fail: function(err) {
  135. console.log(err);
  136. }
  137. })
  138. },
  139. // 监听用户是否登录
  140. watchlogin() {
  141. const that = this;
  142. uni.getStorage({
  143. key: 'token',
  144. success: function(res) {
  145. let user = that.$jwt(res.data);
  146. if (user) {
  147. that.$set(that, `user`, user)
  148. that.search();
  149. }
  150. }
  151. })
  152. },
  153. async search() {
  154. const that = this;
  155. let info = {
  156. skip: that.skip,
  157. limit: that.limit,
  158. group: that.id
  159. }
  160. let res = await that.$api(`/groupOrder/userView`, 'GET', {
  161. ...info,
  162. ...that.searchInfo
  163. }, 'group');
  164. if (res.errcode == '0') {
  165. let list = [...that.list, ...res.data];
  166. for (let val of list) {
  167. if (val.status) val.zhStatus = that.searchStatus(val.status)
  168. }
  169. list.sort(function(a, b) {
  170. return a.buy_time < b.buy_time ? 1 : -1;
  171. })
  172. that.$set(that, `list`, list);
  173. that.$set(that, `total`, res.total)
  174. } else {
  175. uni.showToast({
  176. title: res.errmsg,
  177. icon: 'none'
  178. })
  179. }
  180. },
  181. // 查询状态
  182. searchStatus(e) {
  183. const that = this;
  184. let data = that.statusList.find((i) => i.value == e);
  185. if (data) return data.label
  186. else return '暂无'
  187. },
  188. // 订单详细信息
  189. toView(item) {
  190. const that = this;
  191. that.clearPage();
  192. uni.navigateTo({
  193. url: `/pagesMy/dough/info?id=${item._id}`
  194. })
  195. },
  196. // 分页
  197. toPage(e) {
  198. const that = this;
  199. let list = that.list;
  200. let limit = that.limit;
  201. if (that.total > list.length) {
  202. uni.showLoading({
  203. title: '加载中',
  204. mask: true
  205. })
  206. let page = that.page + 1;
  207. that.$set(that, `page`, page)
  208. let skip = page * limit;
  209. that.$set(that, `skip`, skip)
  210. that.search();
  211. uni.hideLoading();
  212. } else that.$set(that, `is_bottom`, true)
  213. },
  214. toScroll(e) {
  215. const that = this;
  216. let up = that.scrollTop;
  217. that.$set(that, `scrollTop`, e.detail.scrollTop);
  218. let num = Math.sign(up - e.detail.scrollTop);
  219. if (num == 1) that.$set(that, `is_bottom`, false);
  220. },
  221. // 输入框
  222. toInput(e) {
  223. const that = this;
  224. if (that.searchInfo.goods) {
  225. that.$set(that.searchInfo, `customer`, e.detail.value)
  226. } else {
  227. that.$set(that, `searchInfo`, {})
  228. }
  229. that.clearPage();
  230. that.search();
  231. },
  232. // 订单详细信息
  233. toInfo(item) {
  234. const that = this;
  235. that.clearPage();
  236. uni.navigateTo({
  237. url: `/pagesMy/order/info?id=${item._id}&status=${item.status}`
  238. })
  239. },
  240. // 取消订单-未支付||取消订单-已支付
  241. toCancel(e) {
  242. const that = this;
  243. uni.showModal({
  244. title: '提示',
  245. content: '确定取消订单吗?',
  246. success: async function(res) {
  247. if (res.confirm) {
  248. if (e.status == '0') {
  249. const arr = await that.$api(`/orderDeal/cancel`, 'POST', {
  250. order_id: e._id
  251. }, 'group');
  252. if (arr.errcode == '0') {
  253. uni.showToast({
  254. title: '申请取消订单完成',
  255. icon: 'none'
  256. })
  257. that.clearPage();
  258. that.search();
  259. } else {
  260. uni.showToast({
  261. title: arr.errmsg,
  262. icon: 'none'
  263. })
  264. }
  265. } else {
  266. if (e.is_afterSale != true) {
  267. let arr = await that.$api(`/groupAfterSale`, 'POST', {
  268. order_detail: e._id,
  269. type: '4'
  270. }, 'group')
  271. if (arr.errcode == '0') {
  272. uni.showToast({
  273. title: '申请取消订单完成',
  274. icon: 'none'
  275. })
  276. that.clearPage();
  277. that.search();
  278. } else {
  279. uni.showToast({
  280. title: arr.errmsg,
  281. icon: 'none'
  282. })
  283. }
  284. } else {
  285. uni.showToast({
  286. title: `该订单有售后处理中`,
  287. icon: 'none'
  288. })
  289. }
  290. }
  291. }
  292. }
  293. });
  294. },
  295. // 支付
  296. async toPay(e) {
  297. const that = this;
  298. let system = that.system;
  299. if (system.uniPlatform == "mp-weixin") {
  300. uni.showLoading({
  301. title: '加载中'
  302. })
  303. // 支付信息
  304. let p2 = await that.$api('/orderDeal/pay', 'POST', {
  305. order_id: e._id,
  306. }, 'group')
  307. if (p2.errcode == '0' && p2.data.paySign) {
  308. uni.requestPayment({
  309. "provider": "wxpay",
  310. ...p2.data,
  311. success: function(res) {
  312. uni.showToast({
  313. title: '支付成功',
  314. icon: 'none'
  315. })
  316. },
  317. fail: function(err) {
  318. uni.showToast({
  319. title: `支付失败`,
  320. icon: 'none'
  321. })
  322. },
  323. complete: function() {
  324. uni.hideLoading();
  325. that.clearPage();
  326. that.search()
  327. }
  328. })
  329. } else {
  330. uni.showToast({
  331. title: p2.errmsg || '错误信息',
  332. icon: 'none'
  333. })
  334. }
  335. } else if (res.data.uniPlatform == "app") {
  336. // app支付
  337. uni.requestPayment({
  338. provider: 'alipay',
  339. orderInfo: 'orderInfo',
  340. success: function(res) {
  341. console.log('success:' + JSON.stringify(res));
  342. },
  343. fail: function(err) {
  344. console.log('fail:' + JSON.stringify(err));
  345. }
  346. });
  347. } else {
  348. uni.showToast({
  349. title: `平台不支持支付`,
  350. icon: 'none'
  351. })
  352. }
  353. },
  354. // 查看物流
  355. toLogi(e) {
  356. const that = this;
  357. that.clearPage();
  358. uni.navigateTo({
  359. url: `/pagesMy/logistics/index?id=${e._id}&type=${'groupOrder'}`
  360. })
  361. },
  362. // 确认收货
  363. async toConfirm(e) {
  364. const that = this;
  365. uni.showModal({
  366. title: '提示',
  367. content: '确定确认收货吗?',
  368. success: async function(res) {
  369. if (res.confirm) {
  370. const arr = await that.$api(`/groupOrder/${e._id}`, 'POST', {
  371. status: '3'
  372. }, 'group');
  373. if (arr.errcode == '0') {
  374. uni.showToast({
  375. title: '确认收货成功',
  376. icon: 'none'
  377. })
  378. that.clearPage();
  379. that.search();
  380. } else {
  381. uni.showToast({
  382. title: arr.errmsg,
  383. icon: 'none'
  384. })
  385. }
  386. }
  387. }
  388. });
  389. },
  390. // 拒收
  391. async toReject(e) {
  392. const that = this;
  393. uni.showModal({
  394. title: '提示',
  395. content: '确定拒收快递吗?',
  396. success: async function(res) {
  397. if (res.confirm) {
  398. let arr = await that.$api(`/groupAfterSale`, 'POST', {
  399. order_detail: e._id,
  400. type: '5'
  401. }, 'group')
  402. if (arr.errcode == '0') {
  403. uni.showToast({
  404. title: '拒收申请完成',
  405. icon: 'none'
  406. })
  407. that.clearPage();
  408. that.search();
  409. } else {
  410. uni.showToast({
  411. title: arr.errmsg,
  412. icon: 'none'
  413. })
  414. }
  415. }
  416. }
  417. });
  418. },
  419. // 申请售后
  420. toAfter(e) {
  421. const that = this;
  422. that.clearPage();
  423. uni.navigateTo({
  424. url: `/pagesMy/order/service?id=${e._id}&status=${'-3'}`
  425. })
  426. },
  427. // 查询其他信息
  428. async searchOther() {
  429. const that = this;
  430. let res;
  431. // 查询状态
  432. res = await that.$api(`/dictData`, 'GET', {
  433. code: 'order_process'
  434. })
  435. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  436. },
  437. // 清空列表
  438. clearPage() {
  439. const that = this;
  440. that.$set(that, `list`, [])
  441. that.$set(that, `skip`, 0)
  442. that.$set(that, `limit`, 6)
  443. that.$set(that, `page`, 0)
  444. }
  445. },
  446. }
  447. </script>
  448. <style lang="scss">
  449. .main {
  450. display: flex;
  451. flex-direction: column;
  452. width: 100vw;
  453. height: 100vh;
  454. .one {
  455. padding: 2vw;
  456. input {
  457. padding: 2vw;
  458. background-color: var(--f1Color);
  459. font-size: var(--font14Size);
  460. border-radius: 5px;
  461. }
  462. }
  463. .two {
  464. position: relative;
  465. flex-grow: 1;
  466. background-color: var(--f9Color);
  467. .list {
  468. background-color: #fff;
  469. border: 1px solid var(--f5Color);
  470. padding: 2vw;
  471. margin: 0 2vw 2vw 2vw;
  472. border-radius: 5px;
  473. .list_1 {
  474. .list_1_1 {
  475. display: flex;
  476. justify-content: space-between;
  477. margin: 0 0 2vw 0;
  478. .shopname {
  479. text:last-child {
  480. padding: 0 0 0 2vw;
  481. }
  482. }
  483. .status {
  484. color: var(--ff0Color);
  485. }
  486. }
  487. .list_1_2 {
  488. border-bottom: 1px solid #f1f1f1;
  489. .goods {
  490. display: flex;
  491. padding: 0 0 2vw 0;
  492. .goods_1 {
  493. width: 20vw;
  494. height: 20vw;
  495. .image {
  496. width: 100%;
  497. height: 100%;
  498. border-radius: 5px;
  499. }
  500. }
  501. .goods_2 {
  502. width: 55vw;
  503. padding: 0 0 0 2vw;
  504. .goodsname {
  505. font-size: 16px;
  506. margin: 0 0 1vw 0;
  507. }
  508. .specs {
  509. font-size: 14px;
  510. color: #858585;
  511. }
  512. .time {
  513. font-size: 13px;
  514. color: #858585;
  515. }
  516. }
  517. .goods_3 {
  518. width: 15vw;
  519. text-align: right;
  520. .price {
  521. color: #ff0000;
  522. }
  523. }
  524. }
  525. }
  526. .other {
  527. padding: 0 0 2vw 0;
  528. margin: 2vw 0;
  529. text-align: right;
  530. border-bottom: 1px solid #f1f1f1;
  531. text {
  532. font-size: 14px;
  533. padding: 0 0 0 2vw;
  534. }
  535. }
  536. }
  537. .btn {
  538. text-align: right;
  539. button {
  540. margin: 0 2vw 0 0;
  541. }
  542. }
  543. }
  544. }
  545. }
  546. .scroll-view {
  547. position: absolute;
  548. top: 0;
  549. left: 0;
  550. right: 0;
  551. bottom: 0;
  552. .list-scroll-view {
  553. display: flex;
  554. flex-direction: column;
  555. }
  556. }
  557. .is_bottom {
  558. text-align: center;
  559. text {
  560. padding: 2vw 0;
  561. display: inline-block;
  562. color: #858585;
  563. font-size: 14px;
  564. }
  565. }
  566. </style>