app-flower-sel.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <div class="app-area-sel">
  3. <bottom-popup class="popup-wrap" :show="showPopup" @close="hidePopup">
  4. <div class="map-wrap">
  5. <div class="map-top-tit-wrap">
  6. <div class="map-top-tit">从平台库添加</div>
  7. <app-close icon="iconguanbi" @close="hidePopup" />
  8. </div>
  9. <!-- 搜索 -->
  10. <div class="map-search">
  11. <!-- :focus="false" -->
  12. <app-search-module
  13. ref="aaaaa"
  14. placeholder="请输入关键词"
  15. @input="searchFn"
  16. />
  17. </div>
  18. <!-- 列表 -->
  19. <scroll-view class="customer-list" scroll-y @scrolltolower="loadMoreEvent">
  20. <block v-if="!$util.isEmpty(list.data)">
  21. <view
  22. v-for="(item, itemIndex) in list.data"
  23. :key="itemIndex"
  24. @click="switchFlower(item, itemIndex)"
  25. class="customer-item"
  26. >
  27. <view class="item-avatar">
  28. <image :src="item.cover" alt="商品图" />
  29. </view>
  30. <view class="item-info">
  31. <view class="item-name"> {{ item.name }}</view>
  32. <view class="item-weight">{{ item.weight }}斤/扎</view>
  33. <view class="item-price"> ¥{{ item.cost }}/扎</view></view
  34. >
  35. <view class="item-tag" v-if="hasSelect(item)">
  36. <text class="iconfont icondagou"> </text>
  37. </view>
  38. </view>
  39. </block>
  40. <block v-else>
  41. <AppWrapperEmpty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
  42. </block>
  43. </scroll-view>
  44. </div>
  45. </bottom-popup>
  46. </div>
  47. </template>
  48. <script>
  49. import BottomPopup from "@/components/plugin/bottom-popup";
  50. import AppClose from "@/components/module/app-close";
  51. import AppSearchModule from "@/components/module/app-search";
  52. import AppWrapperEmpty from "@/components/app-wrapper-empty";
  53. // api
  54. import { getPlatformFlowerListApi } from "@/api/storehouse/flower";
  55. import { list } from "@/mixins";
  56. export default {
  57. name: "app-customer-sel",
  58. components: {
  59. BottomPopup,
  60. AppClose,
  61. AppSearchModule,
  62. AppWrapperEmpty
  63. },
  64. props: {
  65. show: {
  66. type: Boolean,
  67. default: false
  68. },
  69. selectList: {
  70. type: Array,
  71. default() {
  72. return [];
  73. }
  74. }
  75. },
  76. mixins: [list],
  77. data() {
  78. return {
  79. showPopup: false,
  80. keyword: ""
  81. };
  82. },
  83. mounted() {
  84. this.showPopup = this.show;
  85. },
  86. // onLoad(val) {
  87. // this.mapCtx = uni.createMapContext('myMap')
  88. // this.query = val
  89. // this.reload()
  90. // },
  91. watch: {
  92. show(val) {
  93. this.showPopup = val;
  94. // #ifdef H5
  95. this.$nextTick(function() {
  96. setTimeout(() => {
  97. this.$refs.aaaaa.$refs.searchInput._focusInput();
  98. }, 1000);
  99. });
  100. // #endif
  101. if (val) {
  102. console.log(11111111);
  103. this.initData();
  104. }
  105. }
  106. },
  107. methods: {
  108. initData() {
  109. let options = {
  110. keyword: this.keyword,
  111. page: this.list.page,
  112. pageSize: this.list.pageSize
  113. };
  114. return getPlatformFlowerListApi(options)
  115. .then(res => {
  116. this.completes(res);
  117. })
  118. .catch(err => {});
  119. },
  120. // 搜索
  121. searchFn(e) {
  122. this.keyword = e;
  123. this.getAreaList();
  124. // this.$emit('search', e)
  125. },
  126. hidePopup() {
  127. this.$emit("update:show", false);
  128. this.$emit("hide");
  129. },
  130. switchFlower(item, index) {
  131. this.$emit("select", item);
  132. this.hidePopup();
  133. },
  134. loadMoreEvent() {
  135. this.initData();
  136. },
  137. hasSelect(item) {
  138. let has = false;
  139. for (const selectItem of this.selectList) {
  140. if (selectItem.id == item.id) {
  141. has = true;
  142. break;
  143. }
  144. }
  145. return has;
  146. }
  147. }
  148. };
  149. </script>
  150. <style lang="scss" scoped>
  151. // 弹窗
  152. /deep/.popup-wrap {
  153. .tui-popup-class {
  154. border-top-left-radius: 20px;
  155. border-top-right-radius: 20px;
  156. }
  157. }
  158. .map-wrap {
  159. .map-top-tit-wrap {
  160. padding: 30px 0;
  161. text-align: center;
  162. font-size: 34px;
  163. }
  164. .map-search {
  165. padding: 0 30px;
  166. margin-bottom: 20px;
  167. }
  168. .map-box {
  169. .current-site-icon {
  170. width: 63px;
  171. height: 90px;
  172. position: absolute;
  173. top: 50%;
  174. left: 50%;
  175. transform: translate(-50%, -50%);
  176. }
  177. }
  178. // 列表
  179. .customer-list {
  180. min-height: 500rpx;
  181. max-height: 820rpx;
  182. // padding-bottom: 110rpx;
  183. box-sizing: border-box;
  184. .customer-item {
  185. display: flex;
  186. width: 100%;
  187. align-items: center;
  188. line-height: 40rpx;
  189. padding: 18rpx 30px;
  190. text-align: left;
  191. border-bottom: 1px solid #eee;
  192. position: relative;
  193. .item-avatar {
  194. flex-shrink: 0;
  195. width: 66px;
  196. height: 66px;
  197. border-radius: 50%;
  198. overflow: hidden;
  199. image {
  200. width: 100%;
  201. height: 100%;
  202. }
  203. }
  204. .item-info {
  205. margin: 0 20upx;
  206. flex: 1;
  207. display: flex;
  208. align-items: center;
  209. }
  210. .item-name {
  211. margin: 0 20upx;
  212. flex: 1;
  213. }
  214. .item-weight {
  215. flex-shrink: 0;
  216. margin: 0 20upx;
  217. flex: 1;
  218. }
  219. .item-price {
  220. margin: 0 20upx;
  221. flex: 1;
  222. }
  223. .item-tag {
  224. display: flex;
  225. color: #3385ff;
  226. .iconfont {
  227. font-size: 32upx;
  228. }
  229. }
  230. }
  231. }
  232. .add-customer-bar {
  233. width: 100%;
  234. height: 100px;
  235. display: flex;
  236. justify-content: center;
  237. align-items: center;
  238. color: #3385ff;
  239. font-size: 26px;
  240. box-shadow: 0px -1px 6px 0px rgba(4, 0, 0, 0.06);
  241. }
  242. }
  243. </style>