index.vue 7.9 KB

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