index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-01-12 11:57:48
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-05-22 15:31:58
  6. * @Description: file content
  7. * @FilePath: \oms\pages\distributor\index.vue
  8. -->
  9. <template>
  10. <view class="home">
  11. <view class="nav">
  12. <view :style="{ paddingTop }">
  13. <view class="title" :style="[{ height }, { lineHeight: height }]">
  14. <view class="back" @click="goBack()">
  15. <u-icon name="arrow-left" color="#ffffff" size="22"></u-icon>
  16. </view>
  17. <text>合作伙伴</text>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="main">
  22. <!-- tabs -->
  23. <view class="tabs">
  24. <u-tabs
  25. @change="changeTabs"
  26. lineWidth="8"
  27. :current="curTabIndex"
  28. lineHeight="8"
  29. :scrollable="false"
  30. :list="list"
  31. :lineColor="`url(${lineBg}) 100% 100%`"
  32. :activeStyle="{
  33. color: '#3E7EF8',
  34. fontWeight: 'bold',
  35. }"
  36. :inactiveStyle="{
  37. color: '#969696',
  38. }"
  39. itemStyle="height: 90rpx;"></u-tabs>
  40. </view>
  41. <!-- 搜索 -->
  42. <view class="query-wrap">
  43. <view class="search-container">
  44. <view class="search-input">
  45. <u-input
  46. clearable
  47. placeholderStyle="font-size:26rpx"
  48. :customStyle="{ height: '66rpx' }"
  49. v-model="distName"
  50. prefixIcon="search"
  51. prefixIconStyle="font-size: 22px;color: #909399"
  52. placeholder="请输入名称"
  53. shape="circle"
  54. border="surround"></u-input>
  55. </view>
  56. <view class="search-btn" @click="searchList">搜索</view>
  57. </view>
  58. </view>
  59. <u-empty v-if="customerData.length == 0" mode="list" text="暂无数据"></u-empty>
  60. <scroll-view :scroll-y="true" class="data-list" @scrolltolower="lower" v-else>
  61. <view>
  62. <view class="data-item" v-for="(v, i) in customerData" :key="i" @click="toDetails(v)">
  63. <view class="customer-name flex">
  64. <text class="name">{{ v.distName }}</text>
  65. </view>
  66. <view class="customer-info flex">
  67. <view class="info-left flex_1">
  68. <view class="info-row flex_l">
  69. <text class="info-label">所在省份:</text>
  70. <u-text color="#323232" size="24rpx" :text="v.provinceDesc || '-'"></u-text>
  71. </view>
  72. <view class="info-row flex_l">
  73. <text class="info-label">业务范围:</text>
  74. <u-text color="#323232" size="24rpx" :text="v.businessScope || '-'"></u-text>
  75. </view>
  76. <view class="info-row flex_l">
  77. <text class="info-label">归属销售:</text>
  78. <u-text color="#323232" size="24rpx" :text="v.belongSale || '-'"></u-text>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <u-loadmore :status="loadStatus" />
  84. </view>
  85. </scroll-view>
  86. </view>
  87. <!-- 新增按钮 -->
  88. <view class="fixed-btn-group" :style="{ width: openBtnWidth ? '180rpx' : '90rpx' }">
  89. <view class="flex1" v-if="openBtnWidth">
  90. <view class="btn center" @click="addDistr">增</view>
  91. </view>
  92. <view class="btn center" @click="openBtnWidth = !openBtnWidth">
  93. <u-icon name="plus" color="#fff" size="20"></u-icon>
  94. </view>
  95. </view>
  96. <!-- 消息提示 -->
  97. <u-toast ref="uToast"></u-toast>
  98. </view>
  99. </template>
  100. <script>
  101. import distrApi from '../../api/base/distr'
  102. import to from 'await-to-js'
  103. export default {
  104. name: 'omsIndex',
  105. components: {},
  106. data() {
  107. return {
  108. openBtnWidth: false,
  109. lineBg: require('@/static/images/up.png'),
  110. curTabIndex: 0,
  111. distrType: '10',
  112. list: [
  113. {
  114. name: '经销商',
  115. index: 0,
  116. type: '10',
  117. },
  118. {
  119. name: '代理商',
  120. index: 1,
  121. type: '20',
  122. },
  123. ],
  124. height: '',
  125. paddingTop: '',
  126. pageNum: 0,
  127. pageSize: 10,
  128. customerData: [], //客户列表
  129. customerDataTotal: 0, //列表元素数量
  130. loadStatus: '', //加载状态
  131. distName: '', //经销商名称
  132. }
  133. },
  134. created() {
  135. const navData = uni.getMenuButtonBoundingClientRect()
  136. this.height = navData.height + 'px'
  137. this.paddingTop = navData.top + 'px'
  138. },
  139. onShow() {
  140. this.getOptions()
  141. this.searchList()
  142. },
  143. methods: {
  144. // 改变tab
  145. changeTabs(data) {
  146. this.distrType = data.type
  147. this.curTabIndex = data.index
  148. this.searchList()
  149. },
  150. // openAdd() {
  151. // uni.navigateTo({
  152. // //保留当前页面,跳转到应用内的某个页面
  153. // url: '/pages/distributor/create',
  154. // })
  155. // },
  156. getOptions() {
  157. Promise.all([this.getDicts('cust_idy')])
  158. .then(([industry]) => {
  159. // this.levelOptions = level.data.values || []
  160. this.industryOptions = industry.data.values || []
  161. })
  162. .catch((err) => console.log(err))
  163. },
  164. // 确认
  165. confirmFilter() {
  166. this.searchList()
  167. },
  168. // 上拉滚动
  169. lower() {
  170. if (this.customerData.length < this.customerDataTotal && this.loadStatus != 'loading') {
  171. this.$u.throttle(this.getCustomerData(), 2000, false)
  172. }
  173. },
  174. // 查询列表
  175. searchList() {
  176. this.pageNum = 0
  177. this.getCustomerData(true)
  178. },
  179. async getCustomerData(reset) {
  180. this.loadStatus = 'loading'
  181. this.pageNum++
  182. let params = {
  183. distType: this.distrType,
  184. distName: this.distName,
  185. pageNum: this.pageNum,
  186. pageSize: this.pageSize,
  187. }
  188. const [err, res] = await to(distrApi.getList(params))
  189. if (err) {
  190. this.loadStatus = 'nomore'
  191. return
  192. }
  193. if (res && res.code == 200) {
  194. if (reset) {
  195. this.customerData = res.data.list || []
  196. } else {
  197. this.customerData = [...this.customerData, ...(res.data.list || [])]
  198. }
  199. this.customerDataTotal = res.data.total
  200. this.loadStatus = this.customerData.length == this.customerDataTotal ? 'nomore' : 'loadmore'
  201. } else {
  202. this.loadStatus = 'nomore'
  203. }
  204. },
  205. goBack() {
  206. uni.navigateBack({
  207. //关闭当前页面,返回上一页面或多级页面。
  208. delta: 1,
  209. })
  210. },
  211. toDetails(v) {
  212. uni.navigateTo({
  213. //保留当前页面,跳转到应用内的某个页面
  214. url: '/pages/distributor/details?id=' + v.id + '&distrType=' + this.distrType,
  215. })
  216. },
  217. // 增加经销商
  218. addDistr() {
  219. uni.navigateTo({
  220. //保留当前页面,跳转到应用内的某个页面
  221. url: '/pages/distributor/create',
  222. })
  223. },
  224. },
  225. }
  226. </script>
  227. <style>
  228. page {
  229. background: #f2f3f5;
  230. }
  231. </style>
  232. <style lang="scss" scoped>
  233. .home {
  234. padding-top: 188rpx;
  235. .nav {
  236. position: absolute;
  237. left: 0;
  238. top: 0;
  239. width: 100%;
  240. height: 284rpx;
  241. background: #3e7ef8;
  242. .title {
  243. position: relative;
  244. text-align: center;
  245. font-size: 32rpx;
  246. font-weight: bold;
  247. color: #ffffff;
  248. .back {
  249. position: absolute;
  250. top: 0;
  251. bottom: 0;
  252. margin: auto;
  253. left: 70rpx;
  254. display: flex;
  255. }
  256. }
  257. }
  258. .main {
  259. position: absolute;
  260. width: 100%;
  261. height: calc(100vh - 188rpx);
  262. background: #ffffff;
  263. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  264. border-radius: 31rpx 31rpx 0 0;
  265. padding: 0 32rpx;
  266. padding-bottom: 64rpx;
  267. .query-wrap {
  268. padding-top: 20rpx;
  269. .search-container {
  270. display: flex;
  271. align-items: center;
  272. .search-input {
  273. flex: 1;
  274. }
  275. .search-btn {
  276. text-align: center;
  277. line-height: 60rpx;
  278. border-radius: 12rpx;
  279. width: 100rpx;
  280. height: 60rpx;
  281. font-size: 26rpx;
  282. margin: 0 0 0 12rpx;
  283. background: $u-primary;
  284. color: #ffffff;
  285. }
  286. }
  287. }
  288. .data-list {
  289. width: 100%;
  290. height: calc(100vh - 372rpx);
  291. overflow: auto;
  292. .data-item {
  293. background: rgba(242, 243, 245, 0.5);
  294. border-radius: 15rpx;
  295. padding: 28rpx 40rpx 28rpx 38rpx;
  296. margin-top: 32rpx;
  297. .customer-name {
  298. .name {
  299. flex: 1;
  300. color: #323232;
  301. font-weight: bold;
  302. font-size: 28rpx;
  303. margin-right: 12rpx;
  304. }
  305. .user-code {
  306. width: 180rpx;
  307. height: 32rpx;
  308. font-size: 24rpx;
  309. color: #323232;
  310. line-height: 32rpx;
  311. }
  312. }
  313. .customer-info {
  314. .info-left {
  315. .transfer-btn {
  316. margin-top: 20rpx;
  317. width: 150rpx;
  318. }
  319. .info-row {
  320. margin-top: 12rpx;
  321. .info-label {
  322. color: #646464;
  323. font-size: 24rpx;
  324. }
  325. }
  326. }
  327. .info-right {
  328. padding-top: 30rpx;
  329. .user-img {
  330. border-radius: 50%;
  331. width: 46rpx;
  332. height: 46rpx;
  333. }
  334. }
  335. }
  336. }
  337. }
  338. }
  339. .filter-popup {
  340. background: rgba(0, 0, 0, 0.8);
  341. position: fixed;
  342. width: 100%;
  343. height: 100%;
  344. left: 0;
  345. z-index: 1;
  346. .filter-wrap {
  347. width: 100%;
  348. padding: 20rpx;
  349. background: #ffffff;
  350. .filter-item {
  351. padding-bottom: 30rpx;
  352. .tit {
  353. font-size: 26rpx;
  354. color: #323232;
  355. font-weight: bold;
  356. padding-bottom: 20rpx;
  357. }
  358. .menu-list {
  359. display: flex;
  360. flex-wrap: wrap;
  361. .menu-item {
  362. margin-right: 40rpx;
  363. margin-bottom: 20rpx;
  364. }
  365. }
  366. }
  367. }
  368. .btn-box {
  369. width: 698rpx;
  370. height: 75px;
  371. display: flex;
  372. align-items: center;
  373. justify-content: space-between;
  374. > view {
  375. width: 320rpx;
  376. height: 40px;
  377. border-radius: 40px;
  378. border: solid 1rpx #ec652b;
  379. align-items: center;
  380. justify-content: center;
  381. text-align: center;
  382. line-height: 40px;
  383. }
  384. .reset {
  385. color: #ec652b;
  386. }
  387. .submit {
  388. color: #fff;
  389. background-color: #ec652b;
  390. }
  391. }
  392. }
  393. .fixed-btn-group {
  394. position: fixed;
  395. display: flex;
  396. justify-content: space-around;
  397. align-items: center;
  398. width: 90rpx;
  399. height: 90rpx;
  400. bottom: 50rpx;
  401. right: 50rpx;
  402. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  403. border-radius: 20px;
  404. transition: all 0.2s;
  405. background: #fff;
  406. .btn {
  407. width: 60rpx;
  408. height: 60rpx;
  409. background: #3e7ef8;
  410. border-radius: 50%;
  411. margin: 10rpx;
  412. font-size: 26rpx;
  413. font-weight: bold;
  414. color: #ffffff;
  415. }
  416. }
  417. }
  418. </style>