myProduct.vue 5.4 KB

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