index.vue 8.4 KB

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