index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  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.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.search();
  126. }
  127. } catch (e) {
  128. uni.showToast({
  129. title: err.errmsg,
  130. icon: 'error',
  131. duration: 2000
  132. });
  133. }
  134. },
  135. async search() {
  136. const that = this;
  137. let user = that.user;
  138. let status = that.status;
  139. let info = {
  140. skip: that.skip,
  141. limit: that.limit,
  142. user: user._id,
  143. status: status
  144. }
  145. let res;
  146. res = await that.$api(`/OrderDetail/queryInfo`, 'GET', {
  147. ...info,
  148. ...that.searchInfo
  149. });
  150. if (res.errcode == '0') {
  151. let list = [...that.list, ...res.data];
  152. for (let val of list) {
  153. val.zhStatus = that.searchStatus(val.status)
  154. }
  155. that.$set(that, `list`, list);
  156. that.$set(that, `total`, res.total)
  157. } else {
  158. uni.showToast({
  159. title: res.errmsg,
  160. icon: 'none'
  161. })
  162. }
  163. },
  164. // 查询状态
  165. searchStatus(e) {
  166. const that = this;
  167. let data = that.statusList.find((i) => i.value == e);
  168. if (data) return data.label
  169. else return '暂无'
  170. },
  171. // 确认发货
  172. async toConfirm(item) {
  173. const that = this;
  174. let user = that.user;
  175. let obj = {
  176. status: '6'
  177. }
  178. uni.showModal({
  179. title: '提示',
  180. content: '是否要确认收货?',
  181. success: async function(res) {
  182. if (res.confirm) {
  183. const res = await that.$api(`/OrderDetail/${item._id}`, 'POST', obj);
  184. if (res.errcode == '0') {
  185. uni.showToast({
  186. title: '维护信息成功',
  187. icon: 'none'
  188. })
  189. that.clearPage()
  190. that.search()
  191. } else {
  192. uni.showToast({
  193. title: res.errmsg,
  194. icon: 'none'
  195. })
  196. }
  197. }
  198. }
  199. });
  200. },
  201. // 查看详情
  202. toInfo(item) {
  203. console.log(item);
  204. },
  205. // 分页
  206. toPage(e) {
  207. const that = this;
  208. let list = that.list;
  209. let limit = that.limit;
  210. if (that.total > list.length) {
  211. uni.showLoading({
  212. title: '加载中',
  213. mask: true
  214. })
  215. let page = that.page + 1;
  216. that.$set(that, `page`, page)
  217. let skip = page * limit;
  218. that.$set(that, `skip`, skip)
  219. that.searchMarket();
  220. uni.hideLoading();
  221. } else that.$set(that, `is_bottom`, true)
  222. },
  223. // 触底
  224. toScroll(e) {
  225. const that = this;
  226. let up = that.scrollTop;
  227. that.$set(that, `scrollTop`, e.detail.scrollTop);
  228. let num = Math.sign(up - e.detail.scrollTop);
  229. if (num == 1) that.$set(that, `is_bottom`, false);
  230. },
  231. // 输入框
  232. toInput(e) {
  233. const that = this;
  234. if (that.searchInfo.goods) that.$set(that.searchInfo, `goods`, e.detail.value)
  235. else that.$set(that, `searchInfo`, {})
  236. that.clearPage();
  237. that.search();
  238. },
  239. // 查询其他信息
  240. async searchOther() {
  241. const that = this;
  242. let res;
  243. // 查询状态
  244. res = await that.$api(`/DictData`, 'GET', {
  245. type: 'order_status'
  246. })
  247. if (res.errcode == '0') {
  248. that.$set(that, `statusList`, res.data);
  249. let status = res.data.filter((i) => {
  250. return i.value == '0' || i.value == '4' || i.value == '5' || i.value == '6' || i
  251. .value == '7';
  252. });
  253. var menu = status.map((item) => {
  254. return {
  255. title: item.label,
  256. active: item.value
  257. }
  258. })
  259. that.$set(that.tabs, `menu`, menu)
  260. }
  261. },
  262. // 选择选项卡
  263. tabsChange(e) {
  264. const that = this;
  265. that.$set(that.tabs, `active`, e.active)
  266. that.$set(that, `status`, e.active);
  267. that.clearPage();
  268. that.search()
  269. },
  270. // 清空列表
  271. clearPage() {
  272. const that = this;
  273. that.$set(that, `list`, [])
  274. that.$set(that, `skip`, 0)
  275. that.$set(that, `limit`, 6)
  276. that.$set(that, `page`, 0)
  277. }
  278. }
  279. }
  280. </script>
  281. <style lang="scss">
  282. .content {
  283. display: flex;
  284. flex-direction: column;
  285. width: 100vw;
  286. height: 100vh;
  287. .one {
  288. padding: 2vw;
  289. input {
  290. padding: 2vw;
  291. background-color: var(--f1Color);
  292. font-size: var(--font14Size);
  293. border-radius: 5px;
  294. }
  295. }
  296. .two {
  297. position: relative;
  298. flex-grow: 1;
  299. background-color: var(--f9Color);
  300. .tabsList {
  301. position: relative;
  302. width: 100vw;
  303. height: 82vh;
  304. .list {
  305. background-color: #fff;
  306. border: 1px solid var(--f5Color);
  307. padding: 2vw;
  308. margin: 0 2vw 2vw 2vw;
  309. border-radius: 5px;
  310. .list_1 {
  311. display: flex;
  312. justify-content: space-between;
  313. padding: 2vw 0;
  314. font-size: var(--font14Size);
  315. .status {
  316. color: var(--fF0Color);
  317. }
  318. }
  319. .list_2 {
  320. display: flex;
  321. .left {
  322. .image {
  323. width: 20vw;
  324. height: 20vw;
  325. border-radius: 5px;
  326. }
  327. }
  328. .right {
  329. width: 70vw;
  330. margin: 0 0 0 2vw;
  331. .right_1 {
  332. display: flex;
  333. justify-content: space-between;
  334. margin: 2vw 0;
  335. .name {
  336. font-size: var(--font14Size);
  337. }
  338. .num {
  339. display: flex;
  340. flex-direction: column;
  341. align-items: flex-end;
  342. text:last-child {
  343. font-size: var(--font13Size);
  344. color: var(--f85Color);
  345. }
  346. }
  347. }
  348. .right_2 {
  349. font-size: var(--font12Size);
  350. color: var(--f85Color);
  351. }
  352. }
  353. }
  354. .bottom {
  355. text-align: center;
  356. padding: 1vw 0;
  357. button {
  358. margin: 0 5px 0 0;
  359. }
  360. }
  361. }
  362. }
  363. }
  364. }
  365. .scroll-view {
  366. position: absolute;
  367. top: 0;
  368. left: 0;
  369. right: 0;
  370. bottom: 0;
  371. .list-scroll-view {
  372. display: flex;
  373. flex-direction: column;
  374. }
  375. }
  376. .is_bottom {
  377. text-align: center;
  378. text {
  379. padding: 2vw 0;
  380. display: inline-block;
  381. color: var(--f85Color);
  382. font-size: var(--font14Size);
  383. }
  384. }
  385. </style>