index.vue 7.8 KB

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