index.vue 14 KB

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