123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <template>
- <view>
- <view style="padding: 20rpx;">
- <u-search placeholder="请输入客户名称" v-model="name" @custom="custom"></u-search>
- </view>
-
- <view class="dataBox">
- <view class="forDataBox" v-for="(item,index) of dataList" :key="item.id" @click="choice(item,index)" >
- <view>{{item.cname}}</view>
- <view>{{item.tel}}</view>
- </view>
- </view>
-
- <!-- <u-index-list :indexList="indexList" v-if="!loading">
- <template v-for="(item, index) in itemArr">
- #ifdef APP-NVUE
- <u-index-anchor :text="indexList[index]" :key="index" v-if="item.length>0"></u-index-anchor>
- #endif
- <u-index-item :key="index">
- #ifndef APP-NVUE
- <u-index-anchor :text="indexList[index]" v-if="item.length>0"></u-index-anchor>
- #endif
- <view class="list" v-for="(item1, index1) in item" :key="index1">
- <view class="list__item" @click="choice(item1,index1)">
- <text class="list__item__user-name">{{item1.cname}}</text>
- <text class="list__item__user-tel">{{item1.tel}}</text>
- </view>
- <u-line></u-line>
- </view>
- </u-index-item>
- </template>
- </u-index-list> -->
-
- <!-- <u-loading-page loading-mode="spinner" :loading="loading"></u-loading-page> -->
- <u-loadmore v-if="total !== 0 && dataList.length != 0" :status="status" />
- <u-modal :show="show" :content="'是否确认选择:'+ form.cname" @confirm="confirm" @cancel="show = false"
- :showCancelButton="true" style="text-align: center;"></u-modal>
- </view>
- </template>
- <script>
- import {
- queryAllCustomer,
- } from '@/api/views/sale/index.js'
- import {
- queryList,
- } from '@/api/views/customer/index.js'
- const indexList = () => {
- const indexList = []
- const charCodeOfA = 'A'.charCodeAt(0)
- for (let i = 0; i < 26; i++) {
- indexList.push(String.fromCharCode(charCodeOfA + i))
- }
- indexList.push('#')
- return indexList
- }
- export default {
- data() {
- return {
- name:'',
- indexList: indexList(),
- itemArrTwo: [],
- loading: true,
- show: false,
- form: {},
- params:{},
- page: {
- current: 1,
- size: 30,
- },
- total:0,
- dataList:[],
- status:'loadmore',
- }
- },
- onLoad(params) {
- this.params = {
- ...params,
- adminProfiles: uni.getStorageSync('userInfo').user_id
- }
- this.queryListfun()
- // queryAllCustomer(this.params).then(res=>{
- // this.itemArrTwo = res.data
- // this.loading = false
- // })
- },
- onReachBottom() {
- this.status = 'loading'
- if (this.dataList.length < this.total) {
- this.page.current++
- this.queryListfun()
- } else {
- this.status = 'nomore'
- }
- },
- computed: {
- itemArr() {
- return this.indexList.map((item,index) => {
- return this.itemArrTwo[index]
- })
- }
- },
- onNavigationBarButtonTap(e) {
- uni.$u.route('/pages/views/customer/customerDetails');
- },
- methods: {
- // 新的列表数据
- queryListfun() {
- uni.showLoading({
- title: '加载中',
- mask: true
- });
- queryList({
- ...this.page,
- cname:this.name,
- corpType: 'KH'
- }).then(res => {
- if (res.data.records) {
- this.dataList = this.dataList.concat(res.data.records)
- }
- this.total = res.data.total || 0
- uni.hideLoading();
- if (this.total < 10) {
- this.status = 'nomore'
- }
- })
- },
- // 搜索
- custom(){
- // this.loading = true
- this.dataList = []
- this.queryListfun()
- // queryAllCustomer({
- // ...this.params,
- // cname:this.name
- // }).then(res=>{
- // this.itemArrTwo = res.data
- // this.loading = false
- // })
- },
- // 点击调起弹窗
- choice(item1, index1) {
- this.form = item1
- this.show = true
- },
- // 把数据抛给父级
- confirm() {
- let pages = getCurrentPages() // 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
- let prevPage = pages[pages.length - 2] //上一页页面实例
- prevPage.$vm.otherFun(this.form)
- uni.navigateBack()
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .dataBox {
- // width: 96%;
- // margin: 0 auto;
- }
- .forDataBox {
- font-size: 32rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 15rpx 30rpx;
- box-sizing: border-box;
- border-bottom: 2rpx solid #e5e5e6;
- }
-
- .list {
- &__item {
- @include flex;
- padding: 6px 12px;
- align-items: center;
- justify-content: space-between;
- &__user-name {
- font-size: 32rpx;
- color: $u-main-color;
- }
- &__user-tel {
- font-size: 32rpx;
- margin-right: 20rpx;
- color: $u-main-color;
- }
- }
- &__footer {
- color: $u-tips-color;
- font-size: 14px;
- text-align: center;
- margin: 15px 0;
- }
- }
- </style>
|