app-supplier-sel.vue 5.3 KB

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