handle.vue 13 KB

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