index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  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. let obj = {
  246. order_id: item._id,
  247. user: item.user,
  248. user_name: item.user_name,
  249. good: item.goods,
  250. good_name: item.good_name,
  251. good_file: [item.good_file],
  252. spec: item.spec,
  253. spec_name: item.spec_name,
  254. spec_file: [item.spec_file],
  255. supplier: item.supplier_id,
  256. supplier_name: item.supplier_name,
  257. address: item.address,
  258. apply_time: moment().format('YYYY-MM-DD HH:mm:ss')
  259. }
  260. const res = await that.$api(`/Upkeep`, 'POST', obj);
  261. if (res.errcode == '0') {
  262. uni.showToast({
  263. title: '维护信息成功',
  264. icon: 'none'
  265. })
  266. that.clearPage()
  267. that.search()
  268. } else {
  269. uni.showToast({
  270. title: res.errmsg,
  271. icon: 'none'
  272. })
  273. }
  274. }
  275. }
  276. });
  277. },
  278. // 查看详情
  279. toInfo(e) {
  280. uni.navigateTo({
  281. url: `/pagesMy/order/detail?id=${e.id||e._id}`
  282. })
  283. },
  284. // 分页
  285. toPage(e) {
  286. const that = this;
  287. let list = that.list;
  288. let limit = that.limit;
  289. if (that.total > list.length) {
  290. uni.showLoading({
  291. title: '加载中',
  292. mask: true
  293. })
  294. let page = that.page + 1;
  295. that.$set(that, `page`, page)
  296. let skip = page * limit;
  297. that.$set(that, `skip`, skip)
  298. that.search();
  299. uni.hideLoading();
  300. } else that.$set(that, `is_bottom`, true)
  301. },
  302. // 触底
  303. toScroll(e) {
  304. const that = this;
  305. let up = that.scrollTop;
  306. that.$set(that, `scrollTop`, e.detail.scrollTop);
  307. let num = Math.sign(up - e.detail.scrollTop);
  308. if (num == 1) that.$set(that, `is_bottom`, false);
  309. },
  310. // 输入框
  311. toInput(e) {
  312. const that = this;
  313. if (that.searchInfo.goods) that.$set(that.searchInfo, `goods`, e.detail.value)
  314. else that.$set(that, `searchInfo`, {})
  315. that.clearPage();
  316. that.search();
  317. },
  318. // 查询其他信息
  319. async searchOther() {
  320. const that = this;
  321. let res;
  322. // 查询状态
  323. res = await that.$api(`/DictData`, 'GET', {
  324. type: 'order_status',
  325. is_use: '0',
  326. })
  327. if (res.errcode == '0') {
  328. that.$set(that, `statusList`, res.data);
  329. let status = res.data.filter((i) => {
  330. return i.value == '0' || i.value == '4' || i.value == '5' || i.value == '6' || i
  331. .value == '-2' || i.value == '-3';
  332. });
  333. var menu = status.map((item) => {
  334. return {
  335. title: item.label,
  336. active: item.value
  337. }
  338. })
  339. menu.unshift({
  340. title: '全部',
  341. active: '-1'
  342. })
  343. that.$set(that.tabs, `menu`, menu)
  344. }
  345. },
  346. // 选择选项卡
  347. tabsChange(e) {
  348. const that = this;
  349. that.$set(that.tabs, `active`, e.active)
  350. that.$set(that, `status`, e.active);
  351. that.clearPage();
  352. that.search()
  353. },
  354. // 清空列表
  355. clearPage() {
  356. const that = this;
  357. that.$set(that, `list`, [])
  358. that.$set(that, `skip`, 0)
  359. that.$set(that, `limit`, 6)
  360. that.$set(that, `page`, 0)
  361. }
  362. }
  363. }
  364. </script>
  365. <style lang="scss">
  366. .content {
  367. display: flex;
  368. flex-direction: column;
  369. width: 100vw;
  370. height: 100vh;
  371. .one {
  372. padding: 2vw;
  373. input {
  374. padding: 2vw;
  375. background-color: var(--f1Color);
  376. font-size: var(--font14Size);
  377. border-radius: 5px;
  378. }
  379. }
  380. .two {
  381. position: relative;
  382. flex-grow: 1;
  383. background-color: var(--f9Color);
  384. .tabsList {
  385. position: relative;
  386. width: 100vw;
  387. height: 82vh;
  388. .list {
  389. background-color: var(--mainColor);
  390. border: 1px solid var(--f5Color);
  391. padding: 2vw;
  392. margin: 0 2vw 2vw 2vw;
  393. border-radius: 5px;
  394. .list_1 {
  395. display: flex;
  396. justify-content: space-between;
  397. padding: 2vw 0;
  398. font-size: var(--font16Size);
  399. .status {
  400. font-size: var(--font14Size);
  401. color: var(--fF0Color);
  402. }
  403. }
  404. .list_2 {
  405. display: flex;
  406. .left {
  407. .image {
  408. width: 20vw;
  409. height: 20vw;
  410. border-radius: 5px;
  411. border: 1px solid var(--f9Color);
  412. }
  413. }
  414. .right {
  415. width: 70vw;
  416. margin: 0 0 0 2vw;
  417. .right_1 {
  418. display: flex;
  419. justify-content: space-between;
  420. margin: 2vw 0;
  421. .name {
  422. font-size: var(--font14Size);
  423. }
  424. .num {
  425. display: flex;
  426. flex-direction: column;
  427. align-items: flex-end;
  428. text:last-child {
  429. font-size: var(--font13Size);
  430. color: var(--f85Color);
  431. }
  432. }
  433. }
  434. .right_2 {
  435. font-size: var(--font12Size);
  436. color: var(--f85Color);
  437. }
  438. }
  439. }
  440. .bottom {
  441. text-align: center;
  442. padding: 1vw 0;
  443. button {
  444. margin: 0 5px 0 0;
  445. }
  446. }
  447. }
  448. }
  449. }
  450. }
  451. .scroll-view {
  452. position: absolute;
  453. top: 0;
  454. left: 0;
  455. right: 0;
  456. bottom: 0;
  457. .list-scroll-view {
  458. display: flex;
  459. flex-direction: column;
  460. }
  461. }
  462. .is_bottom {
  463. width: 100%;
  464. text-align: center;
  465. text {
  466. padding: 2vw 0;
  467. display: inline-block;
  468. color: var(--f85Color);
  469. font-size: var(--font14Size);
  470. }
  471. }
  472. </style>