index.vue 8.5 KB

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