index.vue 9.0 KB

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