app-customer-sel.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. <app-search-module
  12. ref="aaaaa"
  13. placeholder="请填写姓名,支持拼音首字母"
  14. :focus="false"
  15. @input="searchFn"
  16. />
  17. </div>
  18. <!-- 列表 -->
  19. <scroll-view class="customer-list" scroll-y>
  20. <view v-for="(item, index) in customerListData" :key="index" @click="switchCustomer(item, index)" class="customer-item">
  21. <view class="item-avatar">
  22. <image :src="item.smallAvatar" alt="商品图" />
  23. </view>
  24. <view class="item-name"> {{ item.name || "" }} <text v-if="newClientId==item.id">新增</text></view>
  25. <view class="item-level">{{ getCustomerLevelName(item) }}</view>
  26. <!-- <view class="item-tag">NEW</view> -->
  27. </view>
  28. </scroll-view>
  29. <view class="add-customer-bar" @click="gotoAddCustomer">
  30. 没有找到客户?新增
  31. </view>
  32. </div>
  33. </bottom-popup>
  34. </div>
  35. </template>
  36. <script>
  37. import BottomPopup from "@/components/plugin/bottom-popup";
  38. import AppClose from "@/components/module/app-close";
  39. import AppSearchModule from "@/components/module/app-search";
  40. // api
  41. import { getList } from "@/api/member/index";
  42. export default {
  43. name: "app-customer-sel",
  44. components: {
  45. BottomPopup,
  46. AppClose,
  47. AppSearchModule
  48. },
  49. props: {
  50. show: {
  51. type: Boolean,
  52. default: false
  53. }
  54. },
  55. data() {
  56. return {
  57. showPopup: false,
  58. name: "",
  59. newClientId: "",
  60. customerListData: []
  61. };
  62. },
  63. mounted() {
  64. this.showPopup = this.show;
  65. },
  66. computed: {},
  67. watch: {
  68. show(val) {
  69. this.showPopup = val;
  70. // #ifdef H5
  71. this.$nextTick(function() {
  72. setTimeout(() => {
  73. this.$refs.aaaaa.$refs.searchInput._focusInput();
  74. }, 1000);
  75. });
  76. // #endif
  77. if (val) {
  78. this.initList();
  79. }
  80. }
  81. },
  82. methods: {
  83. initList() {
  84. return getList({name: this.name })
  85. .then(res => {
  86. const {data: { list }} = res;
  87. this.newClientId = uni.getStorageSync("newClient")?uni.getStorageSync("newClient").id:'';
  88. this.customerListData = list;
  89. })
  90. .catch(err => {});
  91. },
  92. // 搜索
  93. searchFn(e) {
  94. this.name = e;
  95. this.initList();
  96. // this.$emit('search', e)
  97. },
  98. hidePopup() {
  99. this.$emit("update:show", false);
  100. this.$emit("hide");
  101. },
  102. switchCustomer(item, index) {
  103. this.$emit("change", item);
  104. this.hidePopup();
  105. },
  106. getCustomerLevelName(level) {
  107. let levelName = "";
  108. switch (Number(level)) {
  109. case 0:
  110. levelName = "普通客户";
  111. break;
  112. case 1:
  113. levelName = "一级会员";
  114. break;
  115. case 2:
  116. levelName = "二级会员";
  117. break;
  118. default:
  119. break;
  120. }
  121. return levelName;
  122. },
  123. gotoAddCustomer() {
  124. uni.navigateTo({
  125. url: "/pagesClient/member/add",
  126. success: result => {
  127. this.hidePopup();
  128. },
  129. fail: () => {},
  130. complete: () => {}
  131. });
  132. }
  133. }
  134. };
  135. </script>
  136. <style lang="scss" scoped>
  137. // 弹窗
  138. /deep/.popup-wrap {
  139. .tui-popup-class {
  140. border-top-left-radius: 20px;
  141. border-top-right-radius: 20px;
  142. }
  143. }
  144. .map-wrap {
  145. .map-top-tit-wrap {
  146. padding: 34px 0;
  147. text-align: center;
  148. font-size: 34px;
  149. }
  150. .map-search {
  151. padding: 0 30px;
  152. margin-bottom: 20px;
  153. }
  154. .map-box {
  155. .current-site-icon {
  156. width: 63px;
  157. height: 90px;
  158. position: absolute;
  159. top: 50%;
  160. left: 50%;
  161. transform: translate(-50%, -50%);
  162. }
  163. }
  164. // 列表
  165. .customer-list {
  166. min-height: 500rpx;
  167. max-height: 820rpx;
  168. // padding-bottom: 110rpx;
  169. box-sizing: border-box;
  170. .customer-item {
  171. display: flex;
  172. width: 100%;
  173. align-items: center;
  174. line-height: 40rpx;
  175. padding: 18rpx 30px;
  176. text-align: left;
  177. border-bottom: 1px solid #eee;
  178. position: relative;
  179. .item-avatar {
  180. flex-shrink: 0;
  181. width: 66px;
  182. height: 66px;
  183. border-radius: 50%;
  184. overflow: hidden;
  185. image {
  186. width: 100%;
  187. height: 100%;
  188. }
  189. }
  190. .item-name {
  191. flex-shrink: 0;
  192. margin: 0 20upx;
  193. /*width: 200upx;*/
  194. text{
  195. padding: 0 10rpx;
  196. margin-left: 20rpx;
  197. color: #3385ff;
  198. border: 1px solid #3385ff;
  199. }
  200. }
  201. .item-level {
  202. margin: 0 20upx;
  203. flex: 1;
  204. }
  205. .item-tag {
  206. display: flex;
  207. align-items: center;
  208. justify-content: center;
  209. width: 78px;
  210. height: 34px;
  211. flex-shrink: 0;
  212. background-color: #3385ff;
  213. border-radius: 17px 17px 17px 0;
  214. font-size: 20px;
  215. color: #fff;
  216. }
  217. }
  218. }
  219. .add-customer-bar {
  220. width: 100%;
  221. height: 100px;
  222. display: flex;
  223. justify-content: center;
  224. align-items: center;
  225. color: #3385ff;
  226. font-size: 26px;
  227. box-shadow: 0px -1px 6px 0px rgba(4, 0, 0, 0.06);
  228. }
  229. }
  230. </style>