index.vue 11 KB

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