searchPage.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <view class="searchPage-wrap">
  3. <!-- 自定义标题 -->
  4. <u-navbar :is-back="false" :border-bottom="false" id="navbar">
  5. <view class="slot-wrap">
  6. <u-search class="left-icon" :focus="true" shape="square" placeholder="请输入门店名称搜索" v-model="keyword" action-text="取消" @change="change" @search="search" @custom="custom"></u-search>
  7. </view>
  8. </u-navbar>
  9. <!-- 列表数据 -->
  10. <view class="listData-con">
  11. <view class="listData-item" v-for="(item, index) in list" :key="index" @click="goPage(item)">
  12. <view class="listData-item-l">
  13. <u-icon class="listData-item-l-icon" name="mendian" custom-prefix="xd-icon" size="40" color="#888"></u-icon>
  14. <text class="listData-item-l-name">{{item.name}}</text>
  15. </view>
  16. <view class="listData-item-r">
  17. <u-icon class="listData-item-r-icon" name="yuanchengxundian" custom-prefix="xd-icon" size="40" color="#2b85e4"></u-icon>
  18. </view>
  19. </view>
  20. <u-empty :text="noDataText" img-width="120" v-if="list.length == 0 && status != 'loading'" :margin-top="400" mode="list"></u-empty>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import { clzConfirm } from '@/libs/tools.js'
  26. import { findStoreList } from '@/api/store.js'
  27. import { queryCurrentTaskUsing } from '@/api/task.js'
  28. export default{
  29. data(){
  30. return{
  31. keyword: '', // 关键字
  32. list: [], // 数据列表
  33. noDataText: '暂无数据', // 数据异常提示
  34. status: 'loading', // 加载状态
  35. }
  36. },
  37. methods: {
  38. // 用户点击右侧控件时触发
  39. custom(val){
  40. // 关闭当前页面 返回列表页面
  41. uni.navigateBack()
  42. },
  43. // 输入框内容发生变化时触发
  44. change(val){
  45. // `debounce` 是一个限制操作频率的函数。防抖操作,在0.5秒内连续更改数据不进行查询
  46. this.$u.debounce(this.getStoreList, 500)
  47. },
  48. // 用户确定搜索时触发,用户按回车键,或者手机键盘右下角的"搜索"键时触发
  49. search(val){
  50. this.getStoreList()
  51. },
  52. getStoreList(){
  53. this.status = 'loading'
  54. findStoreList({ name: this.keyword }).then(res => {
  55. if(res.status == 200){
  56. this.list = res.data
  57. this.noDataText = '暂无数据' // 有列表数据时不显示,因此只用默认设置为无数据时所需显示的'暂无数据'即可
  58. }else{
  59. this.list = []
  60. this.noDataText = res.message
  61. }
  62. this.status = 'loadmore'
  63. })
  64. },
  65. // 选择门店
  66. goPage(item){
  67. // 校验是否有历史巡店记录
  68. queryCurrentTaskUsing({ storeId: item.id }).then(res => {
  69. if(res.status == 200){
  70. if(res.data){ // 为true有历史巡店记录
  71. clzConfirm({
  72. title: '提示',
  73. content: '有进行中的巡店任务,是否继续?',
  74. confirmText: '继续巡店',
  75. cancelText: '重新开始',
  76. buttons: ['继续巡店','重新开始'],
  77. success: function (result) {
  78. if (result.confirm || result.index==0) { // 继续巡店
  79. uni.navigateTo({
  80. url: '/pages/shopTour/shopTour?storeId=' + item.id + '&taskId='+ res.data + '&restart=0&types=video'
  81. })
  82. }else if(result.cancel || result.index==1){ // 重新开始
  83. uni.navigateTo({
  84. url: '/pages/shopTour/shopTour?storeId=' + item.id + '&taskId='+ res.data + '&restart=1&types=video'
  85. })
  86. }
  87. }
  88. })
  89. }else{
  90. uni.navigateTo({
  91. url: '/pages/shopTour/shopTour?storeId=' + item.id + '&types=video'
  92. })
  93. }
  94. }else{
  95. uni.showToast({icon: 'none', title: res.message})
  96. }
  97. })
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. page {
  104. background-color: #f8f8f8;
  105. height: calc(100vh - 44px);
  106. }
  107. .searchPage-wrap{
  108. padding: 0 30upx;
  109. /* 自定义导航栏样式 */
  110. .slot-wrap {
  111. display: flex;
  112. align-items: center;
  113. /* 如果您想让slot内容占满整个导航栏的宽度 */
  114. flex: 1;
  115. /* 如果您想让slot内容与导航栏左右有空隙 */
  116. padding: 0 30rpx;
  117. font-size: 28upx;
  118. .left-icon {
  119. flex-grow: 1;
  120. font-size: 32upx;
  121. margin-right: 10upx;
  122. text-align: center;
  123. }
  124. .right-icon {
  125. padding-left: 50upx;
  126. }
  127. .uni-icons {
  128. margin-right: 10upx;
  129. }
  130. }
  131. .listData-con{
  132. .listData-item{
  133. display: flex;
  134. justify-content: space-between;
  135. align-items: center;
  136. padding: 20upx 0;
  137. border-bottom: 1upx dashed #f8f8f8;
  138. &-l{
  139. flex-grow: 1;
  140. padding-right: 10upx;
  141. position: relative;
  142. padding-left: 50upx;
  143. &-icon{
  144. vertical-align: sub;
  145. padding-right: 8upx;
  146. position: absolute;
  147. left: 0;
  148. top: -4upx;
  149. }
  150. }
  151. &-r{
  152. flex-shrink: 0;
  153. }
  154. }
  155. }
  156. }
  157. </style>