index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <input type="text" v-model="searchInfo.good_name" @input="toInput" placeholder="搜索商品">
  5. </view>
  6. <view class="two">
  7. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  8. <view class="list-scroll-view">
  9. <view class="list" v-for="(item,index) in list" :key="index" @tap="toInfo(item)">
  10. <view class="list_1">
  11. <text>
  12. <text class="iconfont icon-changshangguanli"></text>
  13. {{item.supplier_name}}
  14. </text>
  15. <text class="status">{{item.zhStatus}}</text>
  16. </view>
  17. <view class="list_2">
  18. <view class="left">
  19. <image v-if="item.spec_file" class="image" :src="item.spec_file?item.spec_file.url:''"
  20. mode="">
  21. </image>
  22. <image v-else class="image" :src="item.good_file?item.good_file.url:''" mode="">
  23. </image>
  24. </view>
  25. <view class="right">
  26. <view class="right_1">
  27. <view class="name textOver">
  28. <text>{{item.good_name||'暂无'}}</text>
  29. </view>
  30. <view class="num">
  31. <text>¥{{item.total_money||'0'}}</text>
  32. <text>×{{item.num||'0'}}</text>
  33. </view>
  34. </view>
  35. <view class="right_2">
  36. <view class="spec textOver">
  37. <text>规格:</text>
  38. <text>{{item.spec_name||'暂无'}}</text>
  39. </view>
  40. <view class="spec textOver">
  41. <text>购买用户:</text>
  42. <text>{{item.user_name||'暂无'}}</text>
  43. </view>
  44. <view class="spec textOver">
  45. <text>用户角色:</text>
  46. <text>{{item.zhRole||'暂无'}}</text>
  47. </view>
  48. <view class="spec textOver">
  49. <text>申请时间:</text>
  50. <text>{{item.apply_time||'暂无'}}</text>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="is_bottom" v-if="is_bottom">
  57. <text>{{config.bottom_title}}</text>
  58. </view>
  59. </view>
  60. </scroll-view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. export default {
  66. data() {
  67. return {
  68. // 系统设置
  69. config: {},
  70. user: {},
  71. searchInfo: {},
  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. roleList: []
  83. }
  84. },
  85. onLoad: function(e) {
  86. const that = this;
  87. that.searchConfig();
  88. },
  89. onShow: async function(e) {
  90. const that = this;
  91. await that.searchOther();
  92. that.searchToken();
  93. },
  94. onPullDownRefresh: async function() {
  95. const that = this;
  96. that.clearPage();
  97. await that.search();
  98. uni.stopPullDownRefresh();
  99. },
  100. methods: {
  101. searchConfig() {
  102. const that = this;
  103. try {
  104. const res = uni.getStorageSync('config');
  105. if (res) that.$set(that, `config`, res);
  106. } catch (e) {
  107. uni.showToast({
  108. title: err.errmsg,
  109. icon: 'error',
  110. duration: 2000
  111. });
  112. }
  113. },
  114. searchToken() {
  115. const that = this;
  116. try {
  117. const res = uni.getStorageSync('token');
  118. if (res) {
  119. that.$set(that, `user`, res);
  120. that.clearPage();
  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 info = {
  135. skip: that.skip,
  136. limit: that.limit,
  137. user: user._id
  138. };
  139. let res;
  140. res = await that.$api(`/Upkeep`, 'GET', {
  141. ...info,
  142. ...that.searchInfo
  143. });
  144. if (res.errcode == '0') {
  145. let list = [...that.list, ...res.data];
  146. for (let val of list) {
  147. val.zhStatus = that.searchDict(val.status, 'status')
  148. }
  149. that.$set(that, `list`, list);
  150. that.$set(that, `total`, res.total)
  151. } else {
  152. uni.showToast({
  153. title: res.errmsg,
  154. icon: 'none'
  155. })
  156. }
  157. },
  158. // 查看详情
  159. toInfo(e) {
  160. uni.navigateTo({
  161. url: `/pagesMy/repair/detail?id=${e.id||e._id}`
  162. })
  163. },
  164. // 查询字典表
  165. searchDict(e, model) {
  166. const that = this;
  167. let data
  168. if (model == 'status') {
  169. data = that.statusList.find((i) => i.value == e);
  170. if (data) return data.label
  171. else return '暂无'
  172. }
  173. },
  174. // 分页
  175. toPage(e) {
  176. const that = this;
  177. let list = that.list;
  178. let limit = that.limit;
  179. if (that.total > list.length) {
  180. uni.showLoading({
  181. title: '加载中',
  182. mask: true
  183. })
  184. let page = that.page + 1;
  185. that.$set(that, `page`, page)
  186. let skip = page * limit;
  187. that.$set(that, `skip`, skip)
  188. that.search();
  189. uni.hideLoading();
  190. } else that.$set(that, `is_bottom`, true)
  191. },
  192. // 触底
  193. toScroll(e) {
  194. const that = this;
  195. let up = that.scrollTop;
  196. that.$set(that, `scrollTop`, e.detail.scrollTop);
  197. let num = Math.sign(up - e.detail.scrollTop);
  198. if (num == 1) that.$set(that, `is_bottom`, false);
  199. },
  200. // 输入框
  201. toInput(e) {
  202. const that = this;
  203. if (that.searchInfo.good_name) that.$set(that.searchInfo, `good_name`, e.detail.value)
  204. else that.$set(that, `searchInfo`, {})
  205. that.clearPage();
  206. that.search();
  207. },
  208. // 查询其他信息
  209. async searchOther() {
  210. const that = this;
  211. let res;
  212. // 查询状态
  213. res = await that.$api(`/DictData`, 'GET', {
  214. type: 'upkeep',
  215. is_use: '0'
  216. })
  217. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  218. },
  219. // 清空列表
  220. clearPage() {
  221. const that = this;
  222. that.$set(that, `list`, [])
  223. that.$set(that, `skip`, 0)
  224. that.$set(that, `limit`, 6)
  225. that.$set(that, `page`, 0)
  226. }
  227. }
  228. }
  229. </script>
  230. <style lang="scss">
  231. .content {
  232. display: flex;
  233. flex-direction: column;
  234. width: 100vw;
  235. height: 100vh;
  236. .one {
  237. padding: 2vw;
  238. input {
  239. padding: 2vw;
  240. background-color: var(--f1Color);
  241. font-size: var(--font14Size);
  242. border-radius: 5px;
  243. }
  244. }
  245. .two {
  246. position: relative;
  247. flex-grow: 1;
  248. background-color: var(--f9Color);
  249. .list {
  250. background-color: #fff;
  251. border: 1px solid var(--f5Color);
  252. padding: 2vw;
  253. margin: 2vw 2vw 0 2vw;
  254. border-radius: 5px;
  255. .list_1 {
  256. display: flex;
  257. justify-content: space-between;
  258. padding: 2vw 0;
  259. font-size: var(--font16Size);
  260. .status {
  261. font-size: var(--font14Size);
  262. color: var(--fF0Color);
  263. }
  264. }
  265. .list_2 {
  266. display: flex;
  267. .left {
  268. .image {
  269. width: 20vw;
  270. height: 20vw;
  271. border-radius: 5px;
  272. border: 1px solid var(--f9Color);
  273. }
  274. }
  275. .right {
  276. width: 70vw;
  277. margin: 0 0 0 2vw;
  278. .right_1 {
  279. display: flex;
  280. justify-content: space-between;
  281. margin: 2vw 0;
  282. .name {
  283. font-size: var(--font14Size);
  284. }
  285. .num {
  286. display: flex;
  287. flex-direction: column;
  288. align-items: flex-end;
  289. text:last-child {
  290. font-size: var(--font13Size);
  291. color: var(--f85Color);
  292. }
  293. }
  294. }
  295. .right_2 {
  296. font-size: var(--font12Size);
  297. .spec {
  298. text:first-child {
  299. color: var(--f85Color);
  300. }
  301. }
  302. }
  303. }
  304. }
  305. }
  306. }
  307. }
  308. .scroll-view {
  309. position: absolute;
  310. top: 0;
  311. left: 0;
  312. right: 0;
  313. bottom: 0;
  314. .list-scroll-view {
  315. display: flex;
  316. flex-direction: column;
  317. }
  318. }
  319. .is_bottom {
  320. width: 100%;
  321. text-align: center;
  322. text {
  323. padding: 2vw 0;
  324. display: inline-block;
  325. color: var(--f85Color);
  326. font-size: var(--font14Size);
  327. }
  328. }
  329. </style>