index.vue 10 KB

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