index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <view class="one_1" v-if="!focus">
  5. <input type='text' v-model="name" @input="focusHandler" placeholder='搜索商品'></input>
  6. </view>
  7. <view class="one_2" v-if="focus">
  8. <view class="left">
  9. <input type="text" v-model="name" @input="focusHandler" placeholder="搜索商品">
  10. </view>
  11. <view class="right">
  12. <button size="mini" class="button" type="default" @click="cancelHandler">取消</button>
  13. </view>
  14. </view>
  15. <!-- 搜索结果显示框 -->
  16. <scroll-view v-if="focus" class="one_3" scroll-y="true">
  17. <view class="list" v-for="(item, index) in goodsList" :index="index" :key="index"
  18. @click="toInput(item)">
  19. <text class="name"> {{item.name}}</text>
  20. </view>
  21. </scroll-view>
  22. </view>
  23. <view class="two">
  24. <tabs :tabs="tabs" @tabsChange="tabsChange">
  25. <view class="tabsList">
  26. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  27. <view class="list-scroll-view">
  28. <view class="list" v-for="(item,index) in list" :key="index" @tap="toInfo(item)">
  29. <view class="list_1">
  30. <text>
  31. <text class="iconfont icon-changshangguanli"></text>
  32. {{item.supplier_name}}
  33. </text>
  34. <text class="status">{{item.zhStatus}}</text>
  35. </view>
  36. <view class="list_2">
  37. <view class="left">
  38. <image v-if="item.spec_file" class="image"
  39. :src="item.spec_file?item.spec_file.url:''" mode="">
  40. </image>
  41. <image v-else class="image" :src="item.good_file?item.good_file.url:''" mode="">
  42. </image>
  43. </view>
  44. <view class="right">
  45. <view class="right_1">
  46. <view class="name textOver">
  47. <text>{{item.good_name||'暂无'}}</text>
  48. </view>
  49. <view class="num">
  50. <text>¥{{item.total_money||'0'}}</text>
  51. <text>×{{item.num||'0'}}</text>
  52. </view>
  53. </view>
  54. <view class="right_2">
  55. <view class="spec textOver">
  56. <text>规格:{{item.spec_name||'暂无'}}</text>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="bottom">
  62. <button v-if="item.status=='5'" size="mini" type="default"
  63. @tap.stop="toConfirm(item)">确认发货</button>
  64. <button v-if="item.status=='-2'||item.status=='-3'" size="mini" type="default"
  65. @tap.stop="toExam(item)">重新申请购买</button>
  66. <button v-if="item.status=='8'||item.status=='9'||item.status=='10'" size="mini"
  67. type="warn" @tap.stop="toKeep(item)">申请维修</button>
  68. <button v-if="item.status=='4'||item.status=='5'||item.status=='6'" size="mini"
  69. type="warn" @tap.stop="toRefund(item)">申请退货</button>
  70. </view>
  71. </view>
  72. <view class="is_bottom" v-if="is_bottom">
  73. <text>{{config.bottom_title}}</text>
  74. </view>
  75. </view>
  76. </scroll-view>
  77. </view>
  78. </tabs>
  79. </view>
  80. </view>
  81. </template>
  82. <script>
  83. import moment from 'moment';
  84. import tabs from '../../components/tabs/index.vue';
  85. export default {
  86. components: {
  87. tabs
  88. },
  89. data() {
  90. return {
  91. // 系统设置
  92. config: {},
  93. user: {},
  94. status: '',
  95. tabs: {
  96. active: '0',
  97. menu: []
  98. },
  99. list: [],
  100. total: 0,
  101. skip: 0,
  102. limit: 6,
  103. page: 0,
  104. // 数据是否触底
  105. is_bottom: false,
  106. scrollTop: 0,
  107. // 字典表
  108. statusList: [],
  109. // 搜索
  110. focus: false, //控制是否显示带取消按钮的搜索框
  111. searchInfo: {},
  112. name: '',
  113. goodsList: [],
  114. }
  115. },
  116. onLoad: function(e) {
  117. const that = this;
  118. that.$set(that, `status`, e.status || '0');
  119. that.$set(that.tabs, `active`, e.status || '0');
  120. that.searchConfig();
  121. },
  122. onShow: async function(e) {
  123. const that = this;
  124. await that.searchOther();
  125. that.searchToken();
  126. },
  127. onPullDownRefresh: async function() {
  128. const that = this;
  129. that.clearPage();
  130. await that.search();
  131. uni.stopPullDownRefresh();
  132. },
  133. methods: {
  134. searchConfig() {
  135. const that = this;
  136. try {
  137. const res = uni.getStorageSync('config');
  138. if (res) that.$set(that, `config`, res);
  139. } catch (e) {
  140. uni.showToast({
  141. title: err.errmsg,
  142. icon: 'error',
  143. duration: 2000
  144. });
  145. }
  146. },
  147. searchToken() {
  148. const that = this;
  149. try {
  150. const res = uni.getStorageSync('token');
  151. if (res) {
  152. that.$set(that, `user`, res);
  153. that.$set(that, `name`, '')
  154. that.$set(that, `searchInfo`, {})
  155. that.clearPage();
  156. that.search();
  157. }
  158. } catch (e) {
  159. uni.showToast({
  160. title: err.errmsg,
  161. icon: 'error',
  162. duration: 2000
  163. });
  164. }
  165. },
  166. async search() {
  167. const that = this;
  168. let user = that.user;
  169. let status = that.status;
  170. let info = {
  171. skip: that.skip,
  172. limit: that.limit,
  173. user: user._id,
  174. }
  175. if (status != '-1') info.status = status
  176. let res;
  177. res = await that.$api(`/OrderDetail/queryInfo`, 'GET', {
  178. ...info,
  179. ...that.searchInfo
  180. });
  181. if (res.errcode == '0') {
  182. let list = [...that.list, ...res.data];
  183. for (let val of list) {
  184. val.zhStatus = that.searchStatus(val.status)
  185. }
  186. that.$set(that, `list`, list);
  187. that.$set(that, `total`, res.total)
  188. } else {
  189. uni.showToast({
  190. title: res.errmsg,
  191. icon: 'none'
  192. })
  193. }
  194. },
  195. // 查询状态
  196. searchStatus(e) {
  197. const that = this;
  198. let data = that.statusList.find((i) => i.value == e);
  199. if (data) return data.label
  200. else return '暂无'
  201. },
  202. // 申请退货
  203. toRefund(item) {
  204. const that = this;
  205. let user = that.user;
  206. let obj = {
  207. status: '60'
  208. }
  209. uni.showModal({
  210. title: '提示',
  211. content: '是否要申请退货?',
  212. success: async function(res) {
  213. if (res.confirm) {
  214. const res = await that.$api(`/OrderDetail/${item._id}`, 'POST', obj);
  215. if (res.errcode == '0') {
  216. uni.showToast({
  217. title: '维护信息成功',
  218. icon: 'none'
  219. })
  220. that.clearPage()
  221. that.search()
  222. } else {
  223. uni.showToast({
  224. title: res.errmsg,
  225. icon: 'none'
  226. })
  227. }
  228. }
  229. }
  230. });
  231. },
  232. // 确认发货
  233. async toConfirm(item) {
  234. const that = this;
  235. let user = that.user;
  236. let obj = {
  237. status: '6'
  238. }
  239. uni.showModal({
  240. title: '提示',
  241. content: '是否要确认收货?',
  242. success: async function(res) {
  243. if (res.confirm) {
  244. const res = await that.$api(`/OrderDetail/${item._id}`, 'POST', obj);
  245. if (res.errcode == '0') {
  246. uni.showToast({
  247. title: '维护信息成功',
  248. icon: 'none'
  249. })
  250. that.clearPage()
  251. that.search()
  252. } else {
  253. uni.showToast({
  254. title: res.errmsg,
  255. icon: 'none'
  256. })
  257. }
  258. }
  259. }
  260. });
  261. },
  262. // 重新审批
  263. async toExam(item) {
  264. const that = this;
  265. let user = that.user;
  266. let obj = {
  267. status: '0'
  268. };
  269. uni.showModal({
  270. title: '提示',
  271. content: '确定重新申请该订单吗?',
  272. success: async function(res) {
  273. if (res.confirm) {
  274. const res = await that.$api(`/OrderDetail/${item._id}`, 'POST', obj);
  275. if (res.errcode == '0') {
  276. uni.showToast({
  277. title: '维护信息成功',
  278. icon: 'none'
  279. })
  280. that.clearPage()
  281. that.search()
  282. } else {
  283. uni.showToast({
  284. title: res.errmsg,
  285. icon: 'none'
  286. })
  287. }
  288. }
  289. }
  290. });
  291. },
  292. // 申请维修
  293. toKeep(item) {
  294. const that = this;
  295. let user = that.user;
  296. uni.showModal({
  297. title: '提示',
  298. content: '确定申请维修该商品吗?',
  299. success: async function(res) {
  300. if (res.confirm) {
  301. let obj = {
  302. order_id: item._id,
  303. user: item.user,
  304. user_name: item.user_name,
  305. good: item.good,
  306. good_name: item.good_name,
  307. good_file: [item.good_file],
  308. spec: item.spec,
  309. spec_name: item.spec_name,
  310. spec_file: [item.spec_file],
  311. supplier: item.supplier,
  312. supplier_name: item.supplier_name,
  313. address: item.address,
  314. apply_time: moment().format('YYYY-MM-DD HH:mm:ss')
  315. }
  316. const res = await that.$api(`/Upkeep`, 'POST', obj);
  317. if (res.errcode == '0') {
  318. uni.showToast({
  319. title: '申请维修成功',
  320. icon: 'none'
  321. })
  322. that.clearPage()
  323. that.search()
  324. } else {
  325. uni.showToast({
  326. title: res.errmsg,
  327. icon: 'none'
  328. })
  329. }
  330. }
  331. }
  332. });
  333. },
  334. // 查看详情
  335. toInfo(e) {
  336. uni.navigateTo({
  337. url: `/pagesMy/order/detail?id=${e.id||e._id}`
  338. })
  339. },
  340. // 分页
  341. toPage(e) {
  342. const that = this;
  343. let list = that.list;
  344. let limit = that.limit;
  345. if (that.total > list.length) {
  346. uni.showLoading({
  347. title: '加载中',
  348. mask: true
  349. })
  350. let page = that.page + 1;
  351. that.$set(that, `page`, page)
  352. let skip = page * limit;
  353. that.$set(that, `skip`, skip)
  354. that.search();
  355. uni.hideLoading();
  356. } else that.$set(that, `is_bottom`, true)
  357. },
  358. // 触底
  359. toScroll(e) {
  360. const that = this;
  361. let up = that.scrollTop;
  362. that.$set(that, `scrollTop`, e.detail.scrollTop);
  363. let num = Math.sign(up - e.detail.scrollTop);
  364. if (num == 1) that.$set(that, `is_bottom`, false);
  365. },
  366. // 输入框
  367. toInput(e) {
  368. const that = this;
  369. if (e.name) that.$set(that.searchInfo, `good`, e._id)
  370. else that.$set(that, `searchInfo`, {})
  371. that.$set(that, `name`, e.name)
  372. that.clearPage();
  373. that.search();
  374. that.$set(that, `focus`, false)
  375. },
  376. // 点击查看商品名称列表
  377. async focusHandler(e) {
  378. const that = this;
  379. if (e.detail.value) {
  380. let res;
  381. let info = {
  382. name: e.detail.value,
  383. is_use: '0'
  384. }
  385. res = await that.$api(`/Good/search`, 'GET', {
  386. ...info,
  387. })
  388. if (res.errcode == '0') that.$set(that, `goodsList`, res.data)
  389. that.$set(that, `focus`, true)
  390. }
  391. },
  392. // 取消搜索
  393. cancelHandler(e) {
  394. const that = this;
  395. that.$set(that, `searchInfo`, {})
  396. that.$set(that, `name`, '')
  397. that.$set(that, `focus`, false)
  398. that.clearPage();
  399. that.search();
  400. },
  401. // 查询其他信息
  402. async searchOther() {
  403. const that = this;
  404. let res;
  405. // 查询状态
  406. res = await that.$api(`/DictData`, 'GET', {
  407. type: 'order_status',
  408. is_use: '0',
  409. })
  410. if (res.errcode == '0') {
  411. that.$set(that, `statusList`, res.data);
  412. let status = res.data.filter((i) => {
  413. return i.value == '0' || i.value == '4' || i.value == '5' || i.value == '6';
  414. });
  415. var menu = status.map((item) => {
  416. return {
  417. title: item.label,
  418. active: item.value
  419. }
  420. })
  421. menu.unshift({
  422. title: '全部',
  423. active: '-1'
  424. })
  425. that.$set(that.tabs, `menu`, menu)
  426. }
  427. },
  428. // 选择选项卡
  429. tabsChange(e) {
  430. const that = this;
  431. that.$set(that.tabs, `active`, e.active)
  432. that.$set(that, `status`, e.active);
  433. that.clearPage();
  434. that.search()
  435. },
  436. // 清空列表
  437. clearPage() {
  438. const that = this;
  439. that.$set(that, `list`, [])
  440. that.$set(that, `skip`, 0)
  441. that.$set(that, `limit`, 6)
  442. that.$set(that, `page`, 0)
  443. }
  444. }
  445. }
  446. </script>
  447. <style lang="scss">
  448. .content {
  449. display: flex;
  450. flex-direction: column;
  451. width: 100vw;
  452. height: 100vh;
  453. .one {
  454. padding: 2vw;
  455. .one_1 {
  456. input {
  457. padding: 2vw;
  458. background-color: var(--f1Color);
  459. font-size: var(--font14Size);
  460. border-radius: 5px;
  461. }
  462. }
  463. .one_2 {
  464. display: flex;
  465. justify-content: center;
  466. align-items: center;
  467. .left {
  468. padding: 0 2vw;
  469. width: 75vw;
  470. input {
  471. padding: 2vw;
  472. background-color: var(--f1Color);
  473. font-size: var(--font14Size);
  474. border-radius: 5px;
  475. }
  476. }
  477. .button {
  478. background-color: var(--f3CColor);
  479. color: var(--mainColor);
  480. }
  481. }
  482. .one_3 {
  483. height: 20vh;
  484. .list {
  485. padding: 2vw;
  486. border-bottom: 1px solid var(--f5Color);
  487. .name {
  488. display: inline-block;
  489. white-space: nowrap;
  490. width: 100%;
  491. overflow: hidden;
  492. text-overflow: ellipsis;
  493. }
  494. }
  495. }
  496. }
  497. .two {
  498. position: relative;
  499. flex-grow: 1;
  500. background-color: var(--f9Color);
  501. .tabsList {
  502. position: relative;
  503. width: 100vw;
  504. height: 82vh;
  505. .list {
  506. background-color: var(--mainColor);
  507. border: 1px solid var(--f5Color);
  508. padding: 2vw;
  509. margin: 0 2vw 2vw 2vw;
  510. border-radius: 5px;
  511. .list_1 {
  512. display: flex;
  513. justify-content: space-between;
  514. padding: 2vw 0;
  515. font-size: var(--font16Size);
  516. .status {
  517. font-size: var(--font14Size);
  518. color: var(--fF0Color);
  519. }
  520. }
  521. .list_2 {
  522. display: flex;
  523. .left {
  524. .image {
  525. width: 20vw;
  526. height: 20vw;
  527. border-radius: 5px;
  528. border: 1px solid var(--f9Color);
  529. }
  530. }
  531. .right {
  532. width: 70vw;
  533. margin: 0 0 0 2vw;
  534. .right_1 {
  535. display: flex;
  536. justify-content: space-between;
  537. margin: 0 0 2vw 0;
  538. .name {
  539. font-size: var(--font14Size);
  540. }
  541. .num {
  542. display: flex;
  543. flex-direction: column;
  544. align-items: flex-end;
  545. text:last-child {
  546. font-size: var(--font13Size);
  547. color: var(--f85Color);
  548. }
  549. }
  550. }
  551. .right_2 {
  552. font-size: var(--font12Size);
  553. color: var(--f85Color);
  554. }
  555. }
  556. }
  557. .bottom {
  558. text-align: center;
  559. padding: 1vw 0;
  560. button {
  561. margin: 0 5px 0 0;
  562. }
  563. }
  564. }
  565. }
  566. }
  567. }
  568. .scroll-view {
  569. position: absolute;
  570. top: 0;
  571. left: 0;
  572. right: 0;
  573. bottom: 0;
  574. .list-scroll-view {
  575. display: flex;
  576. flex-direction: column;
  577. }
  578. }
  579. .is_bottom {
  580. width: 100%;
  581. text-align: center;
  582. text {
  583. padding: 2vw 0;
  584. display: inline-block;
  585. color: var(--f85Color);
  586. font-size: var(--font14Size);
  587. }
  588. }
  589. </style>