selectCustomer.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. console.log(res)
  68. this.itemArrTwo = res.data
  69. this.loading = false
  70. })
  71. },
  72. computed: {
  73. itemArr() {
  74. return this.indexList.map((item,index) => {
  75. return this.itemArrTwo[index]
  76. })
  77. }
  78. },
  79. onNavigationBarButtonTap(e) {
  80. uni.$u.route('/pages/views/customer/customerDetails');
  81. },
  82. methods: {
  83. // queryInitials(item,index){
  84. // queryInitialsCustomer({initials:item}).then(res=>{
  85. // console.log(res.data)
  86. // })
  87. // },
  88. custom(){
  89. this.loading = true
  90. queryAllCustomer({
  91. ...this.params,
  92. cname:this.name
  93. }).then(res=>{
  94. this.itemArrTwo = res.data
  95. this.loading = false
  96. })
  97. },
  98. choice(item1, index1) {
  99. this.form = item1
  100. this.show = true
  101. },
  102. confirm() {
  103. let pages = getCurrentPages() // 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
  104. let prevPage = pages[pages.length - 2] //上一页页面实例
  105. prevPage.$vm.otherFun(this.form)
  106. uni.navigateBack()
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang="scss">
  112. .list {
  113. &__item {
  114. @include flex;
  115. padding: 6px 12px;
  116. align-items: center;
  117. justify-content: space-between;
  118. &__user-name {
  119. font-size: 32rpx;
  120. color: $u-main-color;
  121. }
  122. &__user-tel {
  123. font-size: 32rpx;
  124. margin-right: 20rpx;
  125. color: $u-main-color;
  126. }
  127. }
  128. &__footer {
  129. color: $u-tips-color;
  130. font-size: 14px;
  131. text-align: center;
  132. margin: 15px 0;
  133. }
  134. }
  135. </style>