index.vue 12 KB

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