myProduct.vue 5.6 KB

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