skus.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view class="search-box">
  3. <up-search placeholder="搜索关键词" v-model="keyword" height="35" @blur="onSearch" :clearabled="false"
  4. :showAction="false" />
  5. <view v-if="content.where.condition" class="clear" @click.stop="onSearch('')">
  6. <up-icon name="close-circle-fill" size="20" />
  7. </view>
  8. </view>
  9. <view style="height: 20rpx; " />
  10. <My_listbox ref="listBox" :empty="!list.length" @getlist="getList">
  11. <view class="item" hover-class="navigator-hover" v-for="item in list" :key="item.itemid"
  12. @click="selected(item)">
  13. <view class="image-box" >
  14. <up-image :show-loading="true" :src="item.cover" width="80px" height="80px" />
  15. <view class="tag" v-if="item.cardno" :style="{
  16. background: item.isUnderWarranty ? '#27D8B4' : '#E14154',
  17. }">
  18. {{ item.isUnderWarranty ? '在' : '过' }}保
  19. </view>
  20. </view>
  21. <view class="content">
  22. <view class="row">
  23. <text class="label">
  24. 产品名称
  25. </text>
  26. {{ item.itemname || ' --' }}
  27. </view>
  28. <view class="row">
  29. <text class="label">
  30. 产品型号
  31. </text>
  32. {{ item.model || ' --' }}
  33. </view>
  34. <view class="row">
  35. <text class="label">
  36. 序列号
  37. </text>
  38. {{ item.sku || ' --' }}
  39. </view>
  40. <view class="row">
  41. <text class="label">
  42. 保修卡号
  43. </text>
  44. {{ item.cardno || ' --' }}
  45. </view>
  46. <view class="row">
  47. <text class="label">
  48. 保修期限
  49. </text>
  50. {{ item.begdate ? item.begdate + '至' + item.enddate : ' --' }}
  51. </view>
  52. </view>
  53. </view>
  54. <view style="height: 30px;" />
  55. </My_listbox>
  56. </template>
  57. <script setup>
  58. import { ref, reactive, getCurrentInstance } from 'vue';
  59. const { $Http } = getCurrentInstance().proxy;
  60. import { onLoad } from '@dcloudio/uni-app';
  61. const keyword = ref('');
  62. const listBox = ref(null);
  63. const content = reactive({
  64. loading: false,
  65. "pageNumber": 1,
  66. "pageSize": 20,
  67. sys_enterpriseid: '',
  68. "where": {
  69. "condition": ""
  70. }
  71. });
  72. function onSearch(e) {
  73. if (content.where.condition == e) return;
  74. content.where.condition = e;
  75. keyword.value = e;
  76. getList(true);
  77. }
  78. const list = ref([])
  79. onLoad((options) => {
  80. $Http.basic({
  81. "classname": "common.usercenter.usercenter",
  82. "method": "queryUserMsg",
  83. "content": {}
  84. }).then(res => {
  85. if (res.code != 1) return uni.showToast({
  86. title: res.msg,
  87. icon: 'none'
  88. });
  89. content.sys_enterpriseid = res.data.hr.sys_enterpriseid;
  90. getList();
  91. })
  92. });
  93. function getList(init = false) {
  94. if (content.loading) {
  95. listBox.value.refreshToComplete();
  96. listBox.value.setHeight();
  97. return
  98. };
  99. content.loading = true;
  100. if (init) content.pageNumber = 1;
  101. $Http.basic({
  102. "id": "2025082210142103",
  103. content
  104. }).then(res => {
  105. content.loading = false;
  106. if (res.code != 1) return uni.showToast({
  107. title: res.msg,
  108. icon: 'none'
  109. });
  110. console.log("获取产品列表", res)
  111. listBox.value.refreshToComplete();
  112. listBox.value.setHeight();
  113. res.data = res.data.map(v => {
  114. v.isUnderWarranty = new Date() >= new Date(v.begdate) && new Date() <= new Date(v.enddate);
  115. try {
  116. v.cover = v.attinfos.length ? $Http.getSpecifiedImage(v.attinfos[0]) : ''
  117. } catch (error) {
  118. }
  119. return v
  120. })
  121. if (res.code == 1) {
  122. list.value = reactive(res.firstPage ? res.data : list.value.concat(res.data));
  123. content.pageTotal = res.pageTotal;
  124. content.pageNumber = res.pageNumber;
  125. } else {
  126. if (res.msg) uni.showToast({
  127. title: res.msg,
  128. icon: 'none'
  129. });
  130. }
  131. })
  132. }
  133. function selected(item) {
  134. $Http.onSelected && $Http.onSelected(item)
  135. }
  136. </script>
  137. <style lang="scss" scoped>
  138. .search-box {
  139. position: relative;
  140. padding: 20rpx;
  141. background: #fff;
  142. .clear {
  143. position: absolute;
  144. display: flex;
  145. align-items: center;
  146. right: 0;
  147. top: 50%;
  148. transform: translateY(-50%);
  149. width: 80rpx;
  150. padding-left: 10rpx;
  151. height: 70rpx;
  152. z-index: 2;
  153. }
  154. }
  155. .item {
  156. position: relative;
  157. display: flex;
  158. width: 95%;
  159. box-shadow: 0rpx 4rpx 16rpx 2rpx rgba(150, 157, 165, 0.16);
  160. border-radius: 10rpx;
  161. box-sizing: border-box;
  162. padding: 20rpx 30rpx;
  163. overflow: hidden;
  164. margin: 0 auto 20rpx;
  165. background: #fff;
  166. .image-box {
  167. position: relative;
  168. .tag {
  169. position: absolute;
  170. left: 0;
  171. top: 0;
  172. padding: 4rpx 14rpx;
  173. padding-right: 20rpx;
  174. text-align: center;
  175. background: red;
  176. font-size: 22rpx;
  177. color: #fff;
  178. border-radius: 0 0 8rpx 0;
  179. }
  180. }
  181. .content {
  182. margin-left: 20rpx;
  183. .row {
  184. display: flex;
  185. line-height: 32rpx;
  186. font-family: Microsoft YaHei, Microsoft YaHei;
  187. font-size: 24rpx;
  188. margin-top: 8rpx;
  189. .label {
  190. color: #666;
  191. flex-shrink: 0;
  192. }
  193. .label::after {
  194. content: ':';
  195. }
  196. }
  197. }
  198. }
  199. </style>