selectCustomer.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view>
  3. <view style="padding: 20rpx;">
  4. <u-search placeholder="请输入客户名称" v-model="name" @custom="custom"></u-search>
  5. </view>
  6. <u-index-list :indexList="indexList" v-if="!loading">
  7. <template v-for="(item, index) in itemArr">
  8. <!-- #ifdef APP-NVUE -->
  9. <u-index-anchor :text="indexList[index]" :key="index" v-if="item.length>0"></u-index-anchor>
  10. <!-- #endif -->
  11. <u-index-item :key="index">
  12. <!-- #ifndef APP-NVUE -->
  13. <u-index-anchor :text="indexList[index]" v-if="item.length>0"></u-index-anchor>
  14. <!-- #endif -->
  15. <view class="list" v-for="(item1, index1) in item" :key="index1">
  16. <view class="list__item" @click="choice(item1,index1)">
  17. <text class="list__item__user-name">{{item1.cname}}</text>
  18. <text class="list__item__user-tel">{{item1.tel}}</text>
  19. </view>
  20. <u-line></u-line>
  21. </view>
  22. </u-index-item>
  23. </template>
  24. <!-- <view slot="footer" class="u-safe-area-inset--bottom"> -->
  25. <!-- <text class="list__footer">共305位好友</text> -->
  26. <!-- </view> -->
  27. </u-index-list>
  28. <u-loading-page loading-mode="spinner" :loading="loading"></u-loading-page>
  29. <u-modal :show="show" :content="'是否确认选择:'+this.form.cname" @confirm="confirm" @cancel="show = false"
  30. :showCancelButton="true" style="text-align: center;"></u-modal>
  31. </view>
  32. </template>
  33. <script>
  34. import {
  35. queryAllCustomer,
  36. queryInitialsCustomer
  37. } from '@/api/views/sale/index.js'
  38. const indexList = () => {
  39. const indexList = []
  40. const charCodeOfA = 'A'.charCodeAt(0)
  41. // indexList.push("↑")
  42. // indexList.push("☆")
  43. for (let i = 0; i < 26; i++) {
  44. indexList.push(String.fromCharCode(charCodeOfA + i))
  45. }
  46. indexList.push('#')
  47. return indexList
  48. }
  49. export default {
  50. data() {
  51. return {
  52. name:'',
  53. indexList: indexList(),
  54. itemArrTwo: [],
  55. loading: true,
  56. show: false,
  57. form: {},
  58. params:{}
  59. }
  60. },
  61. onLoad(params) {
  62. this.params = {
  63. ...params,
  64. adminProfiles: uni.getStorageSync('userInfo').user_id
  65. }
  66. queryAllCustomer(this.params).then(res=>{
  67. this.itemArrTwo = res.data
  68. this.loading = false
  69. })
  70. },
  71. computed: {
  72. itemArr() {
  73. return this.indexList.map((item,index) => {
  74. return this.itemArrTwo[index]
  75. })
  76. }
  77. },
  78. onNavigationBarButtonTap(e) {
  79. uni.$u.route('/pages/views/supplier/customerDetails');
  80. },
  81. methods: {
  82. // queryInitials(item,index){
  83. // queryInitialsCustomer({initials:item}).then(res=>{
  84. // console.log(res.data)
  85. // })
  86. // },
  87. custom(){
  88. this.loading = true
  89. queryAllCustomer({
  90. ...this.params,
  91. cname:this.name
  92. }).then(res=>{
  93. this.itemArrTwo = res.data
  94. this.loading = false
  95. })
  96. },
  97. choice(item1, index1) {
  98. this.form = item1
  99. this.show = true
  100. },
  101. confirm() {
  102. let pages = getCurrentPages() // 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
  103. let prevPage = pages[pages.length - 2] //上一页页面实例
  104. prevPage.$vm.otherFun(this.form)
  105. uni.navigateBack()
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss">
  111. .list {
  112. &__item {
  113. @include flex;
  114. padding: 6px 12px;
  115. align-items: center;
  116. justify-content: space-between;
  117. &__user-name {
  118. font-size: 32rpx;
  119. color: $u-main-color;
  120. }
  121. &__user-tel {
  122. font-size: 32rpx;
  123. margin-right: 20rpx;
  124. color: $u-main-color;
  125. }
  126. }
  127. &__footer {
  128. color: $u-tips-color;
  129. font-size: 14px;
  130. text-align: center;
  131. margin: 15px 0;
  132. }
  133. }
  134. </style>