storeList.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <view class="content-store">
  3. <view class="input-search">
  4. <u-search placeholder="请输入店铺名称/电话号码" class="search" :show-action="false" input-align="center" v-model="queryWord" @input="getRow(1)"></u-search>
  5. </view>
  6. <scroll-view scroll-y class="list" @scrolltolower="onreachBottom">
  7. <view class="list-item flex align_center" v-for="item in list" :key="item.id" @click="addStore(item.id)">
  8. <u-image src="/static/home_shop.png" width="160" height="160"></u-image>
  9. <view class="item-right flex_1 flex justify_between align_center">
  10. <view class="right-item flex flex_column">
  11. <view >{{item.name}}</view>
  12. <view>{{item.mobile}}</view>
  13. <view>{{item.address}}</view>
  14. </view>
  15. <u-icon name="arrow-right" color="#9DA8B5" font-size="30"></u-icon>
  16. </view>
  17. </view>
  18. <view class="nodata flex justify_center align_center" v-if="list.length==0 && status!='loading'">
  19. <u-empty src="/static/def_result.png" :text="noDataText" icon-size="260" ></u-empty>
  20. </view>
  21. <view v-if="index==current" style="padding: 20upx;">
  22. <u-loadmore v-if="total>pageSize || status=='loading'" :status="status" />
  23. </view>
  24. </scroll-view>
  25. <view class="footer" @click="addStore()">
  26. <view class="add-btn flex justify_center align_center">新增店铺</view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import { shopList } from '@/api/shop.js'
  32. export default {
  33. data() {
  34. return {
  35. list: [], // 列表数据
  36. pageNo: 1, // 当前页码
  37. pageSize: 10, // 每页条数
  38. total: 0, // 数据总条数
  39. noDataText: '暂无数据', // 列表请求状态提示语
  40. status: 'loadmore', // 加载中状态
  41. queryWord:''
  42. }
  43. },
  44. onLoad() {
  45. this.pageInit()
  46. // 开启分享
  47. uni.showShareMenu({
  48. withShareTicket: true,
  49. menus: ['shareAppMessage', 'shareTimeline']
  50. })
  51. },
  52. onShow() {
  53. this.getRow(1)
  54. },
  55. methods: {
  56. pageInit() {
  57. this.pageNo = 1
  58. this.pageSize = 10
  59. this.total = 0
  60. this.list = []
  61. this.getRow(1)
  62. },
  63. // 打电话
  64. callPhone(phone) {
  65. uni.makePhoneCall({
  66. phoneNumber: phone
  67. });
  68. },
  69. // 进入详情
  70. intoDetail(item) {
  71. uni.navigateTo({
  72. url: '/pages/order/hisOrderDetail?orderNo='+item.orderReserveNo
  73. })
  74. },
  75. // scroll-view到底部加载更多
  76. onreachBottom() {
  77. this.action = 'onreachBottom'
  78. if (this.list.length < this.total) {
  79. this.pageNo += 1
  80. this.getRow()
  81. } else {
  82. if(this.list.length) {
  83. uni.showToast({
  84. title: '已经到底了',
  85. icon: 'none'
  86. });
  87. }
  88. this.status = "nomore"
  89. }
  90. },
  91. getArea(obj,state) {
  92. var index=obj.lastIndexOf("\市");
  93. if(state==0){
  94. obj=obj.substring(0,index);
  95. }else {
  96. obj=obj.substring(index+1,obj.length);
  97. }
  98. return obj;
  99. },
  100. // 查询列表
  101. getRow(pageNo) {
  102. this.status = "loadmore"
  103. if (pageNo) {
  104. this.pageNo = pageNo
  105. }
  106. let params = {
  107. pageNo: this.pageNo,
  108. pageSize: this.pageSize,
  109. queryWord:this.queryWord
  110. }
  111. this.noDataText = '暂无数据'
  112. this.status = "loading"
  113. shopList(params).then(res => {
  114. if (res.status == 200) {
  115. res.data.list.map(item=>{
  116. if(item.receiveAddressVO.receiveAreasName){
  117. item.cityAddress=this.getArea(item.receiveAddressVO.receiveAreasName,1)
  118. }
  119. console.log(item.cityAddress,'-----------item.cityAddress=============')
  120. item.address=item.receiveAddressVO ? ((item.receiveAddressVO.receiveAddress? item.receiveAddressVO.receiveAddress:'')+(item.cityAddress? '('+item.cityAddress+')':'')) : ''
  121. })
  122. if (this.pageNo > 1) {
  123. this.list = this.list.concat(res.data.list || [])
  124. } else {
  125. this.list = res.data.list || []
  126. }
  127. this.total = res.data.count || 0
  128. } else {
  129. this.list = []
  130. this.total = 0
  131. this.noDataText = res.message
  132. }
  133. this.status = "loadmore"
  134. })
  135. },
  136. // 新增店铺
  137. addStore(id){
  138. const storeId=id ? id : ''
  139. uni.navigateTo({
  140. url:`/pages/store/addStore?id=${storeId}`
  141. })
  142. }
  143. }
  144. }
  145. </script>
  146. <style lang="less">
  147. .content-store{
  148. width: 100%;
  149. height: 100vh;
  150. background: #F5F5F5;
  151. box-sizing: border-box;
  152. display: flex;
  153. flex-direction: column;
  154. .input-search{
  155. width: 100%;
  156. height: 86upx;
  157. background-color: #fff;
  158. border-bottom: 1px solid #e5e5e5;
  159. // position: fixed;
  160. // top:0;
  161. // left:0;
  162. padding:14upx 32upx ;
  163. .search{
  164. width: 100%;
  165. border-radius: 18px;
  166. }
  167. }
  168. .list{
  169. flex: 1;
  170. overflow-y: scroll;
  171. .list-item{
  172. padding: 32upx;
  173. background-color: #fff;
  174. .item-right{
  175. margin-left:16upx;
  176. border-bottom: 1px solid #e5e5e5;
  177. .right-item{
  178. min-height: 160upx;
  179. view{
  180. min-height: 53upx;
  181. }
  182. }
  183. }
  184. }
  185. .nodata{
  186. margin-top: 50%;
  187. }
  188. }
  189. .footer{
  190. width: 100%;
  191. padding: 14upx 32upx 32upx;
  192. background-color: #fff;
  193. color: #fff;
  194. font-weight: 500;
  195. .add-btn{
  196. height: 84upx;
  197. background: #1995FF;
  198. opacity: 1;
  199. border-radius: 16upx;
  200. }
  201. }
  202. }
  203. </style>