product.vue 4.9 KB

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